File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
22"""
3- Thai soundex - lk82 system
3+ Thai soundex - LK82 system
44
55Python implementation: Korakot Chaovavanich
66https://gist.github.com/korakot/0b772e09340cac2f493868da035597e8
2323
2424def lk82 (text ):
2525 """
26- LK82 - It's a thai soundex rule.
26+ LK82 - It's a Thai soundex rule.
2727
2828 :param str text: Thai word
2929 :return: LK82 soundex
3030 """
3131 if not text :
3232 return ""
3333
34- res = []
3534 text = _RE_1 .sub ("" , text ) # 4.ลบวรรณยุกต์
3635 text = _RE_2 .sub ("" , text ) # 4.ลบตัวการันต์
3736 text = _RE_3 .sub ("" , text ) # 5.ทิ้งไม้ไต่คู่ ฯลฯ
3837
38+ if not text :
39+ return ""
40+
3941 # 6.เข้ารหัสตัวแรก
42+ res = []
4043 if "ก" <= text [0 ] <= "ฮ" :
4144 res .append (text [0 ].translate (_TRANS1 ))
4245 text = text [1 :]
Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ def udom83(text):
5252 text = _RE_10 .sub ("" , text )
5353 text = _RE_11 .sub ("" , text )
5454
55+ if not text :
56+ return ""
57+
5558 sd = text [0 ].translate (_TRANS1 )
5659 sd += text [1 :].translate (_TRANS2 )
5760
You can’t perform that action at this time.
0 commit comments