Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
fix ranking
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioramos committed Jan 10, 2014
1 parent ad244e6 commit b0d36f4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/inverted-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ var inverted = module.exports = function(db, options, getter){
this.algorithm = algorithms[this.options.rank_algorithm];
} else {
this.algorithm = function(a, b){
if(type(a) !== 'array') a = this.parseText(a)
if(type(b) !== 'array') b = this.parseText(b)
if(type(a) !== 'array') a = this.parseText(a, false, true)
if(type(b) !== 'array') b = this.parseText(b, false, true)
return algorithms.cosine(a, b)
}.bind(this)
}
Expand Down Expand Up @@ -507,7 +507,7 @@ inverted.prototype.factorFn = function(done, fn){
}
}

inverted.prototype.parseText = function(text, idf){
inverted.prototype.parseText = function(text, idf, not_unique){
var ocurrences = {}
var idfs = {}

Expand All @@ -534,7 +534,7 @@ inverted.prototype.parseText = function(text, idf){
idfs[word] = Math.log(arr.length / ocurrences[word])
})

words = uniq(words).filter(function(word){
if(!not_unique) words = uniq(words).filter(function(word){
return !stopwords.indexOf(word) >= 0
})

Expand Down

0 comments on commit b0d36f4

Please sign in to comment.