Skip to main content

Character trigram fuzzy set implementation providing cosine similarity-based fuzzy matching.

This library does that one thing on iterables of strings. Any beyond that–Levenshtein distance, scoring, bigram fallback, etc.–is left as an exercise to the reader.

Usage

import os.path
from timeit import timeit
import requests

# Retrieve a file containing around 470,000 English words
url = 'https://github.com/dwyl/english-words/raw/master/words.txt'
r = requests.get(url, stream=True)
words_path = os.path.expanduser('~/words.txt')
if not os.path.isfile(words_path):
    with open(words_path, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk:
                f.write(chunk)

# Usage
import charactertrigramfuzzyset as ctfs
items = [line.rstrip() for line in open(words_path, 'r')]
fs = ctfs.CharacterTrigramFuzzySet(items)
fs.get('bryan')

# Profiling, generally around 10-20 ms per call on my machine
timeit("fs.get('bryan')", setup='''
import charactertrigramfuzzyset as ctfs
items = [line.rstrip() for line in open('{words_path}', 'r')]
fs = ctfs.CharacterTrigramFuzzySet(items)
'''.format(words_path=words_path), number=1000)

Release files for charactertrigramfuzzyset 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for charactertrigramfuzzyset 0.0.2
File Size Uploaded
charactertrigramfuzzyset-0.0.2.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for charactertrigramfuzzyset 0.0.2
File Interpreter ABI Platform
charactertrigramfuzzyset-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.2 kB

Release files / charactertrigramfuzzyset-0.0.2.tar.gz

Download URL charactertrigramfuzzyset-0.0.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b6ef7b5c94acb08f702e6527784bcede22cda991361fc86e2f2398af9cc7c4af
BLAKE2b-256 checksum
How to use checksums
dee8450f3b107bdb71c2123b4a8a85a5639435c3e7017eccabc8b14d492aaf02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / charactertrigramfuzzyset-0.0.2-py3-none-any.whl

Download URL charactertrigramfuzzyset-0.0.2-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50aa1430364ba5bd7cbeb6280c0d2b6347d2ae5b8fbe466a394120d7a9d54034
BLAKE2b-256 checksum
How to use checksums
18fbc7846080640702bf71eacb199c305e9af27fbba31ad3c912559cc073f53f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page