strsimpy 0.3.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- strsimpy-0.4.1/Cargo.lock +137 -0
- strsimpy-0.4.1/Cargo.toml +15 -0
- {strsimpy-0.3.0 → strsimpy-0.4.1}/PKG-INFO +113 -31
- strsimpy-0.3.0/strsimpy.egg-info/PKG-INFO → strsimpy-0.4.1/README.md +94 -40
- strsimpy-0.4.1/crates/strsimpy-core/Cargo.toml +13 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/cosine.rs +148 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/damerau.rs +110 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/jaccard.rs +75 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/jaro_winkler.rs +207 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/levenshtein.rs +85 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/lib.rs +22 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/longest_common_subsequence.rs +87 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/metric_lcs.rs +57 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/ngram.rs +146 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/normalized_levenshtein.rs +67 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/optimal_string_alignment.rs +89 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/overlap_coefficient.rs +79 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/qgram.rs +92 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/shingle.rs +141 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/sift4.rs +305 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/sorensen_dice.rs +83 -0
- strsimpy-0.4.1/crates/strsimpy-core/src/weighted_levenshtein.rs +166 -0
- strsimpy-0.4.1/crates/strsimpy-py/Cargo.toml +22 -0
- strsimpy-0.4.1/crates/strsimpy-py/src/algorithms.rs +459 -0
- strsimpy-0.4.1/crates/strsimpy-py/src/lib.rs +16 -0
- strsimpy-0.4.1/crates/strsimpy-py/src/sift4.rs +491 -0
- strsimpy-0.4.1/crates/strsimpy-py/src/utils.rs +28 -0
- strsimpy-0.4.1/crates/strsimpy-py/src/weighted.rs +150 -0
- strsimpy-0.4.1/pyproject.toml +58 -0
- strsimpy-0.4.1/python/strsimpy/__init__.py +67 -0
- strsimpy-0.4.1/python/strsimpy/_base.py +126 -0
- strsimpy-0.4.1/python/strsimpy/cosine.py +5 -0
- strsimpy-0.4.1/python/strsimpy/damerau.py +5 -0
- strsimpy-0.4.1/python/strsimpy/jaccard.py +5 -0
- strsimpy-0.4.1/python/strsimpy/jaro_winkler.py +5 -0
- strsimpy-0.4.1/python/strsimpy/levenshtein.py +5 -0
- strsimpy-0.4.1/python/strsimpy/longest_common_subsequence.py +5 -0
- strsimpy-0.4.1/python/strsimpy/metric_lcs.py +5 -0
- strsimpy-0.4.1/python/strsimpy/ngram.py +5 -0
- strsimpy-0.4.1/python/strsimpy/normalized_levenshtein.py +5 -0
- strsimpy-0.4.1/python/strsimpy/optimal_string_alignment.py +5 -0
- strsimpy-0.4.1/python/strsimpy/overlap_coefficient.py +5 -0
- strsimpy-0.4.1/python/strsimpy/qgram.py +5 -0
- strsimpy-0.4.1/python/strsimpy/shingle_based.py +5 -0
- strsimpy-0.4.1/python/strsimpy/sift4.py +5 -0
- strsimpy-0.4.1/python/strsimpy/sorensen_dice.py +5 -0
- strsimpy-0.4.1/python/strsimpy/string_distance.py +9 -0
- strsimpy-0.4.1/python/strsimpy/string_similarity.py +5 -0
- strsimpy-0.4.1/python/strsimpy/weighted_levenshtein.py +23 -0
- strsimpy-0.4.1/tests/test_api.py +222 -0
- strsimpy-0.4.1/tests/test_cosine.py +67 -0
- strsimpy-0.4.1/tests/test_damerau.py +41 -0
- strsimpy-0.4.1/tests/test_jaccard.py +42 -0
- strsimpy-0.3.0/strsimpy/jaro_winkler_test.py → strsimpy-0.4.1/tests/test_jaro_winkler.py +23 -21
- strsimpy-0.4.1/tests/test_levenshtein.py +43 -0
- strsimpy-0.4.1/tests/test_longest_common_subsequence.py +28 -0
- strsimpy-0.4.1/tests/test_metric_lcs.py +34 -0
- strsimpy-0.4.1/tests/test_ngram.py +76 -0
- strsimpy-0.3.0/strsimpy/normalized_levenshtein_test.py → strsimpy-0.4.1/tests/test_normalized_levenshtein.py +14 -21
- strsimpy-0.4.1/tests/test_optimal_string_alignment.py +40 -0
- strsimpy-0.3.0/strsimpy/overlap_coefficient_test.py → strsimpy-0.4.1/tests/test_overlap_coefficient.py +5 -0
- strsimpy-0.4.1/tests/test_qgram.py +44 -0
- strsimpy-0.4.1/tests/test_sift4.py +123 -0
- strsimpy-0.4.1/tests/test_sorensen_dice.py +39 -0
- strsimpy-0.4.1/tests/test_weighted_levenshtein.py +100 -0
- strsimpy-0.3.0/README.md +0 -438
- strsimpy-0.3.0/setup.cfg +0 -4
- strsimpy-0.3.0/setup.py +0 -28
- strsimpy-0.3.0/strsimpy/__init__.py +0 -42
- strsimpy-0.3.0/strsimpy/cosine.py +0 -77
- strsimpy-0.3.0/strsimpy/cosine_test.py +0 -63
- strsimpy-0.3.0/strsimpy/damerau.py +0 -62
- strsimpy-0.3.0/strsimpy/damerau_test.py +0 -44
- strsimpy-0.3.0/strsimpy/jaccard.py +0 -51
- strsimpy-0.3.0/strsimpy/jaccard_test.py +0 -38
- strsimpy-0.3.0/strsimpy/jaro_winkler.py +0 -97
- strsimpy-0.3.0/strsimpy/levenshtein.py +0 -50
- strsimpy-0.3.0/strsimpy/levenshtein_test.py +0 -44
- strsimpy-0.3.0/strsimpy/longest_common_subsequence.py +0 -55
- strsimpy-0.3.0/strsimpy/longest_common_subsequence_test.py +0 -45
- strsimpy-0.3.0/strsimpy/metric_lcs.py +0 -40
- strsimpy-0.3.0/strsimpy/metric_lcs_test.py +0 -44
- strsimpy-0.3.0/strsimpy/ngram.py +0 -87
- strsimpy-0.3.0/strsimpy/ngram_test.py +0 -44
- strsimpy-0.3.0/strsimpy/normalized_levenshtein.py +0 -44
- strsimpy-0.3.0/strsimpy/optimal_string_alignment.py +0 -57
- strsimpy-0.3.0/strsimpy/optimal_string_alignment_test.py +0 -44
- strsimpy-0.3.0/strsimpy/overlap_coefficient.py +0 -30
- strsimpy-0.3.0/strsimpy/qgram.py +0 -57
- strsimpy-0.3.0/strsimpy/qgram_test.py +0 -44
- strsimpy-0.3.0/strsimpy/shingle_based.py +0 -44
- strsimpy-0.3.0/strsimpy/sift4.py +0 -188
- strsimpy-0.3.0/strsimpy/sift4_test.py +0 -37
- strsimpy-0.3.0/strsimpy/sorensen_dice.py +0 -48
- strsimpy-0.3.0/strsimpy/sorensen_dice_test.py +0 -52
- strsimpy-0.3.0/strsimpy/string_distance.py +0 -37
- strsimpy-0.3.0/strsimpy/string_similarity.py +0 -31
- strsimpy-0.3.0/strsimpy/weighted_levenshtein.py +0 -80
- strsimpy-0.3.0/strsimpy/weighted_levenshtein_test.py +0 -44
- strsimpy-0.3.0/strsimpy.egg-info/SOURCES.txt +0 -41
- strsimpy-0.3.0/strsimpy.egg-info/dependency_links.txt +0 -1
- strsimpy-0.3.0/strsimpy.egg-info/top_level.txt +0 -1
- {strsimpy-0.3.0 → strsimpy-0.4.1}/LICENSE +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "heck"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "libc"
|
|
13
|
+
version = "0.2.191"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "once_cell"
|
|
19
|
+
version = "1.21.4"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "portable-atomic"
|
|
25
|
+
version = "1.15.0"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "proc-macro2"
|
|
31
|
+
version = "1.0.107"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
34
|
+
dependencies = [
|
|
35
|
+
"unicode-ident",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[[package]]
|
|
39
|
+
name = "pyo3"
|
|
40
|
+
version = "0.30.1"
|
|
41
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
42
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
43
|
+
dependencies = [
|
|
44
|
+
"libc",
|
|
45
|
+
"once_cell",
|
|
46
|
+
"portable-atomic",
|
|
47
|
+
"pyo3-build-config",
|
|
48
|
+
"pyo3-ffi",
|
|
49
|
+
"pyo3-macros",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[[package]]
|
|
53
|
+
name = "pyo3-build-config"
|
|
54
|
+
version = "0.30.1"
|
|
55
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
56
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
57
|
+
dependencies = [
|
|
58
|
+
"target-lexicon",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[[package]]
|
|
62
|
+
name = "pyo3-ffi"
|
|
63
|
+
version = "0.30.1"
|
|
64
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
65
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
66
|
+
dependencies = [
|
|
67
|
+
"libc",
|
|
68
|
+
"pyo3-build-config",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[[package]]
|
|
72
|
+
name = "pyo3-macros"
|
|
73
|
+
version = "0.30.1"
|
|
74
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
75
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
76
|
+
dependencies = [
|
|
77
|
+
"proc-macro2",
|
|
78
|
+
"pyo3-macros-backend",
|
|
79
|
+
"quote",
|
|
80
|
+
"syn",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[[package]]
|
|
84
|
+
name = "pyo3-macros-backend"
|
|
85
|
+
version = "0.30.1"
|
|
86
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
88
|
+
dependencies = [
|
|
89
|
+
"heck",
|
|
90
|
+
"proc-macro2",
|
|
91
|
+
"quote",
|
|
92
|
+
"syn",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[[package]]
|
|
96
|
+
name = "quote"
|
|
97
|
+
version = "1.0.47"
|
|
98
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
99
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
100
|
+
dependencies = [
|
|
101
|
+
"proc-macro2",
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
[[package]]
|
|
105
|
+
name = "strsimpy-core"
|
|
106
|
+
version = "0.4.1"
|
|
107
|
+
|
|
108
|
+
[[package]]
|
|
109
|
+
name = "strsimpy-py"
|
|
110
|
+
version = "0.4.1"
|
|
111
|
+
dependencies = [
|
|
112
|
+
"pyo3",
|
|
113
|
+
"strsimpy-core",
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
[[package]]
|
|
117
|
+
name = "syn"
|
|
118
|
+
version = "3.0.9"
|
|
119
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
120
|
+
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
|
121
|
+
dependencies = [
|
|
122
|
+
"proc-macro2",
|
|
123
|
+
"quote",
|
|
124
|
+
"unicode-ident",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
[[package]]
|
|
128
|
+
name = "target-lexicon"
|
|
129
|
+
version = "0.13.5"
|
|
130
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
131
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
132
|
+
|
|
133
|
+
[[package]]
|
|
134
|
+
name = "unicode-ident"
|
|
135
|
+
version = "1.0.27"
|
|
136
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
137
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
members = ["crates/strsimpy-core", "crates/strsimpy-py"]
|
|
3
|
+
resolver = "2"
|
|
4
|
+
|
|
5
|
+
[workspace.package]
|
|
6
|
+
version = "0.4.1"
|
|
7
|
+
edition = "2021"
|
|
8
|
+
rust-version = "1.85"
|
|
9
|
+
license = "MIT"
|
|
10
|
+
repository = "https://github.com/luozhouyang/python-string-similarity"
|
|
11
|
+
authors = ["ZhouYang Luo <zhouyang.luo@gmail.com>"]
|
|
12
|
+
|
|
13
|
+
[profile.release]
|
|
14
|
+
lto = "thin"
|
|
15
|
+
codegen-units = 1
|
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: strsimpy
|
|
3
|
-
Version: 0.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Operating System :: MacOS
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
10
|
Classifier: Programming Language :: Python :: 3
|
|
10
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
-
Classifier:
|
|
15
|
-
Classifier:
|
|
16
|
-
Description-Content-Type: text/markdown
|
|
15
|
+
Classifier: Programming Language :: Rust
|
|
16
|
+
Classifier: Topic :: Text Processing :: General
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
Summary: A library implementing different string similarity and distance measures
|
|
19
|
+
Keywords: string,similarity,distance,levenshtein,jaro-winkler,rust
|
|
20
|
+
Author-email: ZhouYang Luo <zhouyang.luo@gmail.com>
|
|
21
|
+
License-Expression: MIT
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
24
|
+
Project-URL: Homepage, https://github.com/luozhouyang/python-string-similarity
|
|
25
|
+
Project-URL: Issues, https://github.com/luozhouyang/python-string-similarity/issues
|
|
26
|
+
Project-URL: Repository, https://github.com/luozhouyang/python-string-similarity
|
|
27
27
|
|
|
28
28
|
# python-string-similarity
|
|
29
29
|
|
|
30
|
-
](https://github.com/luozhouyang/python-string-similarity/actions/workflows/python-package.yml)
|
|
31
31
|
[](https://badge.fury.io/py/strsimpy)
|
|
32
32
|
[](https://badge.fury.io/py/strsimpy)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Rust implementation with Python bindings of [tdebatty/java-string-similarity](https://github.com/tdebatty/java-string-similarity)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
A library implementing different string similarity and distance measures. A dozen of algorithms (including Levenshtein edit distance and sibblings, Jaro-Winkler, Longest Common Subsequence, cosine similarity etc.) are currently implemented. Check the summary table below for the complete list...
|
|
37
|
+
A library implementing different string similarity and distance measures. A dozen of algorithms (including Levenshtein edit distance and sibblings, Jaro-Winkler, Longest Common Subsequence, cosine similarity etc.) are currently implemented. The algorithms are written in Rust and exposed as an extension module through [PyO3](https://pyo3.rs/), while the public Python API is unchanged. Check the summary table below for the complete list...
|
|
38
38
|
|
|
39
39
|
- [python-string-similarity](#python-string-similarity)
|
|
40
40
|
- [Download](#download)
|
|
41
|
+
- [Implementation](#implementation)
|
|
41
42
|
- [Overview](#overview)
|
|
42
43
|
- [Normalized, metric, similarity and distance](#normalized-metric-similarity-and-distance)
|
|
43
44
|
- [(Normalized) similarity and distance](#normalized-similarity-and-distance)
|
|
@@ -60,6 +61,7 @@ A library implementing different string similarity and distance measures. A doze
|
|
|
60
61
|
- [Overlap coefficient (i.e., Szymkiewicz-Simpson)](#overlap-coefficient-ie-szymkiewicz-simpson)
|
|
61
62
|
- [Experimental](#experimental)
|
|
62
63
|
- [SIFT4](#sift4)
|
|
64
|
+
- [Development](#development)
|
|
63
65
|
- [Changelog](#changelog)
|
|
64
66
|
- [Users](#users)
|
|
65
67
|
|
|
@@ -75,6 +77,16 @@ pip install -U strsimpy
|
|
|
75
77
|
|
|
76
78
|
Supported on Python 3.10+.
|
|
77
79
|
|
|
80
|
+
Prebuilt abi3 wheels are published for:
|
|
81
|
+
|
|
82
|
+
- Linux: x86_64 and aarch64, both manylinux (glibc) and musllinux (Alpine)
|
|
83
|
+
- macOS: x86_64 and arm64
|
|
84
|
+
- Windows: x64
|
|
85
|
+
|
|
86
|
+
Installing from the source distribution requires a Rust toolchain (1.85 or
|
|
87
|
+
newer) and [maturin](https://www.maturin.rs/); `pip` handles both automatically
|
|
88
|
+
when no wheel is available.
|
|
89
|
+
|
|
78
90
|
All public classes can be imported from the package root:
|
|
79
91
|
|
|
80
92
|
```python
|
|
@@ -88,6 +100,22 @@ from strsimpy import (
|
|
|
88
100
|
|
|
89
101
|
The per-module imports used in the examples below (`from strsimpy.levenshtein import Levenshtein`, etc.) remain supported.
|
|
90
102
|
|
|
103
|
+
## Implementation
|
|
104
|
+
|
|
105
|
+
The project is a Rust workspace with a thin Python packaging layer:
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
crates/strsimpy-core/ Pure Rust implementations of every algorithm
|
|
109
|
+
crates/strsimpy-py/ PyO3 bindings (the strsimpy._strsimpy extension module)
|
|
110
|
+
python/strsimpy/ Python package, base classes and per-module compatibility shims
|
|
111
|
+
tests/ Python integration tests
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
All string algorithms operate on Unicode code points, matching Python's
|
|
115
|
+
`len(str)` and indexing semantics. The Rust core has its own unit tests and is
|
|
116
|
+
usable as a normal Rust library; the Python package adds the historical class
|
|
117
|
+
API, base classes and module layout.
|
|
118
|
+
|
|
91
119
|
## Overview
|
|
92
120
|
|
|
93
121
|
The main characteristics of each implemented algorithm are presented below. The "cost" column gives an estimation of the computational cost to compute the similarity between two strings of length m and n respectively.
|
|
@@ -233,12 +261,12 @@ print(damerau.distance('ABCDEF', 'POIU'))
|
|
|
233
261
|
Will produce:
|
|
234
262
|
|
|
235
263
|
```
|
|
236
|
-
1
|
|
237
|
-
2
|
|
238
|
-
1
|
|
239
|
-
1
|
|
240
|
-
1
|
|
241
|
-
6
|
|
264
|
+
1
|
|
265
|
+
2
|
|
266
|
+
1
|
|
267
|
+
1
|
|
268
|
+
1
|
|
269
|
+
6
|
|
242
270
|
```
|
|
243
271
|
|
|
244
272
|
## Optimal String Alignment
|
|
@@ -258,7 +286,7 @@ print(optimal_string_alignment.distance('CA', 'ABC'))
|
|
|
258
286
|
Will produce:
|
|
259
287
|
|
|
260
288
|
```
|
|
261
|
-
3
|
|
289
|
+
3
|
|
262
290
|
```
|
|
263
291
|
|
|
264
292
|
## Jaro-Winkler
|
|
@@ -444,14 +472,67 @@ from strsimpy import SIFT4
|
|
|
444
472
|
|
|
445
473
|
s = SIFT4()
|
|
446
474
|
|
|
447
|
-
# result: 11
|
|
448
|
-
s.distance('This is the first string', 'And this is another string') # 11
|
|
449
|
-
# result: 12
|
|
475
|
+
# result: 11
|
|
476
|
+
s.distance('This is the first string', 'And this is another string') # 11
|
|
477
|
+
# result: 12
|
|
450
478
|
s.distance('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'Amet Lorm ispum dolor sit amet, consetetur adixxxpiscing elit.', maxoffset=10)
|
|
451
479
|
```
|
|
452
480
|
|
|
481
|
+
## Development
|
|
482
|
+
|
|
483
|
+
Prerequisites: Python 3.10+, Rust 1.85+ and a C compiler. [maturin](https://www.maturin.rs/) drives the build.
|
|
484
|
+
|
|
485
|
+
```bash
|
|
486
|
+
python3 -m venv .venv
|
|
487
|
+
source .venv/bin/activate
|
|
488
|
+
pip install maturin pytest "black==26.10.1" "ruff==0.17.3"
|
|
489
|
+
maturin develop # build the extension and install it in the venv
|
|
490
|
+
pytest # Python integration tests
|
|
491
|
+
black --check python tests # verify formatting
|
|
492
|
+
ruff check --select RUF022 python tests # verify __all__ ordering
|
|
493
|
+
cargo test --workspace # Rust unit tests
|
|
494
|
+
cargo clippy --workspace --all-targets -- -D warnings
|
|
495
|
+
cargo fmt --all -- --check
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Python code is formatted with [Black](https://black.readthedocs.io/) using its
|
|
499
|
+
recommended defaults (88 columns, configured in `pyproject.toml`). Apply the
|
|
500
|
+
formatter with `black python tests`. `__all__` lists are checked with Ruff's
|
|
501
|
+
`RUF022` rule.
|
|
502
|
+
|
|
503
|
+
Build release artifacts locally with:
|
|
504
|
+
|
|
505
|
+
```bash
|
|
506
|
+
maturin build --release --out dist
|
|
507
|
+
maturin sdist --out dist
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
CI runs the Rust checks and the Python test suite on Python 3.10-3.13. The
|
|
511
|
+
release workflow builds abi3 wheels for Linux, macOS and Windows and publishes
|
|
512
|
+
them to PyPI together with the source distribution.
|
|
513
|
+
|
|
453
514
|
## Changelog
|
|
454
515
|
|
|
516
|
+
### 0.4.1
|
|
517
|
+
- Fixed `NGram` treating literal newline characters in the input as its internal
|
|
518
|
+
padding marker, which produced incorrect edit costs and normalized distances
|
|
519
|
+
above 1 (for example, `NGram(1).distance("\na", "\nb")` returned 1.5 instead
|
|
520
|
+
of 0.5) (#41). Thanks to @Narek-Khachikyan.
|
|
521
|
+
|
|
522
|
+
### 0.4.0
|
|
523
|
+
- Reimplemented all algorithms in Rust and exposed them through PyO3. The
|
|
524
|
+
Python API, package root exports and per-module imports are unchanged.
|
|
525
|
+
- Published abi3 wheels (Python 3.10+) for Linux (manylinux and musllinux,
|
|
526
|
+
x86_64/aarch64), macOS (x86_64/arm64) and Windows x64.
|
|
527
|
+
- Fixed `OptimalStringAlignment` returning 0 when one of the strings is empty.
|
|
528
|
+
- Fixed `SorensenDice` raising `ZeroDivisionError` when both shingle profiles
|
|
529
|
+
are empty; similarity is now 0 in that case.
|
|
530
|
+
- `NGram` now uses the upstream `java-string-similarity` loop bounds, fixing
|
|
531
|
+
too-small distances for some length-mismatched inputs.
|
|
532
|
+
- Added a Rust test suite and expanded the Python tests.
|
|
533
|
+
- Python sources are formatted with Black (`black --check` in CI).
|
|
534
|
+
- `__all__` ordering is enforced in CI with Ruff's `RUF022` rule.
|
|
535
|
+
|
|
455
536
|
### 0.3.0
|
|
456
537
|
- Export `JaroWinkler` and `OverlapCoefficient` from the package root, so every public class is importable as `from strsimpy import ...`.
|
|
457
538
|
- Fix `Cosine` and `OverlapCoefficient` raising `ZeroDivisionError` when whitespace normalization leaves an empty shingle profile; similarity is now 0 in that case.
|
|
@@ -463,3 +544,4 @@ s.distance('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'Amet Lor
|
|
|
463
544
|
* [StringSimilarity.NET](https://github.com/feature23/StringSimilarity.NET) a .NET port of java-string-similarity
|
|
464
545
|
|
|
465
546
|
Use java-string-similarity in your project and want it to be mentioned here? Don't hesitate to drop me a line!
|
|
547
|
+
|
|
@@ -1,43 +1,17 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: strsimpy
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: A library implementing different string similarity and distance measures
|
|
5
|
-
Home-page: https://github.com/luozhouyang/python-string-similarity
|
|
6
|
-
Author: ZhouYang Luo
|
|
7
|
-
Author-email: zhouyang.luo@gmail.com
|
|
8
|
-
License: MIT License
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
-
Classifier: Operating System :: OS Independent
|
|
16
|
-
Description-Content-Type: text/markdown
|
|
17
|
-
License-File: LICENSE
|
|
18
|
-
Dynamic: author
|
|
19
|
-
Dynamic: author-email
|
|
20
|
-
Dynamic: classifier
|
|
21
|
-
Dynamic: description
|
|
22
|
-
Dynamic: description-content-type
|
|
23
|
-
Dynamic: home-page
|
|
24
|
-
Dynamic: license
|
|
25
|
-
Dynamic: license-file
|
|
26
|
-
Dynamic: summary
|
|
27
|
-
|
|
28
1
|
# python-string-similarity
|
|
29
2
|
|
|
30
|
-
](https://github.com/luozhouyang/python-string-similarity/actions/workflows/python-package.yml)
|
|
31
4
|
[](https://badge.fury.io/py/strsimpy)
|
|
32
5
|
[](https://badge.fury.io/py/strsimpy)
|
|
33
6
|
|
|
34
|
-
|
|
7
|
+
Rust implementation with Python bindings of [tdebatty/java-string-similarity](https://github.com/tdebatty/java-string-similarity)
|
|
35
8
|
|
|
36
9
|
|
|
37
|
-
A library implementing different string similarity and distance measures. A dozen of algorithms (including Levenshtein edit distance and sibblings, Jaro-Winkler, Longest Common Subsequence, cosine similarity etc.) are currently implemented. Check the summary table below for the complete list...
|
|
10
|
+
A library implementing different string similarity and distance measures. A dozen of algorithms (including Levenshtein edit distance and sibblings, Jaro-Winkler, Longest Common Subsequence, cosine similarity etc.) are currently implemented. The algorithms are written in Rust and exposed as an extension module through [PyO3](https://pyo3.rs/), while the public Python API is unchanged. Check the summary table below for the complete list...
|
|
38
11
|
|
|
39
12
|
- [python-string-similarity](#python-string-similarity)
|
|
40
13
|
- [Download](#download)
|
|
14
|
+
- [Implementation](#implementation)
|
|
41
15
|
- [Overview](#overview)
|
|
42
16
|
- [Normalized, metric, similarity and distance](#normalized-metric-similarity-and-distance)
|
|
43
17
|
- [(Normalized) similarity and distance](#normalized-similarity-and-distance)
|
|
@@ -60,6 +34,7 @@ A library implementing different string similarity and distance measures. A doze
|
|
|
60
34
|
- [Overlap coefficient (i.e., Szymkiewicz-Simpson)](#overlap-coefficient-ie-szymkiewicz-simpson)
|
|
61
35
|
- [Experimental](#experimental)
|
|
62
36
|
- [SIFT4](#sift4)
|
|
37
|
+
- [Development](#development)
|
|
63
38
|
- [Changelog](#changelog)
|
|
64
39
|
- [Users](#users)
|
|
65
40
|
|
|
@@ -75,6 +50,16 @@ pip install -U strsimpy
|
|
|
75
50
|
|
|
76
51
|
Supported on Python 3.10+.
|
|
77
52
|
|
|
53
|
+
Prebuilt abi3 wheels are published for:
|
|
54
|
+
|
|
55
|
+
- Linux: x86_64 and aarch64, both manylinux (glibc) and musllinux (Alpine)
|
|
56
|
+
- macOS: x86_64 and arm64
|
|
57
|
+
- Windows: x64
|
|
58
|
+
|
|
59
|
+
Installing from the source distribution requires a Rust toolchain (1.85 or
|
|
60
|
+
newer) and [maturin](https://www.maturin.rs/); `pip` handles both automatically
|
|
61
|
+
when no wheel is available.
|
|
62
|
+
|
|
78
63
|
All public classes can be imported from the package root:
|
|
79
64
|
|
|
80
65
|
```python
|
|
@@ -88,6 +73,22 @@ from strsimpy import (
|
|
|
88
73
|
|
|
89
74
|
The per-module imports used in the examples below (`from strsimpy.levenshtein import Levenshtein`, etc.) remain supported.
|
|
90
75
|
|
|
76
|
+
## Implementation
|
|
77
|
+
|
|
78
|
+
The project is a Rust workspace with a thin Python packaging layer:
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
crates/strsimpy-core/ Pure Rust implementations of every algorithm
|
|
82
|
+
crates/strsimpy-py/ PyO3 bindings (the strsimpy._strsimpy extension module)
|
|
83
|
+
python/strsimpy/ Python package, base classes and per-module compatibility shims
|
|
84
|
+
tests/ Python integration tests
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
All string algorithms operate on Unicode code points, matching Python's
|
|
88
|
+
`len(str)` and indexing semantics. The Rust core has its own unit tests and is
|
|
89
|
+
usable as a normal Rust library; the Python package adds the historical class
|
|
90
|
+
API, base classes and module layout.
|
|
91
|
+
|
|
91
92
|
## Overview
|
|
92
93
|
|
|
93
94
|
The main characteristics of each implemented algorithm are presented below. The "cost" column gives an estimation of the computational cost to compute the similarity between two strings of length m and n respectively.
|
|
@@ -233,12 +234,12 @@ print(damerau.distance('ABCDEF', 'POIU'))
|
|
|
233
234
|
Will produce:
|
|
234
235
|
|
|
235
236
|
```
|
|
236
|
-
1
|
|
237
|
-
2
|
|
238
|
-
1
|
|
239
|
-
1
|
|
240
|
-
1
|
|
241
|
-
6
|
|
237
|
+
1
|
|
238
|
+
2
|
|
239
|
+
1
|
|
240
|
+
1
|
|
241
|
+
1
|
|
242
|
+
6
|
|
242
243
|
```
|
|
243
244
|
|
|
244
245
|
## Optimal String Alignment
|
|
@@ -258,7 +259,7 @@ print(optimal_string_alignment.distance('CA', 'ABC'))
|
|
|
258
259
|
Will produce:
|
|
259
260
|
|
|
260
261
|
```
|
|
261
|
-
3
|
|
262
|
+
3
|
|
262
263
|
```
|
|
263
264
|
|
|
264
265
|
## Jaro-Winkler
|
|
@@ -444,14 +445,67 @@ from strsimpy import SIFT4
|
|
|
444
445
|
|
|
445
446
|
s = SIFT4()
|
|
446
447
|
|
|
447
|
-
# result: 11
|
|
448
|
-
s.distance('This is the first string', 'And this is another string') # 11
|
|
449
|
-
# result: 12
|
|
448
|
+
# result: 11
|
|
449
|
+
s.distance('This is the first string', 'And this is another string') # 11
|
|
450
|
+
# result: 12
|
|
450
451
|
s.distance('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'Amet Lorm ispum dolor sit amet, consetetur adixxxpiscing elit.', maxoffset=10)
|
|
451
452
|
```
|
|
452
453
|
|
|
454
|
+
## Development
|
|
455
|
+
|
|
456
|
+
Prerequisites: Python 3.10+, Rust 1.85+ and a C compiler. [maturin](https://www.maturin.rs/) drives the build.
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
python3 -m venv .venv
|
|
460
|
+
source .venv/bin/activate
|
|
461
|
+
pip install maturin pytest "black==26.10.1" "ruff==0.17.3"
|
|
462
|
+
maturin develop # build the extension and install it in the venv
|
|
463
|
+
pytest # Python integration tests
|
|
464
|
+
black --check python tests # verify formatting
|
|
465
|
+
ruff check --select RUF022 python tests # verify __all__ ordering
|
|
466
|
+
cargo test --workspace # Rust unit tests
|
|
467
|
+
cargo clippy --workspace --all-targets -- -D warnings
|
|
468
|
+
cargo fmt --all -- --check
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Python code is formatted with [Black](https://black.readthedocs.io/) using its
|
|
472
|
+
recommended defaults (88 columns, configured in `pyproject.toml`). Apply the
|
|
473
|
+
formatter with `black python tests`. `__all__` lists are checked with Ruff's
|
|
474
|
+
`RUF022` rule.
|
|
475
|
+
|
|
476
|
+
Build release artifacts locally with:
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
maturin build --release --out dist
|
|
480
|
+
maturin sdist --out dist
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
CI runs the Rust checks and the Python test suite on Python 3.10-3.13. The
|
|
484
|
+
release workflow builds abi3 wheels for Linux, macOS and Windows and publishes
|
|
485
|
+
them to PyPI together with the source distribution.
|
|
486
|
+
|
|
453
487
|
## Changelog
|
|
454
488
|
|
|
489
|
+
### 0.4.1
|
|
490
|
+
- Fixed `NGram` treating literal newline characters in the input as its internal
|
|
491
|
+
padding marker, which produced incorrect edit costs and normalized distances
|
|
492
|
+
above 1 (for example, `NGram(1).distance("\na", "\nb")` returned 1.5 instead
|
|
493
|
+
of 0.5) (#41). Thanks to @Narek-Khachikyan.
|
|
494
|
+
|
|
495
|
+
### 0.4.0
|
|
496
|
+
- Reimplemented all algorithms in Rust and exposed them through PyO3. The
|
|
497
|
+
Python API, package root exports and per-module imports are unchanged.
|
|
498
|
+
- Published abi3 wheels (Python 3.10+) for Linux (manylinux and musllinux,
|
|
499
|
+
x86_64/aarch64), macOS (x86_64/arm64) and Windows x64.
|
|
500
|
+
- Fixed `OptimalStringAlignment` returning 0 when one of the strings is empty.
|
|
501
|
+
- Fixed `SorensenDice` raising `ZeroDivisionError` when both shingle profiles
|
|
502
|
+
are empty; similarity is now 0 in that case.
|
|
503
|
+
- `NGram` now uses the upstream `java-string-similarity` loop bounds, fixing
|
|
504
|
+
too-small distances for some length-mismatched inputs.
|
|
505
|
+
- Added a Rust test suite and expanded the Python tests.
|
|
506
|
+
- Python sources are formatted with Black (`black --check` in CI).
|
|
507
|
+
- `__all__` ordering is enforced in CI with Ruff's `RUF022` rule.
|
|
508
|
+
|
|
455
509
|
### 0.3.0
|
|
456
510
|
- Export `JaroWinkler` and `OverlapCoefficient` from the package root, so every public class is importable as `from strsimpy import ...`.
|
|
457
511
|
- Fix `Cosine` and `OverlapCoefficient` raising `ZeroDivisionError` when whitespace normalization leaves an empty shingle profile; similarity is now 0 in that case.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "strsimpy-core"
|
|
3
|
+
description = "Pure Rust implementation of string similarity and distance measures"
|
|
4
|
+
version.workspace = true
|
|
5
|
+
edition.workspace = true
|
|
6
|
+
rust-version.workspace = true
|
|
7
|
+
license.workspace = true
|
|
8
|
+
repository.workspace = true
|
|
9
|
+
authors.workspace = true
|
|
10
|
+
|
|
11
|
+
[lib]
|
|
12
|
+
name = "strsimpy_core"
|
|
13
|
+
path = "src/lib.rs"
|