Some collections types for working with rapidfuzz library
Project description
RapidFuzzCollections
Description
A collection of datatypes, using rapidfuzz to allow for fuzzy-string matching:
- RapidFuzzList
- RapidFuzzTuple
- RapidFuzzSet
- RapidFuzzFrozenSet
- RapidFuzzDict
Default collection's classes extended by methods for fuzzy-string matching.
The main idea is using additional memory for keep normalized values of collection.
Requirements
- Python 3.12 or later
- rapidfuzz
Installation
Can be installed with pip
the following way:
pip install rapidfuzz_collections
License
RapidFuzzCollections is licensed under the MIT license.
Usage
Example:
from rapidfuzz_collections import (
Normalizer,
RapidFuzzDict
)
# key is country name, value is country code
data_dict = {
'Aruba': "ABW",
'Afghanistan': "AFG",
'Australia': "AUS",
'Austria': "AUT",
# ...
}
normalizer = Normalizer().isinstance_str().strip().casefold().min_length(3)
rapidfuzz_dict = RapidFuzzDict(data_dict, normalizer=normalizer, score_cutoff=90)
rapidfuzz_dict.fuzzy_contains('Gondor') # False
rapidfuzz_dict.fuzzy_get('Ustralia') # True
rapidfuzz_dict.fuzzy_get('Ustralia') # ( 'Australia', 'AUS', )
rapidfuzz_dict.get_fuzzy_scores('Austraia') # [ ( 'AUS', 94.11764705882352, 'Australia', ), ( 'AUT', 93.33333333333333, 'Austria', ), ( 'ABW', None, 'Aruba', ), ( 'AFG', None, 'Afghanistan', ), ... ]
result = set()
for choice, score, index in rapidfuzz_dict.get_fuzzy_score_iter('Austraia'):
if score is not None:
result.add(( choice, score, index, ))
# result == { ( 'AUS', 94.11764705882352, 'Australia', ), ( 'AUT', 93.33333333333333, 'Austria', ), }
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for rapidfuzz_collections-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 677e22c8bc6e89998d00bc796cb20596cd8a3e94f1a974267302836b4f854e6f |
|
MD5 | 55e60514f7570f656b6a975f7c3c545d |
|
BLAKE2b-256 | f6f16226deb810fd01bd70cee1740a3c856661d007ea81a813742b428ebd9a15 |
Close
Hashes for rapidfuzz_collections-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32ff2903940c758e3536ad6236dad6400d9ac2cf2ab8f8398906fba64ef1a52e |
|
MD5 | 945f203185511115226a8047dadfecae |
|
BLAKE2b-256 | 578e404eb1772dfc6b527df12849d1d712bfd85e8001e68f699c36a009588cf8 |