Skip to main content

Introduction

The smart-match module contains functions for calculating strings/sets similarity.

Concept

  1. similarity: A value in a range of [0, 1], which represents how similar the two strings are. The larger the value, the more similar the two strings are.

  2. dissimilarity: A value in a range of [0, 1], which represents how dissimilar the two strings are. The larger the value, the more dissimilar the two strings are. For a pair of strings, similarity = 1 - dissimilarity

  3. distance: How far the two strings are. Notice that not all the methods support distance method.

  4. score The larger the score, the more similar the two strings are. Notice not all the methods have score method.

We support three levels of string matching.

  1. char: Similarity computation based on characters in the strings.

  2. term: Similarity computation based on terms in the strings.

  3. gram: Similarity computation based on q-grams in the strings.

Methods

We support the following methods.

Method similarity dissimilarity distance score
Levenshtein (default) ✅ ✅ ✅ ❌
Euclidean ✅ ✅ ✅ ❌
Damerau Levenshtein ✅ ✅ ✅ ❌
Block Distance ✅ ✅ ✅ ❌
Cosine ✅ ✅ ❌ ❌
Tanimoto Coefficient ✅ ✅ ❌ ❌
Dice ✅ ✅ ❌ ❌
Simon White ✅ ✅ ❌ ❌
Longest Common Substring ✅ ✅ ✅ ✅
Longest Common SubSequence ✅ ✅ ✅ ✅
Overlap Coefficient ✅ ✅ ❌ ❌
Generalized Overlap Coefficient ✅ ✅ ❌ ❌
Jaccard ✅ ✅ ❌ ❌
Generalized Jaccard ✅ ✅ ❌ ❌
Hamming ✅ ✅ ✅ ❌
Jaro ✅ ✅ ❌ ❌
Jaro Winkler ✅ ✅ ❌ ❌
Needleman Wunch ✅ ✅ ❌ ✅
Smith Waterman ✅ ✅ ❌ ✅
Smith Waterman Gotoh ✅ ✅ ❌ ✅
Monge Elkan ✅ ✅ ❌ ❌

Installation

pip install smart-match

Usage

import smart_match
print(smart_match.similarity('hello', 'hero'))
print(smart_match.dissimilarity('hello', 'hero'))
print(smart_match.distance('hello', 'hero'))

Output:

0.6
0.4
2

Check Wiki for more details.

License

smart-match is a free software. See the file LICENSE for the full text.

Authors

qrcode_for_wechat_official_account

Metadata

Release files for smart-match 0.1.1

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

Source distribution (sdist)

Source distribution for smart-match 0.1.1
File Size Uploaded Provenance Actions
smart_match-0.1.1.tar.gz 22.1 kB Without provenance Details for smart_match-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smart-match 0.1.1
File Interpreter ABI Platform Actions
smart_match-0.1.1-py3-none-any.whl Python 3 none any Details for smart_match-0.1.1-py3-none-any.whl

Total release size: 62.4 kB

Release files / smart_match-0.1.1.tar.gz

Download URL smart_match-0.1.1.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5b38be5f67c2990dad455bef08164c0a4bcb78e885c1e89ef19c9e95089ccdfc
BLAKE2b-256 checksum
How to use checksums
812157d19bbb5c884337946fd09b397b2ed8e9fa6d2778cf4ab7393332dd99c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

Release files / smart_match-0.1.1-py3-none-any.whl

Download URL smart_match-0.1.1-py3-none-any.whl
Size 40.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e11a9db75442612f38fb0080ce474f555c7105eaaa8b6f00e8309d74f5349a6d
BLAKE2b-256 checksum
How to use checksums
3f2a47991f181d7fe70ef072eb380bcc1ebea6dac7b98704d1f54cd9679a0635
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

Security for smart-match 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

0.0.1

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