diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-07 12:31:02 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-07 12:31:02 +0200 |
commit | 1298b37784247d6de486814838b07ddcf69cd970 (patch) | |
tree | d6626351e36518b9e14d557bbcec2ac29235c59e /parse.rb | |
parent | 24e296e97c32fdf6c3b7fd5ecb5596165d4dad14 (diff) |
fix reordering
Diffstat (limited to 'parse.rb')
-rw-r--r-- | parse.rb | 32 |
1 files changed, 2 insertions, 30 deletions
@@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'nlp_ruby' +require_relative 'grammar' class Chart @@ -30,7 +31,7 @@ class Chart end class Item < Grammar::Rule - attr_accessor :lhs, :rhs, :dot, :e + attr_accessor :dot def initialize rule_or_item, left, right, dot @lhs = Grammar::NT.new rule_or_item.lhs.symbol @@ -154,32 +155,3 @@ def parse input, n, active_chart, passive_chart, grammar } end -def main - STDERR.write "> reading input from TODO\n" - #input = 'ich sah ein kleines haus'.split - #input = 'lebensmittel schuld an europäischer inflation'.split - input = 'offizielle prognosen sind von nur 3 prozent ausgegangen , meldete bloomberg .'.split - n = input.size - - STDERR.write "> reading grammar\n" - grammar = Grammar::Grammar.new 'example/grammars/grammar.3.gz' - STDERR.write ">> adding glue grammar\n" - #grammar.add_glue_rules - STDERR.write ">> adding pass-through grammar\n" - #grammar.add_pass_through_rules input - - STDERR.write "> initializing charts\n" - passive_chart = Chart.new n - active_chart = Chart.new n - init input, n, active_chart, passive_chart, grammar - - STDERR.write "> parsing\n" - parse input, n, active_chart, passive_chart, grammar - - puts "\n---\npassive chart" - visit(1, 0, 5) { |i,j| puts "#{i},#{j}"; passive_chart.at(i,j).each { |item| puts ' '+item.to_s }; puts } -end - - -main - |