A Hindi transliteration library based on AI4Bharat's IndicXlit
Project description
Hindi Transliteration Library
A Python library for transliterating English text to Hindi using AI4Bharat's model. This library provides a simple interface for converting English words to their Hindi (Devanagari) equivalents.
Features
- Simple and intuitive API
- Supports both single word and batch transliteration
- Returns multiple transliteration candidates
- CPU-only implementation (no GPU required)
- Interactive command-line interface
Installation
pip install hindi-xlit
Usage
Basic Usage
from hindi_xlit import HindiTransliterator
# Initialize the transliterator
transliterator = HindiTransliterator()
# Transliterate a single word
word = "namaste"
candidates = transliterator.transliterate(word)
print(f"Transliteration candidates for '{word}':")
for i, candidate in enumerate(candidates, 1):
print(f"{i}. {candidate}")
# Transliterate multiple words
words = ["hello", "world"]
results = transliterator.transliterate_batch(words)
for word, candidates in zip(words, results):
print(f"\nTransliteration candidates for '{word}':")
for i, candidate in enumerate(candidates, 1):
print(f"{i}. {candidate}")
Command Line Interface
After installing the package (e.g., via pip from PyPI), you can use the command line interface:
hindi-xlit <word> [topk]
<word>: The word in Roman script to transliterate (required)[topk]: (Optional) Number of transliteration candidates to return (default: 3)
Examples:
hindi-xlit namaste
# Output:
# Transliteration candidates for 'namaste':
# 1. नमस्ते
# 2. नमसते
# 3. नामसते
hindi-xlit hello 5
# Output:
# Transliteration candidates for 'hello':
# 1. हेलो
# 2. हैलो
# 3. हेलों
# 4. हिलो
# 5. हीलो
If you run the command without arguments, it will show usage instructions.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
This library uses the transliteration model from AI4Bharat.
See CHANGELOG.md for release notes.
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 hindi_xlit-1.0.1.tar.gz.
File metadata
- Download URL: hindi_xlit-1.0.1.tar.gz
- Upload date:
- Size: 44.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e85f181a6c1d4b0add2411cf26ab29b6a35c2b22b4cd2f94c45303781915093b
|
|
| MD5 |
65e325a61700225aec416d37682e7e30
|
|
| BLAKE2b-256 |
f24564bbbb465c3fa6a45b12cecc8ab80941be2435d17ec383531ac01bbd81a1
|
File details
Details for the file hindi_xlit-1.0.1-py3-none-any.whl.
File metadata
- Download URL: hindi_xlit-1.0.1-py3-none-any.whl
- Upload date:
- Size: 45.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64375ecb20337e844a5188da40ee82c582715fde64d2014fa08fa025e0504828
|
|
| MD5 |
1adc58b726e7fc24d4b61860ee5bfb37
|
|
| BLAKE2b-256 |
1240f790cb05be3d1db4dca0afe615715cd4d25bb0230a8eefeeb4dbbcdcb8bd
|