simstring-rust 0.4.0__cp310-abi3-win_amd64.whl
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.
- simstring_rust/__init__.py +5 -0
- simstring_rust/simstring_rust.pyd +0 -0
- simstring_rust-0.4.0.dist-info/METADATA +218 -0
- simstring_rust-0.4.0.dist-info/RECORD +7 -0
- simstring_rust-0.4.0.dist-info/WHEEL +4 -0
- simstring_rust-0.4.0.dist-info/licenses/LICENSE +21 -0
- simstring_rust-0.4.0.dist-info/sboms/simstring_rust.cyclonedx.json +1509 -0
|
Binary file
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: simstring-rust
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: POSIX
|
|
15
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Summary: A fast, native Rust implementation of the SimString algorithm with Python bindings.
|
|
19
|
+
Keywords: string-matching,nlp,simstring,fuzzy
|
|
20
|
+
Home-Page: https://github.com/PyDataBlog/simstring_rs
|
|
21
|
+
Author-email: Bernard Brenyah <bbrenyah@gmail.com>
|
|
22
|
+
License: MIT
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
25
|
+
Project-URL: Homepage, https://github.com/PyDataBlog/simstring_rs
|
|
26
|
+
Project-URL: Repository, https://github.com/PyDataBlog/simstring_rs
|
|
27
|
+
|
|
28
|
+
# simstring_rust
|
|
29
|
+
|
|
30
|
+
[](https://github.com/PyDataBlog/simstring_rs/actions)
|
|
31
|
+
[](https://crates.io/crates/simstring_rust)
|
|
32
|
+
[](https://badge.fury.io/py/simstring-rust)
|
|
33
|
+
[](pyproject.toml)
|
|
34
|
+
[](https://docs.rs/simstring_rust)
|
|
35
|
+
[](https://github.com/PyDataBlog/simstring_rs)
|
|
36
|
+
[](https://codecov.io/gh/PyDataBlog/simstring_rs)
|
|
37
|
+
|
|
38
|
+
A native Rust implementation of the CPMerge algorithm, designed for approximate string matching. This crate is particularly useful for natural language processing tasks that require the retrieval of strings/texts from very large corpora (big amounts of texts). Currently, this crate supports both character and word-based N-grams feature generation, with plans to allow custom user-defined feature generation methods.
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- ✅ Fast algorithm for string matching
|
|
43
|
+
- ✅ 100% exact retrieval
|
|
44
|
+
- ✅ Support for Unicode
|
|
45
|
+
- [ ] Support for building databases directly from text files
|
|
46
|
+
- [ ] Mecab-based tokenizer support
|
|
47
|
+
|
|
48
|
+
## Supported String Similarity Measures
|
|
49
|
+
|
|
50
|
+
- ✅ Dice coefficient
|
|
51
|
+
- ✅ Jaccard coefficient
|
|
52
|
+
- ✅ Cosine coefficient
|
|
53
|
+
- ✅ Overlap coefficient
|
|
54
|
+
- ✅ Exact match
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
Requires Rust 1.88 or newer (edition 2024). Python bindings support Python 3.10+.
|
|
59
|
+
See [Rust API migration](#rust-api-migration) for the read-only query engine's trait changes.
|
|
60
|
+
|
|
61
|
+
Add `simstring_rust` to your `Cargo.toml`:
|
|
62
|
+
|
|
63
|
+
```toml
|
|
64
|
+
[dependencies]
|
|
65
|
+
simstring_rust = "0.3.0" # change version accordingly
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
For the latest features, you can add the master branch by specifying the Git repository:
|
|
69
|
+
|
|
70
|
+
```toml
|
|
71
|
+
[dependencies]
|
|
72
|
+
simstring_rust = { git = "https://github.com/PyDataBlog/simstring_rs.git", branch = "main" }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Note: Using the master branch may include experimental features and potential breakages. Use with caution!
|
|
76
|
+
|
|
77
|
+
To revert to a stable version, ensure your Cargo.toml specifies a specific version number instead of the Git repository.
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
Here is a basic example of how to use simstring_rs in your Rust project:
|
|
82
|
+
|
|
83
|
+
```Rust
|
|
84
|
+
use simstring_rust::database::HashDb;
|
|
85
|
+
use simstring_rust::extractors::CharacterNgrams;
|
|
86
|
+
use simstring_rust::measures::Cosine;
|
|
87
|
+
use simstring_rust::Searcher;
|
|
88
|
+
|
|
89
|
+
use std::sync::Arc;
|
|
90
|
+
|
|
91
|
+
fn main() {
|
|
92
|
+
// 1. Setup the database
|
|
93
|
+
let feature_extractor = Arc::new(CharacterNgrams::new(2, "$"));
|
|
94
|
+
let mut db = HashDb::new(feature_extractor);
|
|
95
|
+
|
|
96
|
+
// 2. Index some strings
|
|
97
|
+
db.insert("hello".to_string());
|
|
98
|
+
db.insert("help".to_string());
|
|
99
|
+
db.insert("halo".to_string());
|
|
100
|
+
db.insert("world".to_string());
|
|
101
|
+
|
|
102
|
+
// 3. Search for strings
|
|
103
|
+
let measure = Cosine;
|
|
104
|
+
let searcher = Searcher::new(&db, measure);
|
|
105
|
+
let query = "hell";
|
|
106
|
+
let alpha = 0.5;
|
|
107
|
+
|
|
108
|
+
if let Ok(results) = searcher.ranked_search(query, alpha) {
|
|
109
|
+
println!("Found {} results for query '{}'", results.len(), query);
|
|
110
|
+
for (item, score) in results {
|
|
111
|
+
println!("- Match: '{}', Score: {:.4}", item, score);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Releasing
|
|
118
|
+
|
|
119
|
+
[Release Please](https://github.com/googleapis/release-please) manages stable
|
|
120
|
+
releases from `main`. Its Rust strategy updates `Cargo.toml`, `Cargo.lock`,
|
|
121
|
+
`CHANGELOG.md`, and `.release-please-manifest.json` in a release PR. Maturin derives
|
|
122
|
+
the Python package version from Cargo, so crates.io and PyPI share one version.
|
|
123
|
+
|
|
124
|
+
### Release process
|
|
125
|
+
|
|
126
|
+
1. Squash-merge changes into `main` using Conventional Commit PR titles. After CI
|
|
127
|
+
passes, Release Please creates or updates the pending release PR.
|
|
128
|
+
2. Review the proposed version and release notes after the release PR passes CI.
|
|
129
|
+
**Merging this PR is the approval to release.**
|
|
130
|
+
3. After CI passes, Release Please creates the `vMAJOR.MINOR.PATCH` tag and GitHub
|
|
131
|
+
release. The shared [build/test workflow](.github/workflows/test.yml) runs against
|
|
132
|
+
that exact release commit, producing separately named release wheel artifacts.
|
|
133
|
+
4. The crate is verified and published to crates.io, followed by the tested release
|
|
134
|
+
wheels to PyPI. TestPyPI receives the same wheels independently of production
|
|
135
|
+
publishing. Publication is automatic after the release tests pass.
|
|
136
|
+
|
|
137
|
+
Ordinary merges update the proposed release and run CI. Registry publishing is
|
|
138
|
+
driven by Release Please's `release_created` output.
|
|
139
|
+
|
|
140
|
+
The [configuration](release-please-config.json) and manifest start from
|
|
141
|
+
`v0.3.5-beta.1`. The `prerelease` versioning strategy with `prerelease: false`
|
|
142
|
+
promotes beta/RC versions to stable versions. With the pending feature changes,
|
|
143
|
+
the first release is **`0.4.0`**. Subsequent versions follow Conventional Commits:
|
|
144
|
+
`fix` and `perf` bump the patch, `feat` bumps the minor, and breaking changes bump
|
|
145
|
+
the minor while the project is below `1.0.0`. Include the
|
|
146
|
+
[Rust API migration](#rust-api-migration) when reviewing the first release notes.
|
|
147
|
+
|
|
148
|
+
### Repository setup
|
|
149
|
+
|
|
150
|
+
- Install a release GitHub App on this repository with **Contents**, **Issues**,
|
|
151
|
+
and **Pull requests** read/write permissions. Add its App ID and private key as
|
|
152
|
+
repository secrets `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY`. The App token
|
|
153
|
+
allows CI to run on the release PR that it creates.
|
|
154
|
+
- Configure `main` to require the **CI** and **PR title** checks before merging.
|
|
155
|
+
Enable squash merging and use the PR title as the squash commit title so Release
|
|
156
|
+
Please can determine the version from the merged history.
|
|
157
|
+
- Configure trusted publishers for `PyDataBlog/simstring_rs`, workflow **`CI.yml`**,
|
|
158
|
+
and environment **`testpypi`** on TestPyPI / **`pypi`** on PyPI. These environments
|
|
159
|
+
use automatic publishing, with no required reviewers.
|
|
160
|
+
- Provide `CARGO_REGISTRY_TOKEN` with permission to publish `simstring_rust`.
|
|
161
|
+
|
|
162
|
+
### Retrying publication
|
|
163
|
+
|
|
164
|
+
Use **Re-run failed jobs** on the original release workflow run. This reuses Release
|
|
165
|
+
Please's outputs and the successful build artifacts. Already-published crate
|
|
166
|
+
versions and wheel files are skipped. Check the publishing jobs to confirm that
|
|
167
|
+
the packages are available in their registries.
|
|
168
|
+
|
|
169
|
+
## Rust API migration
|
|
170
|
+
|
|
171
|
+
Version `0.4.0` introduces breaking changes for custom Rust trait implementations.
|
|
172
|
+
The read-only query engine preserves the usual `HashDb` and `Searcher` calls,
|
|
173
|
+
as well as Python method signatures. Custom Rust implementations need these updates:
|
|
174
|
+
|
|
175
|
+
- **FeatureExtractor**: implement
|
|
176
|
+
`visit_features(&self, text: &str, visitor: &mut dyn FnMut(&str))`, emitting
|
|
177
|
+
occurrence-qualified features. The default `features` method interns, sorts,
|
|
178
|
+
and deduplicates them for insertion; search visits them without interning.
|
|
179
|
+
- **Database**: `interner()` returns `&Rodeo` rather than a locked `Arc`.
|
|
180
|
+
`lookup_strings()` returns sorted, unique `Option<&[StringId]>` postings, and
|
|
181
|
+
`get_features()` returns `Option<&[Spur]>`. Implement `feature_sizes()` as a
|
|
182
|
+
sorted, unique slice of populated sizes. Each ID belongs to exactly one size
|
|
183
|
+
bucket; stored features must be sorted and unique, using the same interner.
|
|
184
|
+
- **Measure**: implement `similarity_from_counts(x_len, y_len, common) -> f64`.
|
|
185
|
+
The default `similarity` intersects sorted feature sets and delegates to it.
|
|
186
|
+
Search uses counts directly, so this method must agree with the pruning bounds.
|
|
187
|
+
|
|
188
|
+
Unknown query features still contribute to similarity denominators. Duplicate
|
|
189
|
+
insertions remain distinct results, and queries with no features return no results.
|
|
190
|
+
Both search methods now apply exact score filtering at threshold boundaries.
|
|
191
|
+
|
|
192
|
+
## Contributing
|
|
193
|
+
|
|
194
|
+
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
|
|
195
|
+
|
|
196
|
+
Use [Conventional Commits](https://www.conventionalcommits.org/) for PR titles,
|
|
197
|
+
for example `fix(search): handle empty queries` or `feat(bindings): add an extractor`.
|
|
198
|
+
Mark breaking changes with `!`, such as `refactor(api)!: change the Database trait`,
|
|
199
|
+
and describe the migration in the PR. PR titles are checked automatically and
|
|
200
|
+
become the squash commit titles used by Release Please.
|
|
201
|
+
|
|
202
|
+
License
|
|
203
|
+
|
|
204
|
+
This project is licensed under the MIT License.
|
|
205
|
+
|
|
206
|
+
## Benchmarks
|
|
207
|
+
|
|
208
|
+
The `benches/run_benches.py` harness compares several language bindings (Rust, Python, Julia, Ruby, C++).
|
|
209
|
+
|
|
210
|
+
- `git`, `autoconf`, `automake`, `libtool`, `make`, `python`, `uv` and a C++ compiler (`g++`) to build the C++ CLI.
|
|
211
|
+
|
|
212
|
+
The C++ sources are cloned into `benches/.simstring_cpp/` and a local copy of the `simstring` binary is installed
|
|
213
|
+
under that directory. If you need to rebuild from scratch, remove `benches/.simstring_cpp/` before re-running the benchmark suite.
|
|
214
|
+
|
|
215
|
+
## Acknowledgements
|
|
216
|
+
|
|
217
|
+
Inspired by the [SimString](https://www.chokkan.org/software/simstring/) project.
|
|
218
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
simstring_rust/__init__.py,sha256=848LALFhj3KZD2jqtwOA_Zd5LkhRP-6Bdp6pagM93I0,139
|
|
2
|
+
simstring_rust/simstring_rust.pyd,sha256=ZB68YjL3wlvc1i0fBHplq-MiHKWXM34hcCEzsCuHACI,509952
|
|
3
|
+
simstring_rust-0.4.0.dist-info/METADATA,sha256=zdmAn7LpXQtkgL5Lu_V3LnAf7g_8Os9vRfdiMQygiBA,10320
|
|
4
|
+
simstring_rust-0.4.0.dist-info/WHEEL,sha256=7HL-TGvq44Ofp0yhZL-uRIIFHcJTIqqkRZVQ2wZidzM,96
|
|
5
|
+
simstring_rust-0.4.0.dist-info/licenses/LICENSE,sha256=1h9YYTCkdwcFEQugoPDFIvMfTply9WBS7b0q7BO6wq8,1093
|
|
6
|
+
simstring_rust-0.4.0.dist-info/sboms/simstring_rust.cyclonedx.json,sha256=nYRP0Z2pnP20uO3f-IjpflDy4PF9btXN9mrN0QkV5O4,46648
|
|
7
|
+
simstring_rust-0.4.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Bernard Brenyah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|