summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2014-02-12 18:30:28 +0100
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2014-02-12 18:30:28 +0100
commit1d06f4042c0ebdfc7a12880e78e0610f22c321aa (patch)
tree53fde85d3b9b476fb38da89cf146ee076cd2bc85
parent64dd24e1698e11ce461048f30e3367fe33f626fa (diff)
cdec
-rw-r--r--lib/nlp_ruby/cdec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/nlp_ruby/cdec.rb b/lib/nlp_ruby/cdec.rb
new file mode 100644
index 0000000..1080f14
--- /dev/null
+++ b/lib/nlp_ruby/cdec.rb
@@ -0,0 +1,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
+