-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegrate_messages_md
executable file
·208 lines (146 loc) · 4.88 KB
/
integrate_messages_md
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/tclsh
set filelist [list "msg.txt" "msg_melt.txt" "msg_tt.txt" "msg_simple.txt"]
set psfilelist [list "msg_p_s.txt" "msg_melt_p_s.txt" "msg_tt_p_s.txt" "msg_simple_p_s.txt"]
set directlist [list "direct_msg.txt"]
set poslist [list "eval_pos.txt" "eval_pos_melt.txt" "eval_pos_tt.txt" "eval_pos_simple.txt"]
proc get_data {filename} {
if [catch {open $filename r} f1] {
return [list [list "??.??" "??.??" "??.??" "??.??" "??.??" "??.??"] [list "?.?" "?.?" "?.?" "?.?" "?.?" "?.?"]]
} else {
set p_list {}
set n_list {}
while {[gets $f1 line] >= 0} {
if {[regexp {^WORD.+\((.+)\%\)$} $line all pct]} {
lappend p_list $pct
}
if {[regexp {^TAGS.+tags\, (.+) tags} $line all avgtags]} {
lappend n_list $avgtags
}
}
close $f1
return [list $p_list $n_list]
}
}
proc get_pos_data {filename} {
if [catch {open $filename r} f1] {
return "??.??"
} else {
while {[gets $f1 line] >= 0} {
if {[regexp {^.+word.+\((.+)\%\)$} $line all pct]} {
return $pct
}
}
}
}
proc print_data {filename p_list n_list} {
print_file_indicator $filename
for {set i 0} {$i < [llength $p_list]} {incr i} {
set pi [lindex $p_list $i]
if {[string is double -strict $pi]} {
set p [format "%5.2f" $pi]
} else {
set p "??.??"
}
set ni [lindex $n_list $i]
if {[string is double -strict $ni]} {
set n [format "%4.1f" $ni]
} else {
set n " ?.?"
}
puts -nonewline "$p | $n"
if {$i < [expr [llength $p_list]-1]} {
puts -nonewline " | "
}
}
puts ""
}
proc print_pos_data {flist} {
for {set i 0} {$i < [llength $flist]} {incr i} {
set filename [lindex $flist $i]
print_file_indicator $filename
set p [get_pos_data $filename]
if {[string is double -strict $p]} {
set pos [format "%5.2f" $p]
} else {
set pos " ??.??"
}
puts " $pos"
}
puts ""
}
proc print_file_indicator {filename} {
if {[string equal $filename "msg.txt"]||[string equal $filename "eval_pos.txt"]||[string equal $filename "msg_p_s.txt"]} {
puts -nonewline "Merged | "
} elseif {[string equal $filename "msg_melt.txt"]||[string equal $filename "eval_pos_melt.txt"]||[string equal $filename "msg_melt_p_s.txt"]} {
puts -nonewline "Melt | "
} elseif {[string equal $filename "msg_tt.txt"]||[string equal $filename "eval_pos_tt.txt"]||[string equal $filename "msg_tt_p_s.txt"]} {
puts -nonewline "Tt | "
} elseif {[string equal $filename "msg_simple.txt"]||[string equal $filename "eval_pos_simple.txt"]||[string equal $filename "msg_simple_p_s.txt"]} {
puts -nonewline "Simple | "
} elseif {[string equal $filename "direct_msg.txt"]} {
puts -nonewline "Direct | "
} else {
puts -nonewline "???? "
}
}
proc print_file_time {filename} {
if {[file exists $filename]} {
set m [file mtime $filename]
} else {
set m 0
}
return [clock format $m -format "%Y%m%d %H:%M:%S"]
}
proc print_file_times {list} {
puts "File | Time"
puts "-----|-----:"
for {set i 0} {$i < [llength $list]} {incr i} {
if {$i == 0} {
} elseif {[expr $i & 1] == 0} {
puts ""
} else {
puts -nonewline " "
}
set f [lindex $list $i]
set s [print_file_time $f]
print_file_indicator $f
puts -nonewline $s
}
puts ""
}
puts "##### Supertag models with gold POS tags"
print_file_times $filelist
puts ""
puts "Model | Correct (beta=1) | F/w |Correct (beta=0.1) | F/w | Correct (beta=0.05) | F/w | Correct (beta=0.01) | F/w | Correct (beta=0.005)| F/w | Correct (beta=0.001) | F/w"
puts "------|---------:|-----------:|-------:|----------:|--------:|----------:|--------:|----------:|--------:|----------:|--------:|---------:"
foreach f $filelist {
set l [get_data $f]
print_data $f [lindex $l 0] [lindex $l 1]
}
puts ""
puts "##### Combined POS- and supertagger"
print_file_times $psfilelist
puts ""
puts "Model | Correct (beta=1) | F/w |Correct (beta=0.1) | F/w | Correct (beta=0.05) | F/w | Correct (beta=0.01) | F/w | Correct (beta=0.005)| F/w | Correct (beta=0.001) | F/w"
puts "------|---------:|-----------:|-------:|----------:|--------:|----------:|--------:|----------:|--------:|----------:|--------:|---------:"
foreach f $psfilelist {
set l [get_data $f]
print_data $f [lindex $l 0] [lindex $l 1]
}
puts ""
puts "##### Direct supertagger (no part-of-speech tagging)"
print_file_times "direct_msg.txt"
puts ""
puts "Model | Correct (beta=1) | F/w |Correct (beta=0.1) | F/w | Correct (beta=0.05) | F/w | Correct (beta=0.01) | F/w | Correct (beta=0.005)| F/w | Correct (beta=0.001) | F/w"
puts "------|---------:|-----------:|-------:|----------:|--------:|----------:|--------:|----------:|--------:|----------:|--------:|---------:"
foreach f $directlist {
set l [get_data $f]
print_data $f [lindex $l 0] [lindex $l 1]
}
puts ""
puts "##### POS models"
print_file_times $poslist
puts ""
puts "Model | Correct |"
puts "-----|-----:|"
print_pos_data $poslist