Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use inline flags in token_match patterns #5257

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spacy/lang/fr/tokenizer_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,5 +461,5 @@ def lower_first_letter(text):

TOKENIZER_EXCEPTIONS = _exc
TOKEN_MATCH = re.compile(
"|".join("(?:{})".format(m) for m in _regular_exp), re.IGNORECASE | re.UNICODE
"(?iu)" + "|".join("(?:{})".format(m) for m in _regular_exp)
).match
2 changes: 1 addition & 1 deletion spacy/lang/tokenizer_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
# fmt: on
).strip()

TOKEN_MATCH = re.compile(URL_PATTERN, re.UNICODE).match
TOKEN_MATCH = re.compile("(?u)" + URL_PATTERN).match


BASE_EXCEPTIONS = {}
Expand Down
2 changes: 1 addition & 1 deletion spacy/tokenizer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ cdef class Tokenizer:
))
exclude = util.get_serialization_exclude(deserializers, exclude, kwargs)
msg = util.from_bytes(bytes_data, deserializers, exclude)
for key in ["prefix_search", "suffix_search", "infix_finditer"]:
for key in ["prefix_search", "suffix_search", "infix_finditer", "token_match"]:
if key in data:
data[key] = unescape_unicode(data[key])
if "prefix_search" in data and isinstance(data["prefix_search"], basestring_):
Expand Down