-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeSequentialData.py
32 lines (28 loc) · 1019 Bytes
/
makeSequentialData.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
#!/usr/bin/env python
# coding:utf-8
sortedCategory = []
reader_categoryInfo = open("./categoryInfo","r")
for line in reader_categoryInfo:
sortedCategory.append(line.strip().split("\t")[0])
reader_categoryInfo.close()
counter = 0
while len(sortedCategory) > 0:
print "trainLabel"+str(counter)
for includedCategory in sortedCategory:
print includedCategory
reader_trainLabel = open("./trainLabel","r")
reader_testLabel = open("./testLabel","r")
writer_trainLabelIdx = open("./trainLabel"+str(counter),"w")
writer_testLabelIdx = open("./testLabel"+str(counter),"w")
for line in reader_trainLabel:
if(line.strip().split("\t")[1] in sortedCategory):
writer_trainLabelIdx.write(line.strip()+"\n")
for line in reader_testLabel:
if(line.strip().split("\t")[1] in sortedCategory):
writer_testLabelIdx.write(line.strip()+"\n")
counter += 1
del sortedCategory[0]
reader_trainLabel.close()
reader_testLabel.close()
writer_trainLabelIdx.close()
writer_testLabelIdx.close()