File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ def num_to_thaiword(number: Optional[int]) -> str:
121121 for search , replac in _EXCEPTIONS .items ():
122122 output = output .replace (search , replac )
123123
124+ # เอ็ด rule: trailing หนึ่ง in ones place (after any place marker)
125+ if number != 1 and number != - 1 and output .endswith ("หนึ่ง" ):
126+ output = output [: - len ("หนึ่ง" )] + "เอ็ด"
127+
124128 if number_temp < 0 :
125129 output = "ลบ" + output
126130
Original file line number Diff line number Diff line change @@ -141,6 +141,12 @@ def test_number(self):
141141 self .assertEqual (num_to_thaiword (0 ), "ศูนย์" )
142142 self .assertEqual (num_to_thaiword (112 ), "หนึ่งร้อยสิบสอง" )
143143 self .assertEqual (num_to_thaiword (- 273 ), "ลบสองร้อยเจ็ดสิบสาม" )
144+ # เอ็ด rule: ones=1 must use เอ็ด when number > 1
145+ self .assertEqual (num_to_thaiword (1 ), "หนึ่ง" )
146+ self .assertEqual (num_to_thaiword (- 1 ), "ลบหนึ่ง" )
147+ self .assertEqual (num_to_thaiword (101 ), "หนึ่งร้อยเอ็ด" )
148+ self .assertEqual (num_to_thaiword (1001 ), "หนึ่งพันเอ็ด" )
149+ self .assertEqual (num_to_thaiword (1000001 ), "หนึ่งล้านเอ็ด" )
144150
145151 self .assertEqual (thaiword_to_num ("ศูนย์" ), 0 )
146152 self .assertEqual (thaiword_to_num ("แปด" ), 8 )
You can’t perform that action at this time.
0 commit comments