This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
/
classifier_eng_vs_ta.py
58 lines (43 loc) · 1.7 KB
/
classifier_eng_vs_ta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
## This Python file uses the following encoding: utf-8
## (C) 2017 Muthiah Annamalai <ezhillang@gmail.com>
## This code is released under public domain
import codecs
from tamil import utf8
from transliterate import azhagi, jaffna, combinational, algorithm
def demo_classify():
for l in utf8.get_letters_iterable(u"இதுதாண்டாபோலிசு"):
print("%s - %s" % (l, utf8.classify_letter(l)))
def jaffna_transliterate(eng_string):
tamil_tx = algorithm.Iterative.transliterate(
jaffna.Transliteration.table, eng_string
)
return tamil_tx
def azhagi_transliterate(eng_string):
tamil_tx = algorithm.Iterative.transliterate(
azhagi.Transliteration.table, eng_string
)
return tamil_tx
def combinational_transliterate(eng_string):
tamil_tx = algorithm.Iterative.transliterate(
combinational.Transliteration.table, eng_string
)
return tamil_tx
def operations():
# 3 forms of Tamil transliteration for English word
jfile = codecs.open("english_dictionary_words.jaffna", "w", "utf-8")
cfile = codecs.open("english_dictionary_words.combinational", "w", "utf-8")
afile = codecs.open("english_dictionary_words.azhagi", "w", "utf-8")
with codecs.open("english_dictionary_words.txt", "r") as engf:
for idx, w in enumerate(engf.readlines()):
w = w.strip()
if len(w) < 1:
continue
print(idx)
jfile.write(u"%s\n" % jaffna_transliterate(w))
cfile.write(u"%s\n" % combinational_transliterate(w))
afile.write(u"%s\n" % azhagi_transliterate(w))
jfile.close()
cfile.close()
afile.close()
if __name__ == "__main__":
operations()