-
Notifications
You must be signed in to change notification settings - Fork 0
/
combinePickles.py
53 lines (36 loc) · 1.18 KB
/
combinePickles.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
47
48
49
50
51
52
53
import cPickle
import os
def combineFV(path, getFeat=True, getSkip=False, getErro=False):
# Get files from directory
filenameList = os.listdir(path)
# Ensure correctness of path
if not path.endswith('/'):
path = path + '/'
featVect = {}
skipList = []
erroList = []
for filename in filenameList:
with open(path + filename, 'rb') as f:
data = cPickle.load(f)
if getFeat and filename.startswith('FV'):
featVect.update(data)
elif getSkip and filename.startswith('SL'):
skipList.extend(data)
elif getErro and filename.startswith('ER'):
erroList.extend(data)
def combineDict(path):
# Get files from directory
filenameList = os.listdir(path)
# Ensure correctness of path
if not path.endswith('/'):
path = path + '/'
dataDict = {}
for filename in filenameList:
with open(path + filename, 'rb') as f:
data = cPickle.load(f)
dataDict.update(data)
def main():
picklePath = 'data/pickle/FEATURE_VECTOR/'
combineFV(picklePath, True, False, False)
if __name__ == '__main__':
main()