Skip to content

Commit ab1af0d

Browse files
committed
update tone ordering key
1 parent ff4d4c0 commit ab1af0d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pythainlp/util/collate.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
def _thkey(word: str) -> str:
1616
cv = _RE_TONE.sub("", word) # remove tone
1717
cv = _RE_LV_C.sub("\\2\\1", cv) # switch lead vowel
18-
tone = _RE_TONE.sub(" ", word) # just tone
18+
19+
tone_match = _RE_TONE.search(word)
20+
tone = tone_match.group() if tone_match else ""
1921
return cv + tone
2022

2123

0 commit comments

Comments
 (0)