Sha256: b6bff1e393947bbfc4d956281382ec639a5dece26dfcbdb277e7fa37e7eb4d13
Contents?: true
Size: 572 Bytes
Versions: 1
Compression:
Stored size: 572 Bytes
Contents
require 'iconv' module Fuzzily module String def trigrams normalized_words.map do |word| (0..(word.length - 3)).map { |index| word[index,3] } end.flatten.uniq end private # Remove accents, downcase, replace spaces and word start with '*', # return list of normalized words def normalized_words self.split(/\s+/).map { |word| Iconv.iconv('ascii//translit//ignore', 'utf-8', word).first.downcase.gsub(/\W/,'') }. delete_if(&:empty?). map { |word| "**#{word}" } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fuzzily-0.0.1 | lib/fuzzily/trigram.rb |