2016-03-24 13:19:43 +03:00
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import sputnik
|
|
|
|
from sputnik.package_list import (PackageNotFoundException,
|
|
|
|
CompatiblePackageNotFoundException)
|
|
|
|
|
|
|
|
from . import about
|
|
|
|
|
|
|
|
|
2016-09-14 17:04:09 +03:00
|
|
|
def download(lang, force=False, fail_on_exist=True):
|
2016-03-24 13:19:43 +03:00
|
|
|
if force:
|
|
|
|
sputnik.purge(about.__title__, about.__version__)
|
|
|
|
|
|
|
|
try:
|
2016-03-25 20:54:45 +03:00
|
|
|
sputnik.package(about.__title__, about.__version__, about.__models__[lang])
|
2016-09-14 17:04:09 +03:00
|
|
|
if fail_on_exist:
|
|
|
|
print("Model already installed. Please run 'python -m "
|
|
|
|
"spacy.%s.download --force' to reinstall." % lang, file=sys.stderr)
|
|
|
|
sys.exit(0)
|
2016-03-24 13:19:43 +03:00
|
|
|
except (PackageNotFoundException, CompatiblePackageNotFoundException):
|
|
|
|
pass
|
|
|
|
|
2016-03-25 20:54:45 +03:00
|
|
|
package = sputnik.install(about.__title__, about.__version__, about.__models__[lang])
|
2016-03-24 13:19:43 +03:00
|
|
|
|
|
|
|
try:
|
2016-03-25 20:54:45 +03:00
|
|
|
sputnik.package(about.__title__, about.__version__, about.__models__[lang])
|
2016-03-24 13:19:43 +03:00
|
|
|
except (PackageNotFoundException, CompatiblePackageNotFoundException):
|
|
|
|
print("Model failed to install. Please run 'python -m "
|
|
|
|
"spacy.%s.download --force'." % lang, file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
print("Model successfully installed.", file=sys.stderr)
|