diff --git a/spacy/errors.py b/spacy/errors.py index 6b45e4815..8e1173349 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -48,6 +48,8 @@ class Warnings(object): W008 = ("Evaluating {obj}.similarity based on empty vectors.") W009 = ("Custom factory '{name}' provided by entry points of another " "package overwrites built-in factory.") + W010 = ("As of v2.1.0, the PhraseMatcher doesn't have a phrase length " + "limit anymore, so the max_length argument is now deprecated.") @add_codes @@ -268,6 +270,8 @@ class Errors(object): "NBOR_RELOP.") E101 = ("NODE_NAME should be a new node and NBOR_NAME should already have " "have been declared in previous edges.") + + @add_codes class TempErrors(object): T001 = ("Max length currently 10 for phrase matching") diff --git a/spacy/matcher.pyx b/spacy/matcher.pyx index 8110097bb..b3974977e 100644 --- a/spacy/matcher.pyx +++ b/spacy/matcher.pyx @@ -14,6 +14,7 @@ from .tokens.doc cimport Doc from .tokens.doc cimport get_token_attr from .attrs cimport ID, attr_id_t, NULL_ATTR from .errors import Errors, TempErrors +from .errors import Errors, TempErrors, Warnings, deprecation_warning from .attrs import IDS from .attrs import FLAG61 as U_ENT @@ -550,7 +551,8 @@ cdef class PhraseMatcher: cdef public object _patterns def __init__(self, Vocab vocab, max_length=0): - # TODO: Add deprecation warning on max_length + if max_length != 0: + deprecation_warning(Warnings.W010) self.mem = Pool() self.max_length = max_length self.vocab = vocab