Method: #cdec_kbest

Defined in:
lib/zipf/misc.rb

#cdec_kbest(cdec_bin, input, ini, weights, k, unique = true) ⇒ Object



89
90
91
92
93
94
95
96
97
# File 'lib/zipf/misc.rb', line 89

def cdec_kbest cdec_bin, input, ini, weights, k, unique=true
  require 'open3'
  cmd = "echo \"#{input}\" | #{cdec_bin} -c #{ini} -w #{weights} -k #{k}"
  cmd += " -r" if unique
  o,_ = Open3.capture2 "#{cmd}  2>/dev/null"
  a = []; j = -1
  o.split("\n").map{ |i| j+=1; t=Translation.new; t.from_s(i, false, j); a << t }
  return a
end