-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalter_txt.py
47 lines (40 loc) · 1.24 KB
/
alter_txt.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
import random
import char_utils
dir_txt = './'
f = open(dir_txt+'defp_2.19_val_crop.txt','r')
ff = f.readlines()
random.shuffle (ff)
f.close()
f_new = open(dir_txt+'defp_2.19_val.txt','w')
for line in ff:
if line.split(':')[1] == '\n'or '*' in line.split(':')[1]:
continue
label=[]
for w in line.split(':')[1][:-1]:
if char_utils.encode_maps.get(w, char_utils.UNKNOWN_INDEX)==4165:
print(line,w)
label.append(char_utils.encode_maps.get(w, char_utils.UNKNOWN_INDEX))
# print("UNKNOWN_INDEX:", char_utils.UNKNOWN_INDEX)
# print(label)
# print(line.strip().split(':')[1])
f_new.write(line)
f_new.close()
#
# import random,os
# import char_utils
# dir_txt = './'
# f = open(dir_txt+'defp_2.19_train_new.txt','r')
# ff = f.readlines()
# # random.shuffle (ff)
# f.close()
# # f_new = open(dir_txt+'defp_2.19_train.txt','w')
# for line in ff:
# filename = os.path.basename(line.split(':')[0])
# if not os.path.exists(os.path.join('/home/gytang/project/dataset/2019.1.30/train/',filename)):
# print(filename)
# print("UNKNOWN_INDEX:", char_utils.UNKNOWN_INDEX)
# print(label)
# print(line.strip().split(':')[1])
# f_new.write(line)
#
# f_new.close()