fuzzymap


Namefuzzymap JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/pysnippet/fuzzymap
SummaryThe Fuzzy Map is a polymorph Python dictionary that always returns the value of the closest similar key.
upload_time2023-05-25 07:17:30
maintainer
docs_urlNone
authorArtyom Vancyan
requires_python>=3.6
licenseGPLv2
keywords python map dict match fuzzy matching dictionary fuzzywuzzy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Fuzzy Map <img src="https://github.com/pysnippet.png" align="right" height="64" />

[![PyPI](https://img.shields.io/pypi/v/fuzzymap.svg)](https://pypi.org/project/fuzzymap/)
[![License](https://img.shields.io/pypi/l/fuzzymap.svg?color=blue)](https://github.com/pysnippet/fuzzymap/blob/master/LICENSE)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fpysnippet%2Ffuzzymap.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fpysnippet%2Ffuzzymap?ref=badge_shield)
[![Tests](https://github.com/pysnippet/fuzzymap/actions/workflows/tests.yml/badge.svg)](https://github.com/pysnippet/fuzzymap/actions/workflows/tests.yml)

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.

```python
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.

<p align="center"><img src="https://user-images.githubusercontent.com/44609997/205437148-4fb3d7bd-1fe9-4ce8-8321-d7aef9488e37.svg" height="400" /></p>

## License

Copyright (C) 2022 Artyom Vancyan. [GPLv2](https://github.com/pysnippet/fuzzymap/blob/master/LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pysnippet/fuzzymap",
    "name": "fuzzymap",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python,map,dict,match,fuzzy,matching,dictionary,fuzzywuzzy",
    "author": "Artyom Vancyan",
    "author_email": "artyom@pysnippet.org",
    "download_url": "https://files.pythonhosted.org/packages/f0/da/ce50a634b29c21a664bb45dc55e1fb6eeedb38bb986d7d0389cdbe498b82/fuzzymap-1.1.2.tar.gz",
    "platform": "unix",
    "description": "# Fuzzy Map <img src=\"https://github.com/pysnippet.png\" align=\"right\" height=\"64\" />\n\n[![PyPI](https://img.shields.io/pypi/v/fuzzymap.svg)](https://pypi.org/project/fuzzymap/)\n[![License](https://img.shields.io/pypi/l/fuzzymap.svg?color=blue)](https://github.com/pysnippet/fuzzymap/blob/master/LICENSE)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fpysnippet%2Ffuzzymap.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fpysnippet%2Ffuzzymap?ref=badge_shield)\n[![Tests](https://github.com/pysnippet/fuzzymap/actions/workflows/tests.yml/badge.svg)](https://github.com/pysnippet/fuzzymap/actions/workflows/tests.yml)\n\nThe Fuzzy Map is a polymorph Python dictionary that always returns the value of the closest similar key. This kind of\ndictionary returns the value of the exact key if there is such a key. Otherwise, it will return the value of the most\nsimilar key satisfying the given ratio. The exact mechanism works when setting a new or replacing an old key in the\ndictionary. If the key is not found and does not match any of the keys by the given ratio, it returns none.\n\n## A real-world example\n\nA live data parser collects the coefficients of sports games from different bookmakers at once, and then an analyzer\ntries to find the existing forks. Different bookmakers use different names for the same games. Some of them use the full\nnames, and others use names with a partial abbreviation that makes the analyzer's job harder to find and compare the\ncoefficients of the same game. Rather this could be hard without `FuzzyMap` that can find the game using the name used\nin one of the sources.\n\n```python\nfrom fuzzymap import FuzzyMap\n\nsource_1 = {\n    'Rapid Wien - First Vienna': {'w1': 1.93, 'x': 2.32, 'w2': 7.44},\n    'Al Bourj - Al Nejmeh': {'w1': 26, 'x': 11.5, 'w2': 1.05},\n    # hundreds of other games' data\n}\n\nsource_2 = FuzzyMap({\n    'Bourj FC - Nejmeh SC Beirut': {'w1': 32, 'x': 12, 'w2': 1.05},\n    'SK Rapid Wien - First Vienna FC': {'w1': 1.97, 'x': 2.3, 'w2': 8.2},\n    # hundreds of other games' data\n})\n\nfor game, odds1 in source_1.items():\n    odds2 = source_2[game]\n\n    # odds1 = {\"w1\": 1.93, \"x\": 2.32, \"w2\": 7.44}\n    # odds2 = {\"w1\": 1.97, \"x\": 2.3, \"w2\": 8.2}\n    handle_fork(odds1, odds2)\n```\n\nIn this code example, `source_1` and `source_2` are the dictionary of game and coefficients key-value pairs parsed from\ndifferent sources. And converting the `source_2` dictionary to the `FuzzyMap` dictionary makes it able to find the\ncorresponding game using the game's key used in the `source_1` dictionary.\n\n<p align=\"center\"><img src=\"https://user-images.githubusercontent.com/44609997/205437148-4fb3d7bd-1fe9-4ce8-8321-d7aef9488e37.svg\" height=\"400\" /></p>\n\n## License\n\nCopyright (C) 2022 Artyom Vancyan. [GPLv2](https://github.com/pysnippet/fuzzymap/blob/master/LICENSE)\n",
    "bugtrack_url": null,
    "license": "GPLv2",
    "summary": "The Fuzzy Map is a polymorph Python dictionary that always returns the value of the closest similar key.",
    "version": "1.1.2",
    "project_urls": {
        "Homepage": "https://github.com/pysnippet/fuzzymap"
    },
    "split_keywords": [
        "python",
        "map",
        "dict",
        "match",
        "fuzzy",
        "matching",
        "dictionary",
        "fuzzywuzzy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8fc63d613412a534e431393153f52aa80f2a4cf20363521bc9ea79976f51667",
                "md5": "dfc97c4f1f179eef1976fcd4d68b46e5",
                "sha256": "e2550bf13d5eb4ee30819f6c9d907f56a58f8520aea17f31985173f9e95217d3"
            },
            "downloads": -1,
            "filename": "fuzzymap-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dfc97c4f1f179eef1976fcd4d68b46e5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 11086,
            "upload_time": "2023-05-25T07:17:28",
            "upload_time_iso_8601": "2023-05-25T07:17:28.395611Z",
            "url": "https://files.pythonhosted.org/packages/a8/fc/63d613412a534e431393153f52aa80f2a4cf20363521bc9ea79976f51667/fuzzymap-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0dace50a634b29c21a664bb45dc55e1fb6eeedb38bb986d7d0389cdbe498b82",
                "md5": "70f0f405b88c1034caecab0260ca27bb",
                "sha256": "b0f201d84de73d7c7ec753fa149e749079fa12c8f95b6279faef6e7e6f764a64"
            },
            "downloads": -1,
            "filename": "fuzzymap-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "70f0f405b88c1034caecab0260ca27bb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 10486,
            "upload_time": "2023-05-25T07:17:30",
            "upload_time_iso_8601": "2023-05-25T07:17:30.654119Z",
            "url": "https://files.pythonhosted.org/packages/f0/da/ce50a634b29c21a664bb45dc55e1fb6eeedb38bb986d7d0389cdbe498b82/fuzzymap-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-25 07:17:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pysnippet",
    "github_project": "fuzzymap",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "fuzzymap"
}
        
Elapsed time: 0.19681s