-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlrec_maker.py
64 lines (47 loc) · 1.08 KB
/
lrec_maker.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
54
55
56
57
58
59
60
from tqdm import tqdm
g = open('LREC-Data/hack_LREC_data_complete.csv','w')
g.write('split,input,output,DCS-ID\n')
did = 0
with open('sktWS/skt.train','r') as f:
lines = f.readlines()
inp_sent = ""
gold_sent = ""
for line in tqdm(lines):
if line == '\n':
g.write(f'train,{inp_sent},{gold_sent},{did}\n')
did += 1
inp_sent = ""
gold_sent = ""
else:
sp = line[:-1].split()
inp_sent += sp[0]
gold_sent += sp[1]
with open('sktWS/skt.test','r') as f:
lines = f.readlines()
inp_sent = ""
gold_sent = ""
for line in tqdm(lines):
if line == '\n':
g.write(f'test,{inp_sent},{gold_sent},{did}\n')
did += 1
inp_sent = ""
gold_sent = ""
else:
sp = line[:-1].split()
inp_sent += sp[0]
gold_sent += sp[1]
with open('sktWS/skt.dev','r') as f:
lines = f.readlines()
inp_sent = ""
gold_sent = ""
for line in tqdm(lines):
if line == '\n':
g.write(f'dev,{inp_sent},{gold_sent},{did}\n')
did += 1
inp_sent = ""
gold_sent = ""
else:
sp = line[:-1].split()
inp_sent += sp[0]
gold_sent += sp[1]
g.close()