lib/mongoid_fulltext.rb in mongoid_fulltext-0.5.3 vs lib/mongoid_fulltext.rb in mongoid_fulltext-0.5.4
- old
+ new
@@ -225,21 +225,21 @@
prefixes_seen = {}
filtered_str.split(Regexp.compile(config[:word_separators].keys.join)).each do |word|
next if word.length < config[:ngram_width]-1
prefix = word[0...config[:ngram_width]-1]
if prefixes_seen[prefix].nil? and (config[:stop_words][word].nil? or word == filtered_str)
- ngram_array << {:ngram => prefix, :score => 1}
+ ngram_array << {:ngram => prefix, :score => 1 + 1.0/filtered_str.length}
prefixes_seen[prefix] = true
end
end
end
# Add records to the array of ngrams for each full word in the string that isn't a stop word
if config[:index_full_words]
full_words_seen = {}
filtered_str.split(Regexp.compile(config[:word_separators].keys.join)).each do |word|
if word.length > 1 and full_words_seen[word].nil? and (config[:stop_words][word].nil? or word == filtered_str)
- ngram_array << {:ngram => word, :score => 1}
+ ngram_array << {:ngram => word, :score => 1 + 1.0/filtered_str.length}
full_words_seen[word] = true
end
end
end