diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-04 20:06:53 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-04 20:06:53 +0200 |
commit | dbc15de7a63b939d7c3c51c39b34286aed56739f (patch) | |
tree | ba8a8150aa9b95bf18064dd4e3b728fed44b7614 /test.rb | |
parent | 6f1ed883692e7f9e082cadb92673e1eeed0cdc27 (diff) |
fix all_paths, better json handling
Diffstat (limited to 'test.rb')
-rwxr-xr-x | test.rb | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -3,10 +3,16 @@ require_relative 'hg' - semiring = ViterbiSemiring.new -hypergraph, nodes_by_label, _ = HG::read_hypergraph_from_json('example/json/test.json', semiring, true) -path, _ = HG::viterbi_path hypergraph, nodes_by_label['root'], semiring -s = HG::derive path, path.last.rule.lhs, [] -puts s.map { |i| i.word }.join ' ' +hypergraph, nodes_by_id = HG::read_hypergraph_from_json('example/json/test.json', semiring, true) +path, score = HG::viterbi_path hypergraph, nodes_by_id[-1], semiring +#s = HG::derive path, path.last.rule.lhs, [] +#puts "#{s.map { |i| i.word }.join ' '} ||| #{score}" + +hypergraph.reset +paths = HG::all_paths hypergraph, nodes_by_id[-1] +paths.each { |p| + s = HG::derive p, p.last.rule.lhs, [] +puts "#{s.map { |i| i.word }.join ' '} ||| #{score}" +} |