diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-18 08:28:36 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-18 08:28:36 +0200 |
commit | d92209e3ec223a380c7ad540622caa15712c490c (patch) | |
tree | 91f985fc2d9726a4d1e9f7c86e17cbf7dd2b6ee6 /test_hg.rb | |
parent | ae3bc3e1870d009c4d54c55416ebb4b7c07a483f (diff) |
better integration, chart.to_json
Diffstat (limited to 'test_hg.rb')
-rwxr-xr-x | test_hg.rb | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -3,17 +3,22 @@ require_relative 'hg' +# viterbi semiring = ViterbiSemiring.new -hypergraph, nodes_by_id = HG::read_hypergraph_from_json('example/3/3.json', semiring, true) +hypergraph, nodes_by_id = HG::read_hypergraph_from_json('example/toy/toy.json', semiring, true) +#hypergraph, nodes_by_id = HG::read_hypergraph_from_json('example/glue/glue.json', semiring, true) +#hypergraph, nodes_by_id = HG::read_hypergraph_from_json('example/3/3.json', semiring, true) path, score = HG::viterbi_path hypergraph, nodes_by_id[-1], semiring s = HG::derive path, path.last.head, [] puts "#{s.map { |i| i.word }.join ' '}" puts Math.log score puts -#hypergraph.reset -#paths = HG::all_paths hypergraph, nodes_by_id[-1] -#paths.each_with_index { |p,i| -# s = HG::derive p, p.last.head, [] -# puts "#{i+1}. #{s.map { |i| i.word }.join ' '}" -#} + +# all paths +hypergraph.reset +paths = HG::all_paths hypergraph, nodes_by_id[-1] +paths.each_with_index { |p,i| + s = HG::derive p, p.last.head, [] + puts "#{i+1}. #{s.map { |x| x.word }.join ' '}" +} |