mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Handle deprecated language-specific model downloading
This commit is contained in:
parent
58b884b6d4
commit
71956c94db
|
@ -1,14 +1,5 @@
|
|||
import plac
|
||||
from ..download import download
|
||||
|
||||
|
||||
@plac.annotations(
|
||||
force=("Force overwrite", "flag", "f", bool),
|
||||
data_path=("Path to download model", "option", "d", str)
|
||||
)
|
||||
def main(data_size='all', force=False, data_path=None):
|
||||
download('de', force=force, data_path=data_path)
|
||||
from ..deprecated import ModelDownload as download
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
plac.call(main)
|
||||
download.de()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from pathlib import Path
|
||||
from . import about
|
||||
from . import util
|
||||
from .download import download
|
||||
|
||||
|
||||
def read_lang_data(package):
|
||||
|
@ -77,3 +78,27 @@ def fix_glove_vectors_loading(overrides):
|
|||
if vec_path is not None:
|
||||
overrides['add_vectors'] = lambda vocab: vocab.load_vectors_from_bin_loc(vec_path)
|
||||
return overrides
|
||||
|
||||
|
||||
class ModelDownload():
|
||||
"""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."""
|
||||
|
||||
@classmethod
|
||||
def load(self, lang):
|
||||
util.print_msg(
|
||||
"The spacy.{l}.download command is now deprecated. Please use "
|
||||
"spacy.download [model name or shortcut] instead. For more "
|
||||
"info and available models, see the documentation: {d}. "
|
||||
"Downloading default '{l}' model now...".format(d=about.__docs__, l=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')
|
||||
|
|
|
@ -1,25 +1,5 @@
|
|||
import plac
|
||||
import sputnik
|
||||
|
||||
from ..download import download
|
||||
from .. import about
|
||||
|
||||
|
||||
@plac.annotations(
|
||||
force=("Force overwrite", "flag", "f", bool),
|
||||
data_path=("Path to download model", "option", "d", str)
|
||||
)
|
||||
def main(data_size='all', force=False, data_path=None):
|
||||
if force:
|
||||
sputnik.purge(about.__title__, about.__version__)
|
||||
|
||||
if data_size in ('all', 'parser'):
|
||||
print("Downloading parsing model")
|
||||
download('en', force=False, data_path=data_path)
|
||||
if data_size in ('all', 'glove'):
|
||||
print("Downloading GloVe vectors")
|
||||
download('en_glove_cc_300_1m_vectors', force=False, data_path=data_path)
|
||||
from ..deprecated import ModelDownload as download
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
plac.call(main)
|
||||
download.en()
|
||||
|
|
Loading…
Reference in New Issue
Block a user