Skip to main content

Mon Language Detector

Detects Mon (mnw), Burmese (mya) and English (eng), including mixed-script text. Built for filtering scraped corpora.

fastText over character n-grams, with Unicode rules on top: Mon-exclusive characters override the model, other Myanmar-script languages are refused, and every result carries a reliability flag.

Use

from mon_language_detector import LanguageDetector

detector = LanguageDetector()
result = detector.predict("ပ္ဍဲသၞာံ ၁၉၉၀")

if result.reliable and result.label.startswith("mnw"):
    keep(result)

result.basis says where confidence came from — posterior, mon-exclusive, other-myanmar-script, ambiguous-myanmar, too-short, no-script or empty. Threshold on reliable, not on confidence.

Label Meaning
mnw mya eng One language
mnw-eng mya-eng Mixed with English
mnw-mya Myanmar script, too short to tell which
unknown Empty, no script, or another Myanmar-script language

Accuracy

Retrained 2026-08-11. make evaluate reproduces these, once a split exists — data/ is not in the repository, so build one first (below).

Where reliable 0.9980 over 27,085 lines, 77.4% of the split
Overall 0.9565 over 34,988 held-out lines
Per class eng 1.0000 · mya 0.9675 · mnw 0.9107
Model 8.10 MB .ftz, quantized
Throughput 28,149 lines/s, single-threaded, Apple M5

Corpus filtering keeps the reliable rows and drops the rest, so the first row is the one that describes the workload.

Every remaining error is Mon against Burmese, and it is a length problem: 97.7% of them are in lines of 40 characters or fewer. Lines carrying a Mon-exclusive character had none. MIN_UNAMBIGUOUS_MYANMAR_LEN is set at 30 on that evidence, tuned on the split it is scored on — so 0.9980 is optimistic by an unknown margin.

What it cannot do

Three classes, and the Myanmar script is shared by more. Shan, Khamti, Aiton, Karen and Palaung have nowhere to land, and a Mon scrape collects them.

Text carrying a character exclusive to one of those languages now returns unknown. That covers the ones a character can prove; Shan written without them is still labelled Mon. A fourth class needs Shan data nobody has.

Building a model

uv run datasets --explain                      # what the selection keeps and drops
uv run datasets --corpus-root /path/to/corpus  # link a corpus into datasets/
uv run pipeline --target-mon 150000 --target-mya 150000 --target-eng 150000
uv run train --epoch 20 --dim 128
uv run evaluate

Point --corpus-root at a corpus laid out as a directory per source, each holding .txt files. A directory records where a line came from, not what language it is, so the selection step is where that gets fixed; --explain shows the reasoning.

Targets are 150,000 because Burmese has 46,407 unique lines. More buys repetition.

uv run wrangle cleans raw files first. uv run preview spot-checks a model. make check runs ruff, mypy and the tests.

Install

The model ships inside the wheel, so detection works straight after install with nothing further to download:

pip install mon-language-detector

The wrangle CLI needs the [wrangle] extra on top; detection does not:

pip install "mon-language-detector[wrangle]"

The model's training corpus carries terms the repository's MIT grant does not cover — see LICENSE-MODEL.md before redistributing it.

Deployment

The .ftz works with the standard fastText bindings on Android, iOS and WASM.

Licence

MIT for the code. The shipped model is a derived work of a corpus with mixed and partly unresolved terms, and MIT does not reach it — LICENSE-MODEL.md states which sources are established and which are not.

Documents

Metadata

Release files for mon-language-detector 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mon-language-detector 0.2.1
File Size Uploaded
mon_language_detector-0.2.1.tar.gz 6.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mon-language-detector 0.2.1
File Interpreter ABI Platform
mon_language_detector-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 MB

Release files / mon_language_detector-0.2.1.tar.gz

Download URL mon_language_detector-0.2.1.tar.gz
Size 6.7 MB
Tags Source
SHA-256 checksum
How to use checksums
86aef31342e174327c966741f5001f4698d1da357f6470bff86590c47b6a455f
BLAKE2b-256 checksum
How to use checksums
f71f0c39f0cdfedab7156b5b4d8fc5227922dfa6ea871cb2da1f0bef58e2c8bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / mon_language_detector-0.2.1-py3-none-any.whl

Download URL mon_language_detector-0.2.1-py3-none-any.whl
Size 6.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c53f1dfe961a84a2077c404a11275c621a94ddcb3eebc1e5210219afbfdad645
BLAKE2b-256 checksum
How to use checksums
3df3107a0793bfd891f6244de96aa234b1c1e4d43d5a2fef54761db2a298c054
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.2.2

2 release files

This release

0.2.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page