picky 4.24.0 → 4.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1ccf80ba3d51955047795eb9a44e0bb90eafa14
4
- data.tar.gz: 90a2c17f69019a6dbbdbc214ca238c8183443dab
3
+ metadata.gz: d83031c692b720f4c0e208135d1a9132865f6db8
4
+ data.tar.gz: da41d6d9de9c1762e83aee7c8bb3e62447e24934
5
5
  SHA512:
6
- metadata.gz: 41d01ef1dbe5506274a96747a0dba0617fde5b50735cd59041901d661fea1ba328cfecf76376b06888eb73dcd2f1db5b8c1acb731317487857ae802c1b52f036
7
- data.tar.gz: 05c23d26a4a86e04a84bcf9ba73b5e67a9a391d9541408a63c366e15cce6499cc272a94e0f364adaadf3605e948e8a26cfc5031fdde8478db6edb1ed8fc96542
6
+ metadata.gz: f119107151b6848085eb65eb0cf1c52c4d30bcff59f05bf37c09599007f16d8394bec8fbdeecf0b80ae1465c75496789169055d84ff507f4be632fa21b085b32
7
+ data.tar.gz: 9ab9540294fb221af016c379eff38486b96f9b0752428ed88e0dad44d60748de52f8d13c0172f99e2ebe503f82c6e81a053c130071efbeae6af315858ab6adf7
@@ -42,21 +42,21 @@ module Picky
42
42
  end
43
43
 
44
44
  def configure_from options
45
- @from = options.delete :from
45
+ @from = options.delete :from
46
46
 
47
47
  # Instantly extracted to raise an error instantly.
48
48
  #
49
- @source = Source.from options[:source], true, @index.name
50
- @tokenize = options[:tokenize] != false
51
- @tokenizer = Tokenizer.from options[:indexing], @index.name, name
52
- @ranger = options[:ranging] || Range
49
+ @source = Source.from options[:source], true, @index.name
50
+ @tokenize = options[:tokenize] != false
51
+ @tokenizer = Tokenizer.from options[:indexing], @index.name, name
52
+ @ranger = options[:ranging] || Range
53
53
 
54
- @key_format = options.delete :key_format
55
- @backend = options.delete :backend
54
+ @key_format = options.delete :key_format
55
+ @backend = options.delete :backend
56
56
 
57
- @qualifiers = extract_qualifiers_from options
57
+ @qualifiers = extract_qualifiers_from options
58
58
 
59
- # @symbols = options[:use_symbols] || index.use_symbols? # SYMBOLS.
59
+ @symbol_keys = options[:symbol_keys] || @index.symbol_keys # SYMBOLS.
60
60
  end
61
61
 
62
62
  # TODO I do a lot of helper method calls here. Refactor?
@@ -64,7 +64,7 @@ module Picky
64
64
  # strings to the index for the given id.
65
65
  #
66
66
  def add_text id, text_or_tokens, where = :unshift
67
- # text = text.to_sym if @symbols # SYMBOLS.
67
+ # text_or_tokens = text_or_tokens.to_sym if @symbol_keys # SYMBOLS.
68
68
  tokens = nil
69
69
  if tokenizer
70
70
  tokens, _ = tokenizer.tokenize text_or_tokens
@@ -92,7 +92,7 @@ module Picky
92
92
  return unless text
93
93
 
94
94
  id = id.send key_format if format
95
- # text = text.to_sym if @symbols # SYMBOLS.
95
+ text = text.to_sym if @symbol_keys # SYMBOLS.
96
96
  id.freeze
97
97
 
98
98
  exact.add id, text, where, static
data/lib/picky/index.rb CHANGED
@@ -150,6 +150,16 @@ module Picky
150
150
  end
151
151
  end
152
152
 
153
+ # API method.
154
+ #
155
+ def symbol_keys value = nil
156
+ if value
157
+ @symbol_keys = value
158
+ else
159
+ @symbol_keys
160
+ end
161
+ end
162
+
153
163
  # The directory used by this index.
154
164
  #
155
165
  # Note: Used @directory ||=, but needs to be dynamic.
data/lib/picky/search.rb CHANGED
@@ -138,6 +138,10 @@ module Picky
138
138
  def boost boosts
139
139
  @boosts = extract_boosts boosts
140
140
  end
141
+
142
+ def symbol_keys
143
+ @symbol_keys = true
144
+ end
141
145
 
142
146
  # Ignore given categories and/or combinations of
