vector_embed 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +6 -0
- data/lib/vector_embed/maker/boolean.rb +1 -1
- data/lib/vector_embed/maker/number.rb +6 -1
- data/lib/vector_embed/version.rb +1 -1
- data/spec/vector_embed_spec.rb +39 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjYyYTk3OTE0NmEwYzMwMGE3ZDk5YTZmODA5NmUzOGM1YTlkMDAwNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGJjODkwMTM3NWY5NWE3ZTUyNzQ2YjQxOTgwODVkNWVlMjc0NTVkZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTgxMWNkODk4NjYyMTU3Mzk0YTM1YWMxMjU4YzJkODU2MWIzNTllYjdhYmZk
|
10
|
+
ZjYyN2Q5ZTExMDAxYTVhMzZkODRlMmFmMzljOGY2YjkyMzhmNmViMTJkNWM1
|
11
|
+
ZmEzNTk3Y2QzZGMwOGNjNjFjY2RmMjFkNjEyOTVhMjEyOWJjNGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODI3MjU1YTBlMTc5NGZkNTliY2RkNDcwZmMyNGI2YTIyNmI4MTA4NDNmMGI1
|
14
|
+
YTlhMjJlYmEzY2M0ZmI5NTYwZWNlY2UxYzM4YTc4OGY1MmUwZGZiZmU2ODIz
|
15
|
+
ZjA5ZGQ0YmM1MmZiNmE5NTRlZGQ4ZTE4OGZkODgyNWU2Yzc5OGM=
|
data/CHANGELOG
CHANGED
data/lib/vector_embed/version.rb
CHANGED
data/spec/vector_embed_spec.rb
CHANGED
@@ -98,22 +98,24 @@ describe VectorEmbed do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
describe 'feature values' do
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
101
|
+
describe 'in boolean attributes' do
|
102
|
+
it "stores true/false/nil as (1,0,0)/(0,1,0)/(0,0,1)" do
|
103
|
+
v = VectorEmbed.new
|
104
|
+
v.line(1, 1 => true).should == "1 #{l_h("1\x00true")}:1"
|
105
|
+
v.line(1, 1 => 'true').should == "1 #{l_h("1\x00true")}:1"
|
106
|
+
v.line(1, 1 => 'TRUE').should == "1 #{l_h("1\x00true")}:1"
|
107
|
+
v.line(1, 1 => 't').should == "1 #{l_h("1\x00true")}:1"
|
108
|
+
v.line(1, 1 => 'T').should == "1 #{l_h("1\x00true")}:1"
|
109
|
+
v.line(1, 1 => false).should == "1 #{l_h("1\x00false")}:1"
|
110
|
+
v.line(1, 1 => 'false').should == "1 #{l_h("1\x00false")}:1"
|
111
|
+
v.line(1, 1 => 'FALSE').should == "1 #{l_h("1\x00false")}:1"
|
112
|
+
v.line(1, 1 => 'f').should == "1 #{l_h("1\x00false")}:1"
|
113
|
+
v.line(1, 1 => 'F').should == "1 #{l_h("1\x00false")}:1"
|
114
|
+
v.line(1, 1 => nil).should == "1 #{l_h("1\x00null")}:1"
|
115
|
+
v.line(1, 1 => 'null').should == "1 #{l_h("1\x00null")}:1"
|
116
|
+
v.line(1, 1 => 'NULL').should == "1 #{l_h("1\x00null")}:1"
|
117
|
+
v.line(1, 1 => '\N').should == "1 #{l_h("1\x00null")}:1"
|
118
|
+
end
|
117
119
|
end
|
118
120
|
|
119
121
|
it "stores numbers as numbers" do
|
@@ -135,10 +137,19 @@ describe VectorEmbed do
|
|
135
137
|
|
136
138
|
it "treats nil like zero in number attributes" do
|
137
139
|
v = VectorEmbed.new
|
138
|
-
v.line(1, 1 => 1)
|
140
|
+
v.line(1, 1 => 1) # establish it's a number
|
139
141
|
v.line(1, 1 => nil).should == v.line(1, 1 => 0)
|
140
142
|
end
|
141
143
|
|
144
|
+
it "assumes nil value means a number field" do
|
145
|
+
v = VectorEmbed.new
|
146
|
+
v.line(3, 1 => nil) # don't establish it's a number
|
147
|
+
v.line(3, 1 => nil).should == v.line(3, 1 => 0)
|
148
|
+
v.line(3, 1 => 'null').should == v.line(3, 1 => 0)
|
149
|
+
v.line(3, 1 => 'NULL').should == v.line(3, 1 => 0)
|
150
|
+
v.line(3, 1 => '\N').should == v.line(3, 1 => 0)
|
151
|
+
end
|
152
|
+
|
142
153
|
it "stores strings as m-category attributes" do
|
143
154
|
v = VectorEmbed.new
|
144
155
|
v.line(1, 1 => 'sfh').should == "1 #{l_h("1\x00sfh")}:1"
|
@@ -170,6 +181,17 @@ describe VectorEmbed do
|
|
170
181
|
v.line(1, 'bar' => ['a','b','c']).should == sortme("1 #{l_h("bar\x001\x00b")}:1 #{l_h("bar\x000\x00a")}:1 #{l_h("bar\x002\x00c")}:1")
|
171
182
|
end
|
172
183
|
|
184
|
+
it "stores arrays with proper indices even if some values are zero" do
|
185
|
+
v = VectorEmbed.new
|
186
|
+
v.line(1, 'foo' => [0,99]).should == sortme("1 #{l_h("foo\x001")}:99")
|
187
|
+
v.line(1, 'foo' => [45,0]).should == sortme("1 #{l_h("foo\x000")}:45")
|
188
|
+
v.line(1, 'foo' => [45,99]).should == sortme("1 #{l_h("foo\x000")}:45 #{l_h("foo\x001")}:99")
|
189
|
+
v = VectorEmbed.new
|
190
|
+
v.line(1, 'foo' => [45,0,99]).should == sortme("1 #{l_h("foo\x000")}:45 #{l_h("foo\x002")}:99")
|
191
|
+
v.line(1, 'foo' => [45,0]).should == sortme("1 #{l_h("foo\x000")}:45")
|
192
|
+
v.line(1, 'foo' => [45,33,99]).should == sortme("1 #{l_h("foo\x000")}:45 #{l_h("foo\x001")}:33 #{l_h("foo\x002")}:99")
|
193
|
+
end
|
194
|
+
|
173
195
|
it "in number mode, treats null as 0" do
|
174
196
|
v = VectorEmbed.new
|
175
197
|
v.line(1, 1 => 9).should == "1 #{l_h('1')}:9"
|