Sha256: 13b40c9da6b84f4b83de815b4eccf968930ca2d7d3efc988cb2ccb7ab7b7c541
Contents?: true
Size: 518 Bytes
Versions: 2
Compression:
Stored size: 518 Bytes
Contents
module Util def self.keywords(text, stem_keywords, ignore_list) return [] if text.blank? text = text. mb_chars. normalize(:kd). to_s. gsub(/[._:;'"`,?|+={}()!@#%^&*<>~\$\-\\\/\[\]]/, ' '). # strip punctuation gsub(/[^[:alpha:]\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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid_search-0.2.3 | lib/mongoid_search/util.rb |
mongoid_search-0.2.1 | lib/mongoid_search/util.rb |