Fuzzy Map 
The Fuzzy Map is a polymorph Python dictionary that always returns the value of the closest similar key. This kind of dictionary returns the value of the exact key if there is such a key. Otherwise, it will return the value of the most similar key satisfying the given ratio. The exact mechanism works when setting a new or replacing an old key in the dictionary. If the key is not found and does not match any of the keys by the given ratio, it returns none.
A real-world example
A live data parser collects the coefficients of sports games from different bookmakers at once, and then an analyzer
tries to find the existing forks. Different bookmakers use different names for the same games. Some of them use the full
names, and others use names with a partial abbreviation that makes the analyzer's job harder to find and compare the
coefficients of the same game. Rather this could be hard without FuzzyMap that can find the game using the name used
in one of the sources.
from fuzzymap import FuzzyMap
source_1 = {
'Rapid Wien - First Vienna': {'w1': 1.93, 'x': 2.32, 'w2': 7.44},
'Al Bourj - Al Nejmeh': {'w1': 26, 'x': 11.5, 'w2': 1.05},
# hundreds of other games' data
}
source_2 = FuzzyMap({
'Bourj FC - Nejmeh SC Beirut': {'w1': 32, 'x': 12, 'w2': 1.05},
'SK Rapid Wien - First Vienna FC': {'w1': 1.97, 'x': 2.3, 'w2': 8.2},
# hundreds of other games' data
})
for game, odds1 in source_1.items():
odds2 = source_2[game]
# odds1 = {"w1": 1.93, "x": 2.32, "w2": 7.44}
# odds2 = {"w1": 1.97, "x": 2.3, "w2": 8.2}
handle_fork(odds1, odds2)
In this code example, source_1 and source_2 are the dictionary of game and coefficients key-value pairs parsed from
different sources. And converting the source_2 dictionary to the FuzzyMap dictionary makes it able to find the
corresponding game using the game's key used in the source_1 dictionary.
License
Copyright (C) 2022 Artyom Vancyan. GPLv2
Metadata
Release files for fuzzymap 1.1.2
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 | |
|---|---|---|---|---|
| fuzzymap-1.1.2.tar.gz | 10.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fuzzymap-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.6 kB
Release files / fuzzymap-1.1.2.tar.gz
| Download URL | fuzzymap-1.1.2.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0f201d84de73d7c7ec753fa149e749079fa12c8f95b6279faef6e7e6f764a64
|
|
BLAKE2b-256 checksum How to use checksums |
f0dace50a634b29c21a664bb45dc55e1fb6eeedb38bb986d7d0389cdbe498b82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / fuzzymap-1.1.2-py3-none-any.whl
| Download URL | fuzzymap-1.1.2-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2550bf13d5eb4ee30819f6c9d907f56a58f8520aea17f31985173f9e95217d3
|
|
BLAKE2b-256 checksum How to use checksums |
a8fc63d613412a534e431393153f52aa80f2a4cf20363521bc9ea79976f51667
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for fuzzymap 1.1.2
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.