Skip to content

Commit dce82f7

Browse files
MartinXPNmahnerak
authored andcommitted
remove unnecessary files after extraction
1 parent 80963ba commit dce82f7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

preprocessing.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import numpy as np
66
import json
7+
import os
78
import argparse
89
import cPickle as pickle
910

@@ -40,7 +41,8 @@ def word2vec(word2vec_path):
4041
if not path.exists(word2vec_path):
4142
glove_file_path = get_glove_file_path()
4243
print('Converting Glove to word2vec...', end='')
43-
glove2word2vec(glove_file_path, word2vec_path)
44+
glove2word2vec(glove_file_path, word2vec_path) # Convert glove to word2vec
45+
os.remove(glove_file_path) # Remove glove file and keep only word2vec
4446
print('Done')
4547

4648
print('Reading word2vec data... ', end='')

utils.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import print_function
33
from __future__ import division
44

5+
import os
56
from os import path
67
from keras.utils.data_utils import get_file
78

@@ -33,10 +34,13 @@ def get_glove_file_path():
3334
origin = '{server}{version}.zip'.format(server=SERVER, version=VERSION)
3435
cache_dir = path.join(path.abspath(path.dirname(__file__)), 'data')
3536

36-
get_file('/tmp/glove.zip',
37+
fname = '/tmp/glove.zip'
38+
get_file(fname,
3739
origin=origin,
3840
cache_dir=cache_dir,
3941
cache_subdir='',
4042
extract=True)
4143

44+
# Remove unnecessary .zip file and keep only extracted .txt version
45+
os.remove(fname)
4246
return path.join(cache_dir, VERSION) + '.txt'

0 commit comments

Comments
 (0)