You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from __future__ importabsolute_import,unicode_literals
2
+
3
+
from __future__ importabsolute_import, unicode_literals
3
4
frompythainlp.tokenizeimportword_tokenize
4
-
# ถอดเสียงภาษาไทยเป็น Latin
5
-
defromanization(data,engine='royin'):
6
-
"""
7
-
:param str data: Thai text to be romanized
8
-
:param str engine: choose between 'royin' , 'pyicu' and 'thai2rom'. 'royin' will romanize according to the standard of Thai Royal Institute. 'pyicu' will romanize according to the Internaitonal Phonetic Alphabet. 'thai2rom' is deep learning thai romanization.
9
-
:return: English (more or less) text that spells out how the Thai text should read.
10
-
"""
11
-
word_list=word_tokenize(data)
12
-
listword=[]
13
-
i=0
14
-
ifengine=='royin':
15
-
from .royinimportromanization
16
-
elifengine=='pyicu':
17
-
from .pyicuimportromanization
18
-
elifengine=='thai2rom':
19
-
frompythainlp.romanization.thai2romimportthai2rom
20
-
thai=thai2rom()
21
-
returnthai.romanization(data)
22
-
else:
23
-
raiseException("error no have engine.")
24
-
whilei<len(word_list):
25
-
listword.append(romanization(word_list[i]))
26
-
i+=1
27
-
return''.join(listword)
5
+
6
+
7
+
# ถอดเสียงภาษาไทยเป็นอักษรละติน
8
+
defromanize(text, engine="royin"):
9
+
"""
10
+
:param str data: Thai text to be romanized
11
+
:param str engine: choose between 'royin' (default), 'pyicu', and 'thai2rom'. 'royin' will romanize according to the standard of Thai Royal Institute. 'pyicu' will romanize according to the Internaitonal Phonetic Alphabet. 'thai2rom' is deep learning Thai romanization.
12
+
:return: English (more or less) text that spells out how the Thai text should read.
0 commit comments