-
-
Save KeithHanson/171477 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function splitAndScoreText(results, text, score) { | |
if (text != null) { | |
var words = text.replace(/[^\w]+/g," ").toLowerCase().split(" "); | |
for (var word in words) { | |
if (words[word].length > 1) { | |
if ("a,about,an,and,are,as,at,be,by,from,how,i,in,is,it,of,on,or,that,the,this,to,was,we,what,when,where,which,with".search(words[word]) < 0) { | |
results[words[word]] = (results[words[word]] || 0) + score; | |
} | |
} | |
} | |
} | |
} | |
function(doc) { | |
if (doc['couchrest-type'] == "Exhibitor") { | |
var seenWords = {}; | |
splitAndScoreText(seenWords, doc.name, 100); | |
splitAndScoreText(seenWords, doc.description, 1); | |
for (var word in seenWords) { | |
emit([word, seenWords[word]], null); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment