module Soulheart::Helpers
Public Instance Methods
normalize(str)
click to toggle source
# File lib/soulheart/helpers.rb, line 4 def normalize(str) # Letter, Mark, Number, Connector_Punctuation (Chinese, Japanese, etc.) str.downcase.gsub(/#{Soulheart.normalizer}/i, '').strip end
prefixes_for_phrase(phrase)
click to toggle source
# File lib/soulheart/helpers.rb, line 9 def prefixes_for_phrase(phrase) words = normalize(phrase).split(' ').reject do |w| Soulheart.stop_words.include?(w) end words.map do |w| (0..(w.length - 1)).map { |l| w[0..l] } end.flatten.uniq end