Simple Fuzzy Comparison
Calculating how much two strings are similar to each other by analysing the number of common and uncommon characters in the two strings. The algorithm used has time complexity O(n+m), where n and m are the lengths of the compared words. It uses two lists to keep track of the number of times a character is present in each word and later uses them to calculate the final matching score between 0 and 1, where 1 represents complete match and 0 represents no match.
How To Use
from fuzzy_compare import compare_english_words
print(compare_english_words("hello", "hello")) # Out: 1.0
print(compare_english_words("hello", "helllo")) # Out: 0.9090...
print(compare_english_words("hello", "hell")) # Out: 0.888...
print(compare_english_words("hello", "hallo")) # Out: 0.8
print(compare_english_words("hello", "world")) # Out: 0.4
print(compare_english_words("hello", "")) # Out: 0.0
Support For Other Languages
The algorithm allows to compare two strings containing any python supported characters. The compare_english_words function only keeps track of the Unicode characters with code range between 97 and 122, because 97 is unicode of 'a' and 122 of 'z'.
from fuzzy_compare import CompareStrings
_eng_words_comp_obj = CompareStrings(97, 122)
compare_english_words = _eng_words_comp_obj.compare_strings
print(compare_english_words("hello", "world")) # Out: 0.4
The class CompareStrings can be used to compare strings containing any unicode characters in any given code range. But, remember that the algorithm maintains two lists of length equal to the range of allowed Unicode characters. In case of compare_english_words, two lists of length 26 each are used to keep track of the character count.
Metadata
Release files for fuzzy-compare 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fuzzy_compare-1.1.tar.gz | 3.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fuzzy_compare-1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / fuzzy_compare-1.1.tar.gz
| Download URL | fuzzy_compare-1.1.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8288c7d2e97c4eb9fb70647159baa0faae8fd08e4caad15fbf92990ef43d48e5
|
|
BLAKE2b-256 checksum How to use checksums |
d52d2a9664a69b507ec2a251962f988a9c1061ff9a5fb0653c507cfc4a78a39c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / fuzzy_compare-1.1-py3-none-any.whl
| Download URL | fuzzy_compare-1.1-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac9fccdbe8321fe1f0c2f81a3447f6bc3044575779e9e806e1747cd02f46b7cf
|
|
BLAKE2b-256 checksum How to use checksums |
d403104a62a84633dfa756b2eaa227669a41f6430b0da12acb453b7731fc350c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Security for fuzzy-compare 1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.