myTokenize
myTokenize is a Python library that tokenizes Myanmar text into syllables, words, phrases, and sentences. It supports multiple tokenization techniques using rule-based, statistical, and neural network-based approaches.
Features
- Syllable Tokenization: Break text into syllables using regex rules.
- BPE and Unigram Tokenization: Leverage SentencePiece models for tokenization.
- Word Tokenization: Segment text into words using:
myWord: Dictionary-based tokenization.CRF: Conditional Random Fields-based tokenization.BiLSTM: Neural network-based tokenization.
- Phrase Tokenization: Identify phrases in text using normalized pointwise mutual information (NPMI).
- Sentence Tokenization: Use a BiLSTM model to segment text into sentences.
Installation
-
Clone the repository:
git clone https://github.com/ThuraAung1601/myTokenize.git cd myTokenize
-
Install dependencies:
pip install -r requirements.txt
-
Install the library:
pip install .
Usage
Syllable Tokenizer
from myTokenize import SyllableTokenizer
tokenizer = SyllableTokenizer()
syllables = tokenizer.tokenize("မြန်မာနိုင်ငံ။")
print(syllables) # ['မြန်', 'မာ', 'နိုင်', 'ငံ', '။']
BPE Tokenizer
from myTokenize import BPETokenizer
tokenizer = BPETokenizer()
tokens = tokenizer.tokenize("ရွေးကောက်ပွဲမှာနိုင်ထားတဲ့ဒေါ်နယ်ထရမ့်")
print(tokens) # ['▁ရွေးကောက်ပွဲ', 'မှာ', 'နိုင်', 'ထား', 'တဲ့', 'ဒေါ်', 'နယ်', 'ထ', 'ရ', 'မ့်']
Word Tokenizer
from myTokenize import WordTokenizer
tokenizer = WordTokenizer(engine="CRF") # Use "myWord", "CRF", or "LSTM"
words = tokenizer.tokenize("မြန်မာနိုင်ငံ။")
print(words) # ['မြန်မာ', 'နိုင်ငံ', '။']
Phrase Tokenizer
from myTokenize import PhraseTokenizer
tokenizer = PhraseTokenizer()
phrases = tokenizer.tokenize("ညာဘက်ကိုယူပြီးတော့တည့်တည့်သွားပါ")
print(phrases) # ['ညာဘက်_ကို', 'ယူ', 'ပြီး_တော့', 'တည့်တည့်', 'သွား_ပါ']
Sentence Tokenizer
from myTokenize import SentenceTokenizer
tokenizer = SentenceTokenizer()
sentences = tokenizer.tokenize("ညာဘက်ကိုယူပြီးတော့တည့်တည့်သွားပါခင်ဗျားငါးမိနစ်လောက်ကြာလိမ့်မယ်")
print(sentences) # [['ညာ', 'ဘက်', 'ကို', 'ယူ', 'ပြီး', 'တော့', 'တည့်တည့်', 'သွား', 'ပါ'], ['ခင်ဗျား', 'ငါး', 'မိနစ်', 'လောက်', 'ကြာ', 'လိမ့်', 'မယ်']]
Folder Structure
./myTokenize/
├── CRFTokenizer
│ └── wordseg_c2_crf.crfsuite
├── SentencePiece
│ ├── bpe_sentencepiece_model.model
│ ├── bpe_sentencepiece_model.vocab
│ ├── unigram_sentencepiece_model.model
│ └── unigram_sentencepiece_model.vocab
├── Tokenizer.py
└── myWord
├── phrase_segment.py
└── word_segment.py
Dependencies
- Python 3.7+
- TensorFlow
- SentencePiece
- pycrfsuite
- Numpy
License
This project is licensed under the MIT License. See the LICENSE file for details.
Authors
- Ye Kyaw Thu
- Thura Aung
Metadata
Release files for myTokenize 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mytokenize-0.1.1.tar.gz | 1.8 MB | Without provenance | Details for mytokenize-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| myTokenize-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for myTokenize-0.1.1-py3-none-any.whl |
Total release size: 3.6 MB
Release files / mytokenize-0.1.1.tar.gz
| Download URL | mytokenize-0.1.1.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c27162a55518d74c65e002eca082fa5bed4ed992e3c118af1150e25fbda3df02
|
|
BLAKE2b-256 checksum How to use checksums |
de9ddc5aaf179b96b08929885c3f812054b27b950267416c1bd1efda5227efcd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.20
|
Release files / myTokenize-0.1.1-py3-none-any.whl
| Download URL | myTokenize-0.1.1-py3-none-any.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3a3dc867cb8c50ee2e13177d68f5c05431179d5d2f4ac836069ceb41f150fe0
|
|
BLAKE2b-256 checksum How to use checksums |
99e006849746492e2a712a4a3720684d731ed80595d9ca575c7ba98582f58b60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.20
|
Security for myTokenize 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.