2015-02-01 05:22:23 +03:00
|
|
|
from __future__ import print_function
|
2015-01-02 13:44:41 +03:00
|
|
|
from os import path
|
2015-10-18 13:35:04 +03:00
|
|
|
import sys
|
2015-01-02 13:44:41 +03:00
|
|
|
import os
|
|
|
|
import tarfile
|
|
|
|
import shutil
|
2015-10-18 13:35:04 +03:00
|
|
|
import uget
|
2015-01-31 05:51:56 +03:00
|
|
|
import plac
|
2015-01-02 13:44:41 +03:00
|
|
|
|
2015-02-07 19:32:33 +03:00
|
|
|
# TODO: Read this from the same source as the setup
|
2015-10-13 05:46:17 +03:00
|
|
|
VERSION = '0.9.5'
|
2015-01-02 13:44:41 +03:00
|
|
|
|
2015-09-22 03:26:01 +03:00
|
|
|
AWS_STORE = 'https://s3-us-west-1.amazonaws.com/media.spacynlp.com'
|
2015-01-30 12:27:14 +03:00
|
|
|
|
2015-02-07 19:32:33 +03:00
|
|
|
ALL_DATA_DIR_URL = '%s/en_data_all-%s.tgz' % (AWS_STORE, VERSION)
|
2015-01-30 10:04:01 +03:00
|
|
|
|
2015-10-18 13:35:04 +03:00
|
|
|
DEST_DIR = path.join(path.dirname(path.abspath(__file__)), 'data')
|
2015-01-02 13:44:41 +03:00
|
|
|
|
2015-10-18 13:35:04 +03:00
|
|
|
|
|
|
|
def download_file(url, dest_dir):
|
|
|
|
return uget.download(url, dest_dir, console=sys.stdout)
|
2015-01-02 13:44:41 +03:00
|
|
|
|
2015-01-30 10:04:01 +03:00
|
|
|
|
2015-01-30 12:33:19 +03:00
|
|
|
def install_data(url, dest_dir):
|
2015-01-30 10:04:01 +03:00
|
|
|
filename = download_file(url, dest_dir)
|
2015-10-18 13:35:04 +03:00
|
|
|
t = tarfile.open(filename)
|
2015-01-30 10:04:01 +03:00
|
|
|
t.extractall(dest_dir)
|
|
|
|
|
2015-10-18 13:35:04 +03:00
|
|
|
|
2015-01-17 08:21:17 +03:00
|
|
|
def install_parser_model(url, dest_dir):
|
2015-01-30 10:04:01 +03:00
|
|
|
filename = download_file(url, dest_dir)
|
2015-10-18 13:35:04 +03:00
|
|
|
t = tarfile.open(filename, mode=":gz")
|
|
|
|
t.extractall(dest_dir)
|
2015-01-17 08:21:17 +03:00
|
|
|
|
|
|
|
|
|
|
|
def install_dep_vectors(url, dest_dir):
|
2015-10-18 13:35:04 +03:00
|
|
|
download_file(url, dest_dir)
|
2015-01-17 08:21:17 +03:00
|
|
|
|
|
|
|
|
2015-10-18 13:35:04 +03:00
|
|
|
@plac.annotations(
|
|
|
|
force=("Force overwrite", "flag", "f", bool),
|
|
|
|
)
|
|
|
|
def main(data_size='all', force=False):
|
2015-01-31 05:51:56 +03:00
|
|
|
if data_size == 'all':
|
|
|
|
data_url = ALL_DATA_DIR_URL
|
|
|
|
elif data_size == 'small':
|
|
|
|
data_url = SM_DATA_DIR_URL
|
2015-10-18 13:35:04 +03:00
|
|
|
|
|
|
|
if force and path.exists(DEST_DIR):
|
2015-04-12 08:04:10 +03:00
|
|
|
shutil.rmtree(DEST_DIR)
|
2015-10-18 13:35:04 +03:00
|
|
|
|
|
|
|
if not os.path.exists(DEST_DIR):
|
|
|
|
os.makedirs(DEST_DIR)
|
|
|
|
|
|
|
|
install_data(data_url, DEST_DIR)
|
2015-01-02 13:44:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2015-01-31 05:51:56 +03:00
|
|
|
plac.call(main)
|