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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -18
  3. data/bin/rosy +14 -7
  4. data/lib/rosy/FailedParses.rb +22 -20
  5. data/lib/rosy/FeatureInfo.rb +35 -31
  6. data/lib/rosy/GfInduce.rb +132 -130
  7. data/lib/rosy/GfInduceFeature.rb +86 -68
  8. data/lib/rosy/InputData.rb +59 -55
  9. data/lib/rosy/RosyConfusability.rb +47 -40
  10. data/lib/rosy/RosyEval.rb +55 -55
  11. data/lib/rosy/RosyFeatureExtractors.rb +295 -290
  12. data/lib/rosy/RosyFeaturize.rb +54 -67
  13. data/lib/rosy/RosyInspect.rb +52 -50
  14. data/lib/rosy/RosyIterator.rb +73 -67
  15. data/lib/rosy/RosyPhase2FeatureExtractors.rb +48 -48
  16. data/lib/rosy/RosyPruning.rb +39 -31
  17. data/lib/rosy/RosyServices.rb +116 -115
  18. data/lib/rosy/RosySplit.rb +55 -53
  19. data/lib/rosy/RosyTask.rb +7 -3
  20. data/lib/rosy/RosyTest.rb +174 -191
  21. data/lib/rosy/RosyTrain.rb +46 -50
  22. data/lib/rosy/RosyTrainingTestTable.rb +101 -99
  23. data/lib/rosy/TargetsMostFrequentFrame.rb +13 -9
  24. data/lib/rosy/{AbstractFeatureAndExternal.rb → abstract_feature_extractor.rb} +22 -97
  25. data/lib/rosy/abstract_single_feature_extractor.rb +52 -0
  26. data/lib/rosy/external_feature_extractor.rb +35 -0
  27. data/lib/rosy/opt_parser.rb +231 -201
  28. data/lib/rosy/rosy.rb +63 -64
  29. data/lib/rosy/rosy_conventions.rb +66 -0
  30. data/lib/rosy/rosy_error.rb +15 -0
  31. data/lib/rosy/var_var_restriction.rb +16 -0
  32. data/lib/shalmaneser/rosy.rb +1 -0
  33. metadata +26 -19
  34. data/lib/rosy/ExternalConfigData.rb +0 -58
  35. data/lib/rosy/View.rb +0 -418
  36. data/lib/rosy/rosy_config_data.rb +0 -121
  37. data/test/frprep/test_opt_parser.rb +0 -94
  38. data/test/functional/functional_test_helper.rb +0 -58
  39. data/test/functional/test_fred.rb +0 -47
  40. data/test/functional/test_frprep.rb +0 -99
  41. data/test/functional/test_rosy.rb +0 -40
@@ -1,5 +1,5 @@
1
1
  ####
2
- # ke & sp
2
+ # ke & sp
3
3
  # adapted to new feature extractor class,
4
4
  # Collins and Tiger features combined:
5
5
  # KE November 2005
@@ -8,18 +8,21 @@
8
8
  #
9
9
  # Contract: each feature extractor inherits from the RosyFeatureExtractor class
10
10
  #
11
- # Feature extractors return nil if no feature value could be
11
+ # Feature extractors return nil if no feature value could be
12
12
  # returned
13
13
 
14
14
 
15
15
  # Salsa packages
16
- require 'rosy/AbstractFeatureAndExternal'
17
- require 'common/SalsaTigerRegXML'
16
+ require 'rosy/abstract_feature_extractor'
17
+ # require 'SalsaTigerRegXML'
18
18
 
19
19
  # Fred and Rosy packages
20
- require 'common/RosyConventions'
20
+ require 'rosy/rosy_conventions'
21
21
 
22
+ require 'frappe/path'
22
23
 
24
+ module Shalmaneser
25
+ module Rosy
23
26
  ################################
24
27
  # base class for all following feature extractors
25
28
  class RosyFeatureExtractor < AbstractFeatureExtractor
@@ -29,7 +32,7 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
29
32
  @@target = nil # SynNode: main target node
30
33
  @@target_pos = nil # string: part of speech of main target
31
34
  @@target_voice = nil # string: "active", "passive", or nil
32
- @@terminals_ordered = nil # Hash: sentence terminals, mapped onto their word indices (starting with 1)
35
+ @@terminals_ordered = nil # Hash: sentence terminals, mapped onto their word indices (starting with 1)
33
36
  @@target_gfs = nil # Array of pairs [rel, node]: grammatical functions of the target
34
37
 
35
38
  @@paths = nil # Hash: node ID -> path object, path from main target node to the node with that ID
@@ -48,14 +51,14 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
48
51
  # computed for the training set
49
52
  #
50
53
  # Here: all features in this packages are phase 1
51
- def RosyFeatureExtractor.phase()
54
+ def RosyFeatureExtractor.phase
52
55
  return "phase 1"
53
56
  end
54
57
 
55
58
  ###
56
59
  # returns an array of strings, providing information about
57
60
  # the feature extractor
58
- def RosyFeatureExtractor.info()
61
+ def RosyFeatureExtractor.info
59
62
  return super().concat(["rosy"])
60
63
  end
61
64
 
@@ -76,16 +79,16 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
76
79
  frame) # FrameNode object
77
80
  super(sent, frame)
78
81
 
79
- root = @@sent.syn_roots.first()
82
+ root = @@sent.syn_roots.first
80
83
  word_index_counter = 1
81
- @@terminals_ordered = Hash.new
84
+ @@terminals_ordered = {}
82
85
  root.yield_nodes_ordered.each {|yield_node|
83
86
  @@terminals_ordered[yield_node] = word_index_counter
84
87
  word_index_counter += 1
85
88
  }
86
89
 
87
90
  # @@target: main target node (SynNode)
88
- # WARNING: at this moment, we are
91
+ # WARNING: at this moment, we are
89
92
  # not considering true multiword targets.
90
93
  # Remove the "no_mwe" parameter in determine_main_target
91
94
  # to change this
@@ -93,7 +96,7 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
93
96
  @@target = nil
94
97
  return false
95
98
  end
96
- @@target = @@interpreter_class.main_node_of_expr(frame.target.children(), "no_mwe")
99
+ @@target = @@interpreter_class.main_node_of_expr(frame.target.children, "no_mwe")
97
100
 
98
101
  unless @@target
99
102
  return false
@@ -102,7 +105,7 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
102
105
  # @@target_pos: string, target POS
103
106
  @@target_pos = @@interpreter_class.category(@@target)
104
107
 
105
- # @@target_voice:
108
+ # @@target_voice:
106
109
  # for verb targets, string, active or passive
107
110
  # else nil
108
111
  @@target_voice = @@interpreter_class.voice(@@target)
@@ -113,14 +116,14 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
113
116
 
114
117
  # governing verb of target.
115
118
  # If something goes wrong, this will remain unset
116
- @@gv_paths = Hash.new
119
+ @@gv_paths = {}
117
120
  if (targetlemma = RosyFeatureExtractor.headlemma(@@target))
118
121
  # determine governing verb
119
122
  parent = @@target
120
123
  while (parent = parent.parent)
121
124
  parentlemma = RosyFeatureExtractor.headlemma(parent)
122
125
 
123
- if @@interpreter_class.category(parent) == "verb" and
126
+ if @@interpreter_class.category(parent) == "verb" and
124
127
  parentlemma != targetlemma
125
128
  # success: found the governing verb of the target
126
129
 
@@ -145,9 +148,9 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
145
148
 
146
149
  ###
147
150
  # node: SynNode of the sentence set in set_sentence
148
- def RosyFeatureExtractor.set_node(node)
151
+ def RosyFeatureExtractor.set_node(node)
149
152
  super(node)
150
-
153
+
151
154
  @@instance_ok = true
152
155
 
153
156
  unless @@target
@@ -174,20 +177,20 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
174
177
  # compute_feature_value: first check if instance is OK
175
178
  #
176
179
  # returns: list of features
177
- def compute_features()
180
+ def compute_features
178
181
  unless @@instance_ok
