A simple tokenizer for Mon text
Project description
Mon Tokenizer
Tokenize Mon text like a pro. No fancy stuff, just gets the job done.
Quick Start
# Using pip
pip install mon-tokenizer
# Using uv (faster)
uv add mon-tokenizer
from mon_tokenizer import MonTokenizer
tokenizer = MonTokenizer()
text = "ဂွံအခေါင်အရာမွဲသ္ဂောံဒုင်စသိုင်ကၠာကၠာရ။"
# Tokenize
result = tokenizer.encode(text)
print(result["pieces"]) # ['▁ဂွံ', 'အခေါင်', 'အရာ', 'မွဲ', 'သ္ဂောံ', 'ဒုင်စသိုင်', 'ကၠာ', 'ကၠာ', 'ရ', '။']
# Decode
decoded = tokenizer.decode(result["pieces"])
print(decoded) # ဂွံအခေါင်အရာမွဲသ္ဂောံဒုင်စသိုင်ကၠာကၠာရ။
CLI
# Tokenize
mon-tokenizer "ဂွံအခေါင်အရာမွဲသ္ဂောံဒုင်စသိုင်ကၠာကၠာရ။"
# Verbose mode (shows all the details)
mon-tokenizer -v "ဂွံအခေါင်အရာမွဲသ္ဂောံဒုင်စသိုင်ကၠာကၠာရ။"
# Decode tokens back to text
mon-tokenizer -d -t "▁ဂွံ,အခေါင်,အရာ,မွဲ,သ္ဂောံ,ဒုင်စသိုင်,ကၠာ,ကၠာ,ရ,။"
API
encode(text)- Chop text into tokensdecode(pieces)- Glue tokens back togetherdecode_ids(ids)- Convert IDs back to textget_vocab_size()- How many tokens we knowget_vocab()- The whole vocabulary
Dev Setup
git clone git@github.com:janakhpon/mon_tokenizer.git
cd mon_tokenizer
uv sync --dev
uv run pytest
# Release workflow
uv version --bump patch
git add pyproject.toml
git commit -m "v0.1.1"
git tag v0.1.1
git push origin main --tags
License
MIT - do whatever you want with it.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mon_tokenizer-0.1.4.tar.gz
(949.4 kB
view details)
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
mon_tokenizer-0.1.4-py3-none-any.whl
(950.0 kB
view details)
File details
Details for the file mon_tokenizer-0.1.4.tar.gz.
File metadata
- Download URL: mon_tokenizer-0.1.4.tar.gz
- Upload date:
- Size: 949.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22316915ef5b35791bd55d983724e5e40c2ee61c9ae22c896adccc30382d896c
|
|
| MD5 |
ab5e96f5fed23d1865177770f653274f
|
|
| BLAKE2b-256 |
48b6e87e7e4791c1cb6a8a63d012709b7e52a9b878812c135675460e6a3f5876
|
File details
Details for the file mon_tokenizer-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mon_tokenizer-0.1.4-py3-none-any.whl
- Upload date:
- Size: 950.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10b4526ba43badbfee29441f00231758ef160bea3727d611ac1afe67041071fe
|
|
| MD5 |
b1b222f07695ddb11099a221a0f966dc
|
|
| BLAKE2b-256 |
298bab5b32352b1f529cdc06956b08f255c2c314f915cf9bdad9a8b38cbba19b
|