spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

Custom tokenizer token_match doesn't seem to take proper precedence [reopen #4645]

Open nikeqiang opened this issue 6 years ago • 3 comments

Feature description

Understand there was a design decision to have prefix/suffix matches take precedence over token_match. As noted elsewhere (e.g. #4645), for users that rely heavily on token_match to customize their tokenizer (i.e. not just for URL-matches) this can be a significant breaking change making it difficult to transition to v2.2. Noting there are pros and cons of having pre/suffix take precedence over token_match (and/or special cases, which seem to still take precedence over prefix/suffix), would it be possible to let users decide the order in which the pre/suff-regexes, special cases and token_match are applied in the tokenizer routine? Based on the pseudo code, it seems like this could be a simple fix - i.e. having the token_match come before or after the second while-loop based on user preference. As always, thanks so much for the amazing improvements that are continuously introduced to the spacy library. Really fantastic!

nikeqiang avatar Jun 13 '20 08:06 nikeqiang

Yeah, this change was a bad decision. It worked well for spaCy's internal use of token_match for URLs but not for many other uses. It will be reverted in v2.3.0, which should be released soon. There will then be token_match as in v2.2.1 and url_match for a match with precedence after prefixes and suffixes. If you'd like, you can currently test the dev release spacy==2.3.0.dev1.

adrianeboyd avatar Jun 13 '20 09:06 adrianeboyd

This issue has been automatically closed because it was answered and there was no follow-up discussion.

github-actions[bot] avatar Jun 21 '20 00:06 github-actions[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Nov 04 '21 00:11 github-actions[bot]