texim
texim: text similarity text similarity tool, and it works better for record linkage!
Description
texim is text similarity tool, for record linkage task.
we proposed 2 points for cosine andjaccard similarity:
- length sensitive weight
- semi-match method for field matching
weight type
Classical cosine similarity use TF-IDF as weight of tokens, and we use TF here just for short string. It is common for record linkage to match some field. like name, email, address and so on.
we have 3 weight types here:
- tf : token frequency of token
- len : length of token
- 1 : const 1
semi-match
Abbreviations is common for us, "alan turing" vs "a turing", and semi-match can match "alan"="a" and "turing"="turing".
Install
pip install texim
Examples
from texim import similarity, words_match
## semi-match
tokens1 = ["vandesompele","j"]
tokens2 = ["jo", "vandesompele"]
words_match(tokens1, tokens2, semi_match=False)
# [("vandesompele", "vandesompele")]
words_match(tokens1, tokens2, semi_match=True)
# [("vandesompele", "vandesompele"), ("j", "jo")]
## cosine similarity
text1, text2 = "vandesompele j", "jo vandesompele"
text3, text4 = "a b b b v", "a b b c"
similarity(text1, text2, semi_match=False, wtype="len") # 0.98
similarity(text1, text2, semi_match=True, wtype="len") # 1.0
similarity(text1, text2, semi_match=False, wtype="tf") # 0.5
similarity(text3, text4, semi_match=False, wtype="tf") # 0.86
similarity(text3, text4, semi_match=False, wtype="1") # 0.67
## jaccard similarity
similarity(text1, text2, method="jaccard", semi_match=False, wtype="tf") # 0.33
similarity(text1, text2, method="jaccard", semi_match=False, wtype="len") # 0.8
similarity(text1, text2, method="jaccard", semi_match=True, wtype="tf") # 1.0
similarity(text3, text4, method="jaccard", semi_match=False, wtype="tf") # 0.64
similarity(text3, text4, method="jaccard", semi_match=False, wtype="1") # 0.5
Notice
- all fields need to be converted to lower case.
- you can call texim.cosine and texim.jaccard directly if you need a custom token cutting and weight countting.
Check the setup.py pls!
Metadata
Release files for texim 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| texim-0.0.1.tar.gz | 4.9 kB | Without provenance | Details for texim-0.0.1.tar.gz |
Release files / texim-0.0.1.tar.gz
| Download URL | texim-0.0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9c8f525e1b36768246bf2957c5885c8128e708194dadb838d34bafa06542043
|
|
BLAKE2b-256 checksum How to use checksums |
04b24c0e9fd95e560508795f8263838218f0291048640c8c761c91b401b2dd02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.6
|
Security for texim 0.0.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.