spaCy/spacy/deprecated.py

40 lines
1.4 KiB
Python
Raw Normal View History

2017-04-15 14:05:15 +03:00
# coding: utf8
from __future__ import unicode_literals
2017-05-08 00:25:29 +03:00
from .util import prints
from .cli import download
2017-05-13 14:04:40 +03:00
from . import about
PRON_LEMMA = "-PRON-"
2017-05-08 00:29:22 +03:00
def depr_model_download(lang):
2017-05-14 02:30:29 +03: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 "
"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 22:21:47 +03:00
def resolve_load_name(name, **overrides):
2017-05-14 02:30:29 +03: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 22:21:47 +03: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