Created
August 9, 2020 05:47
-
-
Save rahul1990gupta/6f84dd20b3b95c4a9318b16e3426727e to your computer and use it in GitHub Desktop.
Transliteration from Hindi to english
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from indic_transliteration import sanscript | |
from indic_transliteration.sanscript import SchemeMap, SCHEMES, transliterate | |
def to_hindi(text): | |
return transliterate(text, sanscript.HK, sanscript.DEVANAGARI) | |
def to_roman(text): | |
return transliterate(text, sanscript.DEVANAGARI, sanscript.HK) | |
hindi_sentence = "मैं खाना खा रहा हूँ" | |
print(hindi_sentence) | |
sent2 = to_roman(hindi_sentence) | |
print(sent2) | |
sent3 = to_hindi(sent2) | |
print(sent3) | |
sent4 = to_roman(sent3) | |
print(sent4) | |
assert hindi_sentence == sent3 | |
assert sent2 == sent4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output of the program