vector_embed 0.3.0 → 0.3.1
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.rb +4 -1
- data/lib/vector_embed/version.rb +1 -1
- data/spec/vector_embed_spec.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTI5YmZhZDkxODdmMDA5NzdmYWYyZjkwZjg5YjY4MzM3MzU1OWU1Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzhkOTNhZDk5NmE2MzNmZTdlYjQyZDJlY2NiYWM4MzBjZmEwMDM2Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGYxZTYxMDBhMDRiMzNmYjMyZDNhN2I2MDIzYmJmZGM5MzRhYzk1MWQyN2Vm
|
10
|
+
OWUwMjkzNDAyZjYxNzc3NjcwYWE4YzQzNDY3NmEzMzIyMWVjZTU1Yjk0MjJj
|
11
|
+
MzViMjlkOTI4ODI3MDBlZWNkODEwMWM1Y2UxODRmODQ3ZTU2ZmU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjQxOTUyMzEzZGRiYzcwMzNiZjViNzdjMWNlNTg1NmY2OGRmOGFhNDg4OTA0
|
14
|
+
YjRiMGU3Y2Y0ZmEzZGU5ZTQ5ZGNkYWJjMjhiZWU4MDgxYzA4NzYzMWMzZmUz
|
15
|
+
NmM3MmQxZGFmMmNmZGJjMzM4ZTU5MGYwYzE2Njg4ZjY0M2Y5ZWE=
|
data/CHANGELOG
CHANGED
data/lib/vector_embed/maker.rb
CHANGED
@@ -7,7 +7,10 @@ class VectorEmbed
|
|
7
7
|
class Maker
|
8
8
|
class << self
|
9
9
|
def pick(choices, k, first_v, parent)
|
10
|
-
if
|
10
|
+
if (feature_types = parent.options[:features]) and (type = feature_types.detect { |kk, v| kk.to_s == k.to_s })
|
11
|
+
klass = const_get type[1].to_sym
|
12
|
+
klass.new k, parent
|
13
|
+
elsif klass = choices.detect { |klass| klass.want?(first_v, parent) }
|
11
14
|
parent.logger.debug { "Interpreting #{k.inspect} as #{klass.name.split('::').last} given first value #{first_v.inspect}" }
|
12
15
|
klass.new k, parent
|
13
16
|
else
|
data/lib/vector_embed/version.rb
CHANGED
data/spec/vector_embed_spec.rb
CHANGED
@@ -268,6 +268,24 @@ describe VectorEmbed do
|
|
268
268
|
|
269
269
|
end
|
270
270
|
|
271
|
+
describe 'hinting' do
|
272
|
+
it "lets you tell it what attribute type" do
|
273
|
+
v = VectorEmbed.new(features: { 1 => :Number })
|
274
|
+
v.line(3, 1 => nil)
|
275
|
+
v.line(3, 1 => nil).should == v.line(3, 1 => 0)
|
276
|
+
v.line(3, 1 => 'null').should == v.line(3, 1 => 0)
|
277
|
+
v.line(3, 1 => 'NULL').should == v.line(3, 1 => 0)
|
278
|
+
v.line(3, 1 => '\N').should == v.line(3, 1 => 0)
|
279
|
+
v = VectorEmbed.new(features: { 1 => :Phrase })
|
280
|
+
v.line(3, 1 => nil)
|
281
|
+
v.line(1, 1 => 'foo').should == "1 #{l_h("1\x00foo")}:1"
|
282
|
+
v.line(1, 1 => true).should == "1 #{l_h("1\x00true")}:1"
|
283
|
+
v.line(1, 1 => false).should == "1 #{l_h("1\x00false")}:1"
|
284
|
+
v.line(1, 1 => nil).should == "1 #{l_h("1\x00")}:1"
|
285
|
+
v.line(1, 1 => nil).should == v.line(1, 1 => '')
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
271
289
|
private
|
272
290
|
|
273
291
|
def h(v)
|