-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecode_sentence_splitting.py
More file actions
83 lines (64 loc) · 1.75 KB
/
decode_sentence_splitting.py
File metadata and controls
83 lines (64 loc) · 1.75 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
output = "DiscourseSimplification/output_default.txt"
new_output = "uslt_final_output.txt"
f = open(output,"r")
fr = f.read()
outputs = fr.split("\n")
f.close()
refined_lines = []
"""
for line in outputs:
flag_zero = 0
for i in range(len(line)):
#print(line[i-2:i]=="0\t")
if line[i-3] == line[i-1] == "\t" and flag_zero == 0:
print("yes")
flag_zero = 1
#new_line = line[i:]
#for j in range(len(new_line)):
#if new_line[j:j+6]=="L:LIST":
refined_lines.append(line[i:])
break
new_output = "newer_output.txt"
g = open(new_output,"w")
for line in refined_lines:
g.write(line)
if line != refined_lines[-1]:
g.write("\n")
"""
counter = 0
flag = False
refined_lines = []
for line in outputs:
if len(line) > 0:
if line[0] == "#":
if flag == True:
refined_lines.append(sentence_lines)
flag = True
sentence_lines = []
print("YES")
counter += 1
big_flag = True
flag_zero = 0
for i in range(len(line)):
#print(line[i-2:i]=="0\t")
#try:
if line[i-3] == line[i-1] == "\t" and flag_zero == 0:
print("yes")
flag_zero = 1
#new_line = line[i:]
#for j in range(len(new_line)):
#if new_line[j:j+6]=="L:LIST":
sentence_lines.append(line[i:])
break
#except:
#pass
refined_lines.append(sentence_lines)
g = open(new_output,"w")
for sent_lines in refined_lines:
for line in sent_lines:
g.write(line)
if line[-1] != ".":
g.write(".")
if sent_lines != refined_lines[-1]:
g.write("\n")
print(len(refined_lines))