.\" Man page generated from reStructuredText. . .TH "JELLYFISH" "3" "Jun 18, 2020" "0.8" "jellyfish" .SH NAME jellyfish \- jellyfish Documentation . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH OVERVIEW .sp jellyfish is a library of functions for approximate and phonetic matching of strings. .sp Source code is \fI\%available on GitHub\fP .sp The library provides implementations of the following algorithms: .SS Phonetic Encoding .sp These algorithms convert a string to a normalized phonetic encoding, converting a word to a representation of its pronunciation. Each takes a single string and returns a coded representation. .SS American Soundex .INDENT 0.0 .TP .B soundex(s) Calculate the American Soundex of the string s. .UNINDENT .sp Soundex is an algorithm to convert a word (typically a name) to a four digit code in the form \(aqA123\(aq where \(aqA\(aq is the first letter of the name and the digits represent similar sounds. .sp For example \fBsoundex(\(aqAnn\(aq) == soundex(\(aqAnne\(aq) == \(aqA500\(aq\fP and \fBsoundex(\(aqRupert\(aq) == soundex(\(aqRobert\(aq) == \(aqR163\(aq\fP\&. .sp See the \fI\%Soundex article at Wikipedia\fP for more details. .SS Metaphone .INDENT 0.0 .TP .B metaphone(s) Calculate the metaphone code for the string s. .UNINDENT .sp The metaphone algorithm was designed as an improvement on Soundex. It transforms a word into a string consisting of \(aq0BFHJKLMNPRSTWXY\(aq where \(aq0\(aq is pronounced \(aqth\(aq and \(aqX\(aq is a \(aq[sc]h\(aq sound. .sp For example \fBmetaphone(\(aqKlumpz\(aq) == metaphone(\(aqClumps\(aq) == \(aqKLMPS\(aq\fP\&. .sp See the \fI\%Metaphone article at Wikipedia\fP for more details. .SS NYSIIS .INDENT 0.0 .TP .B nysiis(s) Calculate the NYSIIS code for the string s. .UNINDENT .sp The NYSIIS algorithm is an algorithm developed by the New York State Identification and Intelligence System. It transforms a word into a phonetic code. Like soundex and metaphone it is primarily intended for use on names (as they would be pronounced in English). .sp For example \fBnysiis(\(aqJohn\(aq) == nysiis(\(aqJan\(aq) == JAN\fP\&. .sp See the \fI\%NYSIIS article at Wikipedia\fP for more details. .SS Match Rating Approach (codex) .INDENT 0.0 .TP .B match_rating_codex(s) Calculate the match rating approach value (also called PNI) for the string s. .UNINDENT .sp The Match rating approach algorithm is an algorithm for determining whether or not two names are pronounced similarly. The algorithm consists of an encoding function (similar to soundex or nysiis) which is implemented here as well as \fBmatch_rating_comparison()\fP which does the actual comparison. .sp See the \fI\%Match Rating Approach article at Wikipedia\fP for more details. .SS Stemming .SS Porter Stemmer .INDENT 0.0 .TP .B porter_stem(s) Reduce the string s to its stem using the common Porter stemmer. .UNINDENT .sp Stemming is the process of reducing a word to its root form, for example \(aqstemmed\(aq to \(aqstem\(aq. .sp Martin Porter\(aqs algorithm is a common algorithm used for stemming that works for many purposes. .sp See the \fI\%official homepage for the Porter Stemming Algorithm\fP for more details. .SS String Comparison .sp These methods are all measures of the difference (aka \fIedit distance\fP) between two strings. .SS Levenshtein Distance .INDENT 0.0 .TP .B levenshtein_distance(s1, s2) Compute the Levenshtein distance between s1 and s2. .UNINDENT .sp Levenshtein distance represents the number of insertions, deletions, and substitutions required to change one word to another. .sp For example: \fBlevenshtein_distance(\(aqberne\(aq, \(aqborn\(aq) == 2\fP representing the transformation of the first e to o and the deletion of the second e. .sp See the \fI\%Levenshtein distance article at Wikipedia\fP for more details. .SS Damerau\-Levenshtein Distance .INDENT 0.0 .TP .B damerau_levenshtein_distance(s1, s2) Compute the Damerau\-Levenshtein distance between s1 and s2. .UNINDENT .sp A modification of Levenshtein distance, Damerau\-Levenshtein distance counts transpositions (such as ifsh for fish) as a single edit. .sp Where \fBlevenshtein_distance(\(aqfish\(aq, \(aqifsh\(aq) == 2\fP as it would require a deletion and an insertion, though \fBdamerau_levenshtein_distance(\(aqfish\(aq, \(aqifsh\(aq) == 1\fP as this counts as a transposition. .sp See the \fI\%Damerau\-Levenshtein distance article at Wikipedia\fP for more details. .SS Hamming Distance .INDENT 0.0 .TP .B hamming_distance(s1, s2) Compute the Hamming distance between s1 and s2. .UNINDENT .sp Hamming distance is the measure of the number of characters that differ between two strings. .sp Typically Hamming distance is undefined when strings are of different length, but this implementation considers extra characters as differing. For example \fBhamming_distance(\(aqabc\(aq, \(aqabcd\(aq) == 1\fP\&. .sp See the \fI\%Hamming distance article at Wikipedia\fP for more details. .SS Jaro Similarity .INDENT 0.0 .TP .B jaro_similarity(s1, s2) Compute the Jaro similarity between s1 and s2. .UNINDENT .sp Jaro distance is a string\-edit distance that gives a floating point response in [0,1] where 0 represents two completely dissimilar strings and 1 represents identical strings. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Prior to 0.8.1 this function was named jaro_distance. That name is still available, but no longer functions as expected. It will be replaced in 1.0 with a correct version. .UNINDENT .UNINDENT .SS Jaro\-Winkler Similarity .INDENT 0.0 .TP .B jaro_winkler_similarity(s1, s2) Compute the Jaro\-Winkler distance between s1 and s2. .UNINDENT .sp Jaro\-Winkler is a modification/improvement to Jaro distance, like Jaro it gives a floating point response in [0,1] where 0 represents two completely dissimilar strings and 1 represents identical strings. .sp \fBWARNING:\fP .INDENT 0.0 .INDENT 3.5 Prior to 0.8.1 this function was named jaro_winkler. That name is still available, but no longer functions as expected. It will be replaced in 1.0 with a correct version. .UNINDENT .UNINDENT .sp See the \fI\%Jaro\-Winkler distance article at Wikipedia\fP for more details. .SS Match Rating Approach (comparison) .INDENT 0.0 .TP .B match_rating_comparison(s1, s2) Compare s1 and s2 using the match rating approach algorithm, returns \fBTrue\fP if strings are considered equivalent or \fBFalse\fP if not. Can also return \fBNone\fP if s1 and s2 are not comparable (length differs by more than 3). .UNINDENT .sp The Match rating approach algorithm is an algorithm for determining whether or not two names are pronounced similarly. Strings are first encoded using \fBmatch_rating_codex()\fP then compared according to the MRA algorithm. .sp See the \fI\%Match Rating Approach article at Wikipedia\fP for more details. .SS Changelog .SS 0.8.2 \- 21 May 2020 .INDENT 0.0 .IP \(bu 2 fix jaro_winkler/jaro_winkler_similarity mix\-up .IP \(bu 2 deprecate jaro_distance in favor of jaro_similarity backwards compatible shim left in place, will be removed in 1.0 .IP \(bu 2 (note: 0.8.1 was a broken release without proper C libraries) .UNINDENT .SS 0.8.0 \- 21 May 2020 .INDENT 0.0 .IP \(bu 2 rename jaro_winkler to jaro_winkler_similarity to match other functions backwards compatible shim added, but will be removed in 1.0 .IP \(bu 2 fix soundex bug with W/H cases, #83 .IP \(bu 2 fix metaphone bug with WH prefix, #108 .IP \(bu 2 fix C match rating codex bug with duplicate letters, #121 .IP \(bu 2 fix metaphone bug with leading vowels and \(aqkn\(aq pair, #123 .IP \(bu 2 fix Python jaro_winkler bug #124 .IP \(bu 2 fix Python 3.9 deprecation warning .IP \(bu 2 add manylinux wheels .UNINDENT .SS 0.7.2 \- 5 June 2019 .INDENT 0.0 .IP \(bu 2 fix CJellyfish damerau_levenshtein w/ unicode, thanks to immerrr .IP \(bu 2 fix final H in NYSIIS .IP \(bu 2 fix issue w/ trailing W in metaphone .UNINDENT .SS 0.7.1 \- 10 January 2019 .INDENT 0.0 .IP \(bu 2 restrict install to Python >= 3.4 .UNINDENT .SS 0.7.0 \- 10 January 2019 .INDENT 0.0 .IP \(bu 2 drop Python 2 compatibility & legacy code .IP \(bu 2 add bugfix for NYSIIS for words starting with PF .UNINDENT .SS 0.6.1 \- April 16 2018 .INDENT 0.0 .IP \(bu 2 fixed wheel release issue .UNINDENT .SS 0.6.0 \- April 7 2018 .INDENT 0.0 .IP \(bu 2 fix quite a few bugs & differences between C/Py implementations .IP \(bu 2 add wagner\-fischer testdata .IP \(bu 2 uppercase soundex result .IP \(bu 2 better error handling in nysiis, soundex, and jaro .UNINDENT .SS 0.5.6 \- June 23 2016 .INDENT 0.0 .IP \(bu 2 bugfix for metaphone & soundex raising unexpected TypeErrors on Windows (#54) .UNINDENT .SS 0.5.5 \- June 21 2016 .INDENT 0.0 .IP \(bu 2 bugfix for metaphone WH case .UNINDENT .SS 0.5.4 \- May 13 2016 .INDENT 0.0 .IP \(bu 2 bugfix for C version of damerau_levenshtein thanks to Tyler Sellon .UNINDENT .SS 0.5.3 \- March 15 2016 .INDENT 0.0 .IP \(bu 2 style/packaging changes .UNINDENT .SS 0.5.2 \- February 3 2016 .INDENT 0.0 .IP \(bu 2 testing fixes for Python 3.5 .IP \(bu 2 bugfix for Metaphone w/ silent H thanks to Jeremy Carbaugh .UNINDENT .SS 0.5.1 \- July 12 2015 .INDENT 0.0 .IP \(bu 2 bugfixes for NYSIIS .IP \(bu 2 bugfixes for metaphone .IP \(bu 2 bugfix for C version of jaro_winkler .UNINDENT .SS 0.5.0 \- April 23 2015 .INDENT 0.0 .IP \(bu 2 consistent unicode behavior, all functions take unicode and reject bytes on Py2 and 3, C and Python .IP \(bu 2 parametrize tests .IP \(bu 2 Windows compiler support .UNINDENT .SS 0.4.0 \- March 27 2015 .INDENT 0.0 .IP \(bu 2 tons of new tests .IP \(bu 2 documentation .IP \(bu 2 split out cjellyfish .IP \(bu 2 test all w/ unicode and plenty of fixes to accommodate .IP \(bu 2 100% test coverage .UNINDENT .SS 0.3.4 \- February 4 2015 .INDENT 0.0 .IP \(bu 2 fix segfaults and memory leaks via Danrich Parrol .UNINDENT .SS 0.3.3 \- November 20 2014 .INDENT 0.0 .IP \(bu 2 fix bugs in damerau and NYSIIS .UNINDENT .SS 0.3.2 \- August 11 2014 .INDENT 0.0 .IP \(bu 2 fix for jaro\-winkler from David McKean .IP \(bu 2 more packaging fixes .UNINDENT .SS 0.3.1 \- July 16 2014 .INDENT 0.0 .IP \(bu 2 packaging fix for C/Python alternative .UNINDENT .SS 0.3.0 \- July 15 2014 .INDENT 0.0 .IP \(bu 2 python alternatives where C isn\(aqt available .UNINDENT .SS 0.2.2 \- March 14 2014 .INDENT 0.0 .IP \(bu 2 testing fixes .IP \(bu 2 assorted bugfixes in NYSIIS .UNINDENT .SS 0.2.0 \- January 26 2012 .INDENT 0.0 .IP \(bu 2 incorporate some speed changes from Peter Scott .IP \(bu 2 segfault bugfixes. .UNINDENT .SS 0.1.2 \- September 16 2010 .INDENT 0.0 .IP \(bu 2 initial working release .UNINDENT .SH IMPLEMENTATION .sp Each algorithm has C and Python implementations. .sp On a typical CPython install the C implementation will be used. The Python versions are available for PyPy and systems where compiling the CPython extension is not possible. .sp To explicitly use a specific implementation, refer to the appropriate module: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import jellyfish._jellyfish as pyjellyfish import jellyfish.cjellyfish as cjellyfish .ft P .fi .UNINDENT .UNINDENT .sp If you\(aqve already imported jellyfish and are not sure what implementation you are using, you can check by querying \fBjellyfish.library\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C if jellyfish.library == \(aqPython\(aq: # Python implementation elif jellyfish.library == \(aqC\(aq: # C implementation .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 genindex .IP \(bu 2 modindex .IP \(bu 2 search .UNINDENT .SH AUTHOR James Turk .SH COPYRIGHT 2020, James Turk .\" Generated by docutils manpage writer. .