summaryrefslogtreecommitdiff
path: root/test_hg.rb
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-18 08:28:36 +0200
committerPatrick Simianer <p@simianer.de>2014-06-18 08:28:36 +0200
commitd92209e3ec223a380c7ad540622caa15712c490c (patch)
tree91f985fc2d9726a4d1e9f7c86e17cbf7dd2b6ee6 /test_hg.rb
parentae3bc3e1870d009c4d54c55416ebb4b7c07a483f (diff)
better integration, chart.to_json
Diffstat (limited to 'test_hg.rb')
-rwxr-xr-xtest_hg.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/test_hg.rb b/test_hg.rb
index f4e2ef8..14fe011 100755
--- a/test_hg.rb
+++ b/test_hg.rb
@@ -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 ' '}"
+}