summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/nlp_ruby/SparseVector.rb9
-rw-r--r--lib/nlp_ruby/cdec.rb2
-rw-r--r--lib/nlp_ruby/ttable.rb2
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