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.1.tar.gz (20.2 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.1-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

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

Hashes for mon_tokenizer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7931a950c50eb95f08028f1718304acc5e02dd03eb308d8d1d9180fc42771f02
MD5 4b6cd57c294492afbb38b0e7bc2593ed
BLAKE2b-256 970e74b9e676b85349ad9e47a39d5c00fffcdea93b875cd4d9ade485b6bf1041

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mon_tokenizer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d70f31ae100d79b497b7de4ee0e4ac59797b1fc36b09f7e80812ce955080402
MD5 2a54fa9ac30954eedc2f6e6fcc113e7d
BLAKE2b-256 95dda6da661297909e89cc54be9ae4f036f88e463cd58d916839269c62f96cb1

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