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.1.tar.gz
(20.2 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
File details
Details for the file mon_tokenizer-0.1.1.tar.gz.
File metadata
- Download URL: mon_tokenizer-0.1.1.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7931a950c50eb95f08028f1718304acc5e02dd03eb308d8d1d9180fc42771f02
|
|
| MD5 |
4b6cd57c294492afbb38b0e7bc2593ed
|
|
| BLAKE2b-256 |
970e74b9e676b85349ad9e47a39d5c00fffcdea93b875cd4d9ade485b6bf1041
|
File details
Details for the file mon_tokenizer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mon_tokenizer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d70f31ae100d79b497b7de4ee0e4ac59797b1fc36b09f7e80812ce955080402
|
|
| MD5 |
2a54fa9ac30954eedc2f6e6fcc113e7d
|
|
| BLAKE2b-256 |
95dda6da661297909e89cc54be9ae4f036f88e463cd58d916839269c62f96cb1
|