Skip to main content

A professional Python library for local voice and Hmong language processing

Project description

๐Ÿ“š Documentation

๐Ÿ’ก Use Cases

Language Learning

# Learn basic greetings
print(pyhmong.get_greeting("morning"))  # "Nyob zoo sawv ntxov"

# Practice pronunciation with drills
drills = pyhmong.generate_drill("tone")
for drill in drills:
    print(f"Practice: {drill}")

# Quiz yourself with flashcards
cards = pyhmong.quiz_flashcards("food")

Text Processing

# Clean up messy Hmong text
messy = "kuv   YOG  neeg   HMOOB"
clean = pyhmong.normalize_text(messy)  # "Kuv yog neeg hmoob"

# Analyze syllable structure
analysis = pyhmong.check_pronunciation("ntxawg")
print(analysis)  # Shows onset, nucleus, tone

Translation & Dictionary

# Build a vocabulary list
words = ["niam", "txiv", "tub", "ntxhais"]
for word in words:
    english = pyhmong.translate_hm_to_en(word)
    print(f"{word} = {english}")

# Search for related words
results = pyhmong.search_dictionary("family", lang="en")

Grammar Practice

# Practice tenses
sentence = "Kuv mus tsev"
print(pyhmong.conjugate(sentence, "past"))    # Add past marker
print(pyhmong.conjugate(sentence, "future"))  # Add future marker

# Learn classifiers
print(pyhmong.get_classifiers("neeg"))  # ["tus"]
print(pyhmong.get_classifiers("tsev"))  # ["lub"]

๐ŸŽฏ API Overview

Quick Reference

import pyhmong

# === PHONOLOGY ===
pyhmong.normalize_text(text)          # Clean text
pyhmong.get_tone(syllable)            # Get tone marker
pyhmong.convert_tone(syl, tone)       # Change tone
pyhmong.syllable_split(word)          # Split syllables

# === TRANSLATION ===
pyhmong.translate_hm_to_en(word)      # Hmong โ†’ English
pyhmong.translate_en_to_hm(word)      # English โ†’ Hmong
pyhmong.search_dictionary(query)      # Search both ways

# === GRAMMAR ===
pyhmong.detect_pos(word)              # Part of speech
pyhmong.get_classifiers(noun)         # Get classifiers
pyhmong.conjugate(sent, tense)        # Add tense
pyhmong.substitute(sent, old, new)    # Replace words

# === PHRASEBOOK ===
pyhmong.get_greeting(time)            # Greetings
pyhmong.ask_question(topic)           # Questions
pyhmong.basic_dialogue(unit)          # Dialogues

# === NUMBERS ===
pyhmong.num_to_hmong(n)               # 5 โ†’ "tsib"
pyhmong.hmong_to_num(word)            # "ib" โ†’ 1
pyhmong.convert_measure(val, f, t)    # Unit conversion

# === PROVERBS ===
pyhmong.get_proverb(topic)            # Get proverb
pyhmong.explain_idiom(phrase)         # Explain idiom

# === EDUCATION ===
pyhmong.generate_drill(type)          # Pronunciation drills
pyhmong.quiz_flashcards(category)     # Flashcards
pyhmong.check_pronunciation(word)     # Check structure

๐Ÿ”ง Advanced Usage

Using Classes Directly

from pyhmong import HmongProcessor, HmongTranslator, HmongGrammar

# Advanced text processing
processor = HmongProcessor()
parts = processor.decompose_syllable("ntxawg")
print(parts)  # {'onset': 'ntx', 'nucleus': 'aw', 'coda': 'g'}

# Advanced translation
translator = HmongTranslator()
results = translator.search_dictionary("niam", lang="hm")

# Advanced grammar
grammar = HmongGrammar()
pos = grammar.detect_pos("yog")

Batch Processing

# Process multiple texts
texts = [
    "Kuv yog neeg Hmoob",
    "Koj nyob li cas?",
    "Peb mus tsev"
]

for text in texts:
    clean = pyhmong.normalize_text(text)
    tokens = pyhmong.tokenize(clean)
    
    print(f"Text: {text}")
    print(f"Tokens: {tokens}")
    
    for token in tokens:
        translation = pyhmong.translate_hm_to_en(token)
        print(f"  {token} = {translation}")
    print()

