Skip to content

Commit

Permalink
Add functions to list available maps & to view the mappings for a giv…
Browse files Browse the repository at this point in the history
…en map (#20)

* list available maps

* print map

* update README with usage of map listing functions

* Update README.md
  • Loading branch information
VishnuSanal committed Feb 17, 2024
1 parent a4653fb commit e0afca6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ to Unicode and vice-versa. More fonts can be added by placing their maps in

## Usage
```
>>> from libindic.payyans import Payyans
>>> instance = Payyans()
>>> result = instance.ASCII2Unicode("aebmfw", "ambili")
>>> print(result)
മലയാളം
>>> result2 = instance.Unicode2ASCII(u"കേരളം", "ambili")
>>> print(result2)
tIcfw
from libindic.payyans import Payyans
instance = Payyans()
result = instance.ASCII2Unicode("aebmfw", "ambili")
print(result) # മലയാളം
result2 = instance.Unicode2ASCII(u"കേരളം", "ambili")
print(result2) # tIcfw
instance.listAvailableMaps() # Haritha, ML-TTAmbili, ML-TTKarthika, ML-TTNandini, ML-TTRevathi, MLB-TTIndulekha, Manorama, Matweb, TM-TTValluvar, banglapedia, charaka, panchari, revathi, uma
instance.printMap('Haritha') # prints the whole mapping file
```

[Watch this video to know more about what ASCII and Unicode encodings are](https://smc.org.in/articles/ascii-unicode-fonts)
Expand Down
12 changes: 12 additions & 0 deletions libindic/payyans/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ def ASCII2Unicode(self, ascii_text, font):

return unicode_text # മതം മാറ്റി തിരിച്ചു കൊടുക്ക്വാ !

def listAvailableMaps(self):
for key in maps.keys():
print(key, end=", ")

def printMap(self, font):
rules = self.getRules(font)

print("{:<3} {:<6}".format('Key', 'Target'))

for key, val in rules.items():
print("{:<2} : {:<3}".format(key, val), end="\n")

def getVowelSign(self, vowel_letter, vowel_sign_letter):
vowel = vowel_letter.encode('utf-8')
vowel_sign = vowel_sign_letter.encode('utf-8')
Expand Down

0 comments on commit e0afca6

Please sign in to comment.