mongol-norm (Rust)
English
Shape-aware normalizer for Traditional Mongolian (Hudum) script — the engine behind the
mongol-norm Python package: PyPI ships PyO3 bindings of
this crate (crates/mongol-norm-py in the same repository), so both return byte-identical results
for the same version. It implements the UTN #57 v4 shaping pipeline and the FVS-pinned canonical
normalizer with zero dependencies, verified against the shared corpus and golden fixtures in CI.
[]
= "0.1.1"
(The crate is developed in this repository; a git dependency works too.)
use ;
Command line
The crate ships a mongol-norm binary — the same CLI the Python package installs as its
mongol-norm command. It turns a
word into its rendered written-unit sequence (shape), rewrites any encoding of a word into the
one canonical, FVS-pinned Unicode form (normalize), does the same for every Mongolian word
inside free-form text (normalize-text), encodes pre-shaped written units
(normalize-written-units), and tells whether two encodings render identically (same):
|
--locale MNG|TOD|SIB|MCH selects the script (default MNG; only MNG normalizes),
--allow-fallback keeps an uncovered word instead of failing, errors exit with code 2
(same exits 0/1 for same/different), and mongol-norm --help lists every flag.
- Only
MNG(Hudum) has shaping rules and a normalize table;TOD/SIB/MCHshape default and FVS forms only. - The data tables in
src/generated/are generated frommongol_norm/data/*.jsonbyscripts/gen_rust_tables.py— never edit them by hand. - The corpus and golden tests read the repository's shared
tests/directory, socargo testneeds a repository checkout (the published crate does not include them). - Design and fidelity contract:
docs/superpowers/specs/2026-09-01-rust-core-design.md; the Python bindings:docs/superpowers/specs/2026-09-02-python-bindings-design.md.
中文
传统蒙古文(回鹘式)形态感知规范化器的 Rust 引擎——也是 Python 包
mongol-norm 的底层:PyPI 上发布的是本 crate 的 PyO3 绑定
(同仓库的 crates/mongol-norm-py),因此同版本二者结果逐字节相同。实现完整的 UTN #57 v4
整形流程和 FVS 钉死的 canonical 规范化,零依赖;CI 用共享的语料和 golden 固件验证。
[]
= "0.1.1"
(crate 在本仓库中开发,git 依赖亦可。)
- 只有
MNG(回鹘式蒙古文)有整形规则和规范化表;TOD/SIB/MCH只整形默认形和 FVS 形。 src/generated/下的数据表由scripts/gen_rust_tables.py从mongol_norm/data/*.json生成,请勿手改。- 语料与 golden 测试读取仓库共享的
tests/目录,因此cargo test需要仓库 checkout(发布的 crate 不包含它们)。 - 命令行工具
mongol-norm(Python 包安装的mongol-norm命令就是它):shape输出词的书写单元序列,normalize把同一个词的任意编码统一成唯一的 canonical(FVS 钉死)形式,normalize-text只规范化自由文本中的 蒙古文词,normalize-written-units编码已 shape 的书写单元,same判断两种编码是否同形:
|
(--locale 选文种,--allow-fallback 原样保留未覆盖的词;出错退出码 2,same 用 0/1。)