-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdist.py
34 lines (29 loc) · 1002 Bytes
/
dist.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
import os
import tarfile
def compress_dataset(dir, name, files):
tgz_file = os.path.join(dir, name + '.tgz')
with tarfile.open(tgz_file, "w:gz") as tar:
for file in files:
path = os.path.realpath(file)
name = os.path.basename(path)
tar.add(path, arcname=name)
def main():
os.makedirs('dist', exist_ok=True)
datasets = ['FB15K', 'FB15K-237', 'WN18', 'WN18RR', 'YAGO3-10']
for dataset in datasets:
compress_dataset('dist', dataset + '-ID', [
dataset + '/edges_as_id_all.tsv',
dataset + '/edges_as_id_train.tsv',
dataset + '/edges_as_id_test.tsv',
dataset + '/edges_as_id_valid.tsv',
dataset + '/map_entity_id_to_text.tsv',
dataset + '/map_relation_id_to_text.tsv'
])
compress_dataset('dist', dataset, [
dataset + '/edges_as_text_all.tsv',
dataset + '/edges_as_text_train.tsv',
dataset + '/edges_as_text_test.tsv',
dataset + '/edges_as_text_valid.tsv',
])
if __name__ == '__main__':
main()