From 1298b37784247d6de486814838b07ddcf69cd970 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Sat, 7 Jun 2014 12:31:02 +0200 Subject: fix reordering --- parse.rb | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'parse.rb') diff --git a/parse.rb b/parse.rb index 6adf2c0..24b98c6 100644 --- a/parse.rb +++ b/parse.rb @@ -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 - -- cgit v1.2.3