Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to list available maps & to view the mappings for a given map #20

Merged
merged 4 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -137,6 +137,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
Loading