forked from xiaoqzhou/rcnn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-label.py
42 lines (40 loc) · 1.06 KB
/
get-label.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
import os
import sys
import math
Sum-epoch =25
def generate():
listfile = './data/task3_4label_test.list'
path1 = './Result/'
path2 = './Label/'
strmat = 'rnn_label.txt'
strmat1 = 'rnn_label.txt'
testindex = []
with open(listfile,'r') as fin:
for line in fin:
line = line.strip('\n')
index = line.strip('\r').split('\t')
testindex.append(index[2])
for i in range(Sum-epoch):
epoch = i
filename1 = path1 + str(epoch)+ strmat
filename2 = path2
label = []
filename2 = filename2 + str(epoch+1) + strmat1
ofile = open(filename2,'w')
with open(filename1,'r') as fin:
for line in fin:
vec = line.strip('\n').split()
v = float(vec[0])
if v==0:
label.append('Good')
elif v==1:
label.append('Potential')
elif v==2:
label.append('Bad')
elif v==3:
label.append('Dialogue')
for j in range(len(testindex)):
ofile.write(testindex[j]+'\t'+label[j]+'\n')
ofile.close()
if __name__ == '__main__':
generate()