summaryrefslogtreecommitdiff
path: root/test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test.rb')
-rwxr-xr-xtest.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/test.rb b/test.rb
index a1b07a8..bc2ed30 100755
--- a/test.rb
+++ b/test.rb
@@ -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}"
+}