[Ilugc] counting tamil characters with python

Kenneth Gonsalves lawgon at thenilgiris.com
Wed Nov 24 08:50:17 IST 2010


hi,

in context of the discussion on counting tamil characters, here is one
solution:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import codecs

def countsyll(instring):
    s = codecs.utf_8_encode(instring)
    x = codecs.utf_8_decode(s[0])[0]    
    syllen = 0
    vowels = [u'\u0bbe',u'\u0bbf',u'\u0bc0',
                u'\u0bc1',u'\u0bc2',u'\u0bc6',
                u'\u0bc7',u'\u0bc8',u'\u0bca',
                u'\u0bcb',u'\u0bcc',u'\u0bcd',]
    for y in x:
        if y not in vowels:
            syllen += 1    
    return syllen

if __name__=='__main__':
    print countsyll(u'ஆண்டவரின் துணைவன்')

-- 
regards
KG
http://lawgon.livejournal.com



More information about the ilugc mailing list