2019-02-08 06:27:21 +03:00
|
|
|
|
# coding: utf8
|
|
|
|
|
from __future__ import unicode_literals
|
2019-02-08 16:14:49 +03:00
|
|
|
|
|
2020-05-19 16:59:55 +03:00
|
|
|
|
from ..char_classes import LIST_ELLIPSES, LIST_PUNCT, LIST_HYPHENS
|
|
|
|
|
from ..char_classes import LIST_ICONS, LIST_QUOTES, CURRENCY, UNITS, PUNCT
|
2019-02-08 16:14:49 +03:00
|
|
|
|
from ..char_classes import CONCAT_QUOTES, ALPHA, ALPHA_LOWER, ALPHA_UPPER
|
2020-05-19 16:59:55 +03:00
|
|
|
|
from ..punctuation import TOKENIZER_PREFIXES as BASE_TOKENIZER_PREFIXES
|
2019-02-08 16:14:49 +03:00
|
|
|
|
|
|
|
|
|
_quotes = CONCAT_QUOTES.replace("'", "")
|
|
|
|
|
|
2020-05-21 15:14:01 +03:00
|
|
|
|
_prefixes = _prefixes = [
|
|
|
|
|
r"(długo|krótko|jedno|dwu|trzy|cztero)-"
|
|
|
|
|
] + BASE_TOKENIZER_PREFIXES
|
2020-05-19 16:59:55 +03:00
|
|
|
|
|
2019-02-08 16:14:49 +03:00
|
|
|
|
_infixes = (
|
|
|
|
|
LIST_ELLIPSES
|
2020-05-19 16:59:55 +03:00
|
|
|
|
+ LIST_ICONS
|
|
|
|
|
+ LIST_HYPHENS
|
2019-02-08 16:14:49 +03:00
|
|
|
|
+ [
|
2020-05-19 16:59:55 +03:00
|
|
|
|
r"(?<=[0-9{al}])\.(?=[0-9{au}])".format(al=ALPHA, au=ALPHA_UPPER),
|
2019-02-08 16:14:49 +03:00
|
|
|
|
r"(?<=[{a}])[,!?](?=[{a}])".format(a=ALPHA),
|
2020-05-19 16:59:55 +03:00
|
|
|
|
r"(?<=[{a}])[:<>=\/](?=[{a}])".format(a=ALPHA),
|
2019-02-08 16:14:49 +03:00
|
|
|
|
r"(?<=[{a}]),(?=[{a}])".format(a=ALPHA),
|
2020-05-19 16:59:55 +03:00
|
|
|
|
r"(?<=[{a}])([{q}\)\]\(\[])(?=[\-{a}])".format(a=ALPHA, q=_quotes),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
_suffixes = (
|
|
|
|
|
["''", "’’", r"\.", "…"]
|
|
|
|
|
+ LIST_PUNCT
|
|
|
|
|
+ LIST_QUOTES
|
|
|
|
|
+ LIST_ICONS
|
|
|
|
|
+ [
|
|
|
|
|
r"(?<=[0-9])\+",
|
|
|
|
|
r"(?<=°[FfCcKk])\.",
|
|
|
|
|
r"(?<=[0-9])(?:{c})".format(c=CURRENCY),
|
|
|
|
|
r"(?<=[0-9])(?:{u})".format(u=UNITS),
|
|
|
|
|
r"(?<=[0-9{al}{e}{p}(?:{q})])\.".format(
|
|
|
|
|
al=ALPHA_LOWER, e=r"%²\-\+", q=CONCAT_QUOTES, p=PUNCT
|
|
|
|
|
),
|
|
|
|
|
r"(?<=[{au}])\.".format(au=ALPHA_UPPER),
|
2019-02-08 16:14:49 +03:00
|
|
|
|
]
|
|
|
|
|
)
|
2019-02-08 06:27:21 +03:00
|
|
|
|
|
2020-05-19 16:59:55 +03:00
|
|
|
|
|
|
|
|
|
TOKENIZER_PREFIXES = _prefixes
|
2019-02-08 06:27:21 +03:00
|
|
|
|
TOKENIZER_INFIXES = _infixes
|
2020-05-19 16:59:55 +03:00
|
|
|
|
TOKENIZER_SUFFIXES = _suffixes
|