Skip to main content

A Dzongkha tokenizer and segmenter (32k Subword & Tseg)

Project description

dzoseg-Dzongkha Tokenizer

PyPI version License

dzoseg is a Dzongkha Tokenizer. It offers a hybrid approach, allowing users to choose between high-performance AI subword tokenization and traditional Tseg-based segmentation.

🚀 Features

  • Subword Segmentation: Uses a pre-trained Unigram model with a 32,000 vocabulary size for deep learning applications.
  • Tseg Segmentation: A rule-based approach to split text into syllables based on the traditional Dzongkha Tseg (་).
  • Byte-Fallback: Automatically handles non-Dzongkha characters (English, numbers, etc.) without crashing.

📦 Installation

pip install dzoseg

🛠 Usage
1. Subword (AI-Based) Segmentation
This method is recommended for Machine Learning tasks like machine translation or sentiment analysis.

from dzoseg import DzongkhaTokenizer

# Initialize the segmenter
ds = DzongkhaTokenizer()

text = "འབྲུག་རྒྱལ་གཞུང་གཙུག་ལག་སློབ་སྡེའི་འོག་ལུ་ཡོད་པའི་ཚན་རིག་དང་འཕྲུལ་རིག་མཐོ་རིམ་སློབ་གྲྭའི་གློག་རིག་དང་འཕྲུལ་རིག་ལས་ཁུངས།"

# Get subword tokens
tokens = ds.segment_subwords(text)
print(f"Subwords: {tokens}")

# Expected Output: 
# Subwords: [' འབྲུག་', 'རྒྱལ་གཞུང་', 'གཙུག་ལག་སློབ་སྡེ', 'འི་', 'འོག་ལུ་ཡོད་པའི་', 'ཚན་རིག་', 'དང་', 'འཕྲུལ་རིག་', 'མཐོ་རིམ་སློབ་གྲྭ', 'འི་', 'གློག་རིག་', 'དང་', 'འཕྲུལ་རིག་', 'ལས་ཁུངས།']

2. Tseg-based Segmentation
This method splits the text strictly based on the Dzongkha syllable delimiter (Tseg).

# Get syllable-level tokens
syllables = ds.segment_tseg(text)
print(f"Syllables: {syllables}")

# Expected Output: 
# Syllables: ['འབྲུག','རྒྱལ','གཞུང', 'ཙུག', 'ལག', 'སློབ', 'སྡེའི', 'འོག', 'ལུ', 'ཡོད', 'པའི', 'ཚན', 'རིག', 'དང', 'འཕྲུལ', 'རིག', 'མཐོ', 'རིམ', 'སློབ', 'གྲྭའི', 'གློག', 'རིག', 'དང', 'འཕྲུལ', 'རིག', 'ལས', 'ཁུངས།']

📊 Model Details
Model Type: Unigram (SentencePiece)
Vocabulary Size: 32,000
Character Coverage: 100%
Training Data: Cleaned Dzongkha Web & Literary Corpus

📜 License
This project is licensed under the MIT License.
Maintained by: Karma Wangchuk
Contact: karma.cst@rub.edu.bt

---

## Citation

If you use `dzoseg` in your research or projects, please cite the following paper:

**APA:**
Wangchuk, K., Wangchuk, T., & Namgyel, T. (2023). Dzongkha next words prediction using bidirectional LSTM. *Bhutan Journal of Research & Development*, *Special edition 2023*, 1–17. https://doi.org/10.17102/bjrd.rub.se2.038

**BibTeX:**
```bibtex
@article{wangchuk2023dzongkha,
  title={Dzongkha Next Words Prediction Using Bidirectional LSTM},
  author={Wangchuk, Karma and Wangchuk, Tandin and Namgyel, Tenzin},
  journal={Bhutan Journal of Research \& Development},
  volume={Special edition 2023},
  pages={1--17},
  year={2023},
  publisher={Royal University of Bhutan},
  doi={10.17102/bjrd.rub.se2.038}
}

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

dzoseg-0.1.7.tar.gz (743.5 kB view details)

Uploaded Source

Built Distribution

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

dzoseg-0.1.7-py3-none-any.whl (768.6 kB view details)

Uploaded Python 3

File details

Details for the file dzoseg-0.1.7.tar.gz.

File metadata

  • Download URL: dzoseg-0.1.7.tar.gz
  • Upload date:
  • Size: 743.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for dzoseg-0.1.7.tar.gz
Algorithm Hash digest
SHA256 f7e976dbd2de904d781c6da0477bf710931e90551fb147681199627f789f3346
MD5 13450ee1fcd462fe9cf8413515f1e06e
BLAKE2b-256 d8e171db7cabd86078d5e0895bde0f8dfc45e758758dc3c47089ed7946af3156

See more details on using hashes here.

File details

Details for the file dzoseg-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: dzoseg-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 768.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for dzoseg-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 742eeb5cc7b22e9ddeadd0579709cdf7ee4cf58c2ae9c14ecfaf0bb3836fedd7
MD5 43073b017d31a67ee768ac7f44f8f561
BLAKE2b-256 ecc7bd9d0e94faaa681cf9f833987b458f11faf466f88dc004389b368f80b209

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