-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathutils.py
46 lines (35 loc) · 1.28 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import os
from os import path
from keras.utils.data_utils import get_file
def custom_objects():
from layers import *
from model import *
return locals()
def CoreNLP_path():
SERVER = 'http://nlp.stanford.edu/software/'
VERSION = 'stanford-corenlp-full-2017-06-09'
origin = '{server}{version}.zip'.format(server=SERVER, version=VERSION)
lib_dir = path.join(path.abspath(path.dirname(__file__)), 'lib')
get_file('/tmp/stanford-corenlp.zip',
origin=origin,
cache_dir=lib_dir,
cache_subdir='',
extract=True)
return path.join(lib_dir, VERSION)
def get_glove_file_path():
SERVER = 'http://nlp.stanford.edu/data/'
VERSION = 'glove.840B.300d'
origin = '{server}{version}.zip'.format(server=SERVER, version=VERSION)
cache_dir = path.join(path.abspath(path.dirname(__file__)), 'data')
fname = '/tmp/glove.zip'
get_file(fname,
origin=origin,
cache_dir=cache_dir,
cache_subdir='',
extract=True)
# Remove unnecessary .zip file and keep only extracted .txt version
os.remove(fname)
return path.join(cache_dir, VERSION) + '.txt'