179
182
  return nil
180
183
  end
181
184
 
182
- return make_features_safe_for_sql(compute_features_instanceOK())
185
+ return make_features_safe_for_sql(compute_features_instanceOK)
183
186
  end
184
187
 
185
188
  ############
186
189
  protected
187
190
 
188
-
191
+
189
192
  # returns: list of features
190
- def compute_features_instanceOK()
193
+ def compute_features_instanceOK
191
194
  raise "Overwrite me"
192
195
  end
193
196
 
@@ -196,7 +199,7 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
196
199
  # replace "," by COMMA in order not to confuse SQL
197
200
  def make_features_safe_for_sql(feature_list)
198
201
  return feature_list.map { |feature|
199
- if feature.kind_of? String
202
+ if feature.is_a? String
200
203
  feature.gsub(/,/, "COMMA").gsub(/\\/, "BACK")
201
204
  else
202
205
  feature
@@ -204,7 +207,7 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
204
207
  }
205
208
  end
206
209
 
207
-
210
+
208
211
  ###
209
212
  # lemma of the head terminal of SynNode n
210
213
  def RosyFeatureExtractor.headlemma(n) # SynNode
@@ -229,7 +232,7 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
229
232
 
230
233
  h = @@interpreter_class.head_terminal(n)
231
234
  if h
232
- return h.part_of_speech()
235
+ return h.part_of_speech
233
236
  else
234
237
  return nil
235
238
  end
@@ -247,20 +250,20 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
247
250
  hash = nil) # Hash: nodeID(string) => Path object
248
251
  # initial step of all: no hash existing yet
249
252
  if hash.nil?
250
- hash = Hash.new
251
- hash[n.id()] = Path.new(n)
253
+ hash = {}
254
+ hash[n.id] = ::Shalmaneser::Frappe::Path.new(n)
252
255
  end
253
256
 
254
257
  # invariant at this point: n must be listed in hash
255
- unless hash[n.id()]
258
+ unless hash[n.id]
256
259
  raise "Shouldn't be here"
257
260
  end
258
261
 
259
262
  # for each child c of n: compute its path from the path of n,
260
263
  # and explore paths below c
