Fix chinese number parsing for 11 to 19
This commit is contained in:
parent
70ef6b9e97
commit
0d17f60405
|
@ -66,10 +66,13 @@ def parse_chinese_number:
|
|||
# Special case for when we parse 十 alone
|
||||
| if . == "" then 1 else . end
|
||||
| tonumber
|
||||
# Parsing number by number, ignoring 10, will work as long as there is a digit after 10:
|
||||
# Parsing number by number, ignoring 10, will work as long as there is a digit before and after 10:
|
||||
# 二十八 works because we parse it as 二八 (2 and 8), but 二十 would yield 2 only,
|
||||
# so we multiply manually by 10 when the number ends with 10.
|
||||
| if $input|endswith("十") then . * 10 else . end;
|
||||
# 十八 gives 8 when it should give 18 because it would be parsed as 八, so we add 10 when the number starts with 10.
|
||||
| if $input|endswith("十") then . * 10
|
||||
elif $input|startswith("十") then . + 10
|
||||
else . end;
|
||||
|
||||
# Parse a Traditional or Simplified Chinese date into a Unix timestamp.
|
||||
def parse_chinese_date:
|
||||
|
|
Loading…
Reference in New Issue