@@ -166,21 +166,21 @@ def thai_to_eng(text: str) -> str:
166166def thai_keyboard_dist (c1 : str , c2 : str , shift_dist : float = 0.0 ) -> float :
167167 """
168168 Calculate euclidean distance between two Thai characters
169- according to their location on a keyboard layout.
169+ according to their location on a Thai keyboard layout.
170170
171- A modified TIS 820-2531 standard keyboard layout, which is a development
172- from Kedmanee layout, is used in distance calculation
171+ A modified TIS 820-2531 standard keyboard layout, which is developed
172+ from Kedmanee layout and is the most commonly used Thai keyboard layout,
173+ is used in distance calculation.
173174
174- The most widespread Thai keyboard layout is a keyboard layout using
175- TIS 820-2531 layout with key extensions proposed in TIS 820-2536 Draft.
176- See Figure 4 in
175+ The modified TIS 820-2531 is TIS 820-2531 with few key extensions
176+ proposed in TIS 820-2536 draft. See Figure 4, notice grey keys, in
177177 https://www.nectec.or.th/it-standards/keyboard_layout/thai-key.html
178178
179- Please be noted that the latest TIS 820-2538 standard has slight
180- changes in layout (notice the Thai Baht sign) and difference in shift
181- position (notice ฅ and ฃ pair).
182- See Figure 2 in
179+ Noted that the latest TIS 820-2538 has slight changes in layout from
180+ TIS 820-2531. See Figure 2, notice the Thai Baht sign and ฅ-ฃ pair, in
183181 https://www.nectec.or.th/it-standards/std820/std820.html
182+ Since TIS 820-2538 is not widely adopted by keyboard manufacturer,
183+ this function uses the de facto standard modified TIS 820-2531 instead.
184184
185185 :param str c1: first character
186186 :param str c2: second character
@@ -191,6 +191,8 @@ def thai_keyboard_dist(c1: str, c2: str, shift_dist: float = 0.0) -> float:
191191 :Example:
192192
193193 from pythainlp.util import thai_keyboard_dist
194+ thai_keyboard_dist("ด", "ะ")
195+ # 1.4142135623730951
194196 thai_keyboard_dist("ฟ", "ฤ")
195197 # output: 0.0
196198 thai_keyboard_dist("ฟ", "ห")
0 commit comments