-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_models.py
35 lines (29 loc) · 1.02 KB
/
get_models.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
import os
import requests
location = os.path.normpath('data')
data = {
'train': { 'file': 'train.pair.tok.ctf' },
'val':{ 'file': 'valid.pair.tok.ctf' },
'query': { 'file': 'vocab_Q.wl' },
'answer': { 'file': 'vocab_A.wl' }
}
def download(url, filename):
""" utility function to download a file """
response = requests.get(url, stream=True)
with open(filename, "wb") as handle:
for data in response.iter_content():
handle.write(data)
if __name__ == "__main__":
if not os.path.exists(location):
os.mkdir(location)
for item in data.values():
path = os.path.normpath(os.path.join(location, item['file']))
if os.path.exists(path):
print("Reusing locally cached:", path)
else:
print("Starting download:", item['file'])
url = "http://www.cntk.ai/jup/dat/DSSM/%s.csv"%(item['file'])
print(url)
download(url, path)
print("Download completed")
item['file'] = path