Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Created August 13, 2011 17:22
Show Gist options
  • Save junaidpv/1144055 to your computer and use it in GitHub Desktop.
Save junaidpv/1144055 to your computer and use it in GitHub Desktop.
To get sambandhika form of a malayalam word.
#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