diff --git a/spacy/__init__.py b/spacy/__init__.py index 9acc566ad..36ff2dd1a 100644 --- a/spacy/__init__.py +++ b/spacy/__init__.py @@ -8,8 +8,14 @@ from . import util def load(name, **overrides): - from .deprecated import resolve_load_name - name = resolve_load_name(name, **overrides) + depr_path = overrides.get('path') + if depr_path not in (True, False, None): + util.deprecated( + "As of spaCy v2.0, the keyword argument `path=` is deprecated. " + "You can now call spacy.load with the path as its first argument, " + "and the model's meta.json will be used to determine the language " + "to load. For example:\nnlp = spacy.load('{}')".format(depr_path), + 'error') return util.load_model(name, **overrides) diff --git a/spacy/deprecated.py b/spacy/deprecated.py index a1143474a..eafdbe580 100644 --- a/spacy/deprecated.py +++ b/spacy/deprecated.py @@ -1,40 +1,4 @@ # coding: utf8 from __future__ import unicode_literals -from .util import prints -from .cli import download -from . import about - - PRON_LEMMA = "-PRON-" - - -def depr_model_download(lang): - """Replace en/de download modules within, warn and ownload default models. - - lang (unicode): Language shortcut, 'en' or 'de'. - """ - prints("The spacy.%s.download command is now deprecated. Please use " - "spacy download [model name or shortcut] instead. For " - "more info, see the documentation:" % lang, - about.__docs_models__, - "Downloading default '%s' model now..." % lang, - title="Warning: deprecated command") - download(lang) - - -def resolve_load_name(name, **overrides): - """Resolve model loading if deprecated path kwarg in overrides. - - name (unicode): Name of model to load. - **overrides: Overrides specified in spacy.load(). - RETURNS: Model name or value of path kwarg. - """ - if overrides.get('path') not in (None, False, True): - name = overrides.get('path') - prints("To load a model from a path, you can now use the first " - "argument. The model meta is used to load the Language class.", - "OLD: spacy.load('en', path='/some/path')", - "NEW: spacy.load('/some/path')", - title="Warning: deprecated argument 'path'") - return name diff --git a/spacy/lang/de/download.py b/spacy/lang/de/download.py deleted file mode 100644 index d9ff3652a..000000000 --- a/spacy/lang/de/download.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding: utf8 -from __future__ import unicode_literals - -from ..deprecated import depr_model_download - - -if __name__ == '__main__': - depr_model_download('de') diff --git a/spacy/lang/en/download.py b/spacy/lang/en/download.py deleted file mode 100644 index 73133fb48..000000000 --- a/spacy/lang/en/download.py +++ /dev/null @@ -1,8 +0,0 @@ -# coding: utf8 -from __future__ import unicode_literals - -from ..deprecated import depr_model_download - - -if __name__ == '__main__': - depr_model_download('en') diff --git a/spacy/tokenizer.pyx b/spacy/tokenizer.pyx index ef31a5d5c..3996819ff 100644 --- a/spacy/tokenizer.pyx +++ b/spacy/tokenizer.pyx @@ -62,7 +62,11 @@ cdef class Tokenizer: return (self.__class__, args, None, None) cpdef Doc tokens_from_list(self, list strings): - # TODO: deprecation warning + util.deprecated( + "Tokenizer.from_from list is now deprecated. Create a new Doc " + "object instead and pass in the strings as the `words` keyword " + "argument, for example:\nfrom spacy.tokens import Doc\n" + "doc = Doc(nlp.vocab, words=[...])") return Doc(self.vocab, words=strings) @cython.boundscheck(False) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index dd01343d2..4c3dfc49f 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -842,7 +842,10 @@ cdef class Doc: """ cdef unicode tag, lemma, ent_type if len(args) == 3: - # TODO: Warn deprecation + util.deprecated( + "Positional arguments to Doc.merge are deprecated. Instead, " + "use the keyword arguments, for example tag=, lemma= or " + "ent_type=.") tag, lemma, ent_type = args attributes[TAG] = tag attributes[LEMMA] = lemma diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index af88872fb..3253fa738 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -19,6 +19,7 @@ from ..attrs cimport IS_OOV, IS_TITLE, IS_UPPER, LIKE_URL, LIKE_NUM, LIKE_EMAIL from ..attrs cimport IS_STOP, ID, ORTH, NORM, LOWER, SHAPE, PREFIX, SUFFIX from ..attrs cimport LENGTH, CLUSTER, LEMMA, POS, TAG, DEP from ..compat import is_config +from .. import util from .. import about from .underscore import Underscore @@ -330,8 +331,14 @@ cdef class Token: return self.c.r_kids property sent_start: - # TODO deprecation warning def __get__(self): + util.deprecated( + "Token.sent_start is now deprecated. Use Token.is_sent_start " + "instead, which returns a boolean value or None if the answer " + "is unknown – instead of a misleading 0 for False and 1 for " + "True. It also fixes a quirk in the old logic that would " + "always set the property to 0 for the first word of the " + "document.") # Handle broken backwards compatibility case: doc[0].sent_start # was False. if self.i == 0: