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
The library provides an interactive command-line interface:
hindi-xlit
Available commands:
- Type a word to transliterate
- Type multiple words separated by spaces for batch transliteration
- Type
topk Nto change the number of candidates (default: 5) - Type
helpto show help - Type
quitorexitto exit
API Reference
HindiTransliterator
The main class for Hindi transliteration.
Methods
-
transliterate(word: str, topk: int = 5) -> List[str]- Transliterates a single word to Hindi
- Returns a list of top-k transliteration candidates
-
transliterate_batch(words: List[str], topk: int = 5) -> List[List[str]]- Transliterates multiple words to Hindi
- Returns a list of lists, where each inner list contains top-k transliteration candidates for the corresponding word
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
This library uses the transliteration model from AI4Bharat.
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.0.tar.gz.
File metadata
- Download URL: hindi_xlit-1.0.0.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 |
c55a07c8edb851dedf7d99e5078d72a316dc0f22f6936a310287d4d0f3ef8b5f
|
|
| MD5 |
cc5f52a5fd86f644afd9d92802a5e0e4
|
|
| BLAKE2b-256 |
077dc73cfbcfb73bb884d6f539493716a9f64cef858d33f2018b65a239773baf
|
File details
Details for the file hindi_xlit-1.0.0-py3-none-any.whl.
File metadata
- Download URL: hindi_xlit-1.0.0-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 |
5faa0d9add0576e1338abe9f0cf839779bb3b1ef1456d8c34ddd843bea78c364
|
|
| MD5 |
a2837a923d69cb663d82aa44e89ee8cd
|
|
| BLAKE2b-256 |
0cfa7b09622266e67dbd5fd3d5be64d378617fbb3ec7d5758518225dcba25d19
|