Skip to content

Commit 1cfccd0

Browse files
authored
Merge pull request #785 from kangkengkhadev/dev
Fixed some issues in Khavee. It's a problem with use อ
2 parents e20d06f + 07ceb60 commit 1cfccd0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

pythainlp/khavee/core.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ def check_sara(self, word: str)-> str:
113113
sara.remove('เอ')
114114
sara.remove('อิ')
115115
sara.append('เออ')
116-
elif 'เอะ' in sara and 'อา' in sara:
117-
sara.remove('เอะ')
118-
sara.remove('ออ')
119-
sara.append('เอาะ')
120116
elif 'เอ' in sara and 'ออ' in sara and 'อ' in word[-1]:
121117
sara.remove('เอ')
122118
sara.remove('ออ')
@@ -137,6 +133,9 @@ def check_sara(self, word: str)-> str:
137133
sara.remove('เอ')
138134
sara.remove('อา')
139135
sara.append('เอา')
136+
elif 'เ' in word and 'า' in word and 'ะ' in word:
137+
sara = []
138+
sara.append('เอาะ')
140139
if 'อือ' in sara and 'เออ' in sara:
141140
sara.remove('เออ')
142141
sara.remove('อือ')
@@ -164,6 +163,9 @@ def check_sara(self, word: str)-> str:
164163
elif word == 'เอา':
165164
sara = []
166165
sara.append('เอา')
166+
elif word == 'เอาะ':
167+
sara = []
168+
sara.append('เอาะ')
167169
if 'ฤา' in word or 'ฦา' in word:
168170
sara = []
169171
sara.append('อือ')
@@ -178,6 +180,7 @@ def check_sara(self, word: str)-> str:
178180
sara.append('ออ')
179181
elif sara == [] and len(word) == 3:
180182
sara.append('ออ')
183+
181184
if sara == []:
182185
return 'Cant find Sara in this word'
183186
else:
@@ -309,7 +312,7 @@ def check_klon(self, text: str,k_type: int=8) -> Union[List[str], str]:
309312
list_sumpus_sent3 = []
310313
list_sumpus_sent4 = []
311314
for i, sent in enumerate(text.split()):
312-
sub_sent = subword_tokenize(sent, engine='dict')
315+
sub_sent = subword_tokenize(sent,engine='dict')
313316
# print(i)
314317
if len(sub_sent) > 10:
315318
error.append('In the sentence'+str(i+2)+'there are more than 10 words.'+str(sub_sent))
@@ -343,7 +346,7 @@ def check_klon(self, text: str,k_type: int=8) -> Union[List[str], str]:
343346
else:
344347
return error
345348
except:
346-
return 'Something went wrong Make sure you enter it in correct form of klon4.'
349+
return 'Something went wrong Make sure you enter it in correct form of klon 8.'
347350
elif k_type == 4:
348351
try:
349352
error = []
@@ -353,7 +356,7 @@ def check_klon(self, text: str,k_type: int=8) -> Union[List[str], str]:
353356
list_sumpus_sent3 = []
354357
list_sumpus_sent4 = []
355358
for i, sent in enumerate(text.split()):
356-
sub_sent = subword_tokenize(sent, engine='dict')
359+
sub_sent = subword_tokenize(sent,engine='dict')
357360
if len(sub_sent) > 5:
358361
error.append('In the sentence'+str(i+2)+'there are more than 4 words.'+str(sub_sent))
359362
if (i+1) % 4 == 1:

pythainlp/khavee/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# True
1717

1818
# การตรวจสอบคำสำผัสที่ผิด
19-
print('สรร อัน',kv.check_sumpus('สรร','อัน'))
19+
print('สรร อัน',kv.check_sumpus('หมัน','อัน'))
2020
# False
2121

2222
# การตรวจสอบกลอน 8 ที่ถูกฉันทลักษณ์

0 commit comments

Comments
 (0)