2020-12-22 18:50:34 +03:00
|
|
|
from ...attrs import LIKE_NUM
|
|
|
|
|
|
|
|
_num_words = [
|
|
|
|
"ዜሮ",
|
2021-08-10 14:55:08 +03:00
|
|
|
"ሓደ",
|
2020-12-22 18:50:34 +03:00
|
|
|
"ክልተ",
|
|
|
|
"ሰለስተ",
|
|
|
|
"ኣርባዕተ",
|
|
|
|
"ሓሙሽተ",
|
|
|
|
"ሽድሽተ",
|
|
|
|
"ሸውዓተ",
|
|
|
|
"ሽሞንተ",
|
|
|
|
"ትሽዓተ",
|
2021-08-10 14:55:08 +03:00
|
|
|
"ዓሰርተ",
|
2020-12-22 18:50:34 +03:00
|
|
|
"ዕስራ",
|
|
|
|
"ሰላሳ",
|
|
|
|
"ኣርብዓ",
|
2021-08-10 14:55:08 +03:00
|
|
|
"ሓምሳ",
|
|
|
|
"ሱሳ",
|
2020-12-22 18:50:34 +03:00
|
|
|
"ሰብዓ",
|
|
|
|
"ሰማንያ",
|
2021-08-10 14:55:08 +03:00
|
|
|
"ቴስዓ",
|
2020-12-22 18:50:34 +03:00
|
|
|
"ሚእቲ",
|
|
|
|
"ሺሕ",
|
|
|
|
"ሚልዮን",
|
|
|
|
"ቢልዮን",
|
|
|
|
"ትሪልዮን",
|
|
|
|
"ኳድሪልዮን",
|
2021-08-10 14:55:08 +03:00
|
|
|
"ጋዚልዮን",
|
|
|
|
"ባዚልዮን"
|
2020-12-22 18:50:34 +03:00
|
|
|
]
|
|
|
|
|
2021-08-10 14:55:08 +03:00
|
|
|
# Tigrinya ordinals above 10 are the same as _num_words but start with "መበል "
|
2020-12-22 18:50:34 +03:00
|
|
|
_ordinal_words = [
|
2021-01-15 03:57:36 +03:00
|
|
|
"ቀዳማይ",
|
|
|
|
"ካልኣይ",
|
|
|
|
"ሳልሳይ",
|
2021-08-10 14:55:08 +03:00
|
|
|
"ራብዓይ",
|
2021-01-15 03:57:36 +03:00
|
|
|
"ሓምሻይ",
|
|
|
|
"ሻድሻይ",
|
|
|
|
"ሻውዓይ",
|
|
|
|
"ሻምናይ",
|
2021-08-10 14:55:08 +03:00
|
|
|
"ታሽዓይ",
|
|
|
|
"ዓስራይ"
|
2020-12-22 18:50:34 +03:00
|
|
|
]
|
2021-01-15 03:57:36 +03:00
|
|
|
|
|
|
|
|
2020-12-22 18:50:34 +03:00
|
|
|
def like_num(text):
|
|
|
|
if text.startswith(("+", "-", "±", "~")):
|
|
|
|
text = text[1:]
|
|
|
|
text = text.replace(",", "").replace(".", "")
|
|
|
|
if text.isdigit():
|
|
|
|
return True
|
|
|
|
if text.count("/") == 1:
|
|
|
|
num, denom = text.split("/")
|
|
|
|
if num.isdigit() and denom.isdigit():
|
|
|
|
return True
|
|
|
|
|
|
|
|
text_lower = text.lower()
|
|
|
|
if text_lower in _num_words:
|
|
|
|
return True
|
|
|
|
|
|
|
|
# Check ordinal number
|
|
|
|
if text_lower in _ordinal_words:
|
|
|
|
return True
|
2021-08-10 14:55:08 +03:00
|
|
|
if text_lower.endswith("ይ"):
|
2020-12-22 18:50:34 +03:00
|
|
|
if text_lower[:-2].isdigit():
|
2021-01-15 03:57:36 +03:00
|
|
|
return True
|
2020-12-22 18:50:34 +03:00
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
LEX_ATTRS = {LIKE_NUM: like_num}
|