blob: d2b8f66912dcd468cbbad11098c414ccfca07d7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/usr/bin/env ruby
require_relative 'hg'
semiring = ViterbiSemiring.new
hypergraph, nodes_by_label, _ = HG::read_hypergraph_from_json('example/json/test.json', semiring, true)
path, score = HG::viterbi_path hypergraph, nodes_by_label['root'], semiring
path.each { |e|
#puts e.to_s
puts " "+e.rule.to_s
}
s, score = HG::viterbi_string hypergraph, nodes_by_label['root'], semiring
puts s
|