ctok-rs 0.1.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.
- ctok_rs-0.1.0/CHANGELOG.md +24 -0
- ctok_rs-0.1.0/CONTRIBUTING.md +39 -0
- ctok_rs-0.1.0/Cargo.lock +333 -0
- ctok_rs-0.1.0/Cargo.toml +45 -0
- ctok_rs-0.1.0/LICENSE +22 -0
- ctok_rs-0.1.0/LICENSE.upstream +21 -0
- ctok_rs-0.1.0/PKG-INFO +259 -0
- ctok_rs-0.1.0/README.md +225 -0
- ctok_rs-0.1.0/benchmarks/README.md +22 -0
- ctok_rs-0.1.0/benchmarks/bench.py +656 -0
- ctok_rs-0.1.0/benchmarks/results/ryzen7-5700x-windows11-2026-12-05.json +226 -0
- ctok_rs-0.1.0/data/pieces_v3.json +48890 -0
- ctok_rs-0.1.0/data/pieces_v4_7.json +15358 -0
- ctok_rs-0.1.0/data/unicode_tables.bin +0 -0
- ctok_rs-0.1.0/examples/count.rs +36 -0
- ctok_rs-0.1.0/pyproject.toml +83 -0
- ctok_rs-0.1.0/python/ctok_rs/__init__.py +33 -0
- ctok_rs-0.1.0/python/ctok_rs/__init__.pyi +19 -0
- ctok_rs-0.1.0/python/ctok_rs/_ctok_rs.pyi +54 -0
- ctok_rs-0.1.0/python/ctok_rs/compat.py +47 -0
- ctok_rs-0.1.0/python/ctok_rs/py.typed +0 -0
- ctok_rs-0.1.0/src/error.rs +21 -0
- ctok_rs-0.1.0/src/lib.rs +317 -0
- ctok_rs-0.1.0/src/pins.rs +8 -0
- ctok_rs-0.1.0/src/prepare.rs +242 -0
- ctok_rs-0.1.0/src/python.rs +146 -0
- ctok_rs-0.1.0/src/stream.rs +529 -0
- ctok_rs-0.1.0/src/tile.rs +331 -0
- ctok_rs-0.1.0/src/types.rs +218 -0
- ctok_rs-0.1.0/src/unicode.rs +245 -0
- ctok_rs-0.1.0/src/vocab.rs +475 -0
- ctok_rs-0.1.0/tests/api.rs +197 -0
- ctok_rs-0.1.0/tests/data/ctok_stream_golden.jsonl +3247 -0
- ctok_rs-0.1.0/tests/data/ctok_tile_golden.jsonl +3398 -0
- ctok_rs-0.1.0/tests/data/ctok_vocab_golden.json +1 -0
- ctok_rs-0.1.0/tests/python/conftest.py +38 -0
- ctok_rs-0.1.0/tests/python/test_api.py +152 -0
- ctok_rs-0.1.0/tests/python/test_compat.py +56 -0
- ctok_rs-0.1.0/tests/python/test_parity_corpora.py +58 -0
- ctok_rs-0.1.0/tests/python/test_parity_fuzz.py +101 -0
- ctok_rs-0.1.0/tests/python/test_unicode_edges.py +106 -0
- ctok_rs-0.1.0/tools/README.md +11 -0
- ctok_rs-0.1.0/tools/ctok_fixtures.py +77 -0
- ctok_rs-0.1.0/tools/ctok_fuzz.py +531 -0
- ctok_rs-0.1.0/tools/fuzz_parity.py +102 -0
- ctok_rs-0.1.0/tools/gen_golden_stream.py +488 -0
- ctok_rs-0.1.0/tools/gen_golden_tile.py +258 -0
- ctok_rs-0.1.0/tools/gen_golden_vocab.py +236 -0
- ctok_rs-0.1.0/tools/gen_unicode_tables.py +190 -0
- ctok_rs-0.1.0/tools/parity_report.py +69 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-12-06
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Initial release of `ctok-rs` (Rust crate `ctok-rs` / `ctok_rs` and Python distribution `ctok-rs`).
|
|
15
|
+
- Exact port of upstream `ctok` 1.4.0 counting path covering tokenizer families `v3`, `v4.7`, and `v4.8`.
|
|
16
|
+
- Embedded upstream vocabularies (`data/pieces_v3.json`, `data/pieces_v4_7.json`) verified at load time via SHA-256 pins.
|
|
17
|
+
- Frozen Unicode tables (`data/unicode_tables.bin`) generated from Python 3.12.10, `unicodedata` 15.0.0, and `regex` 2026.5.9.
|
|
18
|
+
- PyO3 Python bindings (`abi3`, Python >= 3.10) exposing `token_count`, `token_counts` (batch, GIL-releasing), `normalize`, `marked_stream`, `__version__`, `UPSTREAM_CTOK_VERSION`, and `UNICODE_PROVENANCE`.
|
|
19
|
+
- `ctok_rs.compat` drop-in module accelerating `token_count`, `normalize`, and `marked_stream` while lazily delegating `tokenize`, `pieces`, and `witness` to upstream `ctok` when installed.
|
|
20
|
+
- Parity test suite and benchmarks against upstream `ctok`.
|
|
21
|
+
- CI and trusted-publishing release workflows.
|
|
22
|
+
|
|
23
|
+
[Unreleased]: https://github.com/StevenTran0410/ctok-rs/compare/v0.1.0...HEAD
|
|
24
|
+
[0.1.0]: https://github.com/StevenTran0410/ctok-rs/releases/tag/v0.1.0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
`ctok-rs` is an exact Rust port of upstream `ctok` 1.4.0. Any change to the counting path must keep **0 mismatches** against upstream `ctok`.
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
- Install Rust `stable` (with `rustfmt` and `clippy`) and Python >= 3.10.
|
|
8
|
+
- Install maturin and build the local extension:
|
|
9
|
+
- `pip install maturin`
|
|
10
|
+
- `maturin develop --release`
|
|
11
|
+
|
|
12
|
+
## Running tests and lint
|
|
13
|
+
|
|
14
|
+
- Rust unit and golden tests: `cargo test`
|
|
15
|
+
- Python tests: `pytest` (parity tests require Python 3.12 and `pip install ctok==1.4.0 regex==2026.5.9`)
|
|
16
|
+
- Fuzz parity against upstream: `python tools/fuzz_parity.py`
|
|
17
|
+
- Lint and formatting:
|
|
18
|
+
- `cargo fmt --check`
|
|
19
|
+
- `cargo clippy --all-targets -- -D warnings`
|
|
20
|
+
- `ruff check .`
|
|
21
|
+
|
|
22
|
+
## Generated data and vocabulary pins
|
|
23
|
+
|
|
24
|
+
- `data/pieces_v3.json` and `data/pieces_v4_7.json` are verbatim upstream blobs pinned by SHA-256 in `src/pins.rs`. Do not edit them directly.
|
|
25
|
+
- `data/unicode_tables.bin` is generated by running `python tools/gen_unicode_tables.py` under Python 3.12 with `ctok==1.4.0` and `regex==2026.5.9`.
|
|
26
|
+
|
|
27
|
+
## Bumping the upstream `ctok` version
|
|
28
|
+
|
|
29
|
+
1. Replace the vocabulary JSON files in `data/` from the new upstream tag.
|
|
30
|
+
2. Update `UPSTREAM_CTOK_VERSION` and the SHA-256 constants in `src/pins.rs`.
|
|
31
|
+
3. Regenerate `data/unicode_tables.bin` and golden fixtures under `tests/data/`.
|
|
32
|
+
4. Re-run `cargo test`, `pytest`, and `python tools/fuzz_parity.py` to confirm 0 mismatches.
|
|
33
|
+
|
|
34
|
+
## PR checklist
|
|
35
|
+
|
|
36
|
+
- [ ] `cargo fmt --check` and `cargo clippy --all-targets -- -D warnings` pass.
|
|
37
|
+
- [ ] `ruff check .` passes with no warnings.
|
|
38
|
+
- [ ] `cargo test` and `pytest` pass, with 0 parity mismatches on upstream corpora and fuzz inputs.
|
|
39
|
+
- [ ] `CHANGELOG.md` updated if user-facing behavior changed.
|
ctok_rs-0.1.0/Cargo.lock
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "block-buffer"
|
|
13
|
+
version = "0.10.4"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
|
16
|
+
dependencies = [
|
|
17
|
+
"generic-array",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[[package]]
|
|
21
|
+
name = "cfg-if"
|
|
22
|
+
version = "1.0.5"
|
|
23
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
25
|
+
|
|
26
|
+
[[package]]
|
|
27
|
+
name = "cpufeatures"
|
|
28
|
+
version = "0.2.17"
|
|
29
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
+
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"libc",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "crypto-common"
|
|
37
|
+
version = "0.1.7"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
|
40
|
+
dependencies = [
|
|
41
|
+
"generic-array",
|
|
42
|
+
"typenum",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "ctok-rs"
|
|
47
|
+
version = "0.1.0"
|
|
48
|
+
dependencies = [
|
|
49
|
+
"pyo3",
|
|
50
|
+
"rustc-hash",
|
|
51
|
+
"serde",
|
|
52
|
+
"serde_json",
|
|
53
|
+
"sha2",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[[package]]
|
|
57
|
+
name = "digest"
|
|
58
|
+
version = "0.10.7"
|
|
59
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
60
|
+
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
|
61
|
+
dependencies = [
|
|
62
|
+
"block-buffer",
|
|
63
|
+
"crypto-common",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[[package]]
|
|
67
|
+
name = "generic-array"
|
|
68
|
+
version = "0.14.7"
|
|
69
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
70
|
+
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
|
71
|
+
dependencies = [
|
|
72
|
+
"typenum",
|
|
73
|
+
"version_check",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "heck"
|
|
78
|
+
version = "0.5.0"
|
|
79
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
81
|
+
|
|
82
|
+
[[package]]
|
|
83
|
+
name = "indoc"
|
|
84
|
+
version = "2.0.8"
|
|
85
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
86
|
+
checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
|
|
87
|
+
dependencies = [
|
|
88
|
+
"rustversion",
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
[[package]]
|
|
92
|
+
name = "itoa"
|
|
93
|
+
version = "1.0.19"
|
|
94
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
95
|
+
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
|
96
|
+
|
|
97
|
+
[[package]]
|
|
98
|
+
name = "libc"
|
|
99
|
+
version = "0.2.191"
|
|
100
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
101
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
102
|
+
|
|
103
|
+
[[package]]
|
|
104
|
+
name = "memchr"
|
|
105
|
+
version = "2.8.3"
|
|
106
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
107
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
108
|
+
|
|
109
|
+
[[package]]
|
|
110
|
+
name = "memoffset"
|
|
111
|
+
version = "0.9.1"
|
|
112
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
113
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
114
|
+
dependencies = [
|
|
115
|
+
"autocfg",
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[[package]]
|
|
119
|
+
name = "once_cell"
|
|
120
|
+
version = "1.21.4"
|
|
121
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
123
|
+
|
|
124
|
+
[[package]]
|
|
125
|
+
name = "portable-atomic"
|
|
126
|
+
version = "1.15.0"
|
|
127
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
128
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
129
|
+
|
|
130
|
+
[[package]]
|
|
131
|
+
name = "proc-macro2"
|
|
132
|
+
version = "1.0.107"
|
|
133
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
135
|
+
dependencies = [
|
|
136
|
+
"unicode-ident",
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
[[package]]
|
|
140
|
+
name = "pyo3"
|
|
141
|
+
version = "0.23.5"
|
|
142
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
143
|
+
checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
|
|
144
|
+
dependencies = [
|
|
145
|
+
"cfg-if",
|
|
146
|
+
"indoc",
|
|
147
|
+
"libc",
|
|
148
|
+
"memoffset",
|
|
149
|
+
"once_cell",
|
|
150
|
+
"portable-atomic",
|
|
151
|
+
"pyo3-build-config",
|
|
152
|
+
"pyo3-ffi",
|
|
153
|
+
"pyo3-macros",
|
|
154
|
+
"unindent",
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
[[package]]
|
|
158
|
+
name = "pyo3-build-config"
|
|
159
|
+
version = "0.23.5"
|
|
160
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
161
|
+
checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
|
|
162
|
+
dependencies = [
|
|
163
|
+
"once_cell",
|
|
164
|
+
"target-lexicon",
|
|
165
|
+
]
|
|
166
|
+
|
|
167
|
+
[[package]]
|
|
168
|
+
name = "pyo3-ffi"
|
|
169
|
+
version = "0.23.5"
|
|
170
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
171
|
+
checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
|
|
172
|
+
dependencies = [
|
|
173
|
+
"libc",
|
|
174
|
+
"pyo3-build-config",
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
[[package]]
|
|
178
|
+
name = "pyo3-macros"
|
|
179
|
+
version = "0.23.5"
|
|
180
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
181
|
+
checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
|
|
182
|
+
dependencies = [
|
|
183
|
+
"proc-macro2",
|
|
184
|
+
"pyo3-macros-backend",
|
|
185
|
+
"quote",
|
|
186
|
+
"syn 2.0.119",
|
|
187
|
+
]
|
|
188
|
+
|
|
189
|
+
[[package]]
|
|
190
|
+
name = "pyo3-macros-backend"
|
|
191
|
+
version = "0.23.5"
|
|
192
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
193
|
+
checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
|
|
194
|
+
dependencies = [
|
|
195
|
+
"heck",
|
|
196
|
+
"proc-macro2",
|
|
197
|
+
"pyo3-build-config",
|
|
198
|
+
"quote",
|
|
199
|
+
"syn 2.0.119",
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
[[package]]
|
|
203
|
+
name = "quote"
|
|
204
|
+
version = "1.0.47"
|
|
205
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
206
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
207
|
+
dependencies = [
|
|
208
|
+
"proc-macro2",
|
|
209
|
+
]
|
|
210
|
+
|
|
211
|
+
[[package]]
|
|
212
|
+
name = "rustc-hash"
|
|
213
|
+
version = "2.1.4"
|
|
214
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
215
|
+
checksum = "ca420ddf5554e546a707e0ecb8bd311d505ee00b40982a7064b8bdc48aa59336"
|
|
216
|
+
|
|
217
|
+
[[package]]
|
|
218
|
+
name = "rustversion"
|
|
219
|
+
version = "1.0.23"
|
|
220
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
221
|
+
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
|
222
|
+
|
|
223
|
+
[[package]]
|
|
224
|
+
name = "serde"
|
|
225
|
+
version = "1.0.229"
|
|
226
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
227
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
228
|
+
dependencies = [
|
|
229
|
+
"serde_core",
|
|
230
|
+
"serde_derive",
|
|
231
|
+
]
|
|
232
|
+
|
|
233
|
+
[[package]]
|
|
234
|
+
name = "serde_core"
|
|
235
|
+
version = "1.0.229"
|
|
236
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
237
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
238
|
+
dependencies = [
|
|
239
|
+
"serde_derive",
|
|
240
|
+
]
|
|
241
|
+
|
|
242
|
+
[[package]]
|
|
243
|
+
name = "serde_derive"
|
|
244
|
+
version = "1.0.229"
|
|
245
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
246
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
247
|
+
dependencies = [
|
|
248
|
+
"proc-macro2",
|
|
249
|
+
"quote",
|
|
250
|
+
"syn 3.0.10",
|
|
251
|
+
]
|
|
252
|
+
|
|
253
|
+
[[package]]
|
|
254
|
+
name = "serde_json"
|
|
255
|
+
version = "1.0.154"
|
|
256
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
257
|
+
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
|
258
|
+
dependencies = [
|
|
259
|
+
"itoa",
|
|
260
|
+
"memchr",
|
|
261
|
+
"serde",
|
|
262
|
+
"serde_core",
|
|
263
|
+
"zmij",
|
|
264
|
+
]
|
|
265
|
+
|
|
266
|
+
[[package]]
|
|
267
|
+
name = "sha2"
|
|
268
|
+
version = "0.10.9"
|
|
269
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
270
|
+
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
|
271
|
+
dependencies = [
|
|
272
|
+
"cfg-if",
|
|
273
|
+
"cpufeatures",
|
|
274
|
+
"digest",
|
|
275
|
+
]
|
|
276
|
+
|
|
277
|
+
[[package]]
|
|
278
|
+
name = "syn"
|
|
279
|
+
version = "2.0.119"
|
|
280
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
281
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
282
|
+
dependencies = [
|
|
283
|
+
"proc-macro2",
|
|
284
|
+
"quote",
|
|
285
|
+
"unicode-ident",
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
[[package]]
|
|
289
|
+
name = "syn"
|
|
290
|
+
version = "3.0.10"
|
|
291
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
292
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
293
|
+
dependencies = [
|
|
294
|
+
"proc-macro2",
|
|
295
|
+
"quote",
|
|
296
|
+
"unicode-ident",
|
|
297
|
+
]
|
|
298
|
+
|
|
299
|
+
[[package]]
|
|
300
|
+
name = "target-lexicon"
|
|
301
|
+
version = "0.12.16"
|
|
302
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
303
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
304
|
+
|
|
305
|
+
[[package]]
|
|
306
|
+
name = "typenum"
|
|
307
|
+
version = "1.20.1"
|
|
308
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
309
|
+
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
|
|
310
|
+
|
|
311
|
+
[[package]]
|
|
312
|
+
name = "unicode-ident"
|
|
313
|
+
version = "1.0.27"
|
|
314
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
315
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
316
|
+
|
|
317
|
+
[[package]]
|
|
318
|
+
name = "unindent"
|
|
319
|
+
version = "0.2.4"
|
|
320
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
321
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
322
|
+
|
|
323
|
+
[[package]]
|
|
324
|
+
name = "version_check"
|
|
325
|
+
version = "0.9.5"
|
|
326
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
327
|
+
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|
328
|
+
|
|
329
|
+
[[package]]
|
|
330
|
+
name = "zmij"
|
|
331
|
+
version = "1.0.23"
|
|
332
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
333
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
ctok_rs-0.1.0/Cargo.toml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "ctok-rs"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "Exact Rust port of ctok's offline Claude token counter, with Python bindings"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
repository = "https://github.com/StevenTran0410/ctok-rs"
|
|
9
|
+
documentation = "https://docs.rs/ctok-rs"
|
|
10
|
+
keywords = ["tokenizer", "tokens", "claude", "anthropic", "ctok"]
|
|
11
|
+
categories = ["text-processing", "api-bindings"]
|
|
12
|
+
authors = ["StevenTran0410"]
|
|
13
|
+
include = [
|
|
14
|
+
"/src",
|
|
15
|
+
"/data",
|
|
16
|
+
"/tests/api.rs",
|
|
17
|
+
"/tests/data",
|
|
18
|
+
"/examples",
|
|
19
|
+
"/Cargo.toml",
|
|
20
|
+
"/README.md",
|
|
21
|
+
"/LICENSE",
|
|
22
|
+
"/LICENSE.upstream",
|
|
23
|
+
"/CHANGELOG.md",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[lib]
|
|
27
|
+
name = "ctok_rs"
|
|
28
|
+
crate-type = ["rlib", "cdylib"]
|
|
29
|
+
|
|
30
|
+
[features]
|
|
31
|
+
default = []
|
|
32
|
+
# Builds the CPython extension module (used by maturin; see pyproject.toml).
|
|
33
|
+
python = ["dep:pyo3"]
|
|
34
|
+
|
|
35
|
+
[dependencies]
|
|
36
|
+
rustc-hash = "2"
|
|
37
|
+
serde = { version = "1", features = ["derive"] }
|
|
38
|
+
serde_json = "1"
|
|
39
|
+
sha2 = "0.10"
|
|
40
|
+
pyo3 = { version = "0.23", optional = true, features = ["extension-module", "abi3-py310"] }
|
|
41
|
+
|
|
42
|
+
[profile.release]
|
|
43
|
+
opt-level = 3
|
|
44
|
+
lto = "fat"
|
|
45
|
+
codegen-units = 1
|
ctok_rs-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sander Land
|
|
4
|
+
Copyright (c) 2026 StevenTran0410
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sander Land
|
|
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.
|