Module: Soulmate::Helpers
Instance Method Summary collapse
Instance Method Details
#normalize(str) ⇒ Object
15 16 17 18 |
# File 'lib/soulmate/helpers.rb', line 15 def normalize(str) # Letter, Mark, Number, Connector_Punctuation (Chinese, Japanese, etc.) str.downcase.gsub(/[^\p{Word}\ ]/i, '').strip end |
#prefixes_for_phrase(phrase) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/soulmate/helpers.rb', line 6 def prefixes_for_phrase(phrase) words = normalize(phrase).split(' ').reject do |w| Soulmate.stop_words.include?(w) end words.map do |w| (Soulmate.min_complete-1..(w.length-1)).map{ |l| w[0..l] } end.flatten.uniq end |