Convert numbers to Indonesian words for Text-to-Speech preprocessing.
Transform numeric text into natural Indonesian words:
"Harga saham naik 2,5% menjadi Rp4.150"
↓
"Harga saham naik dua koma lima persen menjadi empat ribu seratus lima puluh rupiah"
- Numbers: Integers, decimals, negatives
- Currency: IDR, USD, EUR
- Formats: Percentages, time, ordinals
- Text Processing: Automatic number detection and normalization
pip install indonesian-number-normalizer
from indonesian_number_normalizer import create_normalizer
normalizer = create_normalizer()
# Basic numbers
normalizer.number_to_words(1234)
# "seribu dua ratus tiga puluh empat"
# Currency
normalizer.convert_currency(4150)
# "empat ribu seratus lima puluh rupiah"
# Text normalization
text = "Harga saham naik 2,5% menjadi Rp4.150 per lembar."
normalizer.normalize_text(text)
# "Harga saham naik dua koma lima persen menjadi empat ribu seratus lima puluh rupiah per lembar."
# Multiple currency support
normalizer.convert_currency(1500000) # IDR
normalizer.convert_currency(1500.50, "USD") # USD
normalizer.convert_currency(1500.50, "EUR") # EUR
normalizer.convert_time("09:30")
# "sembilan lewat tiga puluh menit"
normalizer.convert_percentage(2.5) # "dua koma lima persen"
normalizer.convert_ordinal(3) # "ketiga"
# Clone repository
git clone https://github.com/fiddien/indonesian-number-normalizer.git
cd indonesian-number-normalizer
# Install development dependencies
pip install -e ".[test]"
# Run tests
pytest
Contributions welcome!
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature
) - Commit changes (
git commit -m 'Add AmazingFeature'
) - Push to branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
MIT License - see LICENSE for details.
@software{indonesian_number_normalizer,
title = {Indonesian Number Normalizer},
author = {Ilma Aliya Fiddien},
year = {2024},
url = {https://github.com/fiddien/indonesian-number-normalizer}
}