Simplify deprecated model downloading

Only relevant for spaCy < v1.7.0.
This commit is contained in:
ines 2017-05-08 15:32:10 +02:00
parent 95edd9e896
commit bd6a7cf4f6
3 changed files with 18 additions and 24 deletions

View File

@ -1,5 +1,8 @@
from ..deprecated import ModelDownload as download
# coding: utf8
from __future__ import unicode_literals
from ..deprecated import depr_model_download
if __name__ == '__main__':
download.de()
depr_model_download('de')

View File

@ -86,26 +86,14 @@ def resolve_model_name(name):
return name
class ModelDownload():
def depr_model_download(lang):
"""
Replace download modules within en and de with deprecation warning and
download default language model (using shortcut). Use classmethods to allow
importing ModelDownload as download and calling download.en() etc.
download default language model (using shortcut).
"""
@classmethod
def load(self, lang):
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 docs: %s." % (lang, about.__docs__),
"Downloading default '%s' model now..." % lang,
title="Warning: deprecated command")
download(lang)
@classmethod
def en(cls, *args, **kwargs):
cls.load('en')
@classmethod
def de(cls, *args, **kwargs):
cls.load('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 docs: %s." % (lang, about.__docs__),
"Downloading default '%s' model now..." % lang,
title="Warning: deprecated command")
download(lang)

View File

@ -1,5 +1,8 @@
from ..deprecated import ModelDownload as download
# coding: utf8
from __future__ import unicode_literals
from ..deprecated import depr_model_download
if __name__ == '__main__':
download.en()
depr_model_download('en')