summaryrefslogtreecommitdiff
path: root/test.rb
blob: a1b07a82d6843c6c55878b5640f61f3b9d82ac94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/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, _ = HG::viterbi_path hypergraph, nodes_by_label['root'], semiring
s = HG::derive path, path.last.rule.lhs, []
puts s.map { |i| i.word }.join ' '