summaryrefslogtreecommitdiff
path: root/lib/nlp_ruby/cdec.rb
blob: 1080f148c0a7fc8777587cb55dc9fbb6eaffe52e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module CDEC

require 'open3'


# FIXME
CDEC_BINARY = "/toolbox/cdec-dtrain/decoder/cdec"


def CDEC::kbest input, ini, weights, k, unique=true
  o, s = Open3.capture2 "echo \"#{input}\" | #{CDEC_BINARY} -c #{ini} -w #{weights} -k #{k} -r  2>/dev/null"
  j = -1
  ret = []
  o.split("\n").map{|i| j+=1; t=Translation.new; t.from_s(i, false, j); ret << t}
  return ret
end


end