๐Ÿ“Š Statistics

  • 22 main functions across 7 categories
  • 100+ Hmong words in dictionary
  • 8 tone markers supported
  • 40+ consonants (including digraphs and trigraphs)
  • 15+ vowels (simple and complex)
  • 3 dialogue units with 12+ phrases
  • 3 flashcard categories (food, family, colors)

๐Ÿ—บ๏ธ Roadmap

Version 0.2.0 (Planned)

  • Extended dictionary (1000+ words)
  • Pahawh Hmong script support
  • Audio pronunciation guide
  • More dialogue units (10+ topics)

Version 0.3.0 (Future)

  • White Hmong vs Green Hmong dialect support
  • Text-to-speech integration
  • Advanced grammar parser
  • Named entity recognition

Version 1.0.0 (Long-term)

  • Machine translation
  • Language detection
  • Part-of-speech tagger (full)
  • Web API wrapper
  • Mobile app support

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Ways to contribute:

  • Add more words to dictionary
  • Create new dialogue units
  • Add proverbs and idioms
  • Improve pronunciation drills
  • Write documentation
  • Report bugs
  • Suggest features

๐Ÿ“– Resources

Learn More About Hmong Language

Related Projects

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Thanks to the Hmong community for preserving this beautiful language
  • Based on Ernest E. Heimbach's White Hmong-English Dictionary
  • Inspired by various NLP libraries and linguistic research
  • Built with modern Python best practices

๐Ÿ“ง Contact & Support

โญ Show Your Support

If you find this library helpful, please consider:

  • Starring the repository โญ
  • Sharing with others who learn Hmong
  • Contributing to the project
  • Reporting issues and suggesting features

๐Ÿ“ Citation

If you use this library in your research or project, please cite:

