vector_embed 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.5.2 / 2013-07-10
2
+
3
+ * Bug fixes
4
+
5
+ * Treat nil as 0 in number feature labels (still disallowed in boolean labels)
6
+
1
7
  0.5.1 / 2013-07-09
2
8
 
3
9
  * Bug fixes
@@ -36,7 +36,7 @@ class VectorEmbed
36
36
  FORMAT % num
37
37
  end
38
38
  when NilClass, NULL, SLASH_N
39
- nil
39
+ keep_zero? ? 0 : nil
40
40
  else
41
41
  raise ArgumentError, "Can't embed #{v.inspect} in number feature #{k.inspect}"
42
42
  end
@@ -1,3 +1,3 @@
1
1
  class VectorEmbed
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
@@ -30,6 +30,25 @@ describe VectorEmbed do
30
30
  v.line(true)
31
31
  lambda { v.line(5.4) }.should raise_error(/Can't embed.*boolean/)
32
32
  end
33
+
34
+ it "stores nil as 0 in number" do
35
+ v = VectorEmbed.new
36
+ v.line(1)
37
+ v.line(nil).should == '0'
38
+ end
39
+
40
+ it "doesn't let you store nil in boolean" do
41
+ v = VectorEmbed.new
42
+ v.line(true)
43
+ lambda { v.line(nil) }.should raise_error(/Can't embed.*boolean/)
44
+ end
45
+
46
+ it "treats nil as evidence of number" do
47
+ v = VectorEmbed.new
48
+ v.line(nil).should == '0'
49
+ v.line(1).should == '1'
50
+ end
51
+
33
52
  end
34
53
 
35
54
  describe 'using a dictionary' do
@@ -170,6 +189,23 @@ describe VectorEmbed do
170
189
  v.line(3, 1 => '0').should == "3"
171
190
  end
172
191
 
192
+ it "DOES output blank strings in phrase attributes" do
193
+ v = VectorEmbed.new
194
+ v.line(3, 5 => 'hello').should == "3 #{l_h("5\x00hello")}:1"
195
+ v.line(3, 5 => nil).should == "3 #{l_h("5\x00")}:1"
196
+ v.line(3, 5 => '').should == "3 #{l_h("5\x00")}:1"
197
+ v.line(3, 5 => ' ').should == "3 #{l_h("5\x00")}:1"
198
+ end
199
+
200
+ it "strips OUTER whitespace" do
201
+ l_h("5\x00").should_not == l_h("5\x00 ")
202
+ l_h("5\x00 ").should_not == l_h("5\x00 ")
203
+ v = VectorEmbed.new
204
+ v.line(3, 5 => 'hello').should == "3 #{l_h("5\x00hello")}:1"
205
+ v.line(3, 5 => ' hello ').should == "3 #{l_h("5\x00hello")}:1"
206
+ v.line(3, 5 => ' hel lo ').should == "3 #{l_h("5\x00hel lo")}:1"
207
+ end
208
+
173
209
  it "treats nil like zero in number attributes" do
174
210
  v = VectorEmbed.new
175
211
  v.line(1, 1 => 1) # establish it's a number
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vector_embed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-09 00:00:00.000000000 Z
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: murmurhash3