Myanmar Text Segmenter
Project description
Grammar-based Text Segmentation
The mmdt-tokenizer is designed with a grammar-oriented approach to Myanmar text segmentation. It models tokenization through the grammatical structure of the language, particularly the use of postpositions, particles, and predicate constructions.
Core Principles
Pattern Protection
Before segmentation, special patterns such as URLs, numbers, emails, and date formats are temporarily protected to prevent accidental splitting during tokenization.
Grammar-driven lexicons
Lexicons are built around grammatical categories such as postpositions, conjunctions, sentence-final particles, auxiliary verbs, and negation markers. Each entry is syllable-based, allowing flexible matching and better handling of morphological variations.
Pipeline-based rule segmentation
The tokenization process passes through a defined sequence of grammatical matchers (e.g., POSTP, AUX, SFP, NEG), which reflect the syntactic order of Myanmar sentences.
Structural merging
Rules like merge_predicate() combine related chunks (e.g., verb + auxiliary + negation + particle) into coherent grammatical units, producing more linguistically meaningful tokens.
Extensible design
The system is designed to grow with additional grammatical patterns and lexicon types without retraining, making it adaptable for both general text and domain-specific applications.
Summary
This approach enables mmdt-tokenizer to segment Myanmar text based on grammar and structure — resulting in context-aware tokenization that aligns with natural language syntax.
Features
- Normalize Myanmar text (remove unwanted spaces, support space removal modes) (Developed by NW)
- Tokenize into syllables (Developed by NW)
- Protection (Developed by NW)
- Tokenize into words using grammar-rules (Developed by Myo)
- Optionally save tokenization results to CSV (Developed by NW)
Credit & Inspiration
This library draws inspiration from the oppaWord: Myanmar Word Segmenter by Ye Kyaw Thu. The license of oppaWord is MIT.
Folder Structure
src/
└── mmdt_tokenizer/
├── __init__.py
├── core.py
│
├── data/
│
├── preprocessing/
│ ├── __init__.py
│ ├── cleaner.py
│ ├── normalizer.py
│ ├── preprocess.py
│ └── protector.py
│
├── rule_segmenter/
│ ├── __init__.py
| ├── cleaner.py
│ ├── collapse.py
│ ├── engine.py
│ ├── lexicon.py
│ ├── merge_ops.py
│ ├── scanner.py
│ └── types.py
│
├── tokenizer/
│ ├── __init__.py
│ ├── syllable_tokenizer.py
│ └── word_tokenizer.py
│
├── utils/
│ ├── __init__.py
│ ├── config.py
│ ├── csv_utils.py
│ ├── data_utils.py
│ └── patterns.py
│
├── scripts/
│ ├── build_lexicons.py
│ └── build_lexicons.ipynb
│
└── tests/
└─ pyproject.toml
└─ LICENSE
└─ README.md
| Folder | Purpose |
|---|---|
data/ |
Holds raw and formatted datasets, lexicon CSVs, and output files. |
preprocessing/ |
Handles text cleaning, normalization, and input preparation. |
rule_segmenter/ |
Core rule-based segmentation logic, including lexicon operations and chunk merging. |
tokenizer/ |
Contains syllable-level and word-level tokenizers. |
utils/ |
Utility functions — CSV and data handling, text patterns, configs, and helpers. |
scripts/ |
Developer utilities and notebooks (e.g., lexicon builder). |
tests/ |
Unit and integration test cases for validation. |
core.py |
Main entry module coordinating tokenization and pipeline components. |
Installation
pip install mmdt-tokenizer
Usage Example
from mmdt_tokenizer import MyanmarTokenizer
tokenizer = MyanmarTokenizer()
text = "သူသွားမယ်သို့မဟုတ်သူလာမယ်။"
tokens = tokenizer.word_tokenize(text)
print(tokens)
# Expected Output: ["သူ", "သွားမယ်", "သို့မဟုတ်", "သူ", "လာမယ်။"]
License
Distributed under the MIT License. See LICENSE for more information.
Changelog / Versioning
v0.1.0 — initial release with core tokenization features
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 mmdt_tokenizer-0.1.3.tar.gz.
File metadata
- Download URL: mmdt_tokenizer-0.1.3.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccaacac74be67451a450c8fceaa1f436890c1fbf59c4c533b3013d742aaa8900
|
|
| MD5 |
19afd8b3441fc7d087c2210b2fb75d5c
|
|
| BLAKE2b-256 |
02b096dd41f72d2dec4d44bc14606cd8ab955d9fbde855901e27c272964bdbe6
|
File details
Details for the file mmdt_tokenizer-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mmdt_tokenizer-0.1.3-py3-none-any.whl
- Upload date:
- Size: 34.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b6682c2a513f6d4d97c399c6663b2ee47d32f49c6fadf41632126060248d6db
|
|
| MD5 |
b320d00941036edf450ab09056f2af5f
|
|
| BLAKE2b-256 |
f936c64bcbcac04c8d4f77464b9ec6814c4a6c4860088d26212606190660cc15
|