-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeTrainData.py
51 lines (42 loc) · 1.44 KB
/
makeTrainData.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
import json
import math
import csv
def labeling(paths, filename):
savepath = "./train-data/humanInspection/"
with open(paths+filename+".json", "rt" , encoding="utf-8") as json_file:
data = json.load(json_file)
commentlist = []
for date in data:
for article in data[date]:
for comment in data[date][article][0]:
# print("comment", comment)
if len(comment)<5 : continue
commentlist.append(comment)
count=0
values = []
# print(commentlist[:10])
while count<100:
print( count,")" ,commentlist[count].replace("\n","") )
value = input(">>")
if value not in ['0', '1']:
count += 1
continue
values.append( int(value))
count += 1
f = open(savepath+filename+"-train.tsv", "wt" , encoding='utf-8', newline='')
wr = csv.writer(f, delimiter='\t')
for i, v in enumerate(values):
wr.writerow([commentlist[i].replace("\n"," "), v])
print(filename+"--end")
tlist = []
for i in range(1,6): tlist.append(["before"+str(i),"after"+str(i)])
filename = "./train-data/makeTrainData.tsv"
commentpath = "./json-okt-comment/"
for tname in tlist:
potal = "daum"
for t in tname:
if t in ["daumafter1-dict-train", "daumbefore1-dict-train"]: continue
labeling(commentpath, potal+t+"-dict")
potal = "naver"
for t in tname:
labeling(commentpath, potal+t+"-dict")