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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjYyYTk3OTE0NmEwYzMwMGE3ZDk5YTZmODA5NmUzOGM1YTlkMDAwNA==
4
+ ZTI5YmZhZDkxODdmMDA5NzdmYWYyZjkwZjg5YjY4MzM3MzU1OWU1Nw==
5
5
  data.tar.gz: !binary |-
6
- OGJjODkwMTM3NWY5NWE3ZTUyNzQ2YjQxOTgwODVkNWVlMjc0NTVkZQ==
6
+ YzhkOTNhZDk5NmE2MzNmZTdlYjQyZDJlY2NiYWM4MzBjZmEwMDM2Nw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTgxMWNkODk4NjYyMTU3Mzk0YTM1YWMxMjU4YzJkODU2MWIzNTllYjdhYmZk
10
- ZjYyN2Q5ZTExMDAxYTVhMzZkODRlMmFmMzljOGY2YjkyMzhmNmViMTJkNWM1
11
- ZmEzNTk3Y2QzZGMwOGNjNjFjY2RmMjFkNjEyOTVhMjEyOWJjNGI=
9
+ MGYxZTYxMDBhMDRiMzNmYjMyZDNhN2I2MDIzYmJmZGM5MzRhYzk1MWQyN2Vm
10
+ OWUwMjkzNDAyZjYxNzc3NjcwYWE4YzQzNDY3NmEzMzIyMWVjZTU1Yjk0MjJj
11
+ MzViMjlkOTI4ODI3MDBlZWNkODEwMWM1Y2UxODRmODQ3ZTU2ZmU=
12
12
  data.tar.gz: !binary |-
13
- ODI3MjU1YTBlMTc5NGZkNTliY2RkNDcwZmMyNGI2YTIyNmI4MTA4NDNmMGI1
14
- YTlhMjJlYmEzY2M0ZmI5NTYwZWNlY2UxYzM4YTc4OGY1MmUwZGZiZmU2ODIz
15
- ZjA5ZGQ0YmM1MmZiNmE5NTRlZGQ4ZTE4OGZkODgyNWU2Yzc5OGM=
13
+ YjQxOTUyMzEzZGRiYzcwMzNiZjViNzdjMWNlNTg1NmY2OGRmOGFhNDg4OTA0
14
+ YjRiMGU3Y2Y0ZmEzZGU5ZTQ5ZGNkYWJjMjhiZWU4MDgxYzA4NzYzMWMzZmUz
15
+ NmM3MmQxZGFmMmNmZGJjMzM4ZTU5MGYwYzE2Njg4ZjY0M2Y5ZWE=
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.3.1 / 2013-05-14
2
+
3
+ * Enhancements
4
+
5
+ * Allow hinting feature types with :features option... possible options are :Number, :Boolean, :Ngram, :Phrase
6
+
1
7
  0.3.0 / 2013-05-14
2
8
 
3
9
  * Breaking changes
@@ -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 klass = choices.detect { |klass| klass.want?(first_v, parent) }
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
@@ -1,3 +1,3 @@
1
1
  class VectorEmbed
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -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)
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere