A Dzongkha tokenizer and segmenter (Subword & Tseg)
Project description
dzoseg 🇧🇹
dzoseg is a lightweight Python library for Dzongkha text segmentation. It offers a hybrid approach, allowing users to choose between high-performance AI subword tokenization (using SentencePiece) 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 (་).
- Zero-Dependency Logic: Simple to integrate into any NLP pipeline.
- Byte-Fallback: Automatically handles non-Dzongkha characters (English, numbers, etc.) without crashing.
📦 Installation
Install the package via pip:
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 DzongkhaSegmenter
# Initialize the segmenter
ds = DzongkhaSegmenter()
text = "འབྲུག་རྒྱལ་གཞུང་གཙུག་ལག་སློབ་སྡེའི་འོག་ལུ་ཡོད་པའི་ཚན་རིག་དང་འཕྲུལ་རིག་མཐོ་རིམ་སློབ་གྲྭའི་གློག་རིག་དང་འཕྲུལ་རིག་ལས་ཁུངས།"
# Get subword tokens
tokens = ds.segment_subwords(text)
print(f"Subwords: {tokens}")
# Expected Output:
# [' འབྲུག་', 'རྒྱལ་གཞུང་', 'གཙུག་ལག་སློབ་སྡེ', 'འི་', 'འོག་ལུ་ཡོད་པའི་', 'ཚན་རིག་', 'དང་', 'འཕྲུལ་རིག་', 'མཐོ་རིམ་སློབ་གྲྭ', 'འི་', 'གློག་རིག་', 'དང་', 'འཕྲུལ་རིག་', 'ལས་ཁུངས།']
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:
# ['འབྲུག','རྒྱལ','གཞུང', 'ཙུག', 'ལག', 'སློབ', 'སྡེའི', 'འོག', 'ལུ', 'ཡོད', 'པའི', 'ཚན', 'རིག', 'དང', 'འཕྲུལ', 'རིག', 'མཐོ', 'རིམ', 'སློབ', 'གྲྭའི', 'གློག', 'རིག', 'དང', 'འཕྲུལ', 'རིག', 'ལས', 'ཁུངས།']
📊 Model Details
Model Type: Unigram (SentencePiece)
Vocabulary Size: "32,000"
Character Coverage: 100% (1.0)
Input Data: Cleaned Dzongkha Web & Literary Corpus
Byte Fallback: Enabled (True)
📂 Project Structure
dzoseg/
├── src/
│ └── dzoseg/
│ ├── models/
│ │ ├── dzo_unigram_32000.model
│ │ └── dzo_unigram_32000.vocab
│ ├── __init__.py
│ └── segmenter.py
├── examples/
│ ├── basic_usage.py
│ └── bulk_segmentation.py
├── pyproject.toml
└── README.md
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
Maintained by: Karma Wangchuk/https://github.com/KarmaCST/
Contact: karma.cst@rub.edu.bt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 dzoseg-0.1.2.tar.gz.
File metadata
- Download URL: dzoseg-0.1.2.tar.gz
- Upload date:
- Size: 743.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5ab864e510bb713729034913285bf373fa9640c66f8149af5703160f12f61b4
|
|
| MD5 |
a0da22c53ebdb602a0ebdfc1ccb8b0f6
|
|
| BLAKE2b-256 |
1a234b72f4629c344704bb0a87e7e3cd966e0bf1ebf829de37ee21b775f41c74
|
File details
Details for the file dzoseg-0.1.2-py3-none-any.whl.
File metadata
- Download URL: dzoseg-0.1.2-py3-none-any.whl
- Upload date:
- Size: 768.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64214c1a01ad00b1e2ee27e2b81121129354c110871aa37aef013f0891d9c891
|
|
| MD5 |
55e5d220738b3f57bf61c2e8f1a3d599
|
|
| BLAKE2b-256 |
6e98c69450bec16fddd5d7986d9a80f13a672a0633dbddf45cd32be3769d8dfa
|