Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/threedaymonk/text
Collection of text algorithms. gem install text
https://github.com/threedaymonk/text
Last synced: about 1 month ago
JSON representation
Collection of text algorithms. gem install text
- Host: GitHub
- URL: https://github.com/threedaymonk/text
- Owner: threedaymonk
- License: other
- Created: 2009-10-11T21:30:45.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2015-04-13T14:55:29.000Z (over 9 years ago)
- Last Synced: 2024-10-29T16:58:32.048Z (about 1 month ago)
- Language: Ruby
- Homepage:
- Size: 503 KB
- Stars: 586
- Watchers: 21
- Forks: 42
- Open Issues: 1
-
Metadata Files:
- Readme: README.rdoc
- License: COPYING.txt
Awesome Lists containing this project
- awesome-ruby - Text - A collection of text algorithms including Levenshtein distance, Metaphone, Soundex 2, Porter stemming & White similarity. (Natural Language Processing)
README
= Text
A collection of text algorithms.
== Usage
require 'text'
=== Levenshtein distance
Text::Levenshtein.distance('test', 'test')
# => 0
Text::Levenshtein.distance('test', 'tent')
# => 1
Text::Levenshtein.distance('test', 'testing')
# => 3
Text::Levenshtein.distance('test', 'testing', 2)
# => 2=== Metaphone
Text::Metaphone.metaphone('BRIAN')
# => 'BRN'Text::Metaphone.double_metaphone('Coburn')
# => ['KPRN', nil]
Text::Metaphone.double_metaphone('Angier')
# => ['ANJ', 'ANJR']=== Soundex
Text::Soundex.soundex('Knuth')
# => 'K530'=== Porter stemming
Text::PorterStemming.stem('abatements') # => 'abat'
=== White similarity
white = Text::WhiteSimilarity.new
white.similarity('Healed', 'Sealed') # 0.8
white.similarity('Healed', 'Help') # 0.25Note that some intermediate information is cached on the instance to improve
performance.== Ruby version compatibility
The 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== License
MIT. See COPYING.txt for details.