From 2ab23ec844862b3ec034f805f74420f36ac639f5 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Wed, 4 Mar 2015 15:24:54 +0100 Subject: SparseVector: fix from_kv -> bump to v1.2.3 --- lib/zipf/SparseVector.rb | 16 ++++++++-------- 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'] -- cgit v1.2.3