Path: blob/master/languages/python/algorithm_syllablecount.py
1240 views
#!/usr/bin/env python1# -*- coding: utf-8 -*-2# written by kennenth gonsalves34import codecs56def countsyll(instring):7"""This function counts the number of characters in a tamil string8This is done by ignoring the vowel additions. If one uses the len9function, the sample string has a length of 17 - but there are actually10only 11 characters"""11s = codecs.utf_8_encode(instring)12print(s)13x = codecs.utf_8_decode(s[0])[0]14print(repr(x))15syllen = 016vowels = ['\u0bbe','\u0bbf','\u0bc0',17'\u0bc1','\u0bc2','\u0bc6',18'\u0bc7','\u0bc8','\u0bca',19'\u0bcb','\u0bcc','\u0bcd',]20for y in x:21if y not in vowels:22syllen += 123return syllen2425if __name__=='__main__':26print(countsyll('ஆண்டவரின் துணைவன்'))272829