261
264
  n.each_child_with_edgelabel { |label, c|
262
- if hash[c.id()].nil?
263
- hash[c.id()] = hash[n.id()].deep_clone().add_last_step("D",
265
+ if hash[c.id].nil?
266
+ hash[c.id] = hash[n.id].deep_clone.add_last_step("D",
264
267
  label,
265
268
  @@interpreter_class.simplified_pt(c),
266
269
  c)
@@ -270,12 +273,12 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
270
273
 
271
274
  # compute the path from n's parent p from the path of n,
272
275
  # and explore paths beyond p
273
- if (p = n.parent) and hash[p.id()].nil?
276
+ if (p = n.parent) and hash[p.id].nil?
274
277
  # node has a parent, and it is not listed in the path hash
275
278
  # make a new path for parent: n's path, plus one up-step
276
- hash[p.id()] = hash[n.id()].deep_clone().add_last_step("U",
277
- n.parent_label,
278
- @@interpreter_class.simplified_pt(p),
279
+ hash[p.id] = hash[n.id].deep_clone.add_last_step("U",
280
+ n.parent_label,
281
+ @@interpreter_class.simplified_pt(p),
279
282
  p)
280
283
  RosyFeatureExtractor.all_paths_from(p, hash)
281
284
  end
@@ -283,11 +286,11 @@ class RosyFeatureExtractor < AbstractFeatureExtractor
283
286
  return hash
284
287
 
285
288
  end
286
-
289
+
287
290
  end
288
291
 
289
292
  ###############################
290
- # Rosy single feature extractor, duplicating stuff from
293
+ # Rosy single feature extractor, duplicating stuff from
291
294
  # AbstractSingleFeatureExtractor
292
295
  class RosySingleFeatureExtractor < RosyFeatureExtractor
293
296
 
@@ -297,31 +300,31 @@ class RosySingleFeatureExtractor < RosyFeatureExtractor
297
300
  # in the experiment file it is chosen by a single designator)
298
301
  #
299
302
  # here: single feature, and the feature name is the designator
300
- def RosySingleFeatureExtractor.designator()
301
- return eval(self.name()).feature_name()
303
+ def RosySingleFeatureExtractor.designator
304
+ feature_name
302
305
  end
303
306
 
304
307
  ###
305
- def RosySingleFeatureExtractor.feature_names()
306
- return [eval(self.name()).feature_name()]
308
+ def RosySingleFeatureExtractor.feature_names
309
+ [feature_name]
307
310
  end
308
311
 
309
312
  ###
310
313
  # compute_feature_value: first check if instance is OK
311
314
  #
312
315
  # returns: list of features
313
- def compute_features()
316
+ def compute_features
314
317
  unless @@instance_ok
315
318
  return nil
316
319
  end
317
320
 
318
- return make_features_safe_for_sql([compute_feature_instanceOK()])
321
+ return make_features_safe_for_sql([compute_feature_instanceOK])
319
322
  end
320
323
 
321
324
  ############
322
325
  private
323
326
 
324
- def compute_feature_instanceOK()
327
+ def compute_feature_instanceOK
325
328
  raise "Overwrite me"
326
329
  end
327
330
 
@@ -334,18 +337,18 @@ end
334
337
  ####################
335
338
  # gold role label
336
339
  class GoldlabelFeature < RosySingleFeatureExtractor
337
- GoldlabelFeature.announce_me()
340
+ GoldlabelFeature.announce_me
338
341
 
339
- def GoldlabelFeature.feature_name()
342
+ def GoldlabelFeature.feature_name
340
343
  return "gold"
341
344
  end
342
- def GoldlabelFeature.sql_type()
345
+ def GoldlabelFeature.sql_type
343
346
  return "VARCHAR(30)"
344
347
  end
345
- def GoldlabelFeature.feature_type()
348
+ def GoldlabelFeature.feature_type
346
349
  return "gold"
347
350
  end
348
- def GoldlabelFeature.info()
351
+ def GoldlabelFeature.info
349
352
  # additional info: I am an index feature
350
353
  return super().concat(["index"])
351
354
  end
@@ -353,15 +356,15 @@ class GoldlabelFeature < RosySingleFeatureExtractor
353
356
  ################
354
357
  private
355
358
 
356
- def compute_feature_instanceOK()
359
+ def compute_feature_instanceOK
357
360
  @@frame.each_fe_by_name {|fe|
358
361
  if fe.children.include? @@node
359
362
  return fe.name
360
- end
363
+ end
361
364
  }
362
-
365
+
363
366
  # no role label for this node
364
- # if @@split_nones
367
+ # if @@split_nones
365
368
  # split "no role" label into:
366
369
  # before/after/dominating the target node
367
370
  # return @@relpos
@@ -374,31 +377,31 @@ end
374
377
  ####################
375
378
  # path features
376
379
  class AbstractPathFeature < RosySingleFeatureExtractor
377
- def AbstractPathFeature.sql_type()
380
+ def AbstractPathFeature.sql_type
378
381
  return "VARCHAR(80)"
379
382
  end
380
- def AbstractPathFeature.feature_type()
383
+ def AbstractPathFeature.feature_type
381
384
  return "syn"
382
385
  end
383
386
 
384
387
  ################
385
388
  private
386
389
 
387
- def compute_feature_instanceOK()
388
- if @@paths[@@node.id()].nil?
390
+ def compute_feature_instanceOK
391
+ if @@paths[@@node.id].nil?
389
392
  path = nil
390
393
  else
391
- path = my_path_computation()
394
+ path = my_path_computation
392
395
  end
393
396
 
394
397
  if path.nil? or path.empty?
395
398
  return nil
396
- else
399
+ else
397
400
  return path
398
401
  end
399
402
  end
400
403
 
401
- def my_path_computation()
404
+ def my_path_computation
402
405
  raise "overwrite me"
403
406
  end
404
407
  end
@@ -407,24 +410,24 @@ end
407
410
  ####################
408
411
  # path consisting of nodelabels, dependencies and directions
409
412
  class PathFeature < AbstractPathFeature
410
- PathFeature.announce_me()
413
+ PathFeature.announce_me
411
414
 
412
- def PathFeature.sql_type()
415
+ def PathFeature.sql_type
413
416
  return "VARCHAR(120)"
414
417
  end
415
- def PathFeature.feature_name()
418
+ def PathFeature.feature_name
416
419
  return "path"
417
420
  end
418
421
 
419
422
  ################
420
423
  private
421
424
 
422
- def my_path_computation()
423
- if @@paths[@@node.id()].nil?
425
+ def my_path_computation
426
+ if @@paths[@@node.id].nil?
424
427
  return nil
425
428
  end
426
429
 
427
- return @@paths[@@node.id()].print(true, true, true)
430
+ return @@paths[@@node.id].print(true, true, true)
428
431
  end
429
432
  end
430
433
 
@@ -433,73 +436,73 @@ end
433
436
  ####################
434
437
  # path consisting of phrase type and directions
435
438
  class NodelabelPathFeature < AbstractPathFeature
436
- NodelabelPathFeature.announce_me()
439
+ NodelabelPathFeature.announce_me
437
440
 
438
- def NodelabelPathFeature.feature_name()
441
+ def NodelabelPathFeature.feature_name
439
442
  return "pt_path"
440
443
  end
441
444
 
442
445
  ################
443
446
  private
444
447
 
445
- def my_path_computation()
446
- if @@paths[@@node.id()].nil?
448
+ def my_path_computation
449
+ if @@paths[@@node.id].nil?
447
450
  return nil
448
451
  end
449
452
 
450
- return @@paths[@@node.id()].print(true, false, true)
453
+ return @@paths[@@node.id].print(true, false, true)
451
454
  end
452
455
  end
453
456
 
454
457
  ####################
455
458
  # path consisting of dependencies and directions
456
459
  class EdgelabelPathFeature < AbstractPathFeature
457
- EdgelabelPathFeature.announce_me()
460
+ EdgelabelPathFeature.announce_me
458
461
 
459
- def EdgelabelPathFeature.feature_name()
462
+ def EdgelabelPathFeature.feature_name
460
463
  return "gf_path"
461
464
  end
462
465
 
463
466
  ################
464
467
  private
465
468
 
466
- def my_path_computation()
467
- if @@paths[@@node.id()].nil?
469
+ def my_path_computation
470
+ if @@paths[@@node.id].nil?
468
471
  return nil
469
472
  end
470
473
 
471
- return @@paths[@@node.id()].print(true, true, false)
474
+ return @@paths[@@node.id].print(true, true, false)
472
475
  end
473
476
  end
474
477
 
475
478
  ####################
476
479
  # features: path from governing verb
477
480
  class AbstractGVPathFeature < RosySingleFeatureExtractor
478
- def AbstractGVPathFeature.sql_type()
481
+ def AbstractGVPathFeature.sql_type
479
482
  return "VARCHAR(80)"
480
483
  end
481
- def AbstractGVPathFeature.feature_type()
484
+ def AbstractGVPathFeature.feature_type
482
485
  return "syn"
483
486
  end
484
487
 
485
488
  ################
486
489
  private
487
490
 
488
- def compute_feature_instanceOK()
489
- if @@gv_paths[@@node.id()].nil?
491
+ def compute_feature_instanceOK
492
+ if @@gv_paths[@@node.id].nil?
490
493
  path = nil
491
494
  else
492
- path = my_path_computation()
495
+ path = my_path_computation
493
496
  end
494
497
 
495
498
  if path.nil? or path.empty?
496
499
  return nil
497
- else
500
+ else
498
501
  return path
499
502
  end
500
503
  end
501
504
 
502
- def my_path_computation()
505
+ def my_path_computation
503
506
  raise "overwrite me"
504
507
  end
505
508
  end
@@ -508,20 +511,20 @@ end
508
511
  ####################
509
512
  # path from governing verb consisting of nodelabels, dependencies and directions
510
513
  class GVPathFeature < AbstractGVPathFeature
511
- GVPathFeature.announce_me()
514
+ GVPathFeature.announce_me
512
515
 
513
- def GVPathFeature.sql_type()
516
+ def GVPathFeature.sql_type
514
517
  return "VARCHAR(120)"
515
518
  end
516
- def GVPathFeature.feature_name()
519
+ def GVPathFeature.feature_name
517
520
  return "gvpath"
518
521
  end
519
522
 
520
523
  ################
521
524
  private
522
525
 
523
- def my_path_computation()
524
- return @@gv_paths[@@node.id()].print(true, true, true)
526
+ def my_path_computation
527
+ return @@gv_paths[@@node.id].print(true, true, true)
525
528
  end
526
529
  end
527
530
 
@@ -529,60 +532,60 @@ end
529
532
  ####################
530
533
  # gov. verb path consisting of phrase type and directions
531
534
  class GVNodelabelPathFeature < AbstractGVPathFeature
532
- GVNodelabelPathFeature.announce_me()
535
+ GVNodelabelPathFeature.announce_me
533
536
 
534
- def GVNodelabelPathFeature.feature_name()
537
+ def GVNodelabelPathFeature.feature_name
535
538
  return "pt_gvpath"
536
539
  end
537
540
 
538
541
  ################
539
542
  private
540
543
 
541
- def my_path_computation()
542
- return @@gv_paths[@@node.id()].print(true, false, true)
544
+ def my_path_computation
545
+ return @@gv_paths[@@node.id].print(true, false, true)
543
546
  end
544
547
  end
545
548
 
546
549
  ####################
547
550
  # gov. verb path consisting of dependencies and directions
548
551
  class GVEdgelabelPathFeature < AbstractGVPathFeature
549
- GVEdgelabelPathFeature.announce_me()
552
+ GVEdgelabelPathFeature.announce_me
550
553
 
551
- def GVEdgelabelPathFeature.feature_name()
554
+ def GVEdgelabelPathFeature.feature_name
552
555
  return "gf_gvpath"
553
556
  end
554
557
 
555
558
  ################
556
559
  private
557
560
 
558
- def my_path_computation()
559
- return @@gv_paths[@@node.id()].print(true, true, false)
561
+ def my_path_computation
562
+ return @@gv_paths[@@node.id].print(true, true, false)
560
563
  end
561
564
  end
562
565
 
563
566
  ####################
564
567
  # path length
565
568
  class PathLengthFeature < RosySingleFeatureExtractor
566
- PathLengthFeature.announce_me()
569
+ PathLengthFeature.announce_me
567
570
 
568
- def PathLengthFeature.feature_name()
571
+ def PathLengthFeature.feature_name
569
572
  return "path_length"
570
573
  end
571
- def PathLengthFeature.sql_type()
574
+ def PathLengthFeature.sql_type
572
575
  return "TINYINT"
573
576
  end
574
- def PathLengthFeature.feature_type()
577
+ def PathLengthFeature.feature_type
575
578
  return "syn"
576
579
  end
577
580
 
578
581
  ################
579
582
  private
580
583
 
581
- def compute_feature_instanceOK()
582
- if @@paths[@@node.id()].nil?
584
+ def compute_feature_instanceOK
585
+ if @@paths[@@node.id].nil?
583
586
  return nil
584
587
  else
585
- return @@paths[@@node.id()].length()
588
+ return @@paths[@@node.id].length
586
589
  end
587
590
  end
588
591
  end
@@ -593,27 +596,27 @@ end
593
596
  # info on whether the target is passive
594
597
  class AbstractCombinedPathFeature < RosySingleFeatureExtractor
595
598
 
596
- def AbstractCombinedPathFeature.sql_type()
599
+ def AbstractCombinedPathFeature.sql_type
597
600
  return "VARCHAR(90)"
598
601
  end
599
- def AbstractCombinedPathFeature.feature_type()
602
+ def AbstractCombinedPathFeature.feature_type
600
603
  return "syn"
601
604
  end
602
605
 
603
606
  ################
604
607
  private
605
608
 
606
- def compute_feature_instanceOK()
607
- if @@paths[@@node.id()].nil?
609
+ def compute_feature_instanceOK
610
+ if @@paths[@@node.id].nil?
608
611
  path = ""
609
612
  else
610
- path = my_path_computation()
613
+ path = my_path_computation
611
614
  end
612
615
  return path + "--" + @@target_pos.to_s + "--" + @@target_voice.to_s
613
616
  end
614
617
 
615
618
  ###
616
- def my_path_computation()
619
+ def my_path_computation
617
620
  raise "Overwrite me"
618
621
  end
619
622
  end
@@ -622,42 +625,42 @@ end
622
625
  ####################
623
626
  # combined path based on nodelabels
624
627
  class NodelabelCombinedPathFeature < AbstractCombinedPathFeature
625
- NodelabelCombinedPathFeature.announce_me()
628
+ NodelabelCombinedPathFeature.announce_me
626
629
 
627
- def NodelabelCombinedPathFeature.feature_name()
630
+ def NodelabelCombinedPathFeature.feature_name
628
631
  return "pt_combined_path"
629
632
  end
630
633
 
631
634
  ################
632
635
  private
633
636
 
634
- def my_path_computation()
635
- if @@paths[@@node.id()].nil?
637
+ def my_path_computation
638
+ if @@paths[@@node.id].nil?
636
639
  return nil
637
640
  end
638
641
 
639
- return @@paths[@@node.id()].print(false, false, true)
642
+ return @@paths[@@node.id].print(false, false, true)
640
643
  end
641
644
  end
642
645
 
643
646
  ####################
644
647
  # combined path based on edgelabels
645
648
  class EdgelabelCombinedPathFeature < AbstractCombinedPathFeature
646
- EdgelabelCombinedPathFeature.announce_me()
649
+ EdgelabelCombinedPathFeature.announce_me
647
650
 
648
- def EdgelabelCombinedPathFeature.feature_name()
651
+ def EdgelabelCombinedPathFeature.feature_name
649
652
  return "gf_combined_path"
650
653
  end
651
654
 
652
655
  ################
653
656
  private
654
657
 
655
- def my_path_computation()
656
- if @@paths[@@node.id()].nil?
658
+ def my_path_computation
659
+ if @@paths[@@node.id].nil?
657
660
  return nil
658
661
  end
659
662
 
660
- return @@paths[@@node.id()].print(false, true, false)
663
+ return @@paths[@@node.id].print(false, true, false)
661
664
  end
662
665
  end
663
666
 
@@ -665,24 +668,24 @@ end
665
668
  ####################
666
669
  # combined path based on nodelabels and edgelabels
667
670
  class CombinedPathFeature < AbstractCombinedPathFeature
668
- CombinedPathFeature.announce_me()
671
+ CombinedPathFeature.announce_me
669
672
 
670
- def CombinedPathFeature.sql_type()
673
+ def CombinedPathFeature.sql_type
671
674
  return "VARCHAR(130)"
672
675
  end
673
- def CombinedPathFeature.feature_name()
676
+ def CombinedPathFeature.feature_name
674
677
  return "combined_path"
675
678
  end
676
679
 
677
680
  ################
678
681
  private
679
682
 
680
- def my_path_computation()
681
- if @@paths[@@node.id()].nil?
683
+ def my_path_computation
684
+ if @@paths[@@node.id].nil?
682
685
  return nil
683
686
  end
684
687
 
685
- return @@paths[@@node.id()].print(false, true, true)
688
+ return @@paths[@@node.id].print(false, true, true)
686
689
  end
687
690
  end
688
691
 
@@ -693,21 +696,21 @@ end
693
696
  # the lowest common ancestor of current node and target
694
697
  class AbstractPartialPathFeature < RosySingleFeatureExtractor
695
698
 
696
- def AbstractPartialPathFeature.sql_type()
699
+ def AbstractPartialPathFeature.sql_type
697
700
  return "VARCHAR(70)"
698
701
  end
699
- def AbstractPartialPathFeature.feature_type()
702
+ def AbstractPartialPathFeature.feature_type
700
703
  return "syn"
701
704
  end
702
705
 
703
706
  ################
704
707
  private
705
708
 
706
- def compute_feature_instanceOK()
707
- if @@paths[@@node.id()].nil?
709
+ def compute_feature_instanceOK
710
+ if @@paths[@@node.id].nil?
708
711
  path = nil
709
712
  else
710
- path = my_path_computation()
713
+ path = my_path_computation
711
714
  end
712
715
  if path.nil? or path.empty?
713
716
  return nil
@@ -720,66 +723,66 @@ end
720
723
  ####
721
724
  # partial path based on node labels
722
725
  class NodelabelPartialPathFeature < AbstractPartialPathFeature
723
- NodelabelPartialPathFeature.announce_me()
726
+ NodelabelPartialPathFeature.announce_me
724
727
 
725
- def NodelabelPartialPathFeature.feature_name()
728
+ def NodelabelPartialPathFeature.feature_name
726
729
  return "pt_partial_path"
727
730
  end
728
731
 
729
732
  ################
730
733
  private
731
734
 
732
- def my_path_computation()
733
- if @@paths[@@node.id()].nil?
735
+ def my_path_computation
736
+ if @@paths[@@node.id].nil?
734
737
  return nil
735
738
  end
736
739
 
737
- return @@paths[@@node.id()].print_downpart(true, false, true)
740
+ return @@paths[@@node.id].print_downpart(true, false, true)
738
741
  end
739
742
  end
740
743
 
741
744
  ####
742
745
  # partial path based on edge labels
743
746
  class EdgelabelPartialPathFeature < AbstractPartialPathFeature
744
- EdgelabelPartialPathFeature.announce_me()
747
+ EdgelabelPartialPathFeature.announce_me
745
748
 
746
- def EdgelabelPartialPathFeature.feature_name()
749
+ def EdgelabelPartialPathFeature.feature_name
747
750
  return "gf_partial_path"
748
751
  end
749
752
 
750
753
  ################
751
754
  private
752
755
 
753
- def my_path_computation()
754
- if @@paths[@@node.id()].nil?
756
+ def my_path_computation
757
+ if @@paths[@@node.id].nil?
755
758
  return nil
756
759
  end
757
760
 
758
- return @@paths[@@node.id()].print_downpart(true, true, false)
761
+ return @@paths[@@node.id].print_downpart(true, true, false)
759
762
  end
760
763
  end
761
764
 
762
765
  ####
763
766
  # partial path based on node and edge labels
764
767
  class PartialPathFeature < AbstractPartialPathFeature
765
- PartialPathFeature.announce_me()
768
+ PartialPathFeature.announce_me
766
769
 
767
- def PartialPathFeature.sql_type()
770
+ def PartialPathFeature.sql_type
768
771
  return "VARCHAR(110)"
769
772
  end
770
- def PartialPathFeature.feature_name()
773
+ def PartialPathFeature.feature_name
771
774
  return "partial_path"
772
775
  end
773
776
 
774
777
  ################
775
778
  private
776
779
 
777
- def my_path_computation()
778
- if @@paths[@@node.id()].nil?
780
+ def my_path_computation
781
+ if @@paths[@@node.id].nil?
779
782
  return nil
780
783
  end
781
784
 
782
- return @@paths[@@node.id()].print_downpart(true, true, true)
785
+ return @@paths[@@node.id].print_downpart(true, true, true)
783
786
  end
784
787
  end
785
788
 
@@ -789,33 +792,33 @@ end
789
792
  # ancestor rule: grammar rule
790
793
  # expanding lowest common ancestor of current node and target
791
794
  class AncestorRuleFeature < RosySingleFeatureExtractor
792
- AncestorRuleFeature.announce_me()
795
+ AncestorRuleFeature.announce_me
793
796
 
794
- def AncestorRuleFeature.feature_name()
797
+ def AncestorRuleFeature.feature_name
795
798
  return "ancestor_rule"
796
799
  end
797
- def AncestorRuleFeature.sql_type()
800
+ def AncestorRuleFeature.sql_type
798
801
  return "VARCHAR(50)"
799
802
  end
800
- def AncestorRuleFeature.feature_type()
803
+ def AncestorRuleFeature.feature_type
801
804
  return "syn"
802
805
  end
803
806
 
804
807
  ################
805
808
  private
806
809
 
807
- def compute_feature_instanceOK()
808
- if @@paths[@@node.id()].nil?
810
+ def compute_feature_instanceOK
811
+ if @@paths[@@node.id].nil?
809
812
  return nil
810
813
  end
811
814
 
812
- lca = @@paths[@@node.id()].lca()
815
+ lca = @@paths[@@node.id].lca
813
816
  unless lca
814
817
  return nil
815
818
  end
816
819
 
817
- return @@interpreter_class.simplified_pt(lca).to_s +
818
- " -> "+
820
+ return @@interpreter_class.simplified_pt(lca).to_s +
821
+ " -> "+
819
822
  lca.children.map {|c| @@interpreter_class.simplified_pt(c).to_s }.join(" ")
820
823
  end
821
824
  end
@@ -823,22 +826,22 @@ end
823
826
  ##################
824
827
  # relative position to target: left, right, including target
825
828
  class RelativePositionFeature < RosySingleFeatureExtractor
826
- RelativePositionFeature.announce_me()
829
+ RelativePositionFeature.announce_me
827
830
 
828
- def RelativePositionFeature.feature_name()
831
+ def RelativePositionFeature.feature_name
829
832
  return "relpos"
830
833
  end
831
- def RelativePositionFeature.sql_type()
834
+ def RelativePositionFeature.sql_type
832
835
  return "CHAR(5)"
833
836
  end
834
- def RelativePositionFeature.feature_type()
837
+ def RelativePositionFeature.feature_type
835
838
  return "syn"
836
839
  end
837
840
 
838
841
  ################
839
842
  private
840
843
 
841
- def compute_feature_instanceOK()
844
+ def compute_feature_instanceOK
842
845
  return @@relpos
843
846
  end
844
847
  end
@@ -847,22 +850,22 @@ end
847
850
  ################
848
851
  # phrase type of the instance node
849
852
  class PhraseTypeFeature < RosySingleFeatureExtractor
850
- PhraseTypeFeature.announce_me()
853
+ PhraseTypeFeature.announce_me
851
854
 
852
- def PhraseTypeFeature.feature_name()
855
+ def PhraseTypeFeature.feature_name
853
856
  return "pt"
854
857
  end
855
- def PhraseTypeFeature.sql_type()
858
+ def PhraseTypeFeature.sql_type
856
859
  return "VARCHAR(15)"
857
860
  end
858
- def PhraseTypeFeature.feature_type()
861
+ def PhraseTypeFeature.feature_type
859
862
  return "syn"
860
863
  end
861
864
 
862
865
  ################
863
866
  private
864
867
 
865
- def compute_feature_instanceOK()
868
+ def compute_feature_instanceOK
866
869
  return @@interpreter_class.simplified_pt(@@node)
867
870
  end
868
871
  end
@@ -870,22 +873,22 @@ end
870
873
  ################
871
874
  # grammatical function that this instance node fills for the target
872
875
  class GFFeature < RosySingleFeatureExtractor
873
- GFFeature.announce_me()
876
+ GFFeature.announce_me
874
877
 
875
- def GFFeature.feature_name()
878
+ def GFFeature.feature_name
876
879
  return "gf"
877
880
  end
878
- def GFFeature.sql_type()
881
+ def GFFeature.sql_type
879
882
  return "VARCHAR(20)"
880
883
  end
881
- def GFFeature.feature_type()
884
+ def GFFeature.feature_type
882
885
  return "syn"
883
886
  end
884
887
 
885
888
  ################
886
889
  private
887
890
 
888
- def compute_feature_instanceOK()
891
+ def compute_feature_instanceOK
889
892
  unless @@target_gfs
890
893
  return nil
891
894
  end
@@ -903,22 +906,22 @@ end
903
906
  ##################
904
907
  # phrase type of parent of this node
905
908
  class FatherPhraseTypeFeature < RosySingleFeatureExtractor
906
- FatherPhraseTypeFeature.announce_me()
909
+ FatherPhraseTypeFeature.announce_me
907
910
 
908
- def FatherPhraseTypeFeature.feature_name()
911
+ def FatherPhraseTypeFeature.feature_name
909
912
  return "father_pt"
910
913
  end
911
- def FatherPhraseTypeFeature.sql_type()
914
+ def FatherPhraseTypeFeature.sql_type
912
915
  return "VARCHAR(15)"
913
916
  end
914
- def FatherPhraseTypeFeature.feature_type()
917
+ def FatherPhraseTypeFeature.feature_type
915
918
  return "syn"
916
919
  end
917
920
 
918
921
  #####
919
922
  private
920
923
 
921
- def compute_feature_instanceOK()
924
+ def compute_feature_instanceOK
922
925
  if @@node.parent
923
926
  return @@interpreter_class.simplified_pt(@@node.parent)
924
927
  else
@@ -930,18 +933,18 @@ end
930
933
  ################
931
934
  # target lemma
932
935
  class TargetLemmaFeature < RosySingleFeatureExtractor
933
- TargetLemmaFeature.announce_me()
936
+ TargetLemmaFeature.announce_me
934
937
 
935
- def TargetLemmaFeature.feature_name()
938
+ def TargetLemmaFeature.feature_name
936
939
  return "target"
937
940
  end
938
- def TargetLemmaFeature.sql_type()
941
+ def TargetLemmaFeature.sql_type
939
942
  return "VARCHAR(20)"
940
943
  end
941
- def TargetLemmaFeature.feature_type()
944
+ def TargetLemmaFeature.feature_type
942
945
  return "ubiq"
943
946
  end
944
- def TargetLemmaFeature.info()
947
+ def TargetLemmaFeature.info
945
948
  # additional info: I am an index feature
946
949
  return super().concat(["index"])
947
950
  end
@@ -949,7 +952,7 @@ class TargetLemmaFeature < RosySingleFeatureExtractor
949
952
  #####
950
953
  private
951
954
 
952
- def compute_feature_instanceOK()
955
+ def compute_feature_instanceOK
953
956
  return @@interpreter_class.lemma_backoff(@@target)
954
957
  end
955
958
  end
@@ -957,18 +960,18 @@ end
957
960
  ################
958
961
  # part of speech of target lemma
959
962
  class TargetPOSFeature < RosySingleFeatureExtractor
960
- TargetPOSFeature.announce_me()
963
+ TargetPOSFeature.announce_me
961
964
 
962
- def TargetPOSFeature.feature_name()
965
+ def TargetPOSFeature.feature_name
963
966
  return "target_pos"
964
967
  end
965
- def TargetPOSFeature.sql_type()
968
+ def TargetPOSFeature.sql_type
966
969
  return "VARCHAR(10)"
967
970
  end
968
- def TargetPOSFeature.feature_type()
971
+ def TargetPOSFeature.feature_type
969
972
  return "ubiq"
970
973
  end
971
- def TargetPOSFeature.info()
974
+ def TargetPOSFeature.info
972
975
  # additional info: I am an index feature
973
976
  return super().concat(["index"])
974
977
  end
@@ -977,7 +980,7 @@ class TargetPOSFeature < RosySingleFeatureExtractor
977
980
  #####
978
981
  private
979
982
 
980
- def compute_feature_instanceOK()
983
+ def compute_feature_instanceOK
981
984
  return @@target_pos
982
985
  end
983
986
  end
@@ -985,15 +988,15 @@ end
985
988
  ################
986
989
  # part of speech of target lemma
987
990
  class TargetFineGrainedPOSFeature < RosySingleFeatureExtractor
988
- TargetFineGrainedPOSFeature.announce_me()
991
+ TargetFineGrainedPOSFeature.announce_me
989
992
 
990
- def TargetFineGrainedPOSFeature.feature_name()
993
+ def TargetFineGrainedPOSFeature.feature_name
991
994
  return "finegrained_target_pos"
992
995
  end
993
- def TargetFineGrainedPOSFeature.sql_type()
996
+ def TargetFineGrainedPOSFeature.sql_type
994
997
  return "VARCHAR(20)"
995
998
  end
996
- def TargetFineGrainedPOSFeature.feature_type()
999
+ def TargetFineGrainedPOSFeature.feature_type
997
1000
  return "ubiq"
998
1001
  end
999
1002
 
@@ -1001,7 +1004,7 @@ class TargetFineGrainedPOSFeature < RosySingleFeatureExtractor
1001
1004
  #####
1002
1005
  private
1003
1006
 
1004
- def compute_feature_instanceOK()
1007
+ def compute_feature_instanceOK
1005
1008
  return @@interpreter_class.pt(@@target)
1006
1009
  end
1007
1010
  end
@@ -1009,22 +1012,22 @@ end
1009
1012
  ################
1010
1013
  # voice of the target lemma
1011
1014
  class TargetVoiceFeature < RosySingleFeatureExtractor
1012
- TargetVoiceFeature.announce_me()
1015
+ TargetVoiceFeature.announce_me
1013
1016
 
1014
- def TargetVoiceFeature.feature_name()
1017
+ def TargetVoiceFeature.feature_name
1015
1018
  return "target_voice"
1016
1019
  end
1017
- def TargetVoiceFeature.sql_type()
1020
+ def TargetVoiceFeature.sql_type
1018
1021
  return "CHAR(4)"
1019
1022
  end
1020
- def TargetVoiceFeature.feature_type()
1023
+ def TargetVoiceFeature.feature_type
1021
1024
  return "ubiq"
1022
1025
  end
1023
1026
 
1024
1027
  #####
1025
1028
  private
1026
1029
 
1027
- def compute_feature_instanceOK()
1030
+ def compute_feature_instanceOK
1028
1031
  voice = @@interpreter_class.voice(@@target)
1029
1032
  if voice
1030
1033
  return voice.slice(0,4)
@@ -1037,22 +1040,22 @@ end
1037
1040
  ################
1038
1041
  # the governing verb of the target
1039
1042
  class GoverningVerbOfTargetFeature < RosySingleFeatureExtractor
1040
- GoverningVerbOfTargetFeature.announce_me()
1043
+ GoverningVerbOfTargetFeature.announce_me
1041
1044
 
1042
- def GoverningVerbOfTargetFeature.feature_name()
1045
+ def GoverningVerbOfTargetFeature.feature_name
1043
1046
  return "gov_verb"
1044
1047
  end
1045
- def GoverningVerbOfTargetFeature.sql_type()
1048
+ def GoverningVerbOfTargetFeature.sql_type
1046
1049
  return "VArCHAR(20)"
1047
1050
  end
1048
- def GoverningVerbOfTargetFeature.feature_type()
1051
+ def GoverningVerbOfTargetFeature.feature_type
1049
1052
  return "sem"
1050
1053
  end
1051
1054
 
1052
1055
  #####
1053
1056
  private
1054
1057
 
1055
- def compute_feature_instanceOK()
1058
+ def compute_feature_instanceOK
1056
1059
  if @@governing_verb
1057
1060
  return RosyFeatureExtractor.headlemma(@@governing_verb)
1058
1061
  else
@@ -1064,22 +1067,22 @@ end
1064
1067
  ################c
1065
1068
  # preposition for this constituent
1066
1069
  class PrepFeature < RosySingleFeatureExtractor
1067
- PrepFeature.announce_me()
1070
+ PrepFeature.announce_me
1068
1071
 
1069
- def PrepFeature.feature_name()
1072
+ def PrepFeature.feature_name
1070
1073
  return "prep"
1071
1074
  end
1072
- def PrepFeature.sql_type()
1075
+ def PrepFeature.sql_type
1073
1076
  return "VARCHAR(20)"
1074
1077
  end
1075
- def PrepFeature.feature_type()
1078
+ def PrepFeature.feature_type
1076
1079
  return "syn"
1077
1080
  end
1078
1081
 
1079
1082
  #####
1080
1083
  private
1081
1084
 
1082
- def compute_feature_instanceOK()
1085
+ def compute_feature_instanceOK
1083
1086
  return @@interpreter_class.preposition(@@node)
1084
1087
  end
1085
1088
  end
@@ -1087,22 +1090,22 @@ end
1087
1090
  ################
1088
1091
  # head lemma of this constituent
1089
1092
  class HeadFeature < RosySingleFeatureExtractor
1090
- HeadFeature.announce_me()
1093
+ HeadFeature.announce_me
1091
1094
 
1092
- def HeadFeature.feature_name()
1095
+ def HeadFeature.feature_name
1093
1096
  return "const_head"
1094
1097
  end
1095
- def HeadFeature.sql_type()
1098
+ def HeadFeature.sql_type
1096
1099
  return "VARCHAR(20)"
1097
1100
  end
1098
- def HeadFeature.feature_type()
1101
+ def HeadFeature.feature_type
1099
1102
  return "sem"
1100
1103
  end
1101
1104
 
1102
1105
  #####
1103
1106
  private
1104
1107
 
1105
- def compute_feature_instanceOK()
1108
+ def compute_feature_instanceOK
1106
1109
  return RosyFeatureExtractor.headlemma(@@node)
1107
1110
  end
1108
1111
  end
@@ -1110,22 +1113,22 @@ end
1110
1113
  ################
1111
1114
  # part of speech of the head of this constituent
1112
1115
  class HeadPosFeature < RosySingleFeatureExtractor
1113
- HeadPosFeature.announce_me()
1116
+ HeadPosFeature.announce_me
1114
1117
 
1115
- def HeadPosFeature.feature_name()
1118
+ def HeadPosFeature.feature_name
1116
1119
  return "const_head_pos"
1117
1120
  end
1118
- def HeadPosFeature.sql_type()
1121
+ def HeadPosFeature.sql_type
1119
1122
  return "VARCHAR(10)"
1120
1123
  end
1121
- def HeadPosFeature.feature_type()
1124
+ def HeadPosFeature.feature_type
1122
1125
  return "syn"
1123
1126
  end
1124
1127
 
1125
1128
  #####
1126
1129
  private
1127
1130
 
1128
- def compute_feature_instanceOK()
1131
+ def compute_feature_instanceOK
1129
1132
  return RosyFeatureExtractor.headpos(@@node)
1130
1133
  end
1131
1134
  end
@@ -1133,25 +1136,25 @@ end
1133
1136
  ################
1134
1137
  # informative content word (see AbstractSynFeature): lemma and POS
1135
1138
  class IcontLemmaFeature < RosyFeatureExtractor
1136
- IcontLemmaFeature.announce_me()
1139
+ IcontLemmaFeature.announce_me
1137
1140
 
1138
- def IcontLemmaFeature.designator()
1141
+ def IcontLemmaFeature.designator
1139
1142
  return "icont_word"
1140
1143
  end
1141
- def IcontLemmaFeature.feature_names()
1144
+ def IcontLemmaFeature.feature_names
1142
1145
  return ["icont_lemma", "icont_pos"]
1143
1146
  end
1144
- def IcontLemmaFeature.sql_type()
1147
+ def IcontLemmaFeature.sql_type
1145
1148
  return "VARCHAR(20)"
1146
1149
  end
1147
- def IcontLemmaFeature.feature_type()
1150
+ def IcontLemmaFeature.feature_type
1148
1151
  return "sem"
1149
1152
  end
1150
1153
 
1151
1154
  #####
1152
1155
  private
1153
1156
 
1154
- def compute_features_instanceOK()
1157
+ def compute_features_instanceOK
1155
1158
  icont_node = @@interpreter_class.informative_content_node(@@node)
1156
1159
  if icont_node
1157
1160
  return [RosyFeatureExtractor.headlemma(icont_node), RosyFeatureExtractor.headpos(icont_node)]
@@ -1165,25 +1168,25 @@ end
1165
1168
  ################
1166
1169
  # leftmost terminal of this constituent
1167
1170
  class FirstWordFeature < RosyFeatureExtractor
1168
- FirstWordFeature.announce_me()
1171
+ FirstWordFeature.announce_me
1169
1172
 
1170
- def FirstWordFeature.designator()
1173
+ def FirstWordFeature.designator
1171
1174
  return "firstword"
1172
1175
  end
1173
- def FirstWordFeature.feature_names()
1176
+ def FirstWordFeature.feature_names
1174
1177
  return ["firstword", "firstword_pos"]
1175
1178
  end
1176
- def FirstWordFeature.sql_type()
1179
+ def FirstWordFeature.sql_type
1177
1180
  return "VARCHAR(20)"
1178
1181
  end
1179
- def FirstWordFeature.feature_type()
1182
+ def FirstWordFeature.feature_type
1180
1183
  return "sem"
1181
1184
  end
1182
1185
 
1183
1186
  #####
1184
1187
  private
1185
1188
 
1186
- def compute_features_instanceOK()
1189
+ def compute_features_instanceOK
1187
1190
  if @@node_leftmost_terminal
1188
1191
  return [RosyFeatureExtractor.headlemma(@@node_leftmost_terminal), RosyFeatureExtractor.headpos(@@node_leftmost_terminal)]
1189
1192
  else
@@ -1196,25 +1199,25 @@ end
1196
1199
  ################
1197
1200
  # rightmost terminal of this constituent
1198
1201
  class LastWordFeature < RosyFeatureExtractor
1199
- LastWordFeature.announce_me()
1202
+ LastWordFeature.announce_me
1200
1203
 
1201
- def LastWordFeature.designator()
1204
+ def LastWordFeature.designator
1202
1205
  return "lastword"
1203
1206
  end
1204
- def LastWordFeature.feature_names()
1207
+ def LastWordFeature.feature_names
1205
1208
  return ["lastword", "lastword_pos"]
1206
1209
  end
1207
- def LastWordFeature.sql_type()
1210
+ def LastWordFeature.sql_type
1208
1211
  return "VARCHAR(30)"
1209
1212
  end
1210
- def LastWordFeature.feature_type()
1213
+ def LastWordFeature.feature_type
1211
1214
  return "sem"
1212
1215
  end
1213
1216
 
1214
1217
  #####
1215
1218
  private
1216
1219
 
1217
- def compute_features_instanceOK()
1220
+ def compute_features_instanceOK
1218
1221
  if @@node_rightmost_terminal
1219
1222
  return [RosyFeatureExtractor.headlemma(@@node_rightmost_terminal), RosyFeatureExtractor.headpos(@@node_rightmost_terminal)]
1220
1223
  else
@@ -1226,25 +1229,25 @@ end
1226
1229
  ################
1227
1230
  # left sibling of the current node
1228
1231
  class LeftSiblingFeature < RosyFeatureExtractor
1229
- LeftSiblingFeature.announce_me()
1232
+ LeftSiblingFeature.announce_me
1230
1233
 
1231
- def LeftSiblingFeature.designator()
1234
+ def LeftSiblingFeature.designator
1232
1235
  return "leftsib"
1233
1236
  end
1234
- def LeftSiblingFeature.feature_names()
1237
+ def LeftSiblingFeature.feature_names
1235
1238
  return ["leftsib_pt", "leftsib_lemma"]
1236
1239
  end
1237
- def LeftSiblingFeature.sql_type()
1240
+ def LeftSiblingFeature.sql_type
1238
1241
  return "VARCHAR(20)"
1239
1242
  end
1240
- def LeftSiblingFeature.feature_type()
1243
+ def LeftSiblingFeature.feature_type
1241
1244
  return "sem"
1242
1245
  end
1243
1246
 
1244
1247
  #####
1245
1248
  private
1246
1249
 
1247
- def compute_features_instanceOK()
1250
+ def compute_features_instanceOK
1248
1251
  # leftsib, rightsib (node)
1249
1252
  # siblings with max lastword/firstword among those with lastword/firstword index
1250
1253
  # smaller/greater than firstword/lastword index of self
@@ -1264,7 +1267,7 @@ class LeftSiblingFeature < RosyFeatureExtractor
1264
1267
  unless sib_ix
1265
1268
  next
1266
1269
  end
1267
-
1270
+
1268
1271
  if sib_ix < node_ix and
1269
1272
  (leftsib.nil? or leftsib_ix < sib_ix)
1270
1273
 
@@ -1275,7 +1278,7 @@ class LeftSiblingFeature < RosyFeatureExtractor
1275
1278
 
1276
1279
  if leftsib
1277
1280
  return [
1278
- @@interpreter_class.simplified_pt(leftsib),
1281
+ @@interpreter_class.simplified_pt(leftsib),
1279
1282
  @@interpreter_class.lemma_backoff(leftsib),
1280
1283
  ]
1281
1284
  else
@@ -1298,22 +1301,22 @@ end
1298
1301
  ################
1299
1302
  # distance between head word of constituent and target (in words)
1300
1303
  class WordDistanceFeature < RosySingleFeatureExtractor
1301
- WordDistanceFeature.announce_me()
1304
+ WordDistanceFeature.announce_me
1302
1305
 
1303
- def WordDistanceFeature.feature_name()
1306
+ def WordDistanceFeature.feature_name
1304
1307
  return "worddistance"
1305
1308
  end
1306
- def WordDistanceFeature.sql_type()
1309
+ def WordDistanceFeature.sql_type
1307
1310
  return "TINYINT"
1308
1311
  end
1309
- def WordDistanceFeature.feature_type()
1312
+ def WordDistanceFeature.feature_type
1310
1313
  return "syn"
1311
1314
  end
1312
1315
 
1313
1316
  #####
1314
1317
  private
1315
1318
 
1316
- def compute_feature_instanceOK()
1319
+ def compute_feature_instanceOK
1317
1320
 
1318
1321
  head_term = @@interpreter_class.head_terminal(@@node)
1319
1322
  targ_term = @@interpreter_class.head_terminal(@@target)
@@ -1325,7 +1328,7 @@ class WordDistanceFeature < RosySingleFeatureExtractor
1325
1328
  if h_id.nil? or t_id.nil?
1326
1329
  return nil
1327
1330
  else
1328
- return (h_id-t_id).abs
1331
+ return (h_id-t_id).abs
1329
1332
  end
1330
1333
  end
1331
1334
  end
@@ -1334,23 +1337,23 @@ end
1334
1337
  # is the current node a maximal projection?
1335
1338
  # heuristic: is my category the same as my parent's?
1336
1339
  class IsMaxProj < RosySingleFeatureExtractor
1337
- IsMaxProj.announce_me()
1340
+ IsMaxProj.announce_me
1338
1341
 
1339
- def IsMaxProj.feature_name()
1342
+ def IsMaxProj.feature_name
1340
1343
  return "ismaxproj"
1341
1344
  end
1342
- def IsMaxProj.sql_type()
1345
+ def IsMaxProj.sql_type
1343
1346
  return "TINYINT"
1344
1347
  end
1345
- def IsMaxProj.feature_type()
1348
+ def IsMaxProj.feature_type
1346
1349
  return "syn"
1347
1350
  end
1348
1351
 
1349
1352
  #####
1350
1353
  private
1351
-
1352
- def compute_feature_instanceOK()
1353
- unless @@node.parent()
1354
+
1355
+ def compute_feature_instanceOK
1356
+ unless @@node.parent
1354
1357
  return 1
1355
1358
  end
1356
1359
  my_cat = @@interpreter_class.category(@@node)
@@ -1366,25 +1369,25 @@ end
1366
1369
  ################
1367
1370
  # right sibling of the current node
1368
1371
  class RightSiblingFeature < RosyFeatureExtractor
1369
- RightSiblingFeature.announce_me()
1372
+ RightSiblingFeature.announce_me
1370
1373
 
1371
- def RightSiblingFeature.designator()
1374
+ def RightSiblingFeature.designator
1372
1375
  return "rightsib"
1373
1376
  end
1374
- def RightSiblingFeature.feature_names()
1377
+ def RightSiblingFeature.feature_names
1375
1378
  return ["rightsib_pt", "rightsib_lemma"]
1376
1379
  end
1377
- def RightSiblingFeature.sql_type()
1380
+ def RightSiblingFeature.sql_type
1378
1381
  return "VARCHAR(20)"
1379
1382
  end
1380
- def RightSiblingFeature.feature_type()
1383
+ def RightSiblingFeature.feature_type
1381
1384
  return "sem"
1382
1385
  end
1383
1386
 
1384
1387
  #####
1385
1388
  private
1386
1389
 
1387
- def compute_features_instanceOK()
1390
+ def compute_features_instanceOK
1388
1391
  # leftsib, rightsib (node)
1389
1392
  # siblings with max lastword/firstword among those with lastword/firstword index
1390
1393
  # smaller/greater than firstword/lastword index of self
@@ -1404,7 +1407,7 @@ class RightSiblingFeature < RosyFeatureExtractor
1404
1407
  unless sib_ix
1405
1408
  next
1406
1409
  end
1407
-
1410
+
1408
1411
  if sib_ix > node_ix and
1409
1412
  (rightsib.nil? or sib_ix < rightsib_ix)
1410
1413
 
@@ -1415,7 +1418,7 @@ class RightSiblingFeature < RosyFeatureExtractor
1415
1418
 
1416
1419
  if rightsib
1417
1420
  return [
1418
- @@interpreter_class.simplified_pt(rightsib),
1421
+ @@interpreter_class.simplified_pt(rightsib),
1419
1422
  @@interpreter_class.lemma_backoff(rightsib),
1420
1423
  ]
1421
1424
  else
@@ -1455,17 +1458,17 @@ end
1455
1458
  # private
1456
1459
 
1457
1460
  # def compute_feature_instanceOK()
1458
-
1461
+
1459
1462
  # fwh = RosyFeatureExtractor.headlemma(@@node_leftmost_terminal)
1460
1463
  # lwh = RosyFeatureExtractor.headlemma(@@node_rightmost_terminal)
1461
1464
 
1462
1465
  # if fwh.nil?
1463
- # fwh = ""
1466
+ # fwh = ""
1464
1467
  # end
1465
1468
  # if lwh.nil?
1466
1469
  # lwh = ""
1467
- # end
1468
-
1470
+ # end
1471
+
1469
1472
  # return fwh+ "-" +lwh
1470
1473
  # end
1471
1474
  # end
@@ -1475,22 +1478,22 @@ end
1475
1478
  # admin feature: my node ID and my father's, separated by a space
1476
1479
  # the highest node (topnode) has ID 0, and no father ID.
1477
1480
  class NodeIDFeature < RosySingleFeatureExtractor
1478
- NodeIDFeature.announce_me()
1481
+ NodeIDFeature.announce_me
1479
1482
 
1480
- def NodeIDFeature.feature_name()
1483
+ def NodeIDFeature.feature_name
1481
1484
  return "nodeID"
1482
1485
  end
1483
- def NodeIDFeature.sql_type()
1486
+ def NodeIDFeature.sql_type
1484
1487
  return "VARCHAR(100)"
1485
1488
  end
1486
- def NodeIDFeature.feature_type()
1489
+ def NodeIDFeature.feature_type
1487
1490
  return "admin"
1488
1491
  end
1489
1492
 
1490
1493
  #####
1491
1494
  private
1492
1495
 
1493
- def compute_feature_instanceOK()
1496
+ def compute_feature_instanceOK
1494
1497
 
1495
1498
  if @@node.parent
1496
1499
  return @@node.id.to_s+ " " + @@node.parent.id.to_s
@@ -1503,18 +1506,18 @@ end
1503
1506
  ################
1504
1507
  # admin feature: sentence ID
1505
1508
  class SentidFeature < RosySingleFeatureExtractor
1506
- SentidFeature.announce_me()
1509
+ SentidFeature.announce_me
1507
1510
 
1508
- def SentidFeature.feature_name()
1511
+ def SentidFeature.feature_name
1509
1512
  return "sentid"
1510
1513
  end
1511
- def SentidFeature.sql_type()
1514
+ def SentidFeature.sql_type
1512
1515
  return "VARCHAR(100)"
1513
1516
  end
1514
- def SentidFeature.feature_type()
1517
+ def SentidFeature.feature_type
1515
1518
  return "admin"
1516
1519
  end
1517
- def SentidFeature.info()
1520
+ def SentidFeature.info
1518
1521
  # additional info: I am an index feature
1519
1522
  return super().concat(["index"])
1520
1523
  end
@@ -1522,8 +1525,8 @@ class SentidFeature < RosySingleFeatureExtractor
1522
1525
  #####
1523
1526
  private
1524
1527
 
1525
- def compute_feature_instanceOK()
1526
- return construct_instance_id(@@sent.id(), @@frame.id())
1528
+ def compute_feature_instanceOK
1529
+ return ::Shalmaneser::Rosy::construct_instance_id(@@sent.id, @@frame.id)
1527
1530
  end
1528
1531
  end
1529
1532
 
@@ -1553,18 +1556,18 @@ end
1553
1556
  ################
1554
1557
  # admin feature: frame assigned by FN
1555
1558
  class FrameFeature < RosySingleFeatureExtractor
1556
- FrameFeature.announce_me()
1559
+ FrameFeature.announce_me
1557
1560
 
1558
- def FrameFeature.feature_name()
1561
+ def FrameFeature.feature_name
1559
1562
  return "frame"
1560
1563
  end
1561
- def FrameFeature.sql_type()
1564
+ def FrameFeature.sql_type
1562
1565
  return "VARCHAR(35)"
1563
1566
  end
1564
- def FrameFeature.feature_type()
1567
+ def FrameFeature.feature_type
1565
1568
  return "ubiq"
1566
1569
  end
1567
- def FrameFeature.info()
1570
+ def FrameFeature.info
1568
1571
  # additional info: I am an index feature
1569
1572
  return super().concat(["index"])
1570
1573
  end
@@ -1572,9 +1575,9 @@ class FrameFeature < RosySingleFeatureExtractor
1572
1575
  #####
1573
1576
  private
1574
1577
 
1575
- def compute_feature_instanceOK()
1578
+ def compute_feature_instanceOK
1576
1579
  if @@frame
1577
- return @@frame.name()
1580
+ return @@frame.name
1578
1581
  else
1579
1582
  return nil
1580
1583
  end
@@ -1584,22 +1587,22 @@ end
1584
1587
  ################
1585
1588
  # admin feature: is this node a terminal?
1586
1589
  class TerminalFeature < RosySingleFeatureExtractor
1587
- TerminalFeature.announce_me()
1590
+ TerminalFeature.announce_me
1588
1591
 
1589
- def TerminalFeature.feature_name()
1592
+ def TerminalFeature.feature_name
1590
1593
  return "term"
1591
1594
  end
1592
- def TerminalFeature.sql_type()
1595
+ def TerminalFeature.sql_type
1593
1596
  return "TINYINT"
1594
1597
  end
1595
- def TerminalFeature.feature_type()
1598
+ def TerminalFeature.feature_type
1596
1599
  return "admin"
1597
1600
  end
1598
1601
 
1599
1602
  #####
1600
1603
  private
1601
1604
 
1602
- def compute_feature_instanceOK()
1605
+ def compute_feature_instanceOK
1603
1606
  if @@node.is_terminal?
1604
1607
  return 1
1605
1608
  else
@@ -1607,3 +1610,5 @@ class TerminalFeature < RosySingleFeatureExtractor
1607
1610
  end
1608
1611
  end
1609
1612
  end
1613
+ end
1614
+ end