143
147
  # categories.
@@ -258,7 +262,7 @@ module Picky
258
262
  def tokenized text, partialize_last = true
259
263
  tokens, originals = tokenizer.tokenize text
260
264
  tokens = Query::Tokens.processed tokens, originals || tokens, @ignore_unassigned
261
- # tokens.symbolize # SYMBOLS.
265
+ tokens.symbolize if @symbol_keys # SYMBOLS.
262
266
  tokens.partialize_last if partialize_last
263
267
  tokens
264
268
  end
@@ -58,7 +58,7 @@ describe 'Search#max_allocations' do
58
58
 
59
59
  performance_of do
60
60
  try_again.search 'hello world'
61
- end.should < (threshold*2/3)
61
+ end.should < (threshold*3/4)
62
62
  end
63
63
 
64
64
  end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ #
3
+ require 'spec_helper'
4
+ require 'ostruct'
5
+
6
+ describe "Option symbol_keys" do
7
+
8
+ let(:index) do
9
+ Picky::Index.new(:results1) { symbol_keys true }
10
+ end
11
+ let(:try) do
12
+ Picky::Search.new(index) { symbol_keys }
13
+ end
14
+
15
+ # Test the enumerator abilities.
16
+ #
17
+ it 'can enumerate through the allocations' do
18
+ index.category :text
19
+
20
+ thing = OpenStruct.new id: 1, text: "ohai"
21
+ other = OpenStruct.new id: 2, text: "ohai kthxbye"
22
+
23
+ index.add thing
24
+ index.add other
25
+
26
+ try.search("text:ohai").ids.should == [2, 1]
27
+ end
28
+
29
+ end
@@ -171,7 +171,7 @@ describe 'Search#terminate_early' do
171
171
  try_fast.search('hello hello').ids
172
172
  end
173
173
  slow.should < 0.00015
174
- fast.should < 0.00009
174
+ fast.should < 0.0001
175
175
  (slow/fast).should >= 1.5
176
176
 
177
177
  try_slow = Picky::Search.new index
@@ -20,7 +20,7 @@ describe Picky::Category do
20
20
 
21
21
  category.partial.similarity_strategy.should be_kind_of(Picky::Generators::Similarity::None)
22
22
 
23
- category.instance_variable_get(:@symbols).should == nil
23
+ category.instance_variable_get(:@symbol_keys).should == nil
24
24
  end
25
25
 
26
26
  context '#==' do
@@ -19,7 +19,6 @@ describe Picky do
19
19
  simple_load = <<-COMMAND
20
20
  #{ruby} -I #{load_path} -r picky -e "puts 'OK'"
21
21
  COMMAND
22
- p IO.popen(simple_load, err: [:child, :out]).readline
23
22
  IO.popen(simple_load, err: [:child, :out]).readline.strip.should == 'OK'
24
23
  end
25
24
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.24.0
4
+ version: 4.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -266,6 +266,7 @@ files:
266
266
  - spec/functional/speed_spec.rb
267
267
  - spec/functional/static_spec.rb
268
268
  - spec/functional/stemming_spec.rb
269
+ - spec/functional/symbol_keys_spec.rb
269
270
  - spec/functional/terminate_early_spec.rb
270
271
  - spec/functional/to_s_spec.rb
271
272
  - spec/functional/tokenizer_spec.rb
@@ -401,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
402
  version: '0'
402
403
  requirements: []
403
404
  rubyforge_project: http://rubyforge.org/projects/picky
404
- rubygems_version: 2.2.2
405
+ rubygems_version: 2.4.1
405
406
  signing_key:
406
407
  specification_version: 4
407
408
  summary: 'Picky: Semantic Search Engine. Clever Interface. Good Tools.'
@@ -448,6 +449,7 @@ test_files:
448
449
  - spec/functional/speed_spec.rb
449
450
  - spec/functional/static_spec.rb
450
451
  - spec/functional/stemming_spec.rb
452
+ - spec/functional/symbol_keys_spec.rb
451
453
  - spec/functional/terminate_early_spec.rb
452
454
  - spec/functional/to_s_spec.rb
453
455
  - spec/functional/tokenizer_spec.rb
@@ -561,4 +563,3 @@ test_files:
561
563
  - spec/lib/tokenizer_spec.rb
562
564
  - spec/performant_spec.rb
563
565
  - spec/tools/picky/cli_spec.rb
564
- has_rdoc: