Normalize and segment
Normalize Khmer Unicode, score dictionary paths by frequency, recover unknown words with deterministic rules, and split long curated forms with runtime word composition.
Khmer language engine
A dictionary-based Viterbi segmenter for NLP preprocessing, search, formal documents, and embedded applications, without a runtime machine-learning model.
Language processing
Normalize Khmer Unicode, score dictionary paths by frequency, recover unknown words with deterministic rules, and split long curated forms with runtime word composition.
Return whole-span typo diagnostics, Khmer-aware ranked suggestions, and unknown_word flags instead of silently changing input.
Generate safe word-break opportunities and typed token metadata with offsets for downstream systems.
Stable pipeline
The same deterministic core can support search indexing, document review, OCR post-processing, or browser applications.
# Python 3.10 or newer python -m venv .venv # Activate .venv, then install from PyPI python -m pip install khmer-viterbi-segmenter # Segment Khmer text khmer-segment segment "ខ្ញុំស្រឡាញ់ប្រទេសកម្ពុជា"
Quick start
Create a virtual environment and install the published package from PyPI. The bundled runtime data works immediately without a separate download.
source .venv/bin/activate on Linux or macOS.venv\Scripts\Activate.ps1 in Windows PowerShellkhmer_segmenterRelease 0.3.2
The 0.3.x line adds a reviewed spelling-authority layer, runtime word composition, and a new out-of-vocabulary diagnostic, with identical behavior across the Python, Rust, and WebAssembly ports.
Split long curated forms into smaller accepted words with a reviewed keep-list, and expose safe Khmer word-break opportunities with a lone-consonant guard.
Choose an official or community spelling authority, with visual accuracy accepted by default so equivalent COENG DA/TA forms both pass.
Report unsupported fragments as unknown_word without guessing a correction, while genuine typos still return ranked suggestions.
អ្នកគ្រូ from being flagged as typos, a secondary Chuon Nath 1967 frequency source is blended into segmentation costs, and the Python, Rust, WebAssembly, and embedded C ports stay aligned.Published for Python
Install version 0.3.2 from PyPI, or review the API, ports, data terms, benchmarks, and examples in the project repository.