Skip to main content

No project description provided

Project description

FuzzDict

FuzzDict extends Python's built-in dict to offer an extra API for fuzzy logic to match keys. FuzzDict only supports string values for creating keys.

Installation

pip install fuzz-dict

Usage

from fuzz_dict import FuzzDict

# create a new dictionary
d = FuzzDict({'apple': 1, 'banana': 2, 'orange': 3}, threshold=0.8)

# get the key that are fuzzy matches for a given key
d.fuzz_getkey('appl', None)   # returns 'apple'
d.fuzz_getkey('kiwi', None)   # returns None

# access a value using fuzzy key matching
d.fuzz_getitem('appl')   # returns 1
d.fuzz_getitem('oran')   # returns 3

# update the dictionary using fuzzy key matching
d.fuzz_setitem('appl', 4)   # updates the 'apple' key with value 4
d.fuzz_setitem('oranj', 5)  # updates the 'orange' key with value 5
d.fuzz_setitem('kiwi', 6)   # creates a new item with 'kiwi' key and value 6

Contributing

Contributions are welcome! Please create a pull request with your changes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fuzz-dict-0.0.4.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file fuzz-dict-0.0.4.tar.gz.

File metadata

  • Download URL: fuzz-dict-0.0.4.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.9.6 requests/2.28.2 setuptools/65.5.0 requests-toolbelt/0.10.1 tqdm/4.65.0 CPython/3.11.3

File hashes

Hashes for fuzz-dict-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5845ec5ecc726d1f299383364f5a04587a3cad465be5012edfa0063e5bc4fce6
MD5 ed5f7f8ceb5ef3f22a2b19a7167791a6
BLAKE2b-256 7d1364b3bf0c89272231e36296fcdef368cabab3a0a18ea10d3f3c8ae3421dd4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page