picky 2.7.0 → 3.0.0.pre1
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/picky/adapters/rack/base.rb +20 -16
- data/lib/picky/adapters/rack/live_parameters.rb +28 -24
- data/lib/picky/adapters/rack/search.rb +67 -0
- data/lib/picky/adapters/rack.rb +27 -23
- data/lib/picky/application.rb +246 -236
- data/lib/picky/backend/base.rb +115 -119
- data/lib/picky/backend/file/basic.rb +102 -98
- data/lib/picky/backend/file/json.rb +27 -23
- data/lib/picky/backend/file/marshal.rb +32 -28
- data/lib/picky/backend/file/text.rb +45 -41
- data/lib/picky/backend/files.rb +19 -15
- data/lib/picky/backend/redis/basic.rb +76 -72
- data/lib/picky/backend/redis/list_hash.rb +40 -36
- data/lib/picky/backend/redis/string_hash.rb +30 -26
- data/lib/picky/backend/redis.rb +32 -28
- data/lib/picky/bundle.rb +82 -57
- data/lib/{bundling.rb → picky/bundling.rb} +0 -0
- data/lib/picky/calculations/location.rb +51 -47
- data/lib/picky/categories.rb +60 -56
- data/lib/picky/categories_indexed.rb +73 -82
- data/lib/picky/categories_indexing.rb +12 -8
- data/lib/picky/category.rb +109 -120
- data/lib/picky/category_indexed.rb +39 -41
- data/lib/picky/category_indexing.rb +123 -125
- data/lib/picky/character_substituters/west_european.rb +32 -26
- data/lib/{constants.rb → picky/constants.rb} +0 -0
- data/lib/picky/cores.rb +96 -92
- data/lib/{deployment.rb → picky/deployment.rb} +0 -0
- data/lib/picky/frontend_adapters/rack.rb +133 -118
- data/lib/picky/generators/aliases.rb +5 -3
- data/lib/picky/generators/base.rb +11 -7
- data/lib/picky/generators/partial/default.rb +7 -3
- data/lib/picky/generators/partial/none.rb +24 -20
- data/lib/picky/generators/partial/strategy.rb +20 -16
- data/lib/picky/generators/partial/substring.rb +94 -90
- data/lib/picky/generators/partial_generator.rb +11 -7
- data/lib/picky/generators/similarity/default.rb +9 -5
- data/lib/picky/generators/similarity/double_metaphone.rb +20 -16
- data/lib/picky/generators/similarity/metaphone.rb +20 -16
- data/lib/picky/generators/similarity/none.rb +23 -19
- data/lib/picky/generators/similarity/phonetic.rb +49 -45
- data/lib/picky/generators/similarity/soundex.rb +20 -16
- data/lib/picky/generators/similarity/strategy.rb +10 -6
- data/lib/picky/generators/similarity_generator.rb +11 -7
- data/lib/picky/generators/strategy.rb +14 -10
- data/lib/picky/generators/weights/default.rb +9 -5
- data/lib/picky/generators/weights/logarithmic.rb +30 -26
- data/lib/picky/generators/weights/strategy.rb +10 -6
- data/lib/picky/generators/weights_generator.rb +11 -7
- data/lib/picky/helpers/measuring.rb +20 -16
- data/lib/picky/indexed/bundle/base.rb +39 -37
- data/lib/picky/indexed/bundle/memory.rb +68 -64
- data/lib/picky/indexed/bundle/redis.rb +73 -69
- data/lib/picky/indexed/wrappers/bundle/calculation.rb +26 -22
- data/lib/picky/indexed/wrappers/bundle/location.rb +30 -26
- data/lib/picky/indexed/wrappers/bundle/wrapper.rb +36 -32
- data/lib/picky/indexed/wrappers/category/location.rb +17 -13
- data/lib/picky/indexed/wrappers/exact_first.rb +46 -42
- data/lib/picky/indexers/base.rb +26 -22
- data/lib/picky/indexers/parallel.rb +62 -58
- data/lib/picky/indexers/serial.rb +41 -37
- data/lib/picky/indexes/index.rb +400 -0
- data/lib/picky/indexes/index_indexed.rb +24 -0
- data/lib/picky/indexes/index_indexing.rb +138 -0
- data/lib/picky/indexes/memory.rb +20 -0
- data/lib/picky/indexes/redis.rb +20 -0
- data/lib/picky/indexes.rb +68 -61
- data/lib/picky/indexes_indexed.rb +16 -12
- data/lib/picky/indexes_indexing.rb +41 -37
- data/lib/picky/indexing/bundle/base.rb +216 -205
- data/lib/picky/indexing/bundle/memory.rb +16 -11
- data/lib/picky/indexing/bundle/redis.rb +14 -12
- data/lib/picky/indexing/wrappers/category/location.rb +17 -13
- data/lib/picky/interfaces/live_parameters.rb +159 -154
- data/lib/picky/loader.rb +267 -304
- data/lib/picky/loggers/search.rb +20 -13
- data/lib/picky/no_source_specified_exception.rb +7 -3
- data/lib/picky/performant.rb +6 -2
- data/lib/picky/query/allocation.rb +71 -67
- data/lib/picky/query/allocations.rb +99 -94
- data/lib/picky/query/combination.rb +70 -66
- data/lib/picky/query/combinations/base.rb +56 -52
- data/lib/picky/query/combinations/memory.rb +36 -32
- data/lib/picky/query/combinations/redis.rb +66 -62
- data/lib/picky/query/indexes.rb +175 -160
- data/lib/picky/query/qualifier_category_mapper.rb +43 -0
- data/lib/picky/query/token.rb +165 -172
- data/lib/picky/query/tokens.rb +86 -82
- data/lib/picky/query/weights.rb +44 -48
- data/lib/picky/query.rb +5 -1
- data/lib/picky/rack/harakiri.rb +51 -47
- data/lib/picky/results.rb +81 -77
- data/lib/picky/search.rb +169 -158
- data/lib/picky/sinatra.rb +34 -0
- data/lib/picky/sources/base.rb +73 -70
- data/lib/picky/sources/couch.rb +61 -57
- data/lib/picky/sources/csv.rb +68 -64
- data/lib/picky/sources/db.rb +139 -135
- data/lib/picky/sources/delicious.rb +52 -48
- data/lib/picky/sources/mongo.rb +68 -63
- data/lib/picky/sources/wrappers/base.rb +20 -16
- data/lib/picky/sources/wrappers/location.rb +37 -33
- data/lib/picky/statistics.rb +46 -43
- data/lib/picky/tasks.rb +3 -0
- data/lib/picky/tokenizers/base.rb +192 -187
- data/lib/picky/tokenizers/index.rb +25 -21
- data/lib/picky/tokenizers/location.rb +33 -29
- data/lib/picky/tokenizers/query.rb +49 -43
- data/lib/picky.rb +21 -13
- data/lib/tasks/application.rake +1 -1
- data/lib/tasks/index.rake +3 -3
- data/lib/tasks/routes.rake +1 -1
- data/lib/tasks/server.rake +1 -1
- data/spec/lib/adapters/rack/base_spec.rb +1 -1
- data/spec/lib/adapters/rack/live_parameters_spec.rb +1 -1
- data/spec/lib/adapters/rack/query_spec.rb +1 -1
- data/spec/lib/application_spec.rb +39 -32
- data/spec/lib/backend/file/basic_spec.rb +2 -2
- data/spec/lib/backend/file/json_spec.rb +2 -2
- data/spec/lib/backend/file/marshal_spec.rb +2 -2
- data/spec/lib/backend/file/text_spec.rb +1 -1
- data/spec/lib/backend/files_spec.rb +14 -24
- data/spec/lib/backend/redis/basic_spec.rb +2 -2
- data/spec/lib/backend/redis/list_hash_spec.rb +3 -3
- data/spec/lib/backend/redis/string_hash_spec.rb +3 -3
- data/spec/lib/backend/redis_spec.rb +20 -13
- data/spec/lib/calculations/location_spec.rb +1 -1
- data/spec/lib/categories_indexed_spec.rb +16 -34
- data/spec/lib/category_indexed_spec.rb +9 -27
- data/spec/lib/category_indexing_spec.rb +2 -3
- data/spec/lib/category_spec.rb +10 -10
- data/spec/lib/character_substituters/west_european_spec.rb +6 -5
- data/spec/lib/cores_spec.rb +17 -17
- data/spec/lib/extensions/symbol_spec.rb +15 -1
- data/spec/lib/frontend_adapters/rack_spec.rb +20 -20
- data/spec/lib/generators/aliases_spec.rb +3 -3
- data/spec/lib/generators/cacher_strategy_spec.rb +1 -1
- data/spec/lib/generators/partial/default_spec.rb +3 -3
- data/spec/lib/generators/partial/none_spec.rb +2 -2
- data/spec/lib/generators/partial/substring_spec.rb +1 -1
- data/spec/lib/generators/partial_generator_spec.rb +3 -3
- data/spec/lib/generators/similarity/double_metaphone_spec.rb +1 -1
- data/spec/lib/generators/similarity/metaphone_spec.rb +1 -1
- data/spec/lib/generators/similarity/none_spec.rb +1 -1
- data/spec/lib/generators/similarity/phonetic_spec.rb +1 -1
- data/spec/lib/generators/similarity/soundex_spec.rb +1 -1
- data/spec/lib/generators/similarity_generator_spec.rb +2 -2
- data/spec/lib/generators/weights/logarithmic_spec.rb +1 -1
- data/spec/lib/generators/weights_generator_spec.rb +1 -1
- data/spec/lib/helpers/measuring_spec.rb +2 -2
- data/spec/lib/indexed/bundle/memory_spec.rb +6 -6
- data/spec/lib/indexed/bundle/redis_spec.rb +4 -4
- data/spec/lib/indexed/wrappers/bundle/calculation_spec.rb +2 -3
- data/spec/lib/indexed/wrappers/bundle/wrapper_spec.rb +2 -2
- data/spec/lib/indexed/wrappers/exact_first_spec.rb +5 -5
- data/spec/lib/indexers/base_spec.rb +1 -1
- data/spec/lib/indexers/parallel_spec.rb +1 -1
- data/spec/lib/indexers/serial_spec.rb +1 -1
- data/spec/lib/{index/base_indexed_spec.rb → indexes/index_indexed_spec.rb} +3 -3
- data/spec/lib/{index/base_indexing_spec.rb → indexes/index_indexing_spec.rb} +19 -2
- data/spec/lib/{index/base_spec.rb → indexes/index_spec.rb} +6 -25
- data/spec/lib/{index → indexes}/redis_spec.rb +1 -1
- data/spec/lib/indexes_class_spec.rb +2 -2
- data/spec/lib/indexes_indexed_spec.rb +1 -1
- data/spec/lib/indexes_indexing_spec.rb +1 -1
- data/spec/lib/indexes_spec.rb +1 -1
- data/spec/lib/indexing/bundle/base_spec.rb +7 -5
- data/spec/lib/indexing/bundle/memory_partial_generation_speed_spec.rb +4 -4
- data/spec/lib/indexing/bundle/memory_spec.rb +15 -15
- data/spec/lib/indexing/bundle/redis_spec.rb +9 -9
- data/spec/lib/interfaces/live_parameters_spec.rb +5 -5
- data/spec/lib/loader_spec.rb +17 -19
- data/spec/lib/loggers/search_spec.rb +2 -2
- data/spec/lib/query/allocation_spec.rb +1 -1
- data/spec/lib/query/allocations_spec.rb +1 -1
- data/spec/lib/query/combination_spec.rb +4 -4
- data/spec/lib/query/combinations/base_spec.rb +1 -1
- data/spec/lib/query/combinations/memory_spec.rb +1 -1
- data/spec/lib/query/combinations/redis_spec.rb +1 -1
- data/spec/lib/query/indexes_spec.rb +7 -2
- data/spec/lib/query/qualifier_category_mapper_spec.rb +34 -0
- data/spec/lib/query/token_spec.rb +32 -53
- data/spec/lib/query/tokens_spec.rb +30 -35
- data/spec/lib/query/weights_spec.rb +16 -16
- data/spec/lib/rack/harakiri_spec.rb +5 -5
- data/spec/lib/results_spec.rb +1 -1
- data/spec/lib/search_spec.rb +24 -22
- data/spec/lib/sinatra_spec.rb +36 -0
- data/spec/lib/sources/base_spec.rb +1 -1
- data/spec/lib/sources/couch_spec.rb +9 -9
- data/spec/lib/sources/csv_spec.rb +7 -7
- data/spec/lib/sources/db_spec.rb +2 -2
- data/spec/lib/sources/delicious_spec.rb +5 -5
- data/spec/lib/sources/mongo_spec.rb +7 -7
- data/spec/lib/sources/wrappers/base_spec.rb +2 -2
- data/spec/lib/sources/wrappers/location_spec.rb +1 -1
- data/spec/lib/statistics_spec.rb +1 -1
- data/spec/lib/tokenizers/base_spec.rb +2 -2
- data/spec/lib/tokenizers/index_spec.rb +1 -1
- data/spec/lib/tokenizers/query_spec.rb +1 -1
- metadata +30 -30
- data/lib/picky/adapters/rack/query.rb +0 -65
- data/lib/picky/index/base.rb +0 -409
- data/lib/picky/index/base_indexed.rb +0 -29
- data/lib/picky/index/base_indexing.rb +0 -127
- data/lib/picky/index/memory.rb +0 -16
- data/lib/picky/index/redis.rb +0 -16
- data/lib/picky/query/qualifiers.rb +0 -76
- data/lib/picky/query/solr.rb +0 -60
- data/lib/picky/signals.rb +0 -8
- data/lib/picky-tasks.rb +0 -6
- data/lib/tasks/spec.rake +0 -11
- data/spec/lib/query/qualifiers_spec.rb +0 -31
|
@@ -1,80 +1,84 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
#
|
|
3
|
-
module
|
|
3
|
+
module Picky
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
module Bundle
|
|
5
|
+
module Indexed # :nodoc:all
|
|
8
6
|
|
|
9
|
-
# This is the _actual_ index (based on memory).
|
|
10
7
|
#
|
|
11
|
-
# Handles exact/partial index, weights index, and similarity index.
|
|
12
8
|
#
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
class Memory < Base
|
|
9
|
+
module Bundle
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
# This is the _actual_ index (based on memory).
|
|
12
|
+
#
|
|
13
|
+
# Handles exact/partial index, weights index, and similarity index.
|
|
14
|
+
#
|
|
15
|
+
# Delegates file handling and checking to an *Indexed*::*Files* object.
|
|
16
|
+
#
|
|
17
|
+
class Memory < Base
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
super name, configuration, *args
|
|
19
|
+
delegate :[], :to => :configuration
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
def initialize name, category, *args
|
|
22
|
+
super name, category, *args
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
end
|
|
24
|
+
@configuration = {} # A hash with config options.
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def ids sym
|
|
30
|
-
@inverted[sym] || []
|
|
31
|
-
end
|
|
32
|
-
# Get a weight for the given symbol.
|
|
33
|
-
#
|
|
34
|
-
def weight sym
|
|
35
|
-
@weights[sym]
|
|
36
|
-
end
|
|
26
|
+
@backend = Backend::Files.new self
|
|
27
|
+
end
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
29
|
+
# Get the ids for the given symbol.
|
|
30
|
+
#
|
|
31
|
+
def ids sym
|
|
32
|
+
@inverted[sym] || []
|
|
33
|
+
end
|
|
34
|
+
# Get a weight for the given symbol.
|
|
35
|
+
#
|
|
36
|
+
def weight sym
|
|
37
|
+
@weights[sym]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Loads the core index.
|
|
41
|
+
#
|
|
42
|
+
def load_inverted
|
|
43
|
+
self.inverted = @backend.load_inverted
|
|
44
|
+
end
|
|
45
|
+
# Loads the weights index.
|
|
46
|
+
#
|
|
47
|
+
def load_weights
|
|
48
|
+
self.weights = @backend.load_weights
|
|
49
|
+
end
|
|
50
|
+
# Loads the similarity index.
|
|
51
|
+
#
|
|
52
|
+
def load_similarity
|
|
53
|
+
self.similarity = @backend.load_similarity
|
|
54
|
+
end
|
|
55
|
+
# Loads the configuration.
|
|
56
|
+
#
|
|
57
|
+
def load_configuration
|
|
58
|
+
self.configuration = @backend.load_configuration
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Loads the core index.
|
|
62
|
+
#
|
|
63
|
+
def clear_inverted
|
|
64
|
+
self.inverted = {}
|
|
65
|
+
end
|
|
66
|
+
# Loads the weights index.
|
|
67
|
+
#
|
|
68
|
+
def clear_weights
|
|
69
|
+
self.weights = {}
|
|
70
|
+
end
|
|
71
|
+
# Loads the similarity index.
|
|
72
|
+
#
|
|
73
|
+
def clear_similarity
|
|
74
|
+
self.similarity = {}
|
|
75
|
+
end
|
|
76
|
+
# Loads the configuration.
|
|
77
|
+
#
|
|
78
|
+
def clear_configuration
|
|
79
|
+
self.configuration = {}
|
|
80
|
+
end
|
|
58
81
|
|
|
59
|
-
# Loads the core index.
|
|
60
|
-
#
|
|
61
|
-
def clear_inverted
|
|
62
|
-
self.inverted = {}
|
|
63
|
-
end
|
|
64
|
-
# Loads the weights index.
|
|
65
|
-
#
|
|
66
|
-
def clear_weights
|
|
67
|
-
self.weights = {}
|
|
68
|
-
end
|
|
69
|
-
# Loads the similarity index.
|
|
70
|
-
#
|
|
71
|
-
def clear_similarity
|
|
72
|
-
self.similarity = {}
|
|
73
|
-
end
|
|
74
|
-
# Loads the configuration.
|
|
75
|
-
#
|
|
76
|
-
def clear_configuration
|
|
77
|
-
self.configuration = {}
|
|
78
82
|
end
|
|
79
83
|
|
|
80
84
|
end
|
|
@@ -1,83 +1,87 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
#
|
|
3
|
-
module
|
|
3
|
+
module Picky
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
module Bundle
|
|
5
|
+
module Indexed # :nodoc:all
|
|
8
6
|
|
|
9
|
-
# This is the _actual_ index (based on Redis).
|
|
10
7
|
#
|
|
11
|
-
# Handles exact/partial index, weights index, and similarity index.
|
|
12
8
|
#
|
|
13
|
-
|
|
9
|
+
module Bundle
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
super name, category, *args
|
|
17
|
-
|
|
18
|
-
@backend = Backend::Redis.new name, category
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Get the ids for the given symbol.
|
|
22
|
-
#
|
|
23
|
-
# Ids are an array of string values in Redis.
|
|
24
|
-
#
|
|
25
|
-
def ids sym
|
|
26
|
-
@backend.ids sym
|
|
27
|
-
end
|
|
28
|
-
# Get a weight for the given symbol.
|
|
29
|
-
#
|
|
30
|
-
# A weight is a string value in Redis. TODO Convert?
|
|
11
|
+
# This is the _actual_ index (based on Redis).
|
|
31
12
|
#
|
|
32
|
-
|
|
33
|
-
@backend.weight sym
|
|
34
|
-
end
|
|
35
|
-
# Settings of this bundle can be accessed via [].
|
|
13
|
+
# Handles exact/partial index, weights index, and similarity index.
|
|
36
14
|
#
|
|
37
|
-
|
|
38
|
-
@backend.setting sym
|
|
39
|
-
end
|
|
15
|
+
class Redis < Base
|
|
40
16
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
17
|
+
def initialize name, category, *args
|
|
18
|
+
super name, category, *args
|
|
19
|
+
|
|
20
|
+
@backend = Backend::Redis.new self
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Get the ids for the given symbol.
|
|
24
|
+
#
|
|
25
|
+
# Ids are an array of string values in Redis.
|
|
26
|
+
#
|
|
27
|
+
def ids sym
|
|
28
|
+
@backend.ids sym
|
|
29
|
+
end
|
|
30
|
+
# Get a weight for the given symbol.
|
|
31
|
+
#
|
|
32
|
+
# A weight is a string value in Redis.
|
|
33
|
+
#
|
|
34
|
+
def weight sym
|
|
35
|
+
@backend.weight sym
|
|
36
|
+
end
|
|
37
|
+
# Settings of this bundle can be accessed via [].
|
|
38
|
+
#
|
|
39
|
+
def [] sym
|
|
40
|
+
@backend.setting sym
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Loads the inverted index.
|
|
44
|
+
#
|
|
45
|
+
def load_inverted
|
|
46
|
+
# No loading needed.
|
|
47
|
+
end
|
|
48
|
+
# Loads the weights index.
|
|
49
|
+
#
|
|
50
|
+
def load_weights
|
|
51
|
+
# No loading needed.
|
|
52
|
+
end
|
|
53
|
+
# Loads the similarity index.
|
|
54
|
+
#
|
|
55
|
+
def load_similarity
|
|
56
|
+
# No loading needed.
|
|
57
|
+
end
|
|
58
|
+
# Loads the configuration.
|
|
59
|
+
#
|
|
60
|
+
def load_configuration
|
|
61
|
+
# No loading needed.
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Loads the inverted index.
|
|
65
|
+
#
|
|
66
|
+
def clear_inverted
|
|
67
|
+
# No clearing possible, currently.
|
|
68
|
+
end
|
|
69
|
+
# Loads the weights index.
|
|
70
|
+
#
|
|
71
|
+
def clear_weights
|
|
72
|
+
# No clearing possible, currently.
|
|
73
|
+
end
|
|
74
|
+
# Loads the similarity index.
|
|
75
|
+
#
|
|
76
|
+
def clear_similarity
|
|
77
|
+
# No clearing possible, currently.
|
|
78
|
+
end
|
|
79
|
+
# Loads the configuration.
|
|
80
|
+
#
|
|
81
|
+
def clear_configuration
|
|
82
|
+
# No clearing possible, currently.
|
|
83
|
+
end
|
|
61
84
|
|
|
62
|
-
# Loads the inverted index.
|
|
63
|
-
#
|
|
64
|
-
def clear_inverted
|
|
65
|
-
# No clearing possible, currently.
|
|
66
|
-
end
|
|
67
|
-
# Loads the weights index.
|
|
68
|
-
#
|
|
69
|
-
def clear_weights
|
|
70
|
-
# No clearing possible, currently.
|
|
71
|
-
end
|
|
72
|
-
# Loads the similarity index.
|
|
73
|
-
#
|
|
74
|
-
def clear_similarity
|
|
75
|
-
# No clearing possible, currently.
|
|
76
|
-
end
|
|
77
|
-
# Loads the configuration.
|
|
78
|
-
#
|
|
79
|
-
def clear_configuration
|
|
80
|
-
# No clearing possible, currently.
|
|
81
85
|
end
|
|
82
86
|
|
|
83
87
|
end
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
module
|
|
2
|
-
module Wrappers
|
|
1
|
+
module Picky
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
module Indexed
|
|
4
|
+
module Wrappers
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
# TODO I really need to allow integers as keys. The code below is just not up to the needed quality.
|
|
9
|
-
#
|
|
10
|
-
class Calculation < Wrapper
|
|
6
|
+
module Bundle
|
|
11
7
|
|
|
8
|
+
# A calculation rewrites the symbol into a float.
|
|
12
9
|
#
|
|
10
|
+
# TODO I really need to allow integers as keys. The code below is just not up to the needed quality.
|
|
13
11
|
#
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
class Calculation < Wrapper
|
|
13
|
+
|
|
14
|
+
#
|
|
15
|
+
#
|
|
16
|
+
def recalculate float
|
|
17
|
+
float
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#
|
|
21
|
+
#
|
|
22
|
+
def ids sym
|
|
23
|
+
@bundle.ids recalculate(sym.to_s.to_f).to_s.to_sym
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
#
|
|
28
|
+
def weight sym
|
|
29
|
+
@bundle.weight recalculate(sym.to_s.to_f).to_s.to_sym
|
|
30
|
+
end
|
|
17
31
|
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
def ids sym
|
|
21
|
-
@bundle.ids recalculate(sym.to_s.to_f).to_s.to_sym
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
def weight sym
|
|
27
|
-
@bundle.weight recalculate(sym.to_s.to_f).to_s.to_sym
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
end
|
|
33
|
-
|
|
34
37
|
end
|
|
38
|
+
|
|
35
39
|
end
|
|
@@ -1,42 +1,46 @@
|
|
|
1
|
-
module
|
|
2
|
-
module Wrappers
|
|
1
|
+
module Picky
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
module Indexed
|
|
4
|
+
module Wrappers
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
class Location < Calculation
|
|
6
|
+
module Bundle
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
# A location calculation recalculates a location to the Picky internal location.
|
|
9
|
+
#
|
|
10
|
+
class Location < Calculation
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
def initialize bundle, options = {}
|
|
13
|
+
super bundle
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
precision = options[:precision] || 1
|
|
16
|
+
user_grid = options[:grid] || raise("Gridsize needs to be given for location #{bundle.identifier}.")
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def recalculate float
|
|
22
|
-
@calculation.recalculate float
|
|
23
|
-
end
|
|
18
|
+
@calculation = Calculations::Location.new user_grid, precision
|
|
19
|
+
end
|
|
24
20
|
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
def load
|
|
28
|
-
# Load first the bundle, then extract the config.
|
|
29
21
|
#
|
|
30
|
-
bundle.load
|
|
31
|
-
# TODO Move the to_f to the backend.
|
|
32
22
|
#
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
def recalculate float
|
|
24
|
+
@calculation.recalculate float
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
#
|
|
28
|
+
#
|
|
29
|
+
def load
|
|
30
|
+
# Load first the bundle, then extract the config.
|
|
31
|
+
#
|
|
32
|
+
bundle.load
|
|
33
|
+
# TODO Move the to_f to the backend.
|
|
34
|
+
#
|
|
35
|
+
minimum = bundle[:location_minimum] && bundle[:location_minimum].to_f || raise("Configuration :location_minimum for #{bundle.identifier} missing. Did you run rake index already?")
|
|
36
|
+
@calculation.minimum = minimum
|
|
37
|
+
end
|
|
38
|
+
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
end
|
|
38
42
|
|
|
39
43
|
end
|
|
40
|
-
|
|
41
44
|
end
|
|
45
|
+
|
|
42
46
|
end
|
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
module
|
|
2
|
-
module Wrappers
|
|
1
|
+
module Picky
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module Bundle
|
|
3
|
+
module Indexed
|
|
4
|
+
module Wrappers
|
|
7
5
|
|
|
8
|
-
#
|
|
6
|
+
# Per Bundle wrappers.
|
|
9
7
|
#
|
|
10
|
-
|
|
8
|
+
module Bundle
|
|
9
|
+
|
|
10
|
+
# Base wrapper. Just delegates all methods to the bundle.
|
|
11
|
+
#
|
|
12
|
+
class Wrapper
|
|
13
|
+
|
|
14
|
+
attr_reader :bundle
|
|
15
|
+
|
|
16
|
+
def initialize bundle
|
|
17
|
+
@bundle = bundle
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
delegate :load,
|
|
21
|
+
:load_inverted,
|
|
22
|
+
:load_weights,
|
|
23
|
+
:load_similarity,
|
|
24
|
+
:load_configuration,
|
|
25
|
+
:clear_inverted,
|
|
26
|
+
:clear_weights,
|
|
27
|
+
:clear_similarity,
|
|
28
|
+
:clear_configuration,
|
|
29
|
+
:ids,
|
|
30
|
+
:weight,
|
|
31
|
+
:identifier,
|
|
32
|
+
:analyze,
|
|
33
|
+
:size,
|
|
34
|
+
:inverted,
|
|
35
|
+
:weights,
|
|
36
|
+
:similarity,
|
|
37
|
+
:configuration,
|
|
38
|
+
:to => :@bundle
|
|
11
39
|
|
|
12
|
-
attr_reader :bundle
|
|
13
|
-
|
|
14
|
-
def initialize bundle
|
|
15
|
-
@bundle = bundle
|
|
16
40
|
end
|
|
17
41
|
|
|
18
|
-
delegate :load,
|
|
19
|
-
:load_inverted,
|
|
20
|
-
:load_weights,
|
|
21
|
-
:load_similarity,
|
|
22
|
-
:load_configuration,
|
|
23
|
-
:clear_inverted,
|
|
24
|
-
:clear_weights,
|
|
25
|
-
:clear_similarity,
|
|
26
|
-
:clear_configuration,
|
|
27
|
-
:ids,
|
|
28
|
-
:weight,
|
|
29
|
-
:identifier,
|
|
30
|
-
:analyze,
|
|
31
|
-
:size,
|
|
32
|
-
:inverted,
|
|
33
|
-
:weights,
|
|
34
|
-
:similarity,
|
|
35
|
-
:configuration,
|
|
36
|
-
:to => :@bundle
|
|
37
|
-
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
end
|
|
41
|
-
|
|
42
45
|
end
|
|
46
|
+
|
|
43
47
|
end
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
module
|
|
2
|
-
module Wrappers
|
|
3
|
-
module Category
|
|
1
|
+
module Picky
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
module Indexed
|
|
4
|
+
module Wrappers
|
|
5
|
+
module Category
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
wrapped_exact = Indexed::Wrappers::Bundle::Location.new category.indexed_exact, grid: grid, precision: precision
|
|
7
|
+
module Location
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
def self.install_on category, grid, precision = 1
|
|
10
|
+
wrapped_exact = Indexed::Wrappers::Bundle::Location.new category.indexed_exact, grid: grid, precision: precision
|
|
11
|
+
|
|
12
|
+
category.class_eval do
|
|
13
|
+
define_method :indexed_exact do
|
|
14
|
+
wrapped_exact
|
|
15
|
+
end
|
|
16
|
+
define_method :indexed_partial do
|
|
17
|
+
wrapped_exact
|
|
18
|
+
end
|
|
16
19
|
end
|
|
20
|
+
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
end
|
|
22
|
-
|
|
23
26
|
end
|
|
24
27
|
end
|
|
28
|
+
|
|
25
29
|
end
|
|
@@ -1,51 +1,55 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
#
|
|
3
|
-
module
|
|
4
|
-
|
|
5
|
-
module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
3
|
+
module Picky
|
|
4
|
+
|
|
5
|
+
module Indexed
|
|
6
|
+
|
|
7
|
+
module Wrappers
|
|
8
|
+
|
|
9
|
+
# This index combines an exact and partial index.
|
|
10
|
+
# It serves to order the results such that exact hits are found first.
|
|
11
|
+
#
|
|
12
|
+
class ExactFirst < Indexed::Bundle::Base
|
|
13
|
+
|
|
14
|
+
delegate :similar,
|
|
15
|
+
:identifier,
|
|
16
|
+
:name,
|
|
17
|
+
:to => :@exact
|
|
18
|
+
delegate :index,
|
|
19
|
+
:category,
|
|
20
|
+
:weight,
|
|
21
|
+
:generate_partial_from,
|
|
22
|
+
:generate_caches_from_memory,
|
|
23
|
+
:generate_derived,
|
|
24
|
+
:dump,
|
|
25
|
+
:load,
|
|
26
|
+
:to => :@partial
|
|
27
|
+
|
|
28
|
+
def initialize category
|
|
29
|
+
@exact = category.indexed_exact
|
|
30
|
+
@partial = category.indexed_partial
|
|
31
|
+
end
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
def self.wrap index_or_category
|
|
34
|
+
if index_or_category.respond_to? :categories
|
|
35
|
+
wrap_each_of index_or_category.categories
|
|
36
|
+
index_or_category
|
|
37
|
+
else
|
|
38
|
+
new index_or_category
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
def self.wrap_each_of categories
|
|
42
|
+
categories.categories.collect! { |category| new(category) }
|
|
37
43
|
end
|
|
38
|
-
end
|
|
39
|
-
def self.wrap_each_of categories
|
|
40
|
-
categories.categories.collect! { |category| new(category) }
|
|
41
|
-
end
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
def ids text
|
|
46
|
+
@exact.ids(text) + @partial.ids(text)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def weight text
|
|
50
|
+
[@exact.weight(text) || 0, @partial.weight(text) || 0].max
|
|
51
|
+
end
|
|
46
52
|
|
|
47
|
-
def weight text
|
|
48
|
-
[@exact.weight(text) || 0, @partial.weight(text) || 0].max
|
|
49
53
|
end
|
|
50
54
|
|
|
51
55
|
end
|