Skip to content

Instantly share code, notes, and snippets.

View molekilla's full-sized avatar

Rogelio Morrell molekilla

  • Panama
View GitHub Profile
@molekilla
molekilla / gist:2400941
Created April 16, 2012 19:29
Lucene Spanish Tokenizer (with UAX29URLEmailTokenizer and SpanishAnalyzer stop words)
// RM: Imports
import scala.collection._
import org.apache.lucene.util._
import org.apache.lucene.analysis.es._
import org.apache.lucene.analysis.standard._
import org.apache.lucene.analysis.snowball._
// RM: Where analyzer is
val TextAnalyzer = new StandardAnalyzer(Version.LUCENE_35, SpanishAnalyzer.getDefaultStopSet)
@molekilla
molekilla / gist:2244116
Created March 29, 2012 21:48
Escuelita de Scala - Parte 5 - Typeahead meat
App.Views.Index = Backbone.View.extend({
tagName: "input",
className: "search-query",
initialize: function() {
this.items = this.options.items;
this.key = this.options.key;
this.autocomplete = $('.search-query').typeahead();
this.autocomplete.source = [];
this.autocomplete.on('keyup', this, this.typeaheadLookup);
if ( this.key != null )
@molekilla
molekilla / gist:2243990
Created March 29, 2012 21:28
Escuelita de Scala - Parte 5 - Backbone MVC Typeahead
// application.js
var App = {
Views: {},
Controllers: {},
Collections: {},
init: function() {
new App.Controllers.TypeaheadItems();
Backbone.history.start();
}
};
@molekilla
molekilla / gist:2243890
Created March 29, 2012 21:17
Escuelita de Scala - Parte 5 - Sample typeahead
[{"item":"VARELA INC."},{"item":"VARELA HERMANOS, S.A."},{"item":"VARELA OIL COMPANY (VAROCO)"},{"item":"VARELA Y MOLLEK S.A."},{"item":"VARELA REAL ESTATES S.A."},{"item":"VARELA CHEMICAL COMPANY INC."},{"item":"VARELA CONSULTING, S.A."},{"item":"VARELA-BARSALLO, S.A."},{"item":"COHEN, VASSILIPULOS, VARELA & CO.,"},{"item":"VARELA INTERNACIONAL,SA."}]
@molekilla
molekilla / gist:2231169
Created March 28, 2012 22:40
Escuelita de Scala - Parte 4b - Indexamiento
// RM: https://github.com/molekilla/ScalaRegPubRobot/blob/master/src/com/ecyware/web/robot/RegPubStorage.scala
def saveOrUpdate(items:Map[String,Object]) {
// webdata is database
// regpub is collection
val ficha = if ( items.containsKey("ficha") ) Some(items("ficha").toString) else None
if ( ficha.isDefined ) {
val document = items.asDBObject
val existingItems = mongoCollection.find(document)
@molekilla
molekilla / gist:2231130
Created March 28, 2012 22:32
Escuelita de Scala - Parte 4b - mongodb with casbah
package services
import com.mongodb.casbah.Imports._
import com.mongodb.casbah.commons.conversions.scala._
import com.mongodb._
import com.mongodb.ServerAddress
import com.mongodb.util._
import scalaj.collection.s2j._
abstract trait RegpubDataUtil {
@molekilla
molekilla / gist:2229438
Created March 28, 2012 18:57
Escuelita de Scala - Parte 4a - typeahead continue
// RegPubServices
class RegPubServices extends SearchService with DataModelService {
def searchTypeahead(query:String):JsValue = {
val hits = typeahead(query)
val companyNames = hits.map( hit => (hit \\ "fields").map( h => Map("item" -> h \ "nombre"))).flatten
// RM: Alternativamente, para no usar Underscore para crear un array
// val companyNames = hits.map( hit => (hit \\ "fields").map( h => h \ "nombre")).flatten
Json.toJson(companyNames)
@molekilla
molekilla / gist:2228366
Created March 28, 2012 17:17
Escuelita de Scala - Parte 4a - Typeahead
package services
import play.api.libs.json._
import org.elasticsearch.action.index._
import org.elasticsearch.common.settings._
import org.elasticsearch.client.transport._
import org.elasticsearch.common.transport.InetSocketTransportAddress
import org.elasticsearch.action.search._
import org.elasticsearch.index.query._
import org.elasticsearch.search.sort._
@molekilla
molekilla / gist:2220670
Created March 27, 2012 21:47
Escuelita de Scala - Parte 4 - RegPubServices
package services
import play.api.libs.json._
import play.api.Logger._
object RegPubServices
{
def apply() = new RegPubServices()
}
@molekilla
molekilla / gist:2220581
Created March 27, 2012 21:39
Escuelita de Scala - Parte 4 - Modelo de servicios
package services
import play.api.libs.json._
import org.elasticsearch.action.index._
import org.elasticsearch.common.settings._
import org.elasticsearch.client.transport._
import org.elasticsearch.common.transport.InetSocketTransportAddress
import org.elasticsearch.action.search._
import org.elasticsearch.index.query._
import org.elasticsearch.search.sort._