From 32f0468ecff9f89598a68598d45acbd67aa50ab5 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Fri, 14 Feb 2014 15:54:15 +0100 Subject: misc --- lib/nlp_ruby/SparseVector.rb | 9 +++++++++ lib/nlp_ruby/cdec.rb | 2 -- lib/nlp_ruby/ttable.rb | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/nlp_ruby/SparseVector.rb b/lib/nlp_ruby/SparseVector.rb index 6843b70..cdf966c 100644 --- a/lib/nlp_ruby/SparseVector.rb +++ b/lib/nlp_ruby/SparseVector.rb @@ -80,6 +80,15 @@ class SparseVector < Hash return a.join ' ' end + # FIXME + def to_kv2 sep='=' + a = [] + self.each_pair { |k,v| + a << "#{k}#{sep}#{v}" + } + return a.join "\n" + end + def join_keys other self.keys + other.keys end diff --git a/lib/nlp_ruby/cdec.rb b/lib/nlp_ruby/cdec.rb index 46651a3..1080f14 100644 --- a/lib/nlp_ruby/cdec.rb +++ b/lib/nlp_ruby/cdec.rb @@ -8,8 +8,6 @@ CDEC_BINARY = "/toolbox/cdec-dtrain/decoder/cdec" def CDEC::kbest input, ini, weights, k, unique=true - puts "asdf #{`cat #{weights}`}" - puts "echo \"#{input}\" | #{CDEC_BINARY} -c #{ini} -w #{weights} -k #{k} -r 2>/dev/null" o, s = Open3.capture2 "echo \"#{input}\" | #{CDEC_BINARY} -c #{ini} -w #{weights} -k #{k} -r 2>/dev/null" j = -1 ret = [] diff --git a/lib/nlp_ruby/ttable.rb b/lib/nlp_ruby/ttable.rb index 14d6c5d..c0f37be 100644 --- a/lib/nlp_ruby/ttable.rb +++ b/lib/nlp_ruby/ttable.rb @@ -51,7 +51,7 @@ class Translation end def to_s2 - [@rank, @s, @f.to_kv, @score, @other_score].join ' ||| ' + [@rank, @s, @score, @other_score].join ' ||| ' end end -- cgit v1.2.3