diff options
author | Patrick Simianer <p@simianer.de> | 2015-03-04 15:24:54 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-03-04 15:24:54 +0100 |
commit | 2ab23ec844862b3ec034f805f74420f36ac639f5 (patch) | |
tree | c048c162b2e76c6338599642ceb9f971358f8507 | |
parent | 2af1e4d316095c550b6de29e624cb2925a6e78da (diff) |
SparseVector: fix from_kv -> bump to v1.2.3
-rw-r--r-- | lib/zipf/SparseVector.rb | 16 | ||||
-rw-r--r-- | zipf.gemspec | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/zipf/SparseVector.rb b/lib/zipf/SparseVector.rb index e9af799..837403a 100644 --- a/lib/zipf/SparseVector.rb +++ b/lib/zipf/SparseVector.rb @@ -37,7 +37,7 @@ class SparseVector < Hash end def from_s s - from_h eval(s) + from_h eval(s.strip) end def self.from_s s @@ -55,12 +55,18 @@ class SparseVector < Hash end def from_kv s, sep='=', join=/\s/ - s.split(join).each { |i| + s.strip.split(join).each { |i| k,v = i.split(sep) self[k] = v.to_f } end + def self.from_kv s, sep='=', join=/\s/ + v = SparseVector.new + v.from_kv s, sep, join + return v + end + def to_json JSON.dump self.to_h end @@ -75,12 +81,6 @@ class SparseVector < Hash return v end - def self.from_kv s, sep='=', join=/\s/ - v = SparseVector.new - v.from_kv s, sep, join - return v - end - def from_file fn, sep='=' f = ReadFile.new(fn) while line = f.gets diff --git a/zipf.gemspec b/zipf.gemspec index 6d2986c..676d319 100644 --- a/zipf.gemspec +++ b/zipf.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'zipf' - s.version = '1.2.2' - s.date = '2015-01-25' + s.version = '1.2.3' + s.date = '2015-03-04' s.summary = 'zipf' s.description = 'NLP related tools and classes' s.authors = ['Patrick Simianer'] |