¶ ↑
TextA collection of text algorithms.
¶ ↑
Usagerequire 'text'
¶ ↑
Levenshtein distanceText::Levenshtein.distance('test', 'test') # => 0 Text::Levenshtein.distance('test', 'tent') # => 1 Text::Levenshtein.distance('test', 'testing') # => 3 Text::Levenshtein.distance('test', 'testing', 2) # => 2
¶ ↑
MetaphoneText::Metaphone.metaphone('BRIAN') # => 'BRN' Text::Metaphone.double_metaphone('Coburn') # => ['KPRN', nil] Text::Metaphone.double_metaphone('Angier') # => ['ANJ', 'ANJR']
¶ ↑
SoundexText::Soundex.soundex('Knuth') # => 'K530'
¶ ↑
Porter stemmingText::PorterStemming.stem('abatements') # => 'abat'
¶ ↑
White similaritywhite = Text::WhiteSimilarity.new white.similarity('Healed', 'Sealed') # 0.8 white.similarity('Healed', 'Help') # 0.25
Note that some intermediate information is cached on the instance to improve performance.
¶ ↑
Ruby version compatibilityThe library has been tested on Ruby 1.8.6 to 1.9.3 and on JRuby.
¶ ↑
Thanks-
Hampton Catlin (hcatlin) for Ruby 1.9 compatibility work
-
Wilker Lúcio for the initial implementation of the White algorithm
¶ ↑
LicenseMIT. See COPYING.txt for details.