strsimpy 0.3.0__tar.gz → 0.4.0__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.
Files changed (103) hide show
  1. strsimpy-0.4.0/Cargo.lock +137 -0
  2. strsimpy-0.4.0/Cargo.toml +15 -0
  3. {strsimpy-0.3.0 → strsimpy-0.4.0}/PKG-INFO +107 -31
  4. strsimpy-0.3.0/strsimpy.egg-info/PKG-INFO → strsimpy-0.4.0/README.md +88 -40
  5. strsimpy-0.4.0/crates/strsimpy-core/Cargo.toml +13 -0
  6. strsimpy-0.4.0/crates/strsimpy-core/src/cosine.rs +148 -0
  7. strsimpy-0.4.0/crates/strsimpy-core/src/damerau.rs +110 -0
  8. strsimpy-0.4.0/crates/strsimpy-core/src/jaccard.rs +75 -0
  9. strsimpy-0.4.0/crates/strsimpy-core/src/jaro_winkler.rs +207 -0
  10. strsimpy-0.4.0/crates/strsimpy-core/src/levenshtein.rs +85 -0
  11. strsimpy-0.4.0/crates/strsimpy-core/src/lib.rs +22 -0
  12. strsimpy-0.4.0/crates/strsimpy-core/src/longest_common_subsequence.rs +87 -0
  13. strsimpy-0.4.0/crates/strsimpy-core/src/metric_lcs.rs +57 -0
  14. strsimpy-0.4.0/crates/strsimpy-core/src/ngram.rs +139 -0
  15. strsimpy-0.4.0/crates/strsimpy-core/src/normalized_levenshtein.rs +67 -0
  16. strsimpy-0.4.0/crates/strsimpy-core/src/optimal_string_alignment.rs +89 -0
  17. strsimpy-0.4.0/crates/strsimpy-core/src/overlap_coefficient.rs +79 -0
  18. strsimpy-0.4.0/crates/strsimpy-core/src/qgram.rs +92 -0
  19. strsimpy-0.4.0/crates/strsimpy-core/src/shingle.rs +141 -0
  20. strsimpy-0.4.0/crates/strsimpy-core/src/sift4.rs +305 -0
  21. strsimpy-0.4.0/crates/strsimpy-core/src/sorensen_dice.rs +83 -0
  22. strsimpy-0.4.0/crates/strsimpy-core/src/weighted_levenshtein.rs +166 -0
  23. strsimpy-0.4.0/crates/strsimpy-py/Cargo.toml +22 -0
  24. strsimpy-0.4.0/crates/strsimpy-py/src/algorithms.rs +459 -0
  25. strsimpy-0.4.0/crates/strsimpy-py/src/lib.rs +16 -0
  26. strsimpy-0.4.0/crates/strsimpy-py/src/sift4.rs +491 -0
  27. strsimpy-0.4.0/crates/strsimpy-py/src/utils.rs +28 -0
  28. strsimpy-0.4.0/crates/strsimpy-py/src/weighted.rs +150 -0
  29. strsimpy-0.4.0/pyproject.toml +58 -0
  30. strsimpy-0.4.0/python/strsimpy/__init__.py +67 -0
  31. strsimpy-0.4.0/python/strsimpy/_base.py +126 -0
  32. strsimpy-0.4.0/python/strsimpy/cosine.py +5 -0
  33. strsimpy-0.4.0/python/strsimpy/damerau.py +5 -0
  34. strsimpy-0.4.0/python/strsimpy/jaccard.py +5 -0
  35. strsimpy-0.4.0/python/strsimpy/jaro_winkler.py +5 -0
  36. strsimpy-0.4.0/python/strsimpy/levenshtein.py +5 -0
  37. strsimpy-0.4.0/python/strsimpy/longest_common_subsequence.py +5 -0
  38. strsimpy-0.4.0/python/strsimpy/metric_lcs.py +5 -0
  39. strsimpy-0.4.0/python/strsimpy/ngram.py +5 -0
  40. strsimpy-0.4.0/python/strsimpy/normalized_levenshtein.py +5 -0
  41. strsimpy-0.4.0/python/strsimpy/optimal_string_alignment.py +5 -0
  42. strsimpy-0.4.0/python/strsimpy/overlap_coefficient.py +5 -0
  43. strsimpy-0.4.0/python/strsimpy/qgram.py +5 -0
  44. strsimpy-0.4.0/python/strsimpy/shingle_based.py +5 -0
  45. strsimpy-0.4.0/python/strsimpy/sift4.py +5 -0
  46. strsimpy-0.4.0/python/strsimpy/sorensen_dice.py +5 -0
  47. strsimpy-0.4.0/python/strsimpy/string_distance.py +9 -0
  48. strsimpy-0.4.0/python/strsimpy/string_similarity.py +5 -0
  49. strsimpy-0.4.0/python/strsimpy/weighted_levenshtein.py +23 -0
  50. strsimpy-0.4.0/tests/test_api.py +222 -0
  51. strsimpy-0.4.0/tests/test_cosine.py +67 -0
  52. strsimpy-0.4.0/tests/test_damerau.py +41 -0
  53. strsimpy-0.4.0/tests/test_jaccard.py +42 -0
  54. strsimpy-0.3.0/strsimpy/jaro_winkler_test.py → strsimpy-0.4.0/tests/test_jaro_winkler.py +23 -21
  55. strsimpy-0.4.0/tests/test_levenshtein.py +43 -0
  56. strsimpy-0.4.0/tests/test_longest_common_subsequence.py +28 -0
  57. strsimpy-0.4.0/tests/test_metric_lcs.py +34 -0
  58. strsimpy-0.4.0/tests/test_ngram.py +48 -0
  59. strsimpy-0.3.0/strsimpy/normalized_levenshtein_test.py → strsimpy-0.4.0/tests/test_normalized_levenshtein.py +14 -21
  60. strsimpy-0.4.0/tests/test_optimal_string_alignment.py +40 -0
  61. strsimpy-0.3.0/strsimpy/overlap_coefficient_test.py → strsimpy-0.4.0/tests/test_overlap_coefficient.py +5 -0
  62. strsimpy-0.4.0/tests/test_qgram.py +44 -0
  63. strsimpy-0.4.0/tests/test_sift4.py +123 -0
  64. strsimpy-0.4.0/tests/test_sorensen_dice.py +39 -0
  65. strsimpy-0.4.0/tests/test_weighted_levenshtein.py +100 -0
  66. strsimpy-0.3.0/README.md +0 -438
  67. strsimpy-0.3.0/setup.cfg +0 -4
  68. strsimpy-0.3.0/setup.py +0 -28
  69. strsimpy-0.3.0/strsimpy/__init__.py +0 -42
  70. strsimpy-0.3.0/strsimpy/cosine.py +0 -77
  71. strsimpy-0.3.0/strsimpy/cosine_test.py +0 -63
  72. strsimpy-0.3.0/strsimpy/damerau.py +0 -62
  73. strsimpy-0.3.0/strsimpy/damerau_test.py +0 -44
  74. strsimpy-0.3.0/strsimpy/jaccard.py +0 -51
  75. strsimpy-0.3.0/strsimpy/jaccard_test.py +0 -38
  76. strsimpy-0.3.0/strsimpy/jaro_winkler.py +0 -97
  77. strsimpy-0.3.0/strsimpy/levenshtein.py +0 -50
  78. strsimpy-0.3.0/strsimpy/levenshtein_test.py +0 -44
  79. strsimpy-0.3.0/strsimpy/longest_common_subsequence.py +0 -55
  80. strsimpy-0.3.0/strsimpy/longest_common_subsequence_test.py +0 -45
  81. strsimpy-0.3.0/strsimpy/metric_lcs.py +0 -40
  82. strsimpy-0.3.0/strsimpy/metric_lcs_test.py +0 -44
  83. strsimpy-0.3.0/strsimpy/ngram.py +0 -87
  84. strsimpy-0.3.0/strsimpy/ngram_test.py +0 -44
  85. strsimpy-0.3.0/strsimpy/normalized_levenshtein.py +0 -44
  86. strsimpy-0.3.0/strsimpy/optimal_string_alignment.py +0 -57
  87. strsimpy-0.3.0/strsimpy/optimal_string_alignment_test.py +0 -44
  88. strsimpy-0.3.0/strsimpy/overlap_coefficient.py +0 -30
  89. strsimpy-0.3.0/strsimpy/qgram.py +0 -57
  90. strsimpy-0.3.0/strsimpy/qgram_test.py +0 -44
  91. strsimpy-0.3.0/strsimpy/shingle_based.py +0 -44
  92. strsimpy-0.3.0/strsimpy/sift4.py +0 -188
  93. strsimpy-0.3.0/strsimpy/sift4_test.py +0 -37
  94. strsimpy-0.3.0/strsimpy/sorensen_dice.py +0 -48
  95. strsimpy-0.3.0/strsimpy/sorensen_dice_test.py +0 -52
  96. strsimpy-0.3.0/strsimpy/string_distance.py +0 -37
  97. strsimpy-0.3.0/strsimpy/string_similarity.py +0 -31
  98. strsimpy-0.3.0/strsimpy/weighted_levenshtein.py +0 -80
  99. strsimpy-0.3.0/strsimpy/weighted_levenshtein_test.py +0 -44
  100. strsimpy-0.3.0/strsimpy.egg-info/SOURCES.txt +0 -41
  101. strsimpy-0.3.0/strsimpy.egg-info/dependency_links.txt +0 -1
  102. strsimpy-0.3.0/strsimpy.egg-info/top_level.txt +0 -1
  103. {strsimpy-0.3.0 → strsimpy-0.4.0}/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.0"
