spaCy/spacy/lang/hu/punctuation.py

54 lines
1.5 KiB
Python
Raw Normal View History

2019-02-08 16:14:49 +03:00
from ..char_classes import LIST_PUNCT, LIST_ELLIPSES, LIST_QUOTES, CONCAT_QUOTES
from ..char_classes import CONCAT_ICONS, UNITS, ALPHA, ALPHA_LOWER, ALPHA_UPPER
2017-05-08 16:49:56 +03:00
# removing ° from the special icons to keep e.g. 99° as one token
_concat_icons = CONCAT_ICONS.replace("\u00B0", "")
2017-05-08 16:49:56 +03:00
_currency = r"\$¢£€¥฿"
_quotes = CONCAT_QUOTES.replace("'", "")
2020-09-02 14:06:16 +03:00
_units = UNITS.replace("%", "")
2017-05-09 01:01:59 +03:00
_prefixes = (
LIST_PUNCT
+ LIST_ELLIPSES
+ LIST_QUOTES
+ [_concat_icons]
+ [r"[,.:](?=[{a}])".format(a=ALPHA)]
)
2017-05-09 01:01:59 +03:00
_suffixes = (
[r"\+"]
+ LIST_PUNCT
+ LIST_ELLIPSES
+ LIST_QUOTES
+ [_concat_icons]
+ [
r"(?<=[0-9])\+",
r"(?<=°[FfCcKk])\.",
r"(?<=[0-9])(?:[{c}])".format(c=_currency),
2020-09-02 14:06:16 +03:00
r"(?<=[0-9])(?:{u})".format(u=_units),
2019-02-08 16:14:49 +03:00
r"(?<=[{al}{e}{q}(?:{c})])\.".format(
al=ALPHA_LOWER, e=r"%²\-\+", q=CONCAT_QUOTES, c=_currency
),
r"(?<=[{al})])-e".format(al=ALPHA_LOWER),
]
)
2017-05-09 01:01:59 +03:00
_infixes = (
LIST_ELLIPSES
+ [_concat_icons]
+ [
r"(?<=[{al}])\.(?=[{au}])".format(al=ALPHA_LOWER, au=ALPHA_UPPER),
r"(?<=[{a}])[,!?](?=[{a}])".format(a=ALPHA),
2019-02-08 16:14:49 +03:00
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),
]
)
2017-05-09 01:01:59 +03:00
TOKENIZER_PREFIXES = _prefixes
TOKENIZER_SUFFIXES = _suffixes
TOKENIZER_INFIXES = _infixes