Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
oorrja
GitHub Repository: oorrja/learntosolveit
Path: blob/master/languages/python/algorithm_syllablecount.py
1240 views
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
# written by kennenth gonsalves
4
5
import codecs
6
7
def countsyll(instring):
8
"""This function counts the number of characters in a tamil string
9
This is done by ignoring the vowel additions. If one uses the len
10
function, the sample string has a length of 17 - but there are actually
11
only 11 characters"""
12
s = codecs.utf_8_encode(instring)
13
print(s)
14
x = codecs.utf_8_decode(s[0])[0]
15
print(repr(x))
16
syllen = 0
17
vowels = ['\u0bbe','\u0bbf','\u0bc0',
18
'\u0bc1','\u0bc2','\u0bc6',
19
'\u0bc7','\u0bc8','\u0bca',
20
'\u0bcb','\u0bcc','\u0bcd',]
21
for y in x:
22
if y not in vowels:
23
syllen += 1
24
return syllen
25
26
if __name__=='__main__':
27
print(countsyll('ஆண்டவரின் துணைவன்'))
28
29