mirror of
https://github.com/explosion/spaCy.git
synced 2025-02-03 21:24:11 +03:00
Add parameter to download() for application to not exit if a Model exists. The default behavior is unchanged.
This commit is contained in:
parent
cccadbf2a2
commit
4c9ccc3b8b
|
@ -9,15 +9,16 @@ from sputnik.package_list import (PackageNotFoundException,
|
||||||
from . import about
|
from . import about
|
||||||
|
|
||||||
|
|
||||||
def download(lang, force=False):
|
def download(lang, force=False, fail_on_exist=True):
|
||||||
if force:
|
if force:
|
||||||
sputnik.purge(about.__title__, about.__version__)
|
sputnik.purge(about.__title__, about.__version__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sputnik.package(about.__title__, about.__version__, about.__models__[lang])
|
sputnik.package(about.__title__, about.__version__, about.__models__[lang])
|
||||||
print("Model already installed. Please run 'python -m "
|
if fail_on_exist:
|
||||||
"spacy.%s.download --force' to reinstall." % lang, file=sys.stderr)
|
print("Model already installed. Please run 'python -m "
|
||||||
sys.exit(0)
|
"spacy.%s.download --force' to reinstall." % lang, file=sys.stderr)
|
||||||
|
sys.exit(0)
|
||||||
except (PackageNotFoundException, CompatiblePackageNotFoundException):
|
except (PackageNotFoundException, CompatiblePackageNotFoundException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user