Skip to content

Commit 5e44053

Browse files
committed
update royin.py
1 parent 853c345 commit 5e44053

File tree

1 file changed

+3
-53
lines changed

1 file changed

+3
-53
lines changed

pythainlp/romanization/royin.py

+3-53
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import,division,unicode_literals,print_function
33
import re
4-
import six
54
vowel_data_py3="""เ*ียว,\\1iao
65
แ*็ว,\\1aeo
76
แ*ว,\\1aeo
@@ -50,58 +49,7 @@
5049
*า,\\1a
5150
*ั,\\1a
5251
*ะ,\\1a"""
53-
vowel_data_py2="""เ*ียว,\1iao
54-
แ*็ว,\1aeo
55-
แ*ว,\1aeo
56-
เ*็ว,\1eo
57-
เ*ว,\1eo
58-
*ิว,\1io
59-
*วย,\1uai
60-
เ*ือย,\1ueai
61-
เ*ย,\1oei
62-
*อย,\1oi
63-
โ*ย,\1oi
64-
*ุย,\1ui
65-
*าย,\1ai
66-
ไ*ย,\1ai
67-
*ัย,\1ai
68-
ไ*,\1ai
69-
ใ*,\1ai
70-
*ว*,\1ua\2
71-
*ัวะ,\1ua
72-
*ัว,\1ua
73-
เ*ือะ,\1uea
74-
เ*ือ,\1uea
75-
เ*ียะ,\1ia
76-
เ*ีย,\1ia
77-
เ*อะ,\1oe
78-
เ*อ,\1oe
79-
เ*ิ,\1oe
80-
*อ,\1o
81-
เ*าะ,\1o
82-
โ*ะ,\1o
83-
โ*,\1o
84-
แ*ะ,\1ae
85-
แ*,\1ae
86-
เ*าะ,\1e
87-
*าว,\1ao
88-
เ*า,\1ao
89-
เ*็,\1e
90-
เ*,\1e
91-
*ู,\1u
92-
*ุ,\1u
93-
*ื,\1ue
94-
*ึ,\1ue
95-
*ี,\1i
96-
*ิ,\1i
97-
*ำ,\1am
98-
*า,\1a
99-
*ั,\1a
100-
*ะ,\1a"""
101-
if six.PY2:
102-
vowel_data=vowel_data_py2.replace('*','([ก-ฮ])')
103-
else:
104-
vowel_data=vowel_data_py3.replace('*','([ก-ฮ])')
52+
vowel_data=vowel_data_py3.replace('*','([ก-ฮ])')
10553
reader = [x.split(',') for x in vowel_data.split('\n')]
10654
def deletetone(data):
10755
'''โค้ดส่วนตัดวรรณยุกต์ออก'''
@@ -180,6 +128,8 @@ def consonants(word,res):
180128
elif i==0 and res[0]!="ห":
181129
word=word.replace(res[0],consonants_data[res[0]][0])
182130
i+=1
131+
elif res[i]=="ร" and (word[i]=="ร" and len(word)==i+1):
132+
word=word.replace(res[i],consonants_data[res[i]][1])
183133
elif res[i]=="ร" and (word[i]=="ร" and word[i+1]=="ร"):
184134
word=list(word)
185135
del word[i+1]

0 commit comments

Comments
 (0)