Sha256: b5c06338658de1d0522194a18d5f87552a109f6aa427214d45a8dbc57755a3d9
Contents?: true
Size: 488 Bytes
Versions: 3
Compression:
Stored size: 488 Bytes
Contents
# coding: utf-8 module Soulmate module Helpers 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 def normalize(str) # Letter, Mark, Number, Connector_Punctuation (Chinese, Japanese, etc.) str.downcase.gsub(/[^\p{Word}\ ]/i, '').strip end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
soulmate_rails-0.3.2 | lib/soulmate/helpers.rb |
soulmate-1.1.0 | lib/soulmate/helpers.rb |
soulmate_rails-0.3.1 | lib/soulmate/helpers.rb |