Add deprecation warning for PhraseMatcher max_length

This commit is contained in:
Ines Montani 2018-11-14 19:10:46 +01:00
parent 64257bf3a7
commit bd1b0e396a
2 changed files with 7 additions and 1 deletions

View File

@ -48,6 +48,8 @@ class Warnings(object):
W008 = ("Evaluating {obj}.similarity based on empty vectors.") W008 = ("Evaluating {obj}.similarity based on empty vectors.")
W009 = ("Custom factory '{name}' provided by entry points of another " W009 = ("Custom factory '{name}' provided by entry points of another "
"package overwrites built-in factory.") "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 @add_codes
@ -268,6 +270,8 @@ class Errors(object):
"NBOR_RELOP.") "NBOR_RELOP.")
E101 = ("NODE_NAME should be a new node and NBOR_NAME should already have " E101 = ("NODE_NAME should be a new node and NBOR_NAME should already have "
"have been declared in previous edges.") "have been declared in previous edges.")
@add_codes @add_codes
class TempErrors(object): class TempErrors(object):
T001 = ("Max length currently 10 for phrase matching") T001 = ("Max length currently 10 for phrase matching")

View File

@ -14,6 +14,7 @@ from .tokens.doc cimport Doc
from .tokens.doc cimport get_token_attr from .tokens.doc cimport get_token_attr
from .attrs cimport ID, attr_id_t, NULL_ATTR from .attrs cimport ID, attr_id_t, NULL_ATTR
from .errors import Errors, TempErrors from .errors import Errors, TempErrors
from .errors import Errors, TempErrors, Warnings, deprecation_warning
from .attrs import IDS from .attrs import IDS
from .attrs import FLAG61 as U_ENT from .attrs import FLAG61 as U_ENT
@ -550,7 +551,8 @@ cdef class PhraseMatcher:
cdef public object _patterns cdef public object _patterns
def __init__(self, Vocab vocab, max_length=0): 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.mem = Pool()
self.max_length = max_length self.max_length = max_length
self.vocab = vocab self.vocab = vocab