Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnjansen/text
A collection of phonetic algorithms for Crystal. Including; Porter-Stemmer, Soundex, Metaphone, Double Metaphone & White Similarity
https://github.com/johnjansen/text
Last synced: 30 days ago
JSON representation
A collection of phonetic algorithms for Crystal. Including; Porter-Stemmer, Soundex, Metaphone, Double Metaphone & White Similarity
- Host: GitHub
- URL: https://github.com/johnjansen/text
- Owner: johnjansen
- License: mit
- Created: 2016-11-08T16:40:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-04-24T05:00:13.000Z (over 5 years ago)
- Last Synced: 2024-08-03T17:12:31.710Z (4 months ago)
- Language: Crystal
- Homepage:
- Size: 126 KB
- Stars: 18
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - text - A collection of text algorithms (Algorithms and Data structures)
README
# Text
[![GitHub version](https://badge.fury.io/gh/johnjansen%2Ftext.svg)](http://badge.fury.io/gh/johnjansen%2Ftext)
[![CI](https://travis-ci.org/johnjansen/text.svg?branch=master)](https://travis-ci.org/johnjansen/text)A collection of text algorithms. Including; Porter-Stemmer, Soundex, Metaphone, Double Metaphone & White Similarity
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
text:
github: johnjansen/text
```## Usage
```crystal
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
- [johnjansen](https://github.com/johnjansen) John Jansen - creator, maintainer
## Thanks
- Paul Battley (threedaymonk)
- Michael Neumann
- Tim Fletcher
- Hampton Catlin (hcatlin)
- Wilker Lúcio
- everyone who contributed to https://github.com/threedaymonk/text