summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/zipf/SparseVector.rb10
-rw-r--r--zipf.gemspec2
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/zipf/SparseVector.rb b/lib/zipf/SparseVector.rb
index 33bb396..3f950c4 100644
--- a/lib/zipf/SparseVector.rb
+++ b/lib/zipf/SparseVector.rb
@@ -55,9 +55,9 @@ class SparseVector < Hash
return a.join join
end
- def from_kv s
- s.split.each { |i|
- k,v = i.split('=')
+ def from_kv s, sep='=', join=/\s/
+ s.split(join).each { |i|
+ k,v = i.split(sep)
self[k] = v.to_f
}
end
@@ -76,9 +76,9 @@ class SparseVector < Hash
return v
end
- def self.from_kv s
+ def self.from_kv s, sep='=', join=/\s/
v = SparseVector.new
- v.from_kv s
+ v.from_kv s, sep, join
return v
end
diff --git a/zipf.gemspec b/zipf.gemspec
index 5e6fcd1..99fe588 100644
--- a/zipf.gemspec
+++ b/zipf.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'zipf'
- s.version = '1.0.2'
+ s.version = '1.0.3'
s.date = '2014-06-17'
s.summary = 'zipf'
s.description = 'NLP related tools and classes'