Skip to main content

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


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.0.tar.gz (742.6 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.0-py3-none-any.whl (767.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dzoseg-0.1.0.tar.gz
  • Upload date:
  • Size: 742.6 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.0.tar.gz
Algorithm Hash digest
SHA256 23fa98030f219ae35a18ec2ebcb94d89f685aaf4edfb49391fdf43843f2cb77b
MD5 cfa24945f2d51d5c86567b2d9ca25815
BLAKE2b-256 5cdaa3da4f46410c9d499e5324b5b3903da304f34d7f91fe1aefa0982b28a6b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dzoseg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 767.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c63d4644fb2f568092fbfd6fe85c88d3cb1a3b8ccec98ce6be74c0f586c4a751
MD5 22021f513521f4611316c07267147350
BLAKE2b-256 8de5ea0ae95a6cb5f31ea7bac235cb59e29e7e851eb0427b59489a39f859e616

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