shalmaneser-rosy 1.2.0.rc4 → 1.2.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -18
- data/bin/rosy +14 -7
- data/lib/rosy/FailedParses.rb +22 -20
- data/lib/rosy/FeatureInfo.rb +35 -31
- data/lib/rosy/GfInduce.rb +132 -130
- data/lib/rosy/GfInduceFeature.rb +86 -68
- data/lib/rosy/InputData.rb +59 -55
- data/lib/rosy/RosyConfusability.rb +47 -40
- data/lib/rosy/RosyEval.rb +55 -55
- data/lib/rosy/RosyFeatureExtractors.rb +295 -290
- data/lib/rosy/RosyFeaturize.rb +54 -67
- data/lib/rosy/RosyInspect.rb +52 -50
- data/lib/rosy/RosyIterator.rb +73 -67
- data/lib/rosy/RosyPhase2FeatureExtractors.rb +48 -48
- data/lib/rosy/RosyPruning.rb +39 -31
- data/lib/rosy/RosyServices.rb +116 -115
- data/lib/rosy/RosySplit.rb +55 -53
- data/lib/rosy/RosyTask.rb +7 -3
- data/lib/rosy/RosyTest.rb +174 -191
- data/lib/rosy/RosyTrain.rb +46 -50
- data/lib/rosy/RosyTrainingTestTable.rb +101 -99
- data/lib/rosy/TargetsMostFrequentFrame.rb +13 -9
- data/lib/rosy/{AbstractFeatureAndExternal.rb → abstract_feature_extractor.rb} +22 -97
- data/lib/rosy/abstract_single_feature_extractor.rb +52 -0
- data/lib/rosy/external_feature_extractor.rb +35 -0
- data/lib/rosy/opt_parser.rb +231 -201
- data/lib/rosy/rosy.rb +63 -64
- data/lib/rosy/rosy_conventions.rb +66 -0
- data/lib/rosy/rosy_error.rb +15 -0
- data/lib/rosy/var_var_restriction.rb +16 -0
- data/lib/shalmaneser/rosy.rb +1 -0
- metadata +26 -19
- data/lib/rosy/ExternalConfigData.rb +0 -58
- data/lib/rosy/View.rb +0 -418
- data/lib/rosy/rosy_config_data.rb +0 -121
- data/test/frprep/test_opt_parser.rb +0 -94
- data/test/functional/functional_test_helper.rb +0 -58
- data/test/functional/test_fred.rb +0 -47
- data/test/functional/test_frprep.rb +0 -99
- data/test/functional/test_rosy.rb +0 -40
@@ -6,15 +6,15 @@
|
|
6
6
|
# for the data in the (training) database there.
|
7
7
|
#
|
8
8
|
# We define confusability as follows:
|
9
|
-
# Given a frame fr, let
|
9
|
+
# Given a frame fr, let
|
10
10
|
# - fes(fr) the FEs of fr (a set)
|
11
11
|
# - gfs(fe) the grammatical functions realizing the FE fe in the data
|
12
12
|
# - gfs(fr) = U_{fe \in fes(fr)} gfs(fe) the grammatical functions realizing roles of fr
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# Then the entropy of a grammatical function gf within fr is
|
15
15
|
#
|
16
16
|
# gfe_{fr}(gf) = \sum_{fe \in fes(fr)} -p(fe|gf) log p(fe|gf)
|
17
|
-
#
|
17
|
+
#
|
18
18
|
# where p(fe|gf) = f(gf, fe) / f(gf)
|
19
19
|
#
|
20
20
|
# And the confusability of a frame element fe of fr is
|
@@ -23,16 +23,21 @@
|
|
23
23
|
#
|
24
24
|
# where p(gf|fe) = f(gf, fe) / f(fe)
|
25
25
|
|
26
|
+
# @todo This require statement is wrong. This file is not read in.
|
26
27
|
require "RosyConfigData"
|
27
28
|
require "RosyIterator"
|
28
29
|
require "RosyConventions"
|
29
30
|
require "TargetsMostFrequentFrame"
|
30
31
|
|
32
|
+
# This is WRONG!!!!
|
33
|
+
# @todo Remove this!
|
31
34
|
require "mysql"
|
32
35
|
|
36
|
+
module Shalmaneser
|
37
|
+
module Rosy
|
33
38
|
class RosyConfusability
|
34
39
|
include TargetsMostFrequentSc
|
35
|
-
|
40
|
+
|
36
41
|
attr_reader :confusability, :counts_fe_glob, :frame_confusability, :overall_confusability
|
37
42
|
|
38
43
|
def initialize(exp) # RosyConfigData object
|
@@ -53,14 +58,14 @@ class RosyConfusability
|
|
53
58
|
"Obj_Comp", "Obj", "Mod_Head", "Ext_Comp_Obj",
|
54
59
|
"Gen_Head", "Ext_Gen_Mod"
|
55
60
|
# with duplicates
|
56
|
-
# "Ext_Comp", "Mod", "Comp", "Gen",
|
57
|
-
# "Ext_Obj", "Ext", "", "Ext_Obj_Comp",
|
58
|
-
# "Ext_Comp_Comp", "Head", "Mod_Mod", "Gen_Mod",
|
59
|
-
# "Ext_Mod", "Comp_Comp", "Mod_Comp", "Ext_Gen",
|
60
|
-
# "Gen_Comp", "Head_Head", "Ext_Comp_Comp_Comp", "Head_Comp",
|
61
|
+
# "Ext_Comp", "Mod", "Comp", "Gen",
|
62
|
+
# "Ext_Obj", "Ext", "", "Ext_Obj_Comp",
|
63
|
+
# "Ext_Comp_Comp", "Head", "Mod_Mod", "Gen_Mod",
|
64
|
+
# "Ext_Mod", "Comp_Comp", "Mod_Comp", "Ext_Gen",
|
65
|
+
# "Gen_Comp", "Head_Head", "Ext_Comp_Comp_Comp", "Head_Comp",
|
61
66
|
# # "Ext_Ext_Comp",
|
62
67
|
# # "Ext_Obj_Comp_Comp", "Obj_Comp",
|
63
|
-
# # "Ext_Mod_Mod", "Comp_Comp_Comp",
|
68
|
+
# # "Ext_Mod_Mod", "Comp_Comp_Comp",
|
64
69
|
# # "Ext_Ext_Obj", "Ext_Mod_Comp", "Comp_Ext", "Obj",
|
65
70
|
# # "Ext_Ext", "Ext_Obj_Obj", "Mod_Mod_Mod", "Gen_Mod_Mod",
|
66
71
|
# # "Ext_Comp_Comp_Comp_Comp", "Gen_Head", "Mod_Head",
|
@@ -74,29 +79,29 @@ class RosyConfusability
|
|
74
79
|
additionals) # array:string: "target", "target_pos", "gframe", "fgframe"
|
75
80
|
###
|
76
81
|
# open and initialize stuff:
|
77
|
-
|
82
|
+
|
78
83
|
# open database
|
79
|
-
database = Mysql.real_connect(@exp.get('host'), @exp.get('user'),
|
84
|
+
database = Mysql.real_connect(@exp.get('host'), @exp.get('user'),
|
80
85
|
@exp.get('passwd'), @exp.get('dbname'))
|
81
86
|
# make an object that creates views.
|
82
87
|
# read one frame at a time.
|
83
88
|
iterator = RosyIterator.new(database, @exp, "train",
|
84
|
-
"splitID" => splitID,
|
89
|
+
"splitID" => splitID,
|
85
90
|
"xwise" => "frame")
|
86
91
|
# get value for "no val"
|
87
92
|
noval = @exp.get("noval")
|
88
93
|
|
89
94
|
counts_frame = Hash.new(0)
|
90
|
-
|
95
|
+
|
91
96
|
# iterate through all frames and compute confusability of each FE
|
92
97
|
iterator.each_group { |group_descr_hash, frame|
|
93
|
-
|
98
|
+
|
94
99
|
$stderr.puts "Computing confusability for #{frame}"
|
95
100
|
|
96
101
|
# read all instances of the frame, columns: FE and GF
|
97
102
|
view = iterator.get_a_view_for_current_group(["sentid","gold", "fn_gf",
|
98
103
|
"target","target_pos", "frame"])
|
99
|
-
|
104
|
+
|
100
105
|
if additionals.include? "tmfframe"
|
101
106
|
# find most frequent gframe for each target
|
102
107
|
tmfframe = determine_target_most_frequent_sc(view, noval)
|
@@ -110,7 +115,7 @@ class RosyConfusability
|
|
110
115
|
view.each_sentence { |sentence|
|
111
116
|
|
112
117
|
# make string consisting of all FN GFs of this sentence
|
113
|
-
allgfs =
|
118
|
+
allgfs = []
|
114
119
|
sentence.each { |inst|
|
115
120
|
if inst["fn_gf"] != noval
|
116
121
|
allgfs << inst["fn_gf"]
|
@@ -132,13 +137,13 @@ class RosyConfusability
|
|
132
137
|
# don't count target among the FEs
|
133
138
|
next
|
134
139
|
end
|
135
|
-
|
140
|
+
|
136
141
|
if row["gold"] != noval
|
137
142
|
counts_fe[row["gold"]] += 1
|
138
143
|
end
|
139
144
|
if row["fn_gf"] != noval and row["fn_gf"] != "target"
|
140
145
|
gf = row["fn_gf"]
|
141
|
-
|
146
|
+
|
142
147
|
additionals.each { |additional|
|
143
148
|
case additional
|
144
149
|
when "target"
|
@@ -154,7 +159,7 @@ class RosyConfusability
|
|
154
159
|
@frequent_gframes.each { |fgframe|
|
155
160
|
if fgframe.subsumed_by?(allgfs)
|
156
161
|
# fgframe is a subset of allgfs
|
157
|
-
if maxfgf.nil? or fgframe.length
|
162
|
+
if maxfgf.nil? or fgframe.length > maxfgf.length
|
158
163
|
maxfgf = fgframe
|
159
164
|
end
|
160
165
|
end
|
@@ -176,26 +181,26 @@ class RosyConfusability
|
|
176
181
|
|
177
182
|
counts_gf[gf] += 1
|
178
183
|
end
|
179
|
-
|
184
|
+
|
180
185
|
if row["gold"] != noval and gf
|
181
186
|
counts_gffe[gf + " " + row["gold"]] += 1
|
182
187
|
end
|
183
188
|
} # each row of sentence
|
184
189
|
} # each sentence of view
|
185
|
-
|
190
|
+
|
186
191
|
# compute gf entropy
|
187
192
|
# gfe_{fr}(gf) = \sum_{fe \in fes(fr)} -p(fe|gf) log_2 p(fe|gf)
|
188
|
-
#
|
193
|
+
#
|
189
194
|
# where p(fe|gf) = f(gf, fe) / f(gf)
|
190
|
-
gf_entropy =
|
191
|
-
|
195
|
+
gf_entropy = {}
|
196
|
+
|
192
197
|
counts_gf.keys.each { |gf|
|
193
198
|
gf_entropy[gf] = 0.0
|
194
|
-
|
199
|
+
|
195
200
|
counts_fe.keys.each { |fe|
|
196
201
|
if counts_gf[gf] > 0
|
197
202
|
p_gf_fe = counts_gffe[gf + " " + fe].to_f / counts_gf[gf].to_f
|
198
|
-
|
203
|
+
|
199
204
|
# get log_2 via log_10
|
200
205
|
if p_gf_fe > 0.0
|
201
206
|
gf_entropy[gf] -= p_gf_fe * Math.log10(p_gf_fe) * 3.32193
|
@@ -203,18 +208,18 @@ class RosyConfusability
|
|
203
208
|
end
|
204
209
|
} # each FE for this GF
|
205
210
|
} # each GF (gf entropy)
|
206
|
-
|
211
|
+
|
207
212
|
# compute FE confusability
|
208
213
|
# c_{fr}(fe) = \sum_{gf \in gfs(fr)} p(gf|fe) gfe_{fr}(gf)
|
209
214
|
#
|
210
215
|
# where p(gf|fe) = f(gf, fe) / f(fe)
|
211
216
|
counts_fe.keys.each { |fe|
|
212
217
|
@confusability[frame + " " + fe] = 0.0
|
213
|
-
|
218
|
+
|
214
219
|
counts_gf.keys.each { |gf|
|
215
220
|
if counts_fe[fe] > 0
|
216
221
|
p_fe_gf = counts_gffe[gf + " " + fe].to_f / counts_fe[fe].to_f
|
217
|
-
|
222
|
+
|
218
223
|
@confusability[frame + " " + fe] += p_fe_gf * gf_entropy[gf]
|
219
224
|
end
|
220
225
|
} # each GF for this FE
|
@@ -239,7 +244,7 @@ class RosyConfusability
|
|
239
244
|
|
240
245
|
# compute overall frame confusability
|
241
246
|
# omitting rare FEs with below 5 occurrences:
|
242
|
-
#
|
247
|
+
#
|
243
248
|
# c(fr) = sum_{fe \in fes(fr)} f(fe)/f(fr) * c_{fr}(fe)
|
244
249
|
# = \sum_{gf \in gfs(fr)} p(gf|fr) gfe_{fr}(gf)
|
245
250
|
#
|
@@ -257,7 +262,7 @@ class RosyConfusability
|
|
257
262
|
end
|
258
263
|
}
|
259
264
|
} # each frame
|
260
|
-
|
265
|
+
|
261
266
|
# compute overall confusability
|
262
267
|
# c = \sum{fr \in frames} f(fr)/N * c(fr)
|
263
268
|
#
|
@@ -271,26 +276,26 @@ class RosyConfusability
|
|
271
276
|
@overall_confusability += (count.to_f / counts_overall.to_f) * @frame_confusability[frame]
|
272
277
|
}
|
273
278
|
end
|
274
|
-
|
279
|
+
|
275
280
|
|
276
281
|
# return a copy of @counts_fe_glob, from which all fes with less than 5 occurrences are deleted
|
277
|
-
def get_global_counts
|
282
|
+
def get_global_counts
|
278
283
|
global_counts = @counts_fe_glob.clone
|
279
284
|
global_counts.delete_if {|key, value| value < 5}
|
280
285
|
return global_counts
|
281
286
|
end
|
282
|
-
|
287
|
+
|
283
288
|
###
|
284
289
|
#
|
285
|
-
# compute sparseness statistics over the set of
|
290
|
+
# compute sparseness statistics over the set of
|
286
291
|
# base events used for computing the confusability
|
287
292
|
# returns an array of length 4:
|
288
293
|
# - number of events with freq 1
|
289
294
|
# - number of events with freq 2
|
290
295
|
# - number of events with freq 3-5
|
291
296
|
# - number of events with freq > 5
|
292
|
-
|
293
|
-
def counts
|
297
|
+
|
298
|
+
def counts
|
294
299
|
counts = [0,0,0,0]
|
295
300
|
@counts_gffe_glob.each_value {|freq|
|
296
301
|
case freq
|
@@ -306,7 +311,7 @@ class RosyConfusability
|
|
306
311
|
}
|
307
312
|
return counts
|
308
313
|
end
|
309
|
-
|
314
|
+
|
310
315
|
def to_file(filename)
|
311
316
|
begin
|
312
317
|
file = File.new(filename,"w")
|
@@ -321,7 +326,7 @@ class RosyConfusability
|
|
321
326
|
},
|
322
327
|
file)
|
323
328
|
end
|
324
|
-
|
329
|
+
|
325
330
|
def from_file(filename)
|
326
331
|
begin
|
327
332
|
file = File.new(filename)
|
@@ -336,3 +341,5 @@ class RosyConfusability
|
|
336
341
|
@overall_confusability = hash["overall_confusability"]
|
337
342
|
end
|
338
343
|
end
|
344
|
+
end
|
345
|
+
end
|
data/lib/rosy/RosyEval.rb
CHANGED
@@ -9,40 +9,42 @@
|
|
9
9
|
# Builds on the general Salsa Eval package
|
10
10
|
|
11
11
|
# Salsa packages
|
12
|
-
require
|
13
|
-
require "
|
12
|
+
require 'eval'
|
13
|
+
require "ruby_class_extensions"
|
14
14
|
|
15
15
|
# Rosy packages
|
16
16
|
require "rosy/RosyIterator"
|
17
17
|
require "rosy/RosySplit"
|
18
18
|
require "rosy/RosyTask"
|
19
19
|
require "rosy/RosyPruning"
|
20
|
+
require 'rosy/rosy_conventions'
|
20
21
|
|
21
|
-
|
22
|
-
require "common/prep_config_data"
|
22
|
+
require 'configuration/frappe_config_data'
|
23
23
|
|
24
24
|
#######################################################################
|
25
25
|
# This class is a subclass of the general evaluation class
|
26
26
|
# Eval, which makes evaluation results readable via
|
27
27
|
# readable object variables
|
28
28
|
#
|
29
|
-
# step: can be argrec, arglab, onestep, as usual, but also
|
29
|
+
# step: can be argrec, arglab, onestep, as usual, but also
|
30
30
|
# - "all":
|
31
31
|
# evaluate argrec and arglab together.
|
32
32
|
# When argrec == NONE, use the argrec value, else use the arglab value
|
33
|
-
# - "prune":
|
33
|
+
# - "prune":
|
34
34
|
# evaluate the pruning column as if it were an argrec assignment
|
35
35
|
#
|
36
36
|
# When step == argrec or prune, evaluate _only_ the target class FE
|
37
37
|
# Otherwise, evaluate all target classes
|
38
|
+
module Shalmaneser
|
39
|
+
module Rosy
|
38
40
|
class RosyEval < Eval
|
39
41
|
def initialize(exp, # RosyConfigData object: experiment file
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
ttt_obj, # RosyTrainingTestTable object
|
43
|
+
step, # string: argrec, arglab, onestep, all, prune
|
44
|
+
splitID, # string: splitlog ID, or nil
|
45
|
+
testID, # string: test ID, or nil
|
46
|
+
outfilename, # string: name of file to print output to
|
47
|
+
logfilename, # string: name of file to print eval log to (may be nil)
|
46
48
|
dont_adjoin_frprep_exp) # string: if non-nil, don't re-adjoin frprep experiment obj
|
47
49
|
@exp = exp
|
48
50
|
@step = step
|
@@ -50,7 +52,7 @@ class RosyEval < Eval
|
|
50
52
|
if outfilename
|
51
53
|
$stderr.puts "Rosy evaluation: printing results to " + outfilename
|
52
54
|
end
|
53
|
-
if logfilename
|
55
|
+
if logfilename
|
54
56
|
$stderr.puts "and printing an evaluation log to " + logfilename
|
55
57
|
end
|
56
58
|
|
@@ -73,7 +75,7 @@ class RosyEval < Eval
|
|
73
75
|
$stderr.puts "Parameter preproc_descr_file_train has to be a readable file."
|
74
76
|
exit 1
|
75
77
|
end
|
76
|
-
preproc_exp =
|
78
|
+
preproc_exp = ::Shalmaneser::Configuration::FrappeConfigData.new(preproc_expname)
|
77
79
|
@exp.adjoin(preproc_exp)
|
78
80
|
end
|
79
81
|
|
@@ -104,7 +106,7 @@ class RosyEval < Eval
|
|
104
106
|
$stderr.puts ttt_obj.runlog_to_s("test", testID, splitID)
|
105
107
|
exit 1
|
106
108
|
end
|
107
|
-
|
109
|
+
|
108
110
|
when "prune"
|
109
111
|
# read pruning column, evaluate as a kind of argrec assignment
|
110
112
|
unless Pruning.prune?(@exp)
|
@@ -127,29 +129,29 @@ class RosyEval < Eval
|
|
127
129
|
exit 1
|
128
130
|
end
|
129
131
|
end
|
130
|
-
|
132
|
+
|
131
133
|
##
|
132
134
|
# make object for iterating through groups and making views
|
133
135
|
case @step
|
134
136
|
when "all"
|
135
137
|
# all: no step in particular
|
136
|
-
@iterator = RosyIterator.new(ttt_obj, exp, "test",
|
137
|
-
"step" => nil,
|
138
|
-
"testID" => testID,
|
138
|
+
@iterator = RosyIterator.new(ttt_obj, exp, "test",
|
139
|
+
"step" => nil,
|
140
|
+
"testID" => testID,
|
139
141
|
"splitID" => splitID,
|
140
142
|
"xwise" => "frame")
|
141
143
|
when "prune"
|
142
144
|
# prune: use argrec
|
143
|
-
@iterator = RosyIterator.new(ttt_obj, exp, "test",
|
144
|
-
"step" => "argrec",
|
145
|
-
"testID" => testID,
|
145
|
+
@iterator = RosyIterator.new(ttt_obj, exp, "test",
|
146
|
+
"step" => "argrec",
|
147
|
+
"testID" => testID,
|
146
148
|
"splitID" => splitID)
|
147
149
|
|
148
150
|
else
|
149
151
|
# use the given step
|
150
|
-
@iterator = RosyIterator.new(ttt_obj, exp, "test",
|
151
|
-
"step" => @step,
|
152
|
-
"testID" => testID,
|
152
|
+
@iterator = RosyIterator.new(ttt_obj, exp, "test",
|
153
|
+
"step" => @step,
|
154
|
+
"testID" => testID,
|
153
155
|
"splitID" => splitID)
|
154
156
|
end
|
155
157
|
|
@@ -162,7 +164,7 @@ class RosyEval < Eval
|
|
162
164
|
@xwise = ["frame"]
|
163
165
|
else
|
164
166
|
# evaluate as you have trained and tested
|
165
|
-
@xwise = @iterator.get_xwise_column_names
|
167
|
+
@xwise = @iterator.get_xwise_column_names
|
166
168
|
end
|
167
169
|
|
168
170
|
##
|
@@ -170,7 +172,7 @@ class RosyEval < Eval
|
|
170
172
|
# in count of gold labels
|
171
173
|
if splitID
|
172
174
|
# get a FailedParses object for this split
|
173
|
-
@failed_parses_split = FailedParses.new
|
175
|
+
@failed_parses_split = FailedParses.new
|
174
176
|
fp_filename = File.new_filename(@exp.instantiate("rosy_dir",
|
175
177
|
"exp_ID" => @exp.get("experiment_ID")),
|
176
178
|
@exp.instantiate("failed_file",
|
@@ -198,7 +200,7 @@ class RosyEval < Eval
|
|
198
200
|
# each_group
|
199
201
|
#
|
200
202
|
# yield each group name in turn
|
201
|
-
def each_group
|
203
|
+
def each_group
|
202
204
|
|
203
205
|
@view = nil
|
204
206
|
|
@@ -224,7 +226,7 @@ class RosyEval < Eval
|
|
224
226
|
|
225
227
|
# for each value sequence for normal_xwise_cols: find out how many values
|
226
228
|
# of extra xwise col.s there are
|
227
|
-
@iterator.each_group
|
229
|
+
@iterator.each_group { |group_descr_hash, group_name|
|
228
230
|
|
229
231
|
# make the hash key
|
230
232
|
key = normal_xwise_cols.sort.map { |col_name|
|
@@ -236,7 +238,7 @@ class RosyEval < Eval
|
|
236
238
|
}
|
237
239
|
end
|
238
240
|
|
239
|
-
@iterator.each_group
|
241
|
+
@iterator.each_group { |group_descr_hash, group_name|
|
240
242
|
|
241
243
|
if @exp.get("verbose")
|
242
244
|
$stderr.puts group_name
|
@@ -255,7 +257,7 @@ class RosyEval < Eval
|
|
255
257
|
|
256
258
|
# get a description of this group, array of pairs [column name, value]
|
257
259
|
# where column name is the name of one database column
|
258
|
-
@xwise.interleave(group_name.split
|
260
|
+
@xwise.interleave(group_name.split).each { |col_name, col_value|
|
259
261
|
case col_name
|
260
262
|
when "frame"
|
261
263
|
frame = col_value
|
@@ -283,7 +285,7 @@ class RosyEval < Eval
|
|
283
285
|
end
|
284
286
|
end
|
285
287
|
|
286
|
-
# failed_fes returns: hash that maps FE names [String] onto numbers of failed FEs [Int]
|
288
|
+
# failed_fes returns: hash that maps FE names [String] onto numbers of failed FEs [Int]
|
287
289
|
if @failed_parses_split
|
288
290
|
@failed_parses_split.failed_fes(frame, target, target_pos).each_pair { |fe, count|
|
289
291
|
# add this number of gold labels we failed to find
|
@@ -299,7 +301,7 @@ class RosyEval < Eval
|
|
299
301
|
|
300
302
|
# yield the name of the group to the Eval object for evaluation
|
301
303
|
yield group_name
|
302
|
-
@view.close
|
304
|
+
@view.close
|
303
305
|
}
|
304
306
|
end
|
305
307
|
|
@@ -324,7 +326,7 @@ class RosyEval < Eval
|
|
324
326
|
yield [ row["gold"], row[@classif_column_arglab] ]
|
325
327
|
end
|
326
328
|
}
|
327
|
-
|
329
|
+
|
328
330
|
when "prune"
|
329
331
|
# step "prune":
|
330
332
|
# if the pruning column has entry 1, regard as assignment "FE",
|
@@ -346,7 +348,7 @@ class RosyEval < Eval
|
|
346
348
|
yield [row["gold"], row[@classif_column]]
|
347
349
|
}
|
348
350
|
end
|
349
|
-
|
351
|
+
|
350
352
|
end
|
351
353
|
end
|
352
354
|
|
@@ -356,12 +358,8 @@ end
|
|
356
358
|
class RosyEvalTask < RosyTask
|
357
359
|
|
358
360
|
def initialize(exp, # RosyConfigData object: experiment description
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
#####
|
363
|
-
# In enduser mode, this whole task is unavailable
|
364
|
-
in_enduser_mode_unavailable()
|
361
|
+
opts, # hash: runtime argument option (string) -> value (string)
|
362
|
+
ttt_obj) # RosyTrainingTestTable object
|
365
363
|
|
366
364
|
@exp = exp
|
367
365
|
@ttt_obj = ttt_obj
|
@@ -370,26 +368,26 @@ class RosyEvalTask < RosyTask
|
|
370
368
|
# check runtime options
|
371
369
|
@step = "both"
|
372
370
|
@splitID = nil
|
373
|
-
@testID = default_test_ID
|
371
|
+
@testID = Rosy.default_test_ID
|
374
372
|
|
375
373
|
opts.each do |opt,arg|
|
376
374
|
case opt
|
377
375
|
when "--step"
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
376
|
+
unless ["argrec", "arglab", "both", "onestep"].include? arg
|
377
|
+
raise "Classification step must be one of: argrec, arglab, both, onestep. I got: " + arg.to_s
|
378
|
+
end
|
379
|
+
@step = arg
|
382
380
|
when "--logID"
|
383
|
-
|
381
|
+
@splitID = arg
|
384
382
|
when "--testID"
|
385
|
-
|
383
|
+
@testID = arg
|
386
384
|
else
|
387
|
-
|
385
|
+
# this is an option that is okay but has already been read and used by rosy.rb
|
388
386
|
end
|
389
387
|
end
|
390
388
|
end
|
391
389
|
|
392
|
-
def perform
|
390
|
+
def perform
|
393
391
|
dont_adjoin_frprep_exp = nil
|
394
392
|
original_step = @step
|
395
393
|
|
@@ -398,7 +396,7 @@ class RosyEvalTask < RosyTask
|
|
398
396
|
# evaluate pruning
|
399
397
|
$stderr.puts "Rosy evaluating pruning"
|
400
398
|
@step = "prune"
|
401
|
-
perform_aux
|
399
|
+
perform_aux
|
402
400
|
dont_adjoin_frprep_exp = "dont_adjoin_frprep_exp"
|
403
401
|
end
|
404
402
|
|
@@ -408,7 +406,7 @@ class RosyEvalTask < RosyTask
|
|
408
406
|
@step = "argrec"
|
409
407
|
perform_aux(dont_adjoin_frprep_exp)
|
410
408
|
|
411
|
-
|
409
|
+
|
412
410
|
$stderr.puts "Rosy evaluating step arglab"
|
413
411
|
@step = "arglab"
|
414
412
|
perform_aux("dont_adjoin_frprep_exp")
|
@@ -438,7 +436,7 @@ class RosyEvalTask < RosyTask
|
|
438
436
|
if @splitID
|
439
437
|
outfilename_id = "split" + @splitID
|
440
438
|
else
|
441
|
-
outfilename_id = "test" + @testID
|
439
|
+
outfilename_id = "test" + @testID
|
442
440
|
end
|
443
441
|
@outfilename = File.new_filename(@exp.instantiate("rosy_dir",
|
444
442
|
"exp_ID" => @exp.get("experiment_ID")),
|
@@ -457,9 +455,11 @@ class RosyEvalTask < RosyTask
|
|
457
455
|
else
|
458
456
|
@logfilename = nil
|
459
457
|
end
|
460
|
-
@eval_obj = RosyEval.new(@exp, @ttt_obj, @step, @splitID, @testID,
|
458
|
+
@eval_obj = RosyEval.new(@exp, @ttt_obj, @step, @splitID, @testID,
|
461
459
|
@outfilename, @logfilename,
|
462
460
|
dont_adjoin_frprep_exp)
|
463
|
-
@eval_obj.compute
|
461
|
+
@eval_obj.compute
|
464
462
|
end
|
465
463
|
end
|
464
|
+
end
|
465
|
+
end
|