spaCy/spacy/deprecated.py

40 lines
1.4 KiB
Python
Raw Normal View History

2017-04-15 11:05:15 +00:00
# coding: utf8
from __future__ import unicode_literals
2017-05-07 21:25:29 +00:00
from .util import prints
from .cli import download
2017-05-13 11:04:40 +00:00
from . import about
PRON_LEMMA = "-PRON-"
2017-05-07 21:29:22 +00:00
def depr_model_download(lang):
2017-05-13 23:30:29 +00:00
"""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 "
"python -m 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)
2017-05-13 19:21:47 +00:00
def resolve_load_name(name, **overrides):
2017-05-13 23:30:29 +00:00
"""Resolve model loading if deprecated path kwarg is specified in overrides.
name (unicode): Name of model to load.
**overrides: Overrides specified in spacy.load().
RETURNS: Model name or value of path kwarg.
"""
2017-05-13 19:21:47 +00:00
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 required Language class.",
"OLD: spacy.load('en', path='/some/path')", "NEW: spacy.load('/some/path')",
title="Warning: deprecated argument 'path'")
return name