2019-04-03 12:13:26 +00:00
|
|
|
|
# coding: utf8
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
2020-04-06 11:18:07 +00:00
|
|
|
|
from ..char_classes import LIST_ELLIPSES, LIST_ICONS, LIST_UNITS, merge_chars
|
|
|
|
|
from ..char_classes import LIST_PUNCT, LIST_QUOTES, CURRENCY, PUNCT
|
2019-04-03 12:13:26 +00:00
|
|
|
|
from ..char_classes import CONCAT_QUOTES, ALPHA, ALPHA_LOWER, ALPHA_UPPER
|
|
|
|
|
|
2020-04-06 11:18:07 +00:00
|
|
|
|
from ..punctuation import TOKENIZER_PREFIXES as BASE_TOKENIZER_PREFIXES
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_prefixes = [",,"] + BASE_TOKENIZER_PREFIXES
|
2019-04-03 12:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Copied from `de` package. Main purpose is to ensure that hyphens are not
|
|
|
|
|
# split on.
|
|
|
|
|
|
2019-08-20 15:36:34 +00:00
|
|
|
|
_quotes = CONCAT_QUOTES.replace("'", "")
|
|
|
|
|
|
|
|
|
|
_infixes = (
|
|
|
|
|
LIST_ELLIPSES
|
|
|
|
|
+ LIST_ICONS
|
|
|
|
|
+ [
|
|
|
|
|
r"(?<=[{}])\.(?=[{}])".format(ALPHA_LOWER, ALPHA_UPPER),
|
|
|
|
|
r"(?<=[{a}])[,!?](?=[{a}])".format(a=ALPHA),
|
|
|
|
|
r'(?<=[{a}"])[:<>=](?=[{a}])'.format(a=ALPHA),
|
|
|
|
|
r"(?<=[{a}]),(?=[{a}])".format(a=ALPHA),
|
|
|
|
|
r"(?<=[{a}])([{q}\)\]\(\[])(?=[{a}])".format(a=ALPHA, q=_quotes),
|
|
|
|
|
r"(?<=[{a}])--(?=[{a}])".format(a=ALPHA),
|
|
|
|
|
]
|
|
|
|
|
)
|
2019-04-03 12:13:26 +00:00
|
|
|
|
|
|
|
|
|
|
2020-04-06 11:18:07 +00:00
|
|
|
|
_list_units = [u for u in LIST_UNITS if u != "%"]
|
|
|
|
|
_units = merge_chars(" ".join(_list_units))
|
|
|
|
|
|
|
|
|
|
_suffixes = (
|
|
|
|
|
["''"]
|
|
|
|
|
+ LIST_PUNCT
|
|
|
|
|
+ LIST_ELLIPSES
|
|
|
|
|
+ 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}][{au}])\.".format(au=ALPHA_UPPER),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
2019-04-03 12:13:26 +00:00
|
|
|
|
|
2020-04-06 11:18:07 +00:00
|
|
|
|
TOKENIZER_PREFIXES = _prefixes
|
2019-04-03 12:13:26 +00:00
|
|
|
|
TOKENIZER_INFIXES = _infixes
|
|
|
|
|
TOKENIZER_SUFFIXES = _suffixes
|