Skip to main content

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 tokens
  • decode(pieces) - Glue tokens back together
  • decode_ids(ids) - Convert IDs back to text
  • get_vocab_size() - How many tokens we know
  • get_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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mon_tokenizer-0.1.4-py3-none-any.whl (950.0 kB view details)

Uploaded Python 3

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

Hashes for mon_tokenizer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 22316915ef5b35791bd55d983724e5e40c2ee61c9ae22c896adccc30382d896c
MD5 ab5e96f5fed23d1865177770f653274f
BLAKE2b-256 48b6e87e7e4791c1cb6a8a63d012709b7e52a9b878812c135675460e6a3f5876

See more details on using hashes here.

File details

Details for the file mon_tokenizer-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mon_tokenizer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 10b4526ba43badbfee29441f00231758ef160bea3727d611ac1afe67041071fe
MD5 b1b222f07695ddb11099a221a0f966dc
BLAKE2b-256 298bab5b32352b1f529cdc06956b08f255c2c314f915cf9bdad9a8b38cbba19b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page