Пример #1
0
    ('chinese yuan', 'CNY'),
    ('dollars', 'USD'),
    ('dollar', 'USD'),
    ('euros', 'EUR'),
    ('euro', 'EUR'),
    ('pounds', 'GBP'),
    ('pound', 'GBP'),
    ('renminbi', 'CNY'),
    ('yens', 'JPY'),
    ('yen', 'JPY'),
    ('yuans', 'CNY'),
    ('yuan', 'CNY')
])

CURRENCY_ABBR_LIST = set(
    list(CURRENCY_SYMBOL_MAP.values()) +
    list(CURRENCY_TOKEN_MAP.values()) +
    list(CURRENCY_PREFIX_MAP.values())
)

CURRENCY_PREFIXES = set(
    list(CURRENCY_PREFIX_MAP.keys()) +
    list(CURRENCY_SYMBOL_MAP.values())
)

CURR_NUM_PTN = NUM_PTN.replace('(?<=\\W|^)', '')

CURRENCY_PTN = r"""
(?P<text>
(?P<prefix>{currency_prefixes}|[{currency_symbols}])\s*
(?P<amount>{num_ptn_1})
Пример #2
0
__version__ = "1.4.0"
__maintainer__ = "LexPredict, LLC"
__email__ = "*****@*****.**"

DEFAULT_CURRENCY = 'USD'

CURRENCY_TOKEN_MAP = OrderedDict([('chinese yuans', 'CNY'),
                                  ('chinese yuan', 'CNY'), ('dollars', 'USD'),
                                  ('dollar', 'USD'), ('euros', 'EUR'),
                                  ('euro', 'EUR'), ('pounds', 'GBP'),
                                  ('pound', 'GBP'), ('renminbi', 'CNY'),
                                  ('yens', 'JPY'), ('yen', 'JPY'),
                                  ('yuans', 'CNY'), ('yuan', 'CNY')])

CURRENCY_ABBR_LIST = set(
    list(CURRENCY_SYMBOL_MAP.values()) + list(CURRENCY_TOKEN_MAP.values()) +
    list(CURRENCY_PREFIX_MAP.values()))

CURRENCY_PREFIXES = set(
    list(CURRENCY_PREFIX_MAP.keys()) + list(CURRENCY_SYMBOL_MAP.values()))

CURR_NUM_PTN = NUM_PTN.replace('(?<=\\W|^)', '')

TRIGGER_WORDS = ['price', 'cost']

CURRENCY_PTN = r"""
(?P<text>
    (?P<prefix>{currency_prefixes}|[{currency_symbols}])\s*
    (?P<amount>{num_ptn_1})
    |
    (?P<amount>{num_ptn_2})\s*