@software{pyhmong,
  author = {YangNobody12},
  title = {pyhmong: A Comprehensive Python Library for Hmong Language Processing},
  year = {2025},
  url = {https://github.com/yangnobody12/pyhmong},
  version = {0.1.0}
}

Made with โค๏ธ for the Hmong community

Ua tsaug! (Thank you!)# pyhmong ๐Ÿ‡ฑ๐Ÿ‡ฆ

PyPI version Python 3.7+ License: MIT Tests

A professional Python library for Hmong language processing. This library provides tools for working with the Hmong language, including text processing, romanization systems, and linguistic utilities.

Features

๐Ÿ”ค 1. Phonology & Orthography

  • normalize_text(): Standardize Hmong text (fix tones, case, spacing)
  • syllable_split(): Split words into syllables (CV + tone structure)
  • get_tone(): Detect tone markers (-b, -j, -v, -s, -g, -d, -m)
  • convert_tone(): Convert syllables between different tones

๐Ÿ“š 2. Dictionary & Translation

  • translate_hm_to_en(): Translate Hmong โ†’ English (Heimbach Dict based)
  • translate_en_to_hm(): Translate English โ†’ Hmong
  • search_dictionary(): Search with examples and fuzzy matching

๐Ÿ“– 3. Grammar

  • detect_pos(): Detect part of speech (noun, verb, classifier, etc.)
  • get_classifiers(): Get appropriate classifiers for nouns
  • conjugate(): Add tense markers (past, present, future)
  • substitute(): Grammar drill exercises

๐Ÿ’ฌ 4. Phrasebook Utilities

  • get_greeting(): Get greetings (morning, afternoon, evening)
  • ask_question(): Common questions (name, age, location, etc.)
  • basic_dialogue(): Pre-built dialogues by topic (food, family, etc.)

๐Ÿ”ข 5. Numbers & Measures

  • num_to_hmong(): Convert numbers to Hmong words (1 = ib, 2 = ob)
  • hmong_to_num(): Convert Hmong words to numbers
  • convert_measure(): Unit conversions (lbs โ†” kg, miles โ†” km)

๐Ÿ’ญ 6. Proverbs & Idioms

  • get_proverb(): Get Hmong proverbs by topic
  • explain_idiom(): Explain cultural expressions and meanings

๐ŸŽ“ 7. Education Tools

  • generate_drill(): Create pronunciation drills (tone, consonant, vowel)
  • quiz_flashcards(): Flashcard sets by category (food, family, colors)
  • check_pronunciation(): Analyze syllable structure and pronunciation

Installation

Enums

RomanizationSystem:

  • RPA: Romanized Popular Alphabet (default)
  • PAHAWH: Pahawh Hmong script

ToneMarker:

  • B: mid-low tone
  • J: high falling tone
  • V: mid-high rising tone
  • S: low breathy tone
  • G: low falling tone
  • D: high tone
  • M: low glottalized tone
  • NONE: mid tone (unmarked)

Project Structure

pyhmong/
โ”œโ”€โ”€ pyhmong/
โ”‚   โ”œโ”€โ”€ __init__.py          # Package initialization
โ”‚   โ”œโ”€โ”€ core.py              # Main library code
โ”‚   โ””โ”€โ”€ data/                # Data files (if any)
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ””โ”€โ”€ test_pyhmong.py      # Unit tests
โ”œโ”€โ”€ docs/                    # Documentation
โ”œโ”€โ”€ setup.py                 # Package setup
โ”œโ”€โ”€ README.md                # This file
โ”œโ”€โ”€ LICENSE                  # MIT License
โ”œโ”€โ”€ requirements.txt         # Dependencies
โ”œโ”€โ”€ requirements-dev.txt     # Development dependencies
โ”œโ”€โ”€ .gitignore              # Git ignore rules
โ””โ”€โ”€ pytest.ini              # Pytest configuration

Development

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=pyhmong --cov-report=html

# Run specific test file
pytest tests/test_pyhmong.py

# Run specific test
pytest tests/test_pyhmong.py::TestHmongProcessor::test_tokenize_basic

Code Quality

# Format code with Black
black pyhmong tests

# Lint with flake8
flake8 pyhmong tests

# Type checking with mypy
mypy pyhmong

Building Documentation

cd docs
make html

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (pytest)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Code Style Guidelines

  • Follow PEP 8 style guide
  • Use Black for code formatting
  • Write docstrings for all public methods
  • Add unit tests for new features
  • Update documentation as needed

Roadmap

  • Support for Pahawh Hmong script
  • Advanced dictionary with more words
  • Text-to-speech integration
  • Language detection
  • Dialect support (White Hmong, Green Hmong)
  • Machine translation support
  • Named entity recognition
  • Part-of-speech tagging

Resources

Learn More About Hmong Language

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the Hmong community for preserving this beautiful language
  • Inspired by various NLP libraries and linguistic research
  • Built with modern Python best practices

Citation

If you use this library in your research, please cite:

@software{pyhmong,
  author = {YangNobody12},
  title = {pyhmong: A Python Library for Hmong Language Processing},
  year = {2025},
  url = {https://github.com/yangnobody12/pyhmong}
}

Support

Changelog

Version 0.1.0 (2025-10-03)

  • Initial release
  • Basic text processing functions
  • Syllable validation and decomposition
  • Tone marker support
  • Simple dictionary implementation
  • RPA romanization support

Made with โค๏ธ for the Hmong community From PyPI (when published)

pip install pyhmong

From Source

git clone https://github.com/yangnobody12/pyhmong.git
cd pyhmong
pip install -e .

For Development

git clone https://github.com/yangnobody12/pyhmong.git
cd pyhmong
pip install -e ".[dev]"

Quick Start

import pyhmong

# 1. Phonology - Normalize and analyze text
text = "kuv  YOG  neeg"
clean = pyhmong.normalize_text(text)  # "Kuv yog neeg"
tone = pyhmong.get_tone("kuv")  # "V"
converted = pyhmong.convert_tone("kuv", "b")  # "kub"

# 2. Translation - Hmong โ†” English
pyhmong.translate_hm_to_en("niam")  # "mother"
pyhmong.translate_en_to_hm("father")  # "txiv"

# 3. Grammar - Analyze and conjugate
pyhmong.detect_pos("yog")  # "verb"
pyhmong.get_classifiers("neeg")  # ["tus"]
pyhmong.conjugate("Kuv mus tsev", "past")  # "Kuv mus tsev lawm"

# 4. Phrasebook - Common phrases
pyhmong.get_greeting("morning")  # "Nyob zoo sawv ntxov"
pyhmong.ask_question("name")  # "Koj lub npe hu li cas?"

# 5. Numbers - Convert numbers
pyhmong.num_to_hmong(5)  # "tsib"
pyhmong.hmong_to_num("kaum")  # 10

# 6. Proverbs - Cultural expressions
pyhmong.get_proverb("wisdom")  # Returns Hmong proverb

# 7. Education - Learning tools
pyhmong.generate_drill("tone")  # ['pab', 'paj', 'pav', ...]
pyhmong.quiz_flashcards("food")  # {'mov': 'rice', ...}

Usage Examples

Basic Text Processing

from pyhmong import HmongProcessor

processor = HmongProcessor()

# Tokenize text
text = "Nyob zoo, koj nyob li cas?"
tokens = processor.tokenize(text)
print(tokens)

# Count syllables
count = processor.count_syllables(text)
print(f"Number of syllables: {count}")

# Validate syllables
syllables = ["kuv", "koj", "xyz", "peb"]
for syllable in syllables:
    valid = processor.is_valid_syllable(syllable)
    print(f"{syllable}: {valid}")

Tone Analysis

from pyhmong import HmongProcessor

processor = HmongProcessor()

# Get tone of a syllable
tone = processor.get_tone("kuv")
print(f"Tone: {tone}")  # ToneMarker.V: 'mid-high rising tone'

# Decompose syllables
syllable = "ntxawg"
parts = processor.decompose_syllable(syllable)
print(parts)  # {'onset': 'ntx', 'nucleus': 'aw', 'coda': 'g'}

Dictionary Lookup

from pyhmong import HmongDictionary

dictionary = HmongDictionary()

# Look up words
print(dictionary.lookup("kuv"))  # "I, me"
print(dictionary.lookup("koj"))  # "you"

# Add custom words
dictionary.add_word("tsev", "house")
print(dictionary.lookup("tsev"))  # "house"

# Get all words
all_words = dictionary.get_all_words()
print(f"Dictionary has {len(all_words)} words")

Advanced Usage

from pyhmong import HmongProcessor, RomanizationSystem

# Initialize with specific romanization system
processor = HmongProcessor(system=RomanizationSystem.RPA)

# Get linguistic components
consonants = processor.get_initial_consonants()
vowels = processor.get_vowels()

print(f"Number of consonants: {len(consonants)}")
print(f"Number of vowels: {len(vowels)}")

# Process multiple texts
texts = [
    "Kuv yog neeg Hmoob",
    "Koj nyob qhov twg?",
    "Peb mus tsev"
]

for text in texts:
    tokens = processor.tokenize(text)
    normalized = processor.normalize(text)
    print(f"Original: {text}")
    print(f"Tokens: {tokens}")
    print(f"Normalized: {normalized}")
    print()

API Reference

HmongProcessor

Main class for processing Hmong text.

Methods:

  • tokenize(text: str) -> List[str]: Tokenize text into syllables
  • is_valid_syllable(syllable: str) -> bool: Check if syllable is valid
  • get_tone(syllable: str) -> Optional[ToneMarker]: Extract tone from syllable
  • decompose_syllable(syllable: str) -> Dict: Break down syllable structure
  • count_syllables(text: str) -> int: Count syllables in text
  • normalize(text: str) -> str: Normalize text formatting
  • get_initial_consonants() -> Set[str]: Get all valid consonants
  • get_vowels() -> Set[str]: Get all valid vowels

HmongDictionary

Dictionary class for Hmong words.

Methods:

  • lookup(word: str) -> Optional[str]: Look up word definition
  • add_word(word: str, definition: str): Add new word to dictionary
  • get_all_words() -> List[str]: Get all words in dictionary

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

pylocalvoice-0.1.0.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

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

pylocalvoice-0.1.0-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pylocalvoice-0.1.0.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pylocalvoice-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba3cb899a4e7efc0977d615e776e39997a7cdeca2665bf2bf7ebd459350d8fcd
MD5 2577cbdbcad03319f326c1583eb7d421
BLAKE2b-256 5f6a4aeeb9444f02c63a2cbc0f32782cc0b209a4951aef47fb64b317618956c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pylocalvoice-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pylocalvoice-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5a00a43309eaf9ef5faa56d8163026b163778a78fa40886a02577d33ad40f47
MD5 5c00b9345432fee585de6c253939d923
BLAKE2b-256 e36f20b39ed2e6a36fd661c5c03a0b4ad0ee24a9fd243e16eed5ee5a521bafa7

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