2019-10-14 13:27:50 +03:00
|
|
|
# coding: utf8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from ...attrs import LIKE_NUM
|
|
|
|
|
|
|
|
|
2019-10-18 12:27:38 +03:00
|
|
|
_num_words = set(
|
|
|
|
"""
|
|
|
|
null eent zwee dräi véier fënnef sechs ziwen aacht néng zéng eelef zwielef dräizéng
|
|
|
|
véierzéng foffzéng siechzéng siwwenzéng uechtzeng uechzeng nonnzéng nongzéng zwanzeg drësseg véierzeg foffzeg sechzeg siechzeg siwenzeg achtzeg achzeg uechtzeg uechzeg nonnzeg
|
2019-10-14 13:27:50 +03:00
|
|
|
honnert dausend millioun milliard billioun billiard trillioun triliard
|
2019-10-18 12:27:38 +03:00
|
|
|
""".split()
|
|
|
|
)
|
2019-10-14 13:27:50 +03:00
|
|
|
|
2019-10-18 12:27:38 +03:00
|
|
|
_ordinal_words = set(
|
|
|
|
"""
|
2019-10-14 13:27:50 +03:00
|
|
|
éischten zweeten drëtten véierten fënneften sechsten siwenten aachten néngten zéngten eeleften
|
|
|
|
zwieleften dräizéngten véierzéngten foffzéngten siechzéngten uechtzéngen uechzéngten nonnzéngten nongzéngten zwanzegsten
|
|
|
|
drëssegsten véierzegsten foffzegsten siechzegsten siwenzegsten uechzegsten nonnzegsten
|
|
|
|
honnertsten dausendsten milliounsten
|
|
|
|
milliardsten billiounsten billiardsten trilliounsten trilliardsten
|
2019-10-18 12:27:38 +03:00
|
|
|
""".split()
|
|
|
|
)
|
|
|
|
|
2019-10-14 13:27:50 +03:00
|
|
|
|
|
|
|
def like_num(text):
|
|
|
|
"""
|
|
|
|
check if text resembles a number
|
|
|
|
"""
|
2019-10-18 12:27:38 +03:00
|
|
|
text = text.replace(",", "").replace(".", "")
|
2019-10-14 13:27:50 +03:00
|
|
|
if text.isdigit():
|
|
|
|
return True
|
2019-10-18 12:27:38 +03:00
|
|
|
if text.count("/") == 1:
|
|
|
|
num, denom = text.split("/")
|
2019-10-14 13:27:50 +03:00
|
|
|
if num.isdigit() and denom.isdigit():
|
|
|
|
return True
|
|
|
|
if text in _num_words:
|
|
|
|
return True
|
|
|
|
if text in _ordinal_words:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2019-10-18 12:27:38 +03:00
|
|
|
LEX_ATTRS = {LIKE_NUM: like_num}
|