Skip to content

Commit

Permalink
add backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
VishnuSanal committed Nov 26, 2023
1 parent c5d838f commit 472843d
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions libindic/payyans/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def Unicode2ASCII(self, unicode_text, font):
unicode_text = self.normalizer.normalize(unicode_text)
index = 0
ascii_text = ""
rulesReverse = maps[font]
rulesReverse = self.getRules(font)
self.rulesDict = {v: k for k, v in rulesReverse.items()}
while index < len(unicode_text):
'''കൂട്ടക്ഷരങ്ങള്‍ക്കൊരു കുറുക്കുവഴി'''
Expand Down Expand Up @@ -104,7 +104,7 @@ def Unicode2ASCII(self, unicode_text, font):
return ascii_text

def ASCII2Unicode(self, ascii_text, font):
self.rulesDict = maps[font]
self.rulesDict = self.getRules(font)

prebase_ascii_letters = [k for k, v in self.rulesDict.items() if v in prebase_letters]
postbase_ascii_letters = [k for k, v in self.rulesDict.items() if v in postbase_letters]
Expand Down Expand Up @@ -171,13 +171,33 @@ def isPostbase(self, letter):
'''
return letter in postbase_letters

def getRules(self, font):
if font in maps.keys():
return maps[font]

old_maps = {
'haritha': 'Haritha',
'ambili': 'ML-TTAmbili',
'karthika': 'ML-TTKarthika',
'nandini': 'ML-TTNandini',
'revathi': 'ML-TTRevathi',
'indulekha': 'MLB-TTIndulekha',
'manorama': 'Manorama',
'matweb': 'Matweb',
'valluvar': 'TM-TTValluvar'
}

if font in old_maps.keys():
return maps[old_maps[font]];

raise AttributeError(f"No such map found: {font}")

def get_module_name(self):
return "Payyans Unicode-ASCII Converter"

def get_info(self):
return "ASCII data - Unicode Convertor based on font maps"



def getInstance():
return Payyans()
return Payyans()

0 comments on commit 472843d

Please sign in to comment.