Sha256: a0f32ac6a22f54f00e64ead3f119a2382427531cd089cac5c2a597d2935ab013
Contents?: true
Size: 529 Bytes
Versions: 3
Compression:
Stored size: 529 Bytes
Contents
module Util def self.keywords(text, stem_keywords, ignore_list) return [] if text.blank? text = text.to_s. mb_chars. normalize(:kd). to_s. gsub(/[._:;'"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/, ' '). # strip punctuation gsub(/[^[:alnum:]\s]/,''). # strip accents downcase. split(' '). reject { |word| word.size < 2 } text = text.reject { |word| ignore_list.include?(word) } unless ignore_list.blank? text = text.map(&:stem) if stem_keywords text end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongoid_search-0.2.6 | lib/mongoid_search/util.rb |
mongoid_search-0.2.5 | lib/mongoid_search/util.rb |
mongoid_search-0.2.4 | lib/mongoid_search/util.rb |