Created
August 13, 2011 17:22
-
-
Save junaidpv/1144055 to your computer and use it in GitHub Desktop.
To get sambandhika form of a malayalam word.
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
#python3 | |
map_ = ( | |
('്', 'ിന്റെ'), | |
('ൾ', 'ളുടെ'), | |
('ൻ', 'ന്റെ'), | |
('ർ', 'റിന്റെ'), | |
('ൺ', 'ണിന്റെ'), | |
('ൽ', 'ലിന്റെ'), | |
('ം', 'ത്തിന്റെ'), | |
('', 'യുടെ'), | |
) | |
def sambandhika(word): | |
global map_ | |
new_word = word | |
for end, replacement in map_: | |
if word.endswith(end): | |
new_word = (word[:len(end) * -1] + replacement) if len(end) > 0 else word + replacement | |
break | |
return new_word | |
words = [ | |
'രാമൻ', | |
'ഇറാഖ്', | |
'രാധ', | |
'തീരുമാനങ്ങൾ', | |
'അവൻ', | |
'ഇവൾ', | |
'തെങ്ങ്', | |
'കാൽ', | |
'തൂൺ', | |
'മൂക്ക്', | |
'കാർ', | |
'സാർ', | |
'അവർ', | |
] | |
for word in words: | |
print(word, '=>', sambandhika(word)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment