switch out C refs for Rust

This commit is contained in:
James Turk 2023-03-25 02:38:34 -05:00
parent 005d657615
commit d790e596e4
2 changed files with 17 additions and 15 deletions

View File

@ -33,17 +33,17 @@ Phonetic encoding:
## Implementations ## Implementations
Each algorithm has C and Python implementations. Each algorithm has Rust and Python implementations.
On a typical CPython install the C implementation will be used. The Python versions The Rust implementations are used by default. The Python
are available for PyPy and systems where compiling the CPython extension is not implementations are a remnant of an early version of
possible. the library and will probably be removed in 1.0.
To explicitly use a specific implementation, refer to the appropriate module:: To explicitly use a specific implementation, refer to the appropriate module::
``` python ``` python
import jellyfish._jellyfish as pyjellyfish import jellyfish._jellyfish as pyjellyfish
import jellyfish.cjellyfish as cjellyfish import jellyfish.rustyfish as rustyfish
``` ```
If you've already imported jellyfish and are not sure what implementation you If you've already imported jellyfish and are not sure what implementation you
@ -52,27 +52,27 @@ are using, you can check by querying `jellyfish.library`.
``` python ``` python
if jellyfish.library == 'Python': if jellyfish.library == 'Python':
# Python implementation # Python implementation
elif jellyfish.library == 'C': elif jellyfish.library == 'Rust':
# C implementation # Rust implementation
``` ```
## Example Usage ## Example Usage
``` python ``` python
>>> import jellyfish >>> import jellyfish
>>> jellyfish.levenshtein_distance(u'jellyfish', u'smellyfish') >>> jellyfish.levenshtein_distance('jellyfish', 'smellyfish')
2 2
>>> jellyfish.jaro_distance(u'jellyfish', u'smellyfish') >>> jellyfish.jaro_distance('jellyfish', 'smellyfish')
0.89629629629629637 0.89629629629629637
>>> jellyfish.damerau_levenshtein_distance(u'jellyfish', u'jellyfihs') >>> jellyfish.damerau_levenshtein_distance('jellyfish', 'jellyfihs')
1 1
>>> jellyfish.metaphone(u'Jellyfish') >>> jellyfish.metaphone('Jellyfish')
'JLFX' 'JLFX'
>>> jellyfish.soundex(u'Jellyfish') >>> jellyfish.soundex('Jellyfish')
'J412' 'J412'
>>> jellyfish.nysiis(u'Jellyfish') >>> jellyfish.nysiis('Jellyfish')
'JALYF' 'JALYF'
>>> jellyfish.match_rating_codex(u'Jellyfish') >>> jellyfish.match_rating_codex('Jellyfish')
'JLLFSH' 'JLLFSH'
``` ```

View File

@ -2,6 +2,8 @@ import warnings
try: try:
from .rustyfish import * from .rustyfish import *
library = "Rust"
except ImportError: except ImportError:
from ._jellyfish import * # noqa from ._jellyfish import * # noqa