summaryrefslogtreecommitdiff
path: root/test.rb
blob: d9fbdfaf080b97dead9b380a510c3e109e0787e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env ruby

require_relative 'hg'


semiring = ViterbiSemiring.new
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 ' '}"
}