Skip to content

Instantly share code, notes, and snippets.

View KeithHanson's full-sized avatar

Keith Hanson KeithHanson

View GitHub Profile
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;
}
}
}