Fast, dependency-free Khmer word segmentation (Rust core with Python bindings)
Project description
khmer-tokenizer
Fast, dependency-free Khmer word segmentation — a Rust core with Python bindings.
Written Khmer has no spaces between words; this package splits it into words correctly and quickly, with an embedded 59,526-word dictionary and no model files, network calls, or Python dependencies.
from khmer_tokenizer import KhmerTokenizer, split_kcc, normalize
tk = KhmerTokenizer()
tk.segment("សួស្តីអ្នកទាំងអស់គ្នា")
# ['សួស្តី', 'អ្នក', 'ទាំងអស់គ្នា']
# Bring your own dictionary and/or strategy:
tk = KhmerTokenizer(strategy="bimm") # bidirectional max-match
tk = KhmerTokenizer(words=["ភាសា", "ខ្មែរ"]) # custom word list
tk = KhmerTokenizer(strategy="unigram",
frequencies={"ភាសា": 500, "ខ្មែរ": 800}) # frequency-scored DP
# Lower-level pieces:
split_kcc("ខ្មែរ") # ['ខ្មែ', 'រ'] — orthographic clusters
normalize("សិទិ្ធ") # 'សិទ្ធិ' — repair Khmer Unicode encoding errors
A typical LLM-pretokenization pipeline: run your corpus through
KhmerTokenizer.segment() and join tokens with a space (or U+200B ZERO
WIDTH SPACE, the Unicode-recommended Khmer boundary marker) before training
a BPE/SentencePiece tokenizer — the learned subword vocabulary will respect
real Khmer word structure instead of merging across word boundaries.
Full documentation, benchmarks (F1 against khPOS and a 80k-sentence web corpus), architecture notes, and the Rust crates live at github.com/Alujack/khmer-tokenizer.
License
MIT OR Apache-2.0. The embedded dictionary is MIT (chamkho / SIL NRSI) —
see the repository's core/ATTRIBUTION.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file khmer_tokenizer-0.1.0.tar.gz.
File metadata
- Download URL: khmer_tokenizer-0.1.0.tar.gz
- Upload date:
- Size: 269.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a03ccb37afac64220b3dfa9f4f177413029ccfcb71d580886f1f46f27c63a8df
|
|
| MD5 |
7f0c36382397b4f2ac42e2eb612999a9
|
|
| BLAKE2b-256 |
4cc29e59a88eb860eb5efbad18431de27cc21bccab567dc9541c6c43556d1883
|
File details
Details for the file khmer_tokenizer-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: khmer_tokenizer-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 485.7 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80e1e54069841e40ee91228713b44a93f92fbc18430aa12f014388ef4e8d6859
|
|
| MD5 |
acb8bcc13ac322d19c8944027646abc6
|
|
| BLAKE2b-256 |
0c52547f76c90a250176aca6c7c5b03b8be2589872864c76a43326d0571456d2
|