picky 4.6.0 → 4.6.1
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.
- data/lib/maybe_compile.rb +8 -8
- data/lib/performant.c +1 -1
- data/lib/picky/backends/memory/json.rb +1 -1
- data/lib/picky/bundle_realtime.rb +4 -2
- data/lib/picky/categories_indexed.rb +1 -1
- data/lib/picky/category.rb +1 -1
- data/lib/picky/category_realtime.rb +2 -2
- data/lib/picky/extensions/object.rb +0 -2
- data/lib/picky/index.rb +1 -1
- data/lib/picky/index_facets.rb +1 -2
- data/lib/picky/index_realtime.rb +1 -1
- data/lib/picky/loader.rb +4 -1
- data/lib/picky/platforms/macruby.rb +0 -4
- data/lib/picky/pool.rb +16 -8
- data/lib/picky/query/allocation.rb +13 -10
- data/lib/picky/query/allocations.rb +1 -3
- data/lib/picky/query/indexes.rb +7 -9
- data/lib/picky/query/token.rb +12 -15
- data/lib/picky/query/tokens.rb +1 -3
- data/lib/picky/results.rb +1 -2
- data/lib/picky/search.rb +2 -2
- data/lib/picky/search_facets.rb +1 -4
- data/lib/picky/wrappers/bundle/calculation.rb +2 -2
- data/lib/picky.rb +1 -1
- data/spec/functional/facets_spec.rb +13 -4
- data/spec/functional/tokenizer_spec.rb +6 -2
- data/spec/lib/categories_indexed_spec.rb +3 -3
- data/spec/lib/pool_spec.rb +1 -0
- data/spec/lib/query/allocation_spec.rb +0 -8
- data/spec/lib/query/token_spec.rb +4 -4
- metadata +53 -19
data/lib/maybe_compile.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
|
4
|
-
# Note: This is handled toplevel to not confuse compilers.
|
1
|
+
# Note: This is handled toplevel (in the file
|
2
|
+
# structure) to not confuse compilers.
|
5
3
|
#
|
6
4
|
failed = 0
|
7
5
|
|
8
6
|
begin
|
9
|
-
require File.expand_path '../performant', __FILE__
|
7
|
+
require ::File.expand_path '../performant', __FILE__
|
10
8
|
rescue LoadError => e
|
11
9
|
failed += 1
|
12
10
|
|
13
11
|
# Have Makefile built.
|
14
12
|
#
|
15
|
-
require File.expand_path '../extconf', __FILE__
|
13
|
+
require ::File.expand_path '../extconf', __FILE__
|
16
14
|
|
17
|
-
# Run make.
|
15
|
+
# Run make in the right gem directory.
|
18
16
|
#
|
19
|
-
|
17
|
+
Dir.chdir(::File.expand_path '..', __FILE__) do
|
18
|
+
puts %x(make)
|
19
|
+
end
|
20
20
|
|
21
21
|
# Try again.
|
22
22
|
#
|
data/lib/performant.c
CHANGED
@@ -55,7 +55,7 @@ inline VALUE memory_efficient_intersect(VALUE self, VALUE unsorted_array_of_arra
|
|
55
55
|
|
56
56
|
// Conversions & presorting.
|
57
57
|
//
|
58
|
-
rb_array_of_arrays = rb_block_call(unsorted_array_of_arrays, rb_intern("sort_by!"), 0, 0, rb_ary_length, 0);
|
58
|
+
rb_array_of_arrays = (struct RArray*) rb_block_call(unsorted_array_of_arrays, rb_intern("sort_by!"), 0, 0, rb_ary_length, 0);
|
59
59
|
smallest_array = (VALUE) RARRAY(rb_ary_dup(RARRAY_PTR(rb_array_of_arrays)[0]));
|
60
60
|
|
61
61
|
// Iterate through all arrays.
|
@@ -17,7 +17,7 @@ module Picky
|
|
17
17
|
# Loads the index hash from json format.
|
18
18
|
#
|
19
19
|
def load
|
20
|
-
MultiJson.decode ::File.open(cache_path, 'r') # , symbolize_keys: true #
|
20
|
+
MultiJson.decode ::File.open(cache_path, 'r') # , symbolize_keys: true # SYMBOLS.
|
21
21
|
end
|
22
22
|
|
23
23
|
# Dumps the index internal backend in json format.
|
@@ -20,7 +20,10 @@ module Picky
|
|
20
20
|
@weights.delete str_or_sym
|
21
21
|
|
22
22
|
# Since no element uses this sym anymore, we can delete the similarity for it.
|
23
|
+
#
|
23
24
|
# TODO Not really. Since multiple syms can point to the same encoded.
|
25
|
+
# In essence, we don't know if and when we can remove it.
|
26
|
+
# (One idea is to add an array of ids and remove from that)
|
24
27
|
#
|
25
28
|
@similarity.delete self.similarity_strategy.encode(str_or_sym)
|
26
29
|
else
|
@@ -92,9 +95,8 @@ module Picky
|
|
92
95
|
|
93
96
|
# Builds the realtime mapping.
|
94
97
|
#
|
95
|
-
# Note: Experimental feature. Might be removed in
|
98
|
+
# Note: Experimental feature. Might be removed in 5.0.
|
96
99
|
#
|
97
|
-
# TODO Subset of #add. Rewrite, optimize.
|
98
100
|
# THINK Maybe load it and just replace the arrays with the corresponding ones.
|
99
101
|
#
|
100
102
|
def build_realtime
|
data/lib/picky/category.rb
CHANGED
@@ -51,7 +51,7 @@ module Picky
|
|
51
51
|
|
52
52
|
@qualifiers = extract_qualifiers_from options
|
53
53
|
|
54
|
-
# @symbols = options[:use_symbols] || index.use_symbols? #
|
54
|
+
# @symbols = options[:use_symbols] || index.use_symbols? # SYMBOLS.
|
55
55
|
|
56
56
|
weights = extract_weight options[:weight]
|
57
57
|
partial = extract_partial options[:partial]
|
@@ -58,7 +58,7 @@ module Picky
|
|
58
58
|
# strings to the index for the given id.
|
59
59
|
#
|
60
60
|
def add_text id, text, where = :unshift
|
61
|
-
# text = text.to_sym if @symbols #
|
61
|
+
# text = text.to_sym if @symbols # SYMBOLS.
|
62
62
|
tokens, _ = tokenizer.tokenize text
|
63
63
|
tokens.each { |text| add_tokenized_token id.send(key_format), text, where, false }
|
64
64
|
end
|
@@ -69,7 +69,7 @@ module Picky
|
|
69
69
|
return unless text
|
70
70
|
|
71
71
|
id = id.send key_format if format
|
72
|
-
# text = text.to_sym if @symbols #
|
72
|
+
# text = text.to_sym if @symbols # SYMBOLS.
|
73
73
|
|
74
74
|
exact.add id, text, where
|
75
75
|
partial.add_partialized id, text, where
|
data/lib/picky/index.rb
CHANGED
data/lib/picky/index_facets.rb
CHANGED
@@ -15,8 +15,7 @@ module Picky
|
|
15
15
|
text_ids = self[category_identifier].exact.inverted
|
16
16
|
no_counts = options[:counts] == false
|
17
17
|
minimal_counts = options[:at_least]
|
18
|
-
text_ids.inject(no_counts ? [] : {}) do |result,
|
19
|
-
text, ids = text_ids
|
18
|
+
text_ids.inject(no_counts ? [] : {}) do |result, (text, ids)|
|
20
19
|
size = ids.size
|
21
20
|
next result if minimal_counts && size < minimal_counts
|
22
21
|
if no_counts
|
data/lib/picky/index_realtime.rb
CHANGED
data/lib/picky/loader.rb
CHANGED
@@ -53,7 +53,10 @@ module Picky
|
|
53
53
|
def load_framework_internals
|
54
54
|
# Load compiled C code.
|
55
55
|
#
|
56
|
-
|
56
|
+
# Note: Picky already tries to compile
|
57
|
+
# when installing the gem.
|
58
|
+
#
|
59
|
+
require_relative '../maybe_compile'
|
57
60
|
|
58
61
|
# Load extensions.
|
59
62
|
#
|
@@ -1,12 +1,8 @@
|
|
1
1
|
# This tests if we are using MacRuby.
|
2
2
|
# If yes, it checks if we already have require_relative.
|
3
3
|
#
|
4
|
-
# TODO Remove (too verbose) message as soon as it is final.
|
5
|
-
#
|
6
4
|
if RUBY_ENGINE == 'macruby' && !Kernel.respond_to?(:require_relative)
|
7
5
|
|
8
|
-
puts "Installing Picky specific MacRuby extensions."
|
9
|
-
|
10
6
|
module Kernel
|
11
7
|
|
12
8
|
def require_relative relative_feature
|
data/lib/picky/pool.rb
CHANGED
@@ -6,23 +6,30 @@ module Picky
|
|
6
6
|
module Pool
|
7
7
|
|
8
8
|
class << self
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
def clear
|
11
|
+
require 'set'
|
12
|
+
@pools = Set.new
|
13
|
+
end
|
11
14
|
|
12
15
|
# Add a Pool to the managed pools.
|
13
16
|
#
|
14
17
|
def add klass
|
15
|
-
|
18
|
+
@pools << klass
|
16
19
|
end
|
17
20
|
|
18
21
|
# Releases all obtained objects.
|
19
22
|
#
|
20
23
|
def release_all
|
21
|
-
|
24
|
+
@pools.each { |pool| pool.release_all }
|
22
25
|
end
|
23
26
|
|
24
27
|
end
|
25
28
|
|
29
|
+
# Reset the pool.
|
30
|
+
#
|
31
|
+
self.clear
|
32
|
+
|
26
33
|
def self.extended klass
|
27
34
|
add klass
|
28
35
|
|
@@ -37,8 +44,6 @@ module Picky
|
|
37
44
|
# Obtain creates a new reference if there is no free one
|
38
45
|
# and uses an existing one if there is.
|
39
46
|
#
|
40
|
-
# (Any caches should be cleared using clear TODO in all initializers)
|
41
|
-
#
|
42
47
|
def obtain *args, &block
|
43
48
|
unless reference = @__free__.shift
|
44
49
|
reference = allocate
|
@@ -53,7 +58,10 @@ module Picky
|
|
53
58
|
#
|
54
59
|
def release instance
|
55
60
|
@__free__ << instance
|
56
|
-
|
61
|
+
|
62
|
+
# Note: This is relatively fast as there are often only
|
63
|
+
# few instances in the used pool.
|
64
|
+
@__used__.delete instance
|
57
65
|
end
|
58
66
|
|
59
67
|
# After you have called release all, you can't
|
@@ -61,7 +69,7 @@ module Picky
|
|
61
69
|
# anymore.
|
62
70
|
#
|
63
71
|
def release_all
|
64
|
-
@
|
72
|
+
@__free__ += @__used__
|
65
73
|
@__used__.clear
|
66
74
|
end
|
67
75
|
|
@@ -23,7 +23,7 @@ module Picky
|
|
23
23
|
def initialize index, combinations
|
24
24
|
@combinations = combinations
|
25
25
|
|
26
|
-
#
|
26
|
+
# THINK Could this be rewritten?
|
27
27
|
#
|
28
28
|
@result_identifier = index.result_identifier
|
29
29
|
@backend = index.backend
|
@@ -32,23 +32,26 @@ module Picky
|
|
32
32
|
# Asks the backend for the total score and
|
33
33
|
# adds the boosts to it.
|
34
34
|
#
|
35
|
-
#
|
35
|
+
# Note: Combinations can be empty on eg.
|
36
|
+
# query "alan history" and category :title is
|
37
|
+
# ignored (ie. removed).
|
36
38
|
#
|
37
39
|
def calculate_score weights
|
38
|
-
@score ||= if @combinations.empty?
|
39
|
-
0
|
40
|
-
else
|
41
|
-
@backend.weight(@combinations) +
|
42
|
-
|
43
|
-
end
|
40
|
+
@score ||= if @combinations.empty?
|
41
|
+
0 # Optimization.
|
42
|
+
else
|
43
|
+
@backend.weight(@combinations) + @combinations.boost_for(weights)
|
44
|
+
end
|
44
45
|
end
|
45
46
|
|
46
47
|
# Asks the backend for the (intersected) ids.
|
47
48
|
#
|
48
|
-
#
|
49
|
+
# Note: Combinations can be empty on eg.
|
50
|
+
# query "alan history" and category :title is
|
51
|
+
# ignored (ie. removed).
|
49
52
|
#
|
50
53
|
def calculate_ids amount, offset
|
51
|
-
return [] if @combinations.empty?
|
54
|
+
return [] if @combinations.empty? # Checked here to avoid checking in each backend.
|
52
55
|
@backend.ids @combinations, amount, offset
|
53
56
|
end
|
54
57
|
|
@@ -104,14 +104,12 @@ module Picky
|
|
104
104
|
#
|
105
105
|
# Note: Slower than #process! especially with large offsets.
|
106
106
|
#
|
107
|
-
# TODO Remove duplicate code.
|
108
|
-
#
|
109
107
|
def process_unique! amount, offset = 0, terminate_early = nil
|
110
108
|
unique_ids = []
|
111
109
|
each do |allocation|
|
112
110
|
calculated_ids = allocation.process_with_illegals! amount, 0, unique_ids
|
113
111
|
projected_offset = offset - allocation.count
|
114
|
-
unique_ids += calculated_ids #
|
112
|
+
unique_ids += calculated_ids # uniq this? <- No, slower than just leaving duplicates.
|
115
113
|
if projected_offset <= 0
|
116
114
|
allocation.ids.slice!(0, offset)
|
117
115
|
end
|
data/lib/picky/query/indexes.rb
CHANGED
@@ -13,8 +13,6 @@ module Picky
|
|
13
13
|
#
|
14
14
|
class Indexes
|
15
15
|
|
16
|
-
# TODO Only needed for .
|
17
|
-
#
|
18
16
|
delegate :size,
|
19
17
|
:first,
|
20
18
|
:to => :@indexes
|
@@ -32,7 +30,7 @@ module Picky
|
|
32
30
|
|
33
31
|
@indexes = indexes
|
34
32
|
|
35
|
-
@mapper = QualifierCategoryMapper.new indexes # TODO Move
|
33
|
+
@mapper = QualifierCategoryMapper.new indexes # TODO Move into search?
|
36
34
|
end
|
37
35
|
|
38
36
|
# Ignore the categories with these qualifiers.
|
@@ -68,23 +66,23 @@ module Picky
|
|
68
66
|
def prepared_allocations_for tokens, weights = {}, amount = nil
|
69
67
|
allocations = allocations_for tokens
|
70
68
|
|
71
|
-
# Removed: Remove potential double allocations.
|
72
|
-
#
|
73
|
-
# Note: allocations are unique by definition.
|
74
|
-
#
|
75
|
-
# allocations.uniq! unless tokens.uniq?
|
76
|
-
|
77
69
|
# Score the allocations using weights as bias.
|
78
70
|
#
|
71
|
+
# Note: Before we can sort them we need to score them.
|
72
|
+
#
|
79
73
|
allocations.calculate_score weights
|
80
74
|
|
81
75
|
# Sort the allocations.
|
82
76
|
# (allocations are sorted according to score, highest to lowest)
|
83
77
|
#
|
78
|
+
# Before we can chop off unimportant allocations, we need to sort them.
|
79
|
+
#
|
84
80
|
allocations.sort!
|
85
81
|
|
86
82
|
# Reduce the amount of allocations.
|
87
83
|
#
|
84
|
+
# Before we remove categories, we should reduce the amount of allocations.
|
85
|
+
#
|
88
86
|
allocations.reduce_to amount if amount
|
89
87
|
|
90
88
|
# Remove categories from allocations.
|
data/lib/picky/query/token.rb
CHANGED
@@ -13,13 +13,10 @@ module Picky
|
|
13
13
|
|
14
14
|
attr_reader :text, :original
|
15
15
|
attr_writer :similar
|
16
|
-
attr_accessor :
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
delegate :blank?,
|
21
|
-
:to => :text
|
22
|
-
|
16
|
+
attr_accessor :predefined_categories
|
17
|
+
|
18
|
+
delegate :blank?, :to => :@text
|
19
|
+
|
23
20
|
# Normal initializer.
|
24
21
|
#
|
25
22
|
# Note:
|
@@ -28,7 +25,7 @@ module Picky
|
|
28
25
|
def initialize text, original = nil, categories = nil
|
29
26
|
@text = text
|
30
27
|
@original = original
|
31
|
-
@
|
28
|
+
@predefined_categories = categories
|
32
29
|
end
|
33
30
|
|
34
31
|
# Returns a qualified and normalized token.
|
@@ -62,10 +59,8 @@ module Picky
|
|
62
59
|
# Note: If this is not done, there is no mapping.
|
63
60
|
# Note: predefined is an Array of mapped categories.
|
64
61
|
#
|
65
|
-
# TODO Rename @user_defined_categories. It could now also be predefined by the query.
|
66
|
-
#
|
67
62
|
def categorize mapper
|
68
|
-
@
|
63
|
+
@predefined_categories ||= extract_predefined mapper
|
69
64
|
end
|
70
65
|
def extract_predefined mapper
|
71
66
|
user_qualified = categorize_with mapper, @qualifiers
|
@@ -196,7 +191,9 @@ module Picky
|
|
196
191
|
# Normalizes this token's text.
|
197
192
|
#
|
198
193
|
def remove_illegals
|
199
|
-
|
194
|
+
# Note: unless @text.blank? was removed.
|
195
|
+
#
|
196
|
+
@text.gsub! @@illegals, EMPTY_STRING unless @text == EMPTY_STRING
|
200
197
|
end
|
201
198
|
def self.redefine_illegals
|
202
199
|
@@illegals = %r{[#{@@no_similar_character}#{@@partial_character}#{@@similar_character}]}
|
@@ -226,11 +223,11 @@ module Picky
|
|
226
223
|
@@qualifiers_delimiter = ','
|
227
224
|
def qualify
|
228
225
|
@qualifiers, @text = (@text || EMPTY_STRING).split(@@qualifier_text_delimiter, 2)
|
229
|
-
if @text
|
226
|
+
if @text
|
227
|
+
@qualifiers = @qualifiers.split @@qualifiers_delimiter
|
228
|
+
else
|
230
229
|
@text = @qualifiers || EMPTY_STRING
|
231
230
|
@qualifiers = nil
|
232
|
-
else
|
233
|
-
@qualifiers = @qualifiers.split @@qualifiers_delimiter
|
234
231
|
end
|
235
232
|
end
|
236
233
|
# Define a character which separates the qualifier
|
data/lib/picky/query/tokens.rb
CHANGED
data/lib/picky/results.rb
CHANGED
@@ -43,8 +43,7 @@ module Picky
|
|
43
43
|
|
44
44
|
# Delegates to allocations.
|
45
45
|
#
|
46
|
-
# TODO Remove parameter in 5.0 and just call
|
47
|
-
# the method with amount.
|
46
|
+
# TODO Remove parameter in 5.0 and just call the method with amount.
|
48
47
|
#
|
49
48
|
# Note that this is an expensive call and
|
50
49
|
# should not be done repeatedly. Just keep
|
data/lib/picky/search.rb
CHANGED
@@ -35,7 +35,7 @@ module Picky
|
|
35
35
|
# search = Search.new(index1, index2, index3) do
|
36
36
|
# searching removes_characters: /[^a-z]/ # etc.
|
37
37
|
# boosts [:author, :title] => +3,
|
38
|
-
#
|
38
|
+
# [:title, :isbn] => +1
|
39
39
|
# end
|
40
40
|
#
|
41
41
|
def initialize *indexes
|
@@ -226,7 +226,7 @@ module Picky
|
|
226
226
|
def tokenized text, partialize_last = true
|
227
227
|
tokens, originals = tokenizer.tokenize text
|
228
228
|
tokens = Query::Tokens.processed tokens, originals || tokens, @ignore_unassigned
|
229
|
-
# tokens.symbolize #
|
229
|
+
# tokens.symbolize # SYMBOLS.
|
230
230
|
tokens.partialize_last if partialize_last
|
231
231
|
tokens
|
232
232
|
end
|
data/lib/picky/search_facets.rb
CHANGED
@@ -38,10 +38,7 @@ module Picky
|
|
38
38
|
|
39
39
|
# Get actual counts.
|
40
40
|
#
|
41
|
-
|
42
|
-
#
|
43
|
-
counts.inject(no_counts ? [] : {}) do |result, key_count|
|
44
|
-
key, _ = key_count
|
41
|
+
counts.inject(no_counts ? [] : {}) do |result, (key, _)|
|
45
42
|
tokenized_query = tokenized "#{category_identifier}:#{key}", false
|
46
43
|
total = search_with(tokenized_filter + tokenized_query, 0, 0).total
|
47
44
|
next result unless total >= minimal_counts
|
@@ -20,7 +20,7 @@ module Picky
|
|
20
20
|
float
|
21
21
|
end
|
22
22
|
|
23
|
-
#
|
23
|
+
# SYMBOLS. Use a block here?
|
24
24
|
#
|
25
25
|
# THINK Move the calculation elsewhere?
|
26
26
|
#
|
@@ -28,7 +28,7 @@ module Picky
|
|
28
28
|
@bundle.ids calculate(float_str.to_f).to_s
|
29
29
|
end
|
30
30
|
|
31
|
-
#
|
31
|
+
# SYMBOLS.
|
32
32
|
#
|
33
33
|
# THINK Move the calculation elsewhere?
|
34
34
|
#
|
data/lib/picky.rb
CHANGED
@@ -58,12 +58,21 @@ describe 'facets' do
|
|
58
58
|
|
59
59
|
# It has two facets.
|
60
60
|
#
|
61
|
-
# TODO Rewrite API.
|
62
|
-
#
|
63
61
|
finder.facets(:name, filter: 'surname:hanke').should == {
|
64
62
|
'fritz' => 1,
|
65
63
|
'florian' => 1
|
66
64
|
}
|
65
|
+
|
66
|
+
# It only uses exact matches (ie. the last token is not partialized).
|
67
|
+
#
|
68
|
+
finder.facets(:name, filter: 'surname:hank').should == {}
|
69
|
+
|
70
|
+
# It allows explicit partial matches.
|
71
|
+
#
|
72
|
+
finder.facets(:name, filter: 'surname:hank*').should == {
|
73
|
+
'fritz' => 1,
|
74
|
+
'florian' => 1
|
75
|
+
}
|
67
76
|
end
|
68
77
|
end
|
69
78
|
end
|
@@ -138,7 +147,7 @@ describe 'facets' do
|
|
138
147
|
'hanke' => 1 # Not 2 since it is filtered.
|
139
148
|
}
|
140
149
|
end
|
141
|
-
it 'has 2 facets >= count
|
150
|
+
it 'has 2 facets >= count 1' do
|
142
151
|
finder.facets(:surname, filter: 'age_category:40 name:peter', at_least: 1).should == {
|
143
152
|
'kunz' => 1,
|
144
153
|
'hanke' => 1
|
@@ -166,7 +175,7 @@ describe 'facets' do
|
|
166
175
|
'hanke'
|
167
176
|
]
|
168
177
|
end
|
169
|
-
it 'has 2 facets >= count
|
178
|
+
it 'has 2 facets >= count 1' do
|
170
179
|
finder.facets(:surname, filter: 'age_category:40 name:peter', at_least: 1, counts: false).should == [
|
171
180
|
'kunz',
|
172
181
|
'hanke'
|
@@ -7,14 +7,18 @@ describe Picky::Tokenizer do
|
|
7
7
|
it 'works correctly' do
|
8
8
|
tokenizer = described_class.new(split_words_on: /\&/, normalizes_words: [[/\&/, 'and']])
|
9
9
|
|
10
|
-
#
|
10
|
+
# Is this really correct? Shouldn't we split after normalizing?
|
11
|
+
#
|
12
|
+
# Yes – we split using more information.
|
11
13
|
#
|
12
14
|
tokenizer.tokenize('M & M').should == [['m', 'and', 'm'], ['m', 'and', 'm']]
|
13
15
|
end
|
14
16
|
it 'works correctly' do
|
15
17
|
tokenizer = described_class.new(stopwords: /\b(and)\b/, normalizes_words: [[/\&/, 'and']])
|
16
18
|
|
17
|
-
#
|
19
|
+
# Is this really correct? Shouldn't we stop words after normalizing?
|
20
|
+
#
|
21
|
+
# Yes – we do stopwords using more information.
|
18
22
|
#
|
19
23
|
tokenizer.tokenize('M & M').should == [['m', 'and', 'm'], ['m', 'and', 'm']]
|
20
24
|
end
|
@@ -107,7 +107,7 @@ describe Picky::Categories do
|
|
107
107
|
context 'without preselected categories' do
|
108
108
|
context 'user defined exists' do
|
109
109
|
before(:each) do
|
110
|
-
@token = stub :token, :
|
110
|
+
@token = stub :token, :predefined_categories => [@category2]
|
111
111
|
end
|
112
112
|
context 'combination exists' do
|
113
113
|
before(:each) do
|
@@ -139,7 +139,7 @@ describe Picky::Categories do
|
|
139
139
|
describe 'possible_categories' do
|
140
140
|
context 'user defined exists' do
|
141
141
|
before(:each) do
|
142
|
-
@token = stub :token, :
|
142
|
+
@token = stub :token, :predefined_categories => [@category2]
|
143
143
|
end
|
144
144
|
it 'should return the right categories' do
|
145
145
|
@categories.possible_categories(@token).should == [@category2]
|
@@ -147,7 +147,7 @@ describe Picky::Categories do
|
|
147
147
|
end
|
148
148
|
context 'user defined does not exist' do
|
149
149
|
before(:each) do
|
150
|
-
@token = stub :token, :
|
150
|
+
@token = stub :token, :predefined_categories => nil
|
151
151
|
end
|
152
152
|
it 'should return all categories' do
|
153
153
|
@categories.possible_categories(@token).should == [@category1, @category2, @category3]
|
data/spec/lib/pool_spec.rb
CHANGED
@@ -212,14 +212,6 @@ describe Picky::Query::Allocation do
|
|
212
212
|
@allocation.calculate_score(:some_boosts).should == 3
|
213
213
|
end
|
214
214
|
end
|
215
|
-
context 'empty combinations' do
|
216
|
-
before(:each) do
|
217
|
-
@combinations.stub! :empty? => true
|
218
|
-
end
|
219
|
-
it 'should just be zero' do
|
220
|
-
@allocation.calculate_score(:some_weights).should == 0
|
221
|
-
end
|
222
|
-
end
|
223
215
|
end
|
224
216
|
|
225
217
|
describe "<=>" do
|
@@ -94,7 +94,7 @@ describe Picky::Query::Token do
|
|
94
94
|
token.similar_tokens_for(@category).map(&:original).should == ['array', 'of', 'similar']
|
95
95
|
end
|
96
96
|
it 'returns a list of tokens with the right categorization' do
|
97
|
-
token.similar_tokens_for(@category).map(&:
|
97
|
+
token.similar_tokens_for(@category).map(&:predefined_categories).should == [[@category], [@category], [@category]]
|
98
98
|
end
|
99
99
|
end
|
100
100
|
context 'without similar' do
|
@@ -147,12 +147,12 @@ describe Picky::Query::Token do
|
|
147
147
|
it_should_qualify 'spec:qualifier', [['spec'], 'qualifier']
|
148
148
|
it_should_qualify 'with:qualifier', [['with'], 'qualifier']
|
149
149
|
it_should_qualify 'without qualifier', [nil, 'without qualifier']
|
150
|
-
it_should_qualify 'name:', [
|
150
|
+
it_should_qualify 'name:', [['name'], '']
|
151
151
|
it_should_qualify ':broken qualifier', [[], 'broken qualifier'] # Unsure about that. Probably should recognize it as text.
|
152
152
|
it_should_qualify '', [nil, '']
|
153
153
|
it_should_qualify 'sp:text', [['sp'], 'text']
|
154
154
|
it_should_qualify '""', [nil, '""']
|
155
|
-
it_should_qualify 'name:', [
|
155
|
+
it_should_qualify 'name:', [['name'], '']
|
156
156
|
it_should_qualify 'name:hanke', [['name'], 'hanke']
|
157
157
|
it_should_qualify 'g:gaga', [['g'], 'gaga']
|
158
158
|
it_should_qualify ':nothing', [[], 'nothing']
|
@@ -160,7 +160,7 @@ describe Picky::Query::Token do
|
|
160
160
|
it_should_qualify 'a:b:c', [['a'], 'b:c']
|
161
161
|
it_should_qualify 'a,b:c', [['a','b'], 'c']
|
162
162
|
it_should_qualify 'a,b,c:d', [['a','b','c'], 'd']
|
163
|
-
it_should_qualify ':', [
|
163
|
+
it_should_qualify ':', [[], '']
|
164
164
|
it_should_qualify 'vorname:qualifier', [['vorname'], 'qualifier']
|
165
165
|
end
|
166
166
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.6.
|
4
|
+
version: 4.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,21 +21,31 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: picky-client
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
31
36
|
- !ruby/object:Gem::Version
|
32
|
-
version: 4.6.
|
37
|
+
version: 4.6.1
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 4.6.1
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: text
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: multi_json
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: activesupport
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ~>
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '3.0'
|
66
86
|
type: :runtime
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3.0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: procrastinate
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ~>
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '0.4'
|
77
102
|
type: :runtime
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.4'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: rack_fast_escape
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,7 +117,12 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :runtime
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
description: Fast Ruby semantic text search engine with comfortable single field interface.
|
92
127
|
email: florian.hanke+picky@gmail.com
|
93
128
|
executables:
|
@@ -394,7 +429,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
394
429
|
version: '0'
|
395
430
|
requirements: []
|
396
431
|
rubyforge_project: http://rubyforge.org/projects/picky
|
397
|
-
rubygems_version: 1.8.
|
432
|
+
rubygems_version: 1.8.23
|
398
433
|
signing_key:
|
399
434
|
specification_version: 3
|
400
435
|
summary: ! 'Picky: Semantic Search Engine. Clever Interface. Good Tools.'
|
@@ -530,4 +565,3 @@ test_files:
|
|
530
565
|
- spec/lib/statistics_spec.rb
|
531
566
|
- spec/lib/tasks/try_spec.rb
|
532
567
|
- spec/lib/tokenizer_spec.rb
|
533
|
-
has_rdoc:
|