Skip to content

A collection of phonetic algorithms for Crystal. Including; Porter-Stemmer, Soundex, Metaphone, Double Metaphone & White Similarity

License

Notifications You must be signed in to change notification settings

johnjansen/text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text

GitHub version CI

A collection of text algorithms. Including; Porter-Stemmer, Soundex, Metaphone, Double Metaphone & White Similarity

Installation

Add this to your application's shard.yml:

dependencies:
  text:
    github: johnjansen/text

Usage

require "text"

Levenshtein distance

You should use the Levenshtein module in the Crystal StdLib though ...

  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.25

Contributing

  1. Fork it ( https://github.com/johnjansen/text/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Thanks

About

A collection of phonetic algorithms for Crystal. Including; Porter-Stemmer, Soundex, Metaphone, Double Metaphone & White Similarity

Resources

License

Stars

Watchers

Forks

Packages

No packages published