diff options
author | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2014-02-13 12:51:42 +0100 |
---|---|---|
committer | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2014-02-13 12:51:42 +0100 |
commit | 7c213980b509bce9cbbf727ee920ced8be9b6b68 (patch) | |
tree | 505c0893d40b564dde8b9082a3fb5c363fb21129 | |
parent | 1d06f4042c0ebdfc7a12880e78e0610f22c321aa (diff) |
zeros, rm Vector
-rwxr-xr-x | lib/nlp_ruby.rb | 1 | ||||
-rw-r--r-- | lib/nlp_ruby/SparseVector.rb | 4 | ||||
-rw-r--r-- | lib/nlp_ruby/cdec.rb | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/lib/nlp_ruby.rb b/lib/nlp_ruby.rb index f0242af..c7af97b 100755 --- a/lib/nlp_ruby.rb +++ b/lib/nlp_ruby.rb @@ -2,7 +2,6 @@ require 'nlp_ruby/stringutil' require 'nlp_ruby/fileutil' -require 'nlp_ruby/Vector' require 'nlp_ruby/SparseVector' require 'nlp_ruby/PriorityQueue' require 'nlp_ruby/tfidf' diff --git a/lib/nlp_ruby/SparseVector.rb b/lib/nlp_ruby/SparseVector.rb index a4e2bce..6843b70 100644 --- a/lib/nlp_ruby/SparseVector.rb +++ b/lib/nlp_ruby/SparseVector.rb @@ -42,6 +42,10 @@ class SparseVector < Hash return sum end + def zeros n + (0).upto(n-1) { |i| self[i] = 0.0 } + end + def magnitude Math.sqrt self.values.inject { |sum,i| sum+i**2 } end diff --git a/lib/nlp_ruby/cdec.rb b/lib/nlp_ruby/cdec.rb index 1080f14..46651a3 100644 --- a/lib/nlp_ruby/cdec.rb +++ b/lib/nlp_ruby/cdec.rb @@ -8,6 +8,8 @@ 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 = [] |