Last active
December 19, 2015 17:19
-
-
Save rmehta/5990234 to your computer and use it in GitHub Desktop.
This file contains 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
# -*- coding: utf-8 -*- | |
my_map = { | |
"B": u"\u0901", | |
"Q": u"\u0948\u0902", | |
"R": u"\u0940\u0902", | |
"W": u"\u0902", | |
"b": u"\u0902", | |
"D": u"\u0905", | |
"F": u"\u0907", | |
"F&": u"\u0908", | |
"G": u"\u0909", | |
"S": u"\u090f", | |
"Ss": u"\u0910", | |
"k": u"\u0915", | |
"K": u"\u0916", | |
"i": u"\u0917", | |
"Û": u"\u091a", | |
"Ú": u"\u091c", | |
"p": u"\u091c", | |
"š": u"\u091f", | |
"[": u"\u0921", | |
"l": u"\u0924", | |
"eòe": u"\u0924\u094d\u0924", | |
"L": u"\u0925", | |
"o": u"\u0926", | |
"O": u"\u0927", | |
"v": u"\u0928", | |
"h": u"\u092a", | |
"H": u"\u092b", | |
"y": u"\u092c", | |
"Y": u"\u092d", | |
"c": u"\u092e", | |
"Ù": u"\u092f", | |
"j": u"\u0930", | |
"&": u"\u0930\u094d", | |
"u": u"\u0932", | |
"J": u"\u0935", | |
"M": u"\u0936", | |
"m": u"\u0938", | |
"n": u"\u0939", | |
"eâe": u"\u093e", | |
"ef": u"\u093f", | |
"r": u"\u093f", | |
"eer": u"\u0940", | |
"g": u"\u0941", | |
"t": u"\u0942", | |
"eâs": u"\u0947", | |
"eâ": "", | |
"es": u"\u0947", | |
"s": u"\u0947", | |
"ew": u"\u0948", | |
"w": u"\u0948", | |
"ees": u"\u094b", | |
"eeW": u"\u094b\u0902", | |
"eew": u"\u094c", | |
"ew": u"\u094c", | |
"â": u"\u094d", | |
"eä": u"\u094d", | |
"~": u"\u0964", | |
"$": u"\u0924\u094d\u0930", # tra | |
"ßeer": u'\u0936\u094d\u0930\u0940' # shree | |
} | |
with open("sample2.txt", "r") as infile: | |
intxt = infile.read() | |
for key_len in (5, 4, 3, 2, 1): | |
for key in my_map: | |
if len(key)==key_len: | |
intxt = intxt.replace(key, my_map[key].encode("utf-8")) | |
# all double ee's are aa | |
intxt = intxt.replace("ee", u"\u093e".encode("utf-8")) | |
# empty plain matra "e" not required in unicode | |
intxt = intxt.replace("e", "") | |
# switch the small ee matras (?) | |
# switch half-r to front (0930, 094d) | |
print intxt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment