~linuxgoose/linguistics-robin

ref: 73053a150327e7c6b35b5abfb209aa08117c359d linguistics-robin/README.md -rw-r--r-- 1.2 KiB
73053a15 — Jordan Robinson Merge pull request #15 from linuxgoose/14-build-pypi-automated-workflow 8 months ago

#Linguistics Robin

Linguistics Robin is a Python linguistics collection that stemmed from a phonetics only library (which is why there is currently more phonetic tooling). Right now, the following algorithms are implemented and supported:

  • Soundex
  • Metaphone
  • Refined Soundex
  • Fuzzy Soundex
  • Lein
  • Matching Rating Approach

In addition, the following distance metrics:

  • Hamming
  • Levenshtein

More will be added in the future.

#Installation (in progress)

The module is available in PyPI, just use pip install linguistics-robin.

#Usage

>>> from linguistics_robin import Soundex
>>> soundex = Soundex()
>>> soundex.phonetics('Rupert')
'R163'
>>> soundex.phonetics('Robert')
'R163'
>>> soundex.sounds_like('Robert', 'Rupert')
True

The same API applies to every algorithm, e.g:

>>> from linguistics_robin import Metaphone
>>> metaphone = Metaphone()
>>> metaphone.phonetics('discrimination')
'TSKRMNXN'

You can also use the distance(word1, word2, metric='levenshtein') method to find the distance between 2 phonetic representations.

>>> from linguistics_robin import RefinedSoundex
>>> rs = RefinedSoundex()
>>> rs.distance('Rupert', 'Robert')
0
>>> rs.distance('assign', 'assist', metric='hamming')
2