2017-03-12 15:07:28 +03:00
|
|
|
|
# coding: utf8
|
2017-02-28 18:07:14 +03:00
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
2017-05-27 18:57:10 +03:00
|
|
|
|
from ..char_classes import LIST_PUNCT, LIST_ELLIPSES, LIST_QUOTES, LIST_ICONS
|
|
|
|
|
from ..char_classes import ALPHA_LOWER, ALPHA_UPPER, ALPHA, HYPHENS, QUOTES, UNITS
|
2017-05-09 01:01:52 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_currency = r"\$|¢|£|€|¥|฿|৳"
|
|
|
|
|
_quotes = QUOTES.replace("'", '')
|
|
|
|
|
_list_punct = LIST_PUNCT + '। ॥'.strip().split()
|
|
|
|
|
|
|
|
|
|
|
2017-05-27 18:57:10 +03:00
|
|
|
|
_prefixes = ([r'\+'] + _list_punct + LIST_ELLIPSES + LIST_QUOTES + LIST_ICONS)
|
2017-05-09 01:01:52 +03:00
|
|
|
|
|
2017-05-27 18:57:10 +03:00
|
|
|
|
_suffixes = (_list_punct + LIST_ELLIPSES + LIST_QUOTES + LIST_ICONS +
|
2017-05-09 01:01:52 +03:00
|
|
|
|
[r'(?<=[0-9])\+',
|
|
|
|
|
r'(?<=°[FfCcKk])\.',
|
|
|
|
|
r'(?<=[0-9])(?:{})'.format(_currency),
|
|
|
|
|
r'(?<=[0-9])(?:{})'.format(UNITS),
|
|
|
|
|
r'(?<=[{}(?:{})])\.'.format('|'.join([ALPHA_LOWER, r'%²\-\)\]\+', QUOTES]), _currency)])
|
|
|
|
|
|
2017-05-27 18:57:10 +03:00
|
|
|
|
_infixes = (LIST_ELLIPSES + LIST_ICONS +
|
2018-09-05 22:49:00 +03:00
|
|
|
|
[r'(?<=[0-9{zero}-{nine}])[+\-\*^=](?=[0-9{zero}-{nine}-])'.format(zero=u'০', nine=u'৯'),
|
2017-05-09 01:01:52 +03:00
|
|
|
|
r'(?<=[{a}]),(?=[{a}])'.format(a=ALPHA),
|
2018-09-05 22:49:00 +03:00
|
|
|
|
r'(?<=[{a}])[{h}](?={ae})'.format(a=ALPHA, h=HYPHENS, ae=u'এ'),
|
|
|
|
|
r'(?<=[{a}])[?";:=,.]*(?:{h})(?=[{a}])'.format(a=ALPHA, h=HYPHENS),
|
|
|
|
|
r'(?<=[{a}"])[:<>=/](?=[{a}])'.format(a=ALPHA)])
|
2017-05-09 01:01:52 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TOKENIZER_PREFIXES = _prefixes
|
|
|
|
|
TOKENIZER_SUFFIXES = _suffixes
|
|
|
|
|
TOKENIZER_INFIXES = _infixes
|