107
+
108
+ [[package]]
109
+ name = "strsimpy-py"
110
+ version = "0.4.0"
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.0"
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.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
3
+ Version: 0.4.0
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: License :: OSI Approved :: MIT License
15
- Classifier: Operating System :: OS Independent
16
- Description-Content-Type: text/markdown
15
+ Classifier: Programming Language :: Rust
16
+ Classifier: Topic :: Text Processing :: General
17
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
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
- ![Python package](https://github.com/luozhouyang/python-string-similarity/workflows/Python%20package/badge.svg)
30
+ [![CI](https://github.com/luozhouyang/python-string-similarity/actions/workflows/python-package.yml/badge.svg)](https://github.com/luozhouyang/python-string-similarity/actions/workflows/python-package.yml)
31
31
  [![PyPI version](https://badge.fury.io/py/strsimpy.svg)](https://badge.fury.io/py/strsimpy)
32
32
  [![Python](https://img.shields.io/pypi/pyversions/strsimpy.svg?style=plastic)](https://badge.fury.io/py/strsimpy)
33
33
 
34
- Python3.x implementation of [tdebatty/java-string-similarity](https://github.com/tdebatty/java-string-similarity)
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.0
237
- 2.0
238
- 1.0
239
- 1.0
240
- 1.0
241
- 6.0
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.0
289
+ 3
262
290
  ```
263
291
 
264
292
  ## Jaro-Winkler
@@ -444,14 +472,61 @@ from strsimpy import SIFT4
444
472
 
445
473
  s = SIFT4()
446
474
 
447
- # result: 11.0
448
- s.distance('This is the first string', 'And this is another string') # 11.0
449
- # result: 12.0
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.0
517
+ - Reimplemented all algorithms in Rust and exposed them through PyO3. The
518
+ Python API, package root exports and per-module imports are unchanged.
519
+ - Published abi3 wheels (Python 3.10+) for Linux (manylinux and musllinux,
520
+ x86_64/aarch64), macOS (x86_64/arm64) and Windows x64.
521
+ - Fixed `OptimalStringAlignment` returning 0 when one of the strings is empty.
522
+ - Fixed `SorensenDice` raising `ZeroDivisionError` when both shingle profiles
523
+ are empty; similarity is now 0 in that case.
524
+ - `NGram` now uses the upstream `java-string-similarity` loop bounds, fixing
525
+ too-small distances for some length-mismatched inputs.
526
+ - Added a Rust test suite and expanded the Python tests.
527
+ - Python sources are formatted with Black (`black --check` in CI).
528
+ - `__all__` ordering is enforced in CI with Ruff's `RUF022` rule.
529
+
455
530
  ### 0.3.0
456
531
  - Export `JaroWinkler` and `OverlapCoefficient` from the package root, so every public class is importable as `from strsimpy import ...`.
457
532
  - Fix `Cosine` and `OverlapCoefficient` raising `ZeroDivisionError` when whitespace normalization leaves an empty shingle profile; similarity is now 0 in that case.
@@ -463,3 +538,4 @@ s.distance('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'Amet Lor
463
538
  * [StringSimilarity.NET](https://github.com/feature23/StringSimilarity.NET) a .NET port of java-string-similarity
464
539
 
465
540
  Use java-string-similarity in your project and want it to be mentioned here? Don't hesitate to drop me a line!
541
+
@@ -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
- ![Python package](https://github.com/luozhouyang/python-string-similarity/workflows/Python%20package/badge.svg)
3
+ [![CI](https://github.com/luozhouyang/python-string-similarity/actions/workflows/python-package.yml/badge.svg)](https://github.com/luozhouyang/python-string-similarity/actions/workflows/python-package.yml)
31
4
  [![PyPI version](https://badge.fury.io/py/strsimpy.svg)](https://badge.fury.io/py/strsimpy)
32
5
  [![Python](https://img.shields.io/pypi/pyversions/strsimpy.svg?style=plastic)](https://badge.fury.io/py/strsimpy)
33
6
 
34
- Python3.x implementation of [tdebatty/java-string-similarity](https://github.com/tdebatty/java-string-similarity)
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.0
237
- 2.0
238
- 1.0
239
- 1.0
240
- 1.0
241
- 6.0
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.0
262
+ 3
262
263
  ```
263
264
 
264
265
  ## Jaro-Winkler
@@ -444,14 +445,61 @@ from strsimpy import SIFT4
444
445
 
445
446
  s = SIFT4()
446
447
 
447
- # result: 11.0
448
- s.distance('This is the first string', 'And this is another string') # 11.0
449
- # result: 12.0
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.0
490
+ - Reimplemented all algorithms in Rust and exposed them through PyO3. The
491
+ Python API, package root exports and per-module imports are unchanged.
492
+ - Published abi3 wheels (Python 3.10+) for Linux (manylinux and musllinux,
493
+ x86_64/aarch64), macOS (x86_64/arm64) and Windows x64.
494
+ - Fixed `OptimalStringAlignment` returning 0 when one of the strings is empty.
495
+ - Fixed `SorensenDice` raising `ZeroDivisionError` when both shingle profiles
496
+ are empty; similarity is now 0 in that case.
497
+ - `NGram` now uses the upstream `java-string-similarity` loop bounds, fixing
498
+ too-small distances for some length-mismatched inputs.
499
+ - Added a Rust test suite and expanded the Python tests.
500
+ - Python sources are formatted with Black (`black --check` in CI).
501
+ - `__all__` ordering is enforced in CI with Ruff's `RUF022` rule.
502
+
455
503
  ### 0.3.0
456
504
  - Export `JaroWinkler` and `OverlapCoefficient` from the package root, so every public class is importable as `from strsimpy import ...`.
457
505
  - 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"