do single-number check AFTER conversion from ordinal
This commit is contained in:
parent
0ff4097a47
commit
18c3996020
1 changed files with 4 additions and 4 deletions
|
|
@ -2793,10 +2793,6 @@ def str2int(number):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if i := _STR2INT_MAP.get(number):
|
|
||||||
# it's a single number, return it
|
|
||||||
return i
|
|
||||||
|
|
||||||
# convert sound changes for generic ordinal numbers
|
# convert sound changes for generic ordinal numbers
|
||||||
if number[-2:] == "th":
|
if number[-2:] == "th":
|
||||||
# remove "th"
|
# remove "th"
|
||||||
|
|
@ -2810,6 +2806,10 @@ def str2int(number):
|
||||||
# custom case for ninth
|
# custom case for ninth
|
||||||
elif number[-3:] == "nin":
|
elif number[-3:] == "nin":
|
||||||
number += "e"
|
number += "e"
|
||||||
|
|
||||||
|
if i := _STR2INT_MAP.get(number):
|
||||||
|
# it's a single number, return it
|
||||||
|
return i
|
||||||
|
|
||||||
# split number words by spaces, hyphens and commas, to accommodate multiple styles
|
# split number words by spaces, hyphens and commas, to accommodate multiple styles
|
||||||
numbers = [ word.lower() for word in re.split(r'[-\s\,]',number) if word ]
|
numbers = [ word.lower() for word in re.split(r'[-\s\,]',number) if word ]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue