picky 0.11.2 → 0.12.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.
- data/lib/picky/Index_api.rb +49 -0
- data/lib/picky/alias_instances.rb +4 -1
- data/lib/picky/application.rb +16 -15
- data/lib/picky/cacher/partial/{subtoken.rb → substring.rb} +19 -18
- data/lib/picky/{character_substitution/european.rb → character_substituters/west_european.rb} +2 -2
- data/lib/picky/configuration/index.rb +67 -0
- data/lib/picky/cores.rb +3 -0
- data/lib/picky/index/bundle.rb +35 -51
- data/lib/picky/index/file/basic.rb +39 -5
- data/lib/picky/index/file/json.rb +10 -0
- data/lib/picky/index/file/marshal.rb +10 -0
- data/lib/picky/index/file/text.rb +22 -0
- data/lib/picky/index/files.rb +11 -36
- data/lib/picky/indexed/bundle.rb +61 -0
- data/lib/picky/{index → indexed}/categories.rb +1 -1
- data/lib/picky/{index → indexed}/category.rb +13 -16
- data/lib/picky/{index/type.rb → indexed/index.rb} +6 -6
- data/lib/picky/{index/types.rb → indexed/indexes.rb} +10 -10
- data/lib/picky/{index → indexed}/wrappers/exact_first.rb +8 -8
- data/lib/picky/indexers/no_source_specified_error.rb +1 -1
- data/lib/picky/indexers/serial.rb +64 -0
- data/lib/picky/indexers/solr.rb +1 -3
- data/lib/picky/indexes_api.rb +41 -0
- data/lib/picky/indexing/bundle.rb +43 -13
- data/lib/picky/indexing/category.rb +17 -64
- data/lib/picky/indexing/{type.rb → index.rb} +13 -3
- data/lib/picky/indexing/{types.rb → indexes.rb} +22 -22
- data/lib/picky/loader.rb +17 -22
- data/lib/picky/query/base.rb +1 -1
- data/lib/picky/rack/harakiri.rb +9 -2
- data/lib/picky/signals.rb +1 -1
- data/lib/picky/sources/base.rb +14 -14
- data/lib/picky/sources/couch.rb +8 -7
- data/lib/picky/sources/csv.rb +10 -10
- data/lib/picky/sources/db.rb +8 -8
- data/lib/picky/sources/delicious.rb +2 -2
- data/lib/picky/sources/wrappers/location.rb +3 -3
- data/lib/picky/tokenizers/base.rb +1 -11
- data/lib/picky/tokenizers/index.rb +0 -1
- data/lib/picky/tokenizers/query.rb +0 -1
- data/lib/tasks/index.rake +4 -4
- data/lib/tasks/shortcuts.rake +4 -4
- data/lib/tasks/try.rake +8 -8
- data/project_prototype/Gemfile +1 -1
- data/project_prototype/app/application.rb +13 -12
- data/spec/lib/application_spec.rb +10 -38
- data/spec/lib/cacher/partial/{subtoken_spec.rb → substring_spec.rb} +0 -0
- data/spec/lib/{character_substitution/european_spec.rb → character_substituters/west_european_spec.rb} +6 -2
- data/spec/lib/configuration/index_spec.rb +80 -0
- data/spec/lib/cores_spec.rb +1 -1
- data/spec/lib/index/file/text_spec.rb +1 -1
- data/spec/lib/index/files_spec.rb +12 -32
- data/spec/lib/indexed/bundle_spec.rb +119 -0
- data/spec/lib/{indexing → indexed}/categories_spec.rb +13 -14
- data/spec/lib/{index → indexed}/category_spec.rb +6 -6
- data/spec/lib/{index/type_spec.rb → indexed/index_spec.rb} +3 -3
- data/spec/lib/{index → indexed}/wrappers/exact_first_spec.rb +5 -5
- data/spec/lib/indexers/serial_spec.rb +62 -0
- data/spec/lib/indexing/bundle_partial_generation_speed_spec.rb +7 -5
- data/spec/lib/indexing/bundle_spec.rb +9 -14
- data/spec/lib/indexing/category_spec.rb +9 -125
- data/spec/lib/indexing/{type_spec.rb → index_spec.rb} +3 -3
- data/spec/lib/query/base_spec.rb +1 -1
- data/spec/lib/query/full_spec.rb +1 -1
- data/spec/lib/query/live_spec.rb +2 -4
- data/spec/lib/sources/couch_spec.rb +5 -5
- data/spec/lib/sources/db_spec.rb +6 -7
- data/spec/lib/tokenizers/base_spec.rb +1 -24
- data/spec/lib/tokenizers/query_spec.rb +0 -1
- metadata +38 -41
- data/lib/picky/bundle.rb +0 -33
- data/lib/picky/configuration/indexes.rb +0 -51
- data/lib/picky/configuration/queries.rb +0 -15
- data/lib/picky/indexers/base.rb +0 -85
- data/lib/picky/indexers/default.rb +0 -3
- data/lib/picky/type.rb +0 -46
- data/lib/picky/types.rb +0 -41
- data/lib/tasks/cache.rake +0 -46
- data/spec/lib/configuration/indexes_spec.rb +0 -28
- data/spec/lib/index/bundle_spec.rb +0 -151
- data/spec/lib/indexers/base_spec.rb +0 -89
@@ -3,18 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe Indexing::Bundle do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@
|
7
|
-
@
|
6
|
+
@index = stub :index, :name => :some_index
|
7
|
+
@category = stub :category, :name => :some_category
|
8
|
+
@configuration = Configuration::Index.new @index, @category
|
9
|
+
|
8
10
|
@partial = stub :partial
|
9
11
|
@weights = stub :weights
|
10
12
|
@similarity = stub :similarity
|
11
|
-
@
|
12
|
-
@index = @index_class.new :some_name, @category, @type, @partial, @weights, @similarity
|
13
|
+
@index = Indexing::Bundle.new :some_name, @configuration, @similarity, @partial, @weights
|
13
14
|
end
|
14
15
|
|
15
16
|
describe 'identifier' do
|
16
17
|
it 'should return a specific identifier' do
|
17
|
-
@index.identifier.should == '
|
18
|
+
@index.identifier.should == 'some_index some_category (some_name)'
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
@@ -212,12 +213,6 @@ describe Indexing::Bundle do
|
|
212
213
|
end
|
213
214
|
|
214
215
|
describe 'initialization' do
|
215
|
-
before(:each) do
|
216
|
-
@category = stub :category, :name => :some_category
|
217
|
-
@type = stub :type, :name => :some_type
|
218
|
-
|
219
|
-
@index = @index_class.new :some_name, @category, @type, :similarity, :partial, :weights
|
220
|
-
end
|
221
216
|
it 'should initialize the index correctly' do
|
222
217
|
@index.index.should == {}
|
223
218
|
end
|
@@ -228,13 +223,13 @@ describe Indexing::Bundle do
|
|
228
223
|
@index.similarity.should == {}
|
229
224
|
end
|
230
225
|
it 'should initialize the partial strategy correctly' do
|
231
|
-
@index.partial_strategy.should ==
|
226
|
+
@index.partial_strategy.should == @partial
|
232
227
|
end
|
233
228
|
it 'should initialize the weights strategy correctly' do
|
234
|
-
@index.weights_strategy.should ==
|
229
|
+
@index.weights_strategy.should == @weights
|
235
230
|
end
|
236
231
|
it 'should initialize the similarity strategy correctly' do
|
237
|
-
@index.similarity_strategy.should ==
|
232
|
+
@index.similarity_strategy.should == @similarity
|
238
233
|
end
|
239
234
|
end
|
240
235
|
|
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
describe Indexing::Category do
|
3
4
|
|
5
|
+
before(:each) do
|
6
|
+
@index = stub :index, :name => :some_index
|
7
|
+
@category = Indexing::Category.new :some_category, @index, :source => :some_given_source
|
8
|
+
end
|
4
9
|
context "unit specs" do
|
5
10
|
before(:each) do
|
6
|
-
@type = stub :some_type, :name => :some_type
|
7
|
-
@category = Indexing::Category.new :some_name, @type
|
8
11
|
@exact = @category.exact
|
9
12
|
@partial = @category.partial
|
10
13
|
end
|
@@ -69,88 +72,12 @@ describe Indexing::Category do
|
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
72
|
-
describe "virtual?" do
|
73
|
-
context "with virtual true" do
|
74
|
-
before(:each) do
|
75
|
-
@category = Indexing::Category.new :some_name, @type, virtual: true
|
76
|
-
end
|
77
|
-
it "returns the right value" do
|
78
|
-
@category.virtual?.should == true
|
79
|
-
end
|
80
|
-
end
|
81
|
-
context "with virtual object" do
|
82
|
-
before(:each) do
|
83
|
-
@category = Indexing::Category.new :some_name, @type, :virtual => 123.6
|
84
|
-
end
|
85
|
-
it "returns the right value" do
|
86
|
-
@category.virtual?.should == true
|
87
|
-
end
|
88
|
-
end
|
89
|
-
context "with virtual nil" do
|
90
|
-
before(:each) do
|
91
|
-
@category = Indexing::Category.new :some_name, @type, :virtual => nil
|
92
|
-
end
|
93
|
-
it "returns the right value" do
|
94
|
-
@category.virtual?.should == false
|
95
|
-
end
|
96
|
-
end
|
97
|
-
context "with virtual false" do
|
98
|
-
before(:each) do
|
99
|
-
@category = Indexing::Category.new :some_name, @type, :virtual => false
|
100
|
-
end
|
101
|
-
it "returns the right value" do
|
102
|
-
@category.virtual?.should == false
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
describe "tokenizer" do
|
107
|
-
context "with specific tokenizer" do
|
108
|
-
before(:each) do
|
109
|
-
@category = Indexing::Category.new :some_name, @type, tokenizer: Tokenizers::Index.new
|
110
|
-
end
|
111
|
-
it "caches" do
|
112
|
-
@category.tokenizer.should == @category.tokenizer
|
113
|
-
end
|
114
|
-
it "returns an instance" do
|
115
|
-
@category.tokenizer.should be_kind_of(Tokenizers::Index)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
describe "indexer" do
|
120
|
-
context "with default indexer" do
|
121
|
-
before(:each) do
|
122
|
-
@category = Indexing::Category.new :some_name, @type
|
123
|
-
end
|
124
|
-
it "caches" do
|
125
|
-
@category.indexer.should == @category.indexer
|
126
|
-
end
|
127
|
-
end
|
128
|
-
context "with specific indexer" do
|
129
|
-
before(:each) do
|
130
|
-
@category = Indexing::Category.new :some_name, @type, tokenizer: Indexers::Default
|
131
|
-
end
|
132
|
-
it "caches" do
|
133
|
-
@category.indexer.should == @category.indexer
|
134
|
-
end
|
135
|
-
it "returns an instance" do
|
136
|
-
@category.indexer.should be_kind_of(Indexers::Default)
|
137
|
-
end
|
138
|
-
it "creates a new instance of the right class" do
|
139
|
-
Indexers::Default.should_receive(:new).once.with @type, @category
|
140
|
-
|
141
|
-
@category.indexer
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
75
|
describe "cache" do
|
146
76
|
before(:each) do
|
147
|
-
@category = Indexing::Category.new :some_name, @type
|
148
|
-
@category.stub! :prepare_cache_directory
|
149
|
-
|
150
77
|
@category.stub! :generate_caches
|
151
78
|
end
|
152
79
|
it "prepares the cache directory" do
|
153
|
-
@category.should_receive(:
|
80
|
+
@category.should_receive(:prepare_index_directory).once.with
|
154
81
|
|
155
82
|
@category.cache
|
156
83
|
end
|
@@ -160,28 +87,13 @@ describe Indexing::Category do
|
|
160
87
|
@category.cache
|
161
88
|
end
|
162
89
|
end
|
163
|
-
describe "prepare_cache_directory" do
|
164
|
-
before(:each) do
|
165
|
-
@category = Indexing::Category.new :some_name, @type
|
166
|
-
|
167
|
-
@category.stub! :cache_directory => :some_cache_directory
|
168
|
-
end
|
169
|
-
it "tells the FileUtils to mkdir_p" do
|
170
|
-
FileUtils.should_receive(:mkdir_p).once.with :some_cache_directory
|
171
|
-
|
172
|
-
@category.prepare_cache_directory
|
173
|
-
end
|
174
|
-
end
|
175
90
|
describe "index" do
|
176
91
|
before(:each) do
|
177
|
-
@category = Indexing::Category.new :some_name, @type
|
178
|
-
@category.stub! :prepare_cache_directory
|
179
|
-
|
180
92
|
@indexer = stub :indexer, :index => nil
|
181
93
|
@category.stub! :indexer => @indexer
|
182
94
|
end
|
183
95
|
it "prepares the cache directory" do
|
184
|
-
@category.should_receive(:
|
96
|
+
@category.should_receive(:prepare_index_directory).once.with
|
185
97
|
|
186
98
|
@category.index
|
187
99
|
end
|
@@ -192,40 +104,12 @@ describe Indexing::Category do
|
|
192
104
|
end
|
193
105
|
end
|
194
106
|
describe "source" do
|
195
|
-
context "with source" do
|
196
|
-
before(:each) do
|
197
|
-
@category = Indexing::Category.new :some_name, @type, :source => :some_given_source
|
198
|
-
end
|
199
|
-
it "returns the given source" do
|
200
|
-
@category.source.should == :some_given_source
|
201
|
-
end
|
202
|
-
end
|
203
107
|
context "without source" do
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
@category = Indexing::Category.new :some_name, @type
|
208
|
-
end
|
209
|
-
it "returns the type's source" do
|
210
|
-
@category.source.should == :some_type_source
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
context "name symbol" do
|
215
|
-
before(:each) do
|
216
|
-
@category = Indexing::Category.new :some_name, @type
|
217
|
-
end
|
218
|
-
describe "search_index_file_name" do
|
219
|
-
it "returns the right file name" do
|
220
|
-
@category.search_index_file_name.should == 'some/search/root/index/test/some_type/prepared_some_name_index.txt'
|
108
|
+
it "raises" do
|
109
|
+
lambda { Indexing::Category.new :some_name, @index }.should raise_error(Indexers::NoSourceSpecifiedException)
|
221
110
|
end
|
222
111
|
end
|
223
112
|
end
|
224
|
-
context "name string" do
|
225
|
-
it "works" do
|
226
|
-
@category = Indexing::Category.new 'some_name', @type
|
227
|
-
end
|
228
|
-
end
|
229
113
|
end
|
230
114
|
|
231
115
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Indexing::
|
3
|
+
describe Indexing::Index do
|
4
4
|
|
5
5
|
context "with categories" do
|
6
6
|
before(:each) do
|
@@ -8,7 +8,7 @@ describe Indexing::Type do
|
|
8
8
|
|
9
9
|
@categories = stub :categories
|
10
10
|
|
11
|
-
@index = Indexing::
|
11
|
+
@index = Indexing::Index.new :some_name, @source
|
12
12
|
@index.add_category :some_category_name1
|
13
13
|
@index.add_category :some_category_name2
|
14
14
|
|
@@ -25,7 +25,7 @@ describe Indexing::Type do
|
|
25
25
|
|
26
26
|
context "no categories" do
|
27
27
|
it "works" do
|
28
|
-
Indexing::
|
28
|
+
Indexing::Index.new :some_name, @source
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
data/spec/lib/query/base_spec.rb
CHANGED
data/spec/lib/query/full_spec.rb
CHANGED
data/spec/lib/query/live_spec.rb
CHANGED
@@ -3,10 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe Query::Live do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
|
7
|
-
|
8
|
-
@type = stub :type
|
9
|
-
@index = stub :index, :index => @type
|
6
|
+
@indexed = stub :indexed
|
7
|
+
@index = stub :index, :indexed => @indexed
|
10
8
|
end
|
11
9
|
|
12
10
|
describe 'result_type' do
|
@@ -7,15 +7,15 @@ describe Sources::Couch do
|
|
7
7
|
lambda { @source = Sources::Couch.new(:a, :b, :c) }.should raise_error(Sources::NoCouchDBGiven)
|
8
8
|
end
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
context "with database" do
|
12
12
|
before(:each) do
|
13
13
|
@source = Sources::Couch.new :a, :b, :c, url: 'http://localhost:5984/picky'
|
14
14
|
RestClient::Request.should_receive(:execute).any_number_of_times.and_return %{{"rows":[{"doc":{"_id":"7","a":"a data","b":"b data","c":"c data"}}]}}
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
describe "harvest" do
|
18
|
-
it "
|
18
|
+
it "yields the right data" do
|
19
19
|
field = stub :b, :name => :b
|
20
20
|
@source.harvest :anything, field do |id, token|
|
21
21
|
id.should eql(7)
|
@@ -23,9 +23,9 @@ describe Sources::Couch do
|
|
23
23
|
end.should have(1).item
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
describe "get_data" do
|
28
|
-
it "
|
28
|
+
it "yields each line" do
|
29
29
|
@source.get_data do |data|
|
30
30
|
data.should == { "_id" => "7", "a" => "a data", "b" => "b data", "c" => "c data" }
|
31
31
|
end.should have(1).item
|
data/spec/lib/sources/db_spec.rb
CHANGED
@@ -112,21 +112,20 @@ describe Sources::DB do
|
|
112
112
|
|
113
113
|
describe "harvest_statement_with_offset" do
|
114
114
|
before(:each) do
|
115
|
-
@
|
116
|
-
@
|
117
|
-
@type = stub :type, :name => :some_type
|
115
|
+
@category = stub :category, :name => :some_category
|
116
|
+
@type = stub :type, :name => :some_type
|
118
117
|
end
|
119
118
|
it "should get a harvest statement and the chunksize to put the statement together" do
|
120
|
-
@source.should_receive(:harvest_statement).once.and_return 'some_example_statement'
|
121
|
-
@source.harvest_statement_with_offset(@type, @
|
119
|
+
@source.should_receive(:harvest_statement).once.with(@type, @category).and_return 'some_example_statement'
|
120
|
+
@source.harvest_statement_with_offset(@type, @category, :some_offset)
|
122
121
|
end
|
123
122
|
it "should add an AND if it already contains a WHERE statement" do
|
124
123
|
@source.should_receive(:harvest_statement).and_return 'WHERE'
|
125
|
-
@source.harvest_statement_with_offset(@type, @
|
124
|
+
@source.harvest_statement_with_offset(@type, @category, :some_offset).should == "WHERE AND st.id > some_offset LIMIT 25000"
|
126
125
|
end
|
127
126
|
it "should add a WHERE if it doesn't already contain one" do
|
128
127
|
@source.should_receive(:harvest_statement).and_return 'some_statement'
|
129
|
-
@source.harvest_statement_with_offset(@type, @
|
128
|
+
@source.harvest_statement_with_offset(@type, @category, :some_offset).should == "some_statement WHERE st.id > some_offset LIMIT 25000"
|
130
129
|
end
|
131
130
|
end
|
132
131
|
|
@@ -13,7 +13,7 @@ describe Tokenizers::Base do
|
|
13
13
|
@tokenizer.substitute_characters('abcdefghijklmnopqrstuvwxyzäöü').should == 'abcdefghijklmnopqrstuvwxyzäöü'
|
14
14
|
end
|
15
15
|
it "uses the substituter to replace characters" do
|
16
|
-
@tokenizer.substitutes_characters_with
|
16
|
+
@tokenizer.substitutes_characters_with CharacterSubstituters::WestEuropean.new
|
17
17
|
|
18
18
|
@tokenizer.substitute_characters('abcdefghijklmnopqrstuvwxyzäöü').should == 'abcdefghijklmnopqrstuvwxyzaeoeue'
|
19
19
|
end
|
@@ -121,29 +121,6 @@ describe Tokenizers::Base do
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
describe 'contracts_expressions' do
|
125
|
-
context 'without contract_expressions called' do
|
126
|
-
it 'should define a method contract' do
|
127
|
-
lambda { @tokenizer.contract('from this text') }.should_not raise_error
|
128
|
-
end
|
129
|
-
it 'should define a method contract that does nothing' do
|
130
|
-
unchanging = stub :unchanging
|
131
|
-
@tokenizer.contract unchanging
|
132
|
-
end
|
133
|
-
end
|
134
|
-
context 'with contracts_expressions called' do
|
135
|
-
before(:each) do
|
136
|
-
@tokenizer.contracts_expressions(/Mister|Mr./, 'mr')
|
137
|
-
end
|
138
|
-
it 'should define a method remove_stopwords' do
|
139
|
-
lambda { @tokenizer.contract('from this text') }.should_not raise_error
|
140
|
-
end
|
141
|
-
it 'should define a method contract that contracts expressions' do
|
142
|
-
@tokenizer.contract('Mister Meyer, Mr. Peter').should == 'mr Meyer, mr Peter'
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
124
|
describe 'stopwords' do
|
148
125
|
context 'without stopwords given' do
|
149
126
|
it 'should define a method remove_stopwords' do
|
@@ -45,7 +45,6 @@ describe Tokenizers::Query do
|
|
45
45
|
|
46
46
|
@tokenizer.should_receive(:remove_illegals).once.ordered.with text
|
47
47
|
@tokenizer.should_receive(:remove_non_single_stopwords).once.ordered.with text
|
48
|
-
@tokenizer.should_receive(:contract).once.ordered
|
49
48
|
|
50
49
|
@tokenizer.preprocess text
|
51
50
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 12
|
8
|
+
- 0
|
9
|
+
version: 0.12.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Florian Hanke
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-23 00:00:00 +01:00
|
18
18
|
default_executable: picky
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -44,13 +44,12 @@ files:
|
|
44
44
|
- lib/deployment.rb
|
45
45
|
- lib/picky/alias_instances.rb
|
46
46
|
- lib/picky/application.rb
|
47
|
-
- lib/picky/bundle.rb
|
48
47
|
- lib/picky/cacher/convenience.rb
|
49
48
|
- lib/picky/cacher/generator.rb
|
50
49
|
- lib/picky/cacher/partial/default.rb
|
51
50
|
- lib/picky/cacher/partial/none.rb
|
52
51
|
- lib/picky/cacher/partial/strategy.rb
|
53
|
-
- lib/picky/cacher/partial/
|
52
|
+
- lib/picky/cacher/partial/substring.rb
|
54
53
|
- lib/picky/cacher/partial_generator.rb
|
55
54
|
- lib/picky/cacher/similarity/default.rb
|
56
55
|
- lib/picky/cacher/similarity/double_levenshtone.rb
|
@@ -62,9 +61,8 @@ files:
|
|
62
61
|
- lib/picky/cacher/weights/logarithmic.rb
|
63
62
|
- lib/picky/cacher/weights/strategy.rb
|
64
63
|
- lib/picky/cacher/weights_generator.rb
|
65
|
-
- lib/picky/
|
66
|
-
- lib/picky/configuration/
|
67
|
-
- lib/picky/configuration/queries.rb
|
64
|
+
- lib/picky/character_substituters/west_european.rb
|
65
|
+
- lib/picky/configuration/index.rb
|
68
66
|
- lib/picky/cores.rb
|
69
67
|
- lib/picky/ext/maybe_compile.rb
|
70
68
|
- lib/picky/ext/ruby19/extconf.rb
|
@@ -78,25 +76,27 @@ files:
|
|
78
76
|
- lib/picky/helpers/gc.rb
|
79
77
|
- lib/picky/helpers/measuring.rb
|
80
78
|
- lib/picky/index/bundle.rb
|
81
|
-
- lib/picky/index/categories.rb
|
82
|
-
- lib/picky/index/category.rb
|
83
79
|
- lib/picky/index/file/basic.rb
|
84
80
|
- lib/picky/index/file/json.rb
|
85
81
|
- lib/picky/index/file/marshal.rb
|
86
82
|
- lib/picky/index/file/text.rb
|
87
83
|
- lib/picky/index/files.rb
|
88
|
-
- lib/picky/
|
89
|
-
- lib/picky/
|
90
|
-
- lib/picky/
|
91
|
-
- lib/picky/
|
92
|
-
- lib/picky/
|
84
|
+
- lib/picky/Index_api.rb
|
85
|
+
- lib/picky/indexed/bundle.rb
|
86
|
+
- lib/picky/indexed/categories.rb
|
87
|
+
- lib/picky/indexed/category.rb
|
88
|
+
- lib/picky/indexed/index.rb
|
89
|
+
- lib/picky/indexed/indexes.rb
|
90
|
+
- lib/picky/indexed/wrappers/exact_first.rb
|
93
91
|
- lib/picky/indexers/no_source_specified_error.rb
|
92
|
+
- lib/picky/indexers/serial.rb
|
94
93
|
- lib/picky/indexers/solr.rb
|
94
|
+
- lib/picky/indexes_api.rb
|
95
95
|
- lib/picky/indexing/bundle.rb
|
96
96
|
- lib/picky/indexing/categories.rb
|
97
97
|
- lib/picky/indexing/category.rb
|
98
|
-
- lib/picky/indexing/
|
99
|
-
- lib/picky/indexing/
|
98
|
+
- lib/picky/indexing/index.rb
|
99
|
+
- lib/picky/indexing/indexes.rb
|
100
100
|
- lib/picky/loader.rb
|
101
101
|
- lib/picky/loggers/search.rb
|
102
102
|
- lib/picky/query/allocation.rb
|
@@ -129,12 +129,9 @@ files:
|
|
129
129
|
- lib/picky/tokenizers/base.rb
|
130
130
|
- lib/picky/tokenizers/index.rb
|
131
131
|
- lib/picky/tokenizers/query.rb
|
132
|
-
- lib/picky/type.rb
|
133
|
-
- lib/picky/types.rb
|
134
132
|
- lib/picky-tasks.rb
|
135
133
|
- lib/picky.rb
|
136
134
|
- lib/tasks/application.rake
|
137
|
-
- lib/tasks/cache.rake
|
138
135
|
- lib/tasks/framework.rake
|
139
136
|
- lib/tasks/index.rake
|
140
137
|
- lib/tasks/routes.rake
|
@@ -163,15 +160,15 @@ files:
|
|
163
160
|
- spec/lib/cacher/cacher_strategy_spec.rb
|
164
161
|
- spec/lib/cacher/partial/default_spec.rb
|
165
162
|
- spec/lib/cacher/partial/none_spec.rb
|
166
|
-
- spec/lib/cacher/partial/
|
163
|
+
- spec/lib/cacher/partial/substring_spec.rb
|
167
164
|
- spec/lib/cacher/partial_generator_spec.rb
|
168
165
|
- spec/lib/cacher/similarity/double_levenshtone_spec.rb
|
169
166
|
- spec/lib/cacher/similarity/none_spec.rb
|
170
167
|
- spec/lib/cacher/similarity_generator_spec.rb
|
171
168
|
- spec/lib/cacher/weights/logarithmic_spec.rb
|
172
169
|
- spec/lib/cacher/weights_generator_spec.rb
|
173
|
-
- spec/lib/
|
174
|
-
- spec/lib/configuration/
|
170
|
+
- spec/lib/character_substituters/west_european_spec.rb
|
171
|
+
- spec/lib/configuration/index_spec.rb
|
175
172
|
- spec/lib/cores_spec.rb
|
176
173
|
- spec/lib/extensions/array_spec.rb
|
177
174
|
- spec/lib/extensions/hash_spec.rb
|
@@ -182,21 +179,21 @@ files:
|
|
182
179
|
- spec/lib/helpers/cache_spec.rb
|
183
180
|
- spec/lib/helpers/gc_spec.rb
|
184
181
|
- spec/lib/helpers/measuring_spec.rb
|
185
|
-
- spec/lib/index/bundle_spec.rb
|
186
|
-
- spec/lib/index/category_spec.rb
|
187
182
|
- spec/lib/index/file/basic_spec.rb
|
188
183
|
- spec/lib/index/file/json_spec.rb
|
189
184
|
- spec/lib/index/file/marshal_spec.rb
|
190
185
|
- spec/lib/index/file/text_spec.rb
|
191
186
|
- spec/lib/index/files_spec.rb
|
192
|
-
- spec/lib/
|
193
|
-
- spec/lib/
|
194
|
-
- spec/lib/
|
187
|
+
- spec/lib/indexed/bundle_spec.rb
|
188
|
+
- spec/lib/indexed/categories_spec.rb
|
189
|
+
- spec/lib/indexed/category_spec.rb
|
190
|
+
- spec/lib/indexed/index_spec.rb
|
191
|
+
- spec/lib/indexed/wrappers/exact_first_spec.rb
|
192
|
+
- spec/lib/indexers/serial_spec.rb
|
195
193
|
- spec/lib/indexing/bundle_partial_generation_speed_spec.rb
|
196
194
|
- spec/lib/indexing/bundle_spec.rb
|
197
|
-
- spec/lib/indexing/categories_spec.rb
|
198
195
|
- spec/lib/indexing/category_spec.rb
|
199
|
-
- spec/lib/indexing/
|
196
|
+
- spec/lib/indexing/index_spec.rb
|
200
197
|
- spec/lib/loader_spec.rb
|
201
198
|
- spec/lib/loggers/search_spec.rb
|
202
199
|
- spec/lib/query/allocation_spec.rb
|
@@ -265,15 +262,15 @@ test_files:
|
|
265
262
|
- spec/lib/cacher/cacher_strategy_spec.rb
|
266
263
|
- spec/lib/cacher/partial/default_spec.rb
|
267
264
|
- spec/lib/cacher/partial/none_spec.rb
|
268
|
-
- spec/lib/cacher/partial/
|
265
|
+
- spec/lib/cacher/partial/substring_spec.rb
|
269
266
|
- spec/lib/cacher/partial_generator_spec.rb
|
270
267
|
- spec/lib/cacher/similarity/double_levenshtone_spec.rb
|
271
268
|
- spec/lib/cacher/similarity/none_spec.rb
|
272
269
|
- spec/lib/cacher/similarity_generator_spec.rb
|
273
270
|
- spec/lib/cacher/weights/logarithmic_spec.rb
|
274
271
|
- spec/lib/cacher/weights_generator_spec.rb
|
275
|
-
- spec/lib/
|
276
|
-
- spec/lib/configuration/
|
272
|
+
- spec/lib/character_substituters/west_european_spec.rb
|
273
|
+
- spec/lib/configuration/index_spec.rb
|
277
274
|
- spec/lib/cores_spec.rb
|
278
275
|
- spec/lib/extensions/array_spec.rb
|
279
276
|
- spec/lib/extensions/hash_spec.rb
|
@@ -284,21 +281,21 @@ test_files:
|
|
284
281
|
- spec/lib/helpers/cache_spec.rb
|
285
282
|
- spec/lib/helpers/gc_spec.rb
|
286
283
|
- spec/lib/helpers/measuring_spec.rb
|
287
|
-
- spec/lib/index/bundle_spec.rb
|
288
|
-
- spec/lib/index/category_spec.rb
|
289
284
|
- spec/lib/index/file/basic_spec.rb
|
290
285
|
- spec/lib/index/file/json_spec.rb
|
291
286
|
- spec/lib/index/file/marshal_spec.rb
|
292
287
|
- spec/lib/index/file/text_spec.rb
|
293
288
|
- spec/lib/index/files_spec.rb
|
294
|
-
- spec/lib/
|
295
|
-
- spec/lib/
|
296
|
-
- spec/lib/
|
289
|
+
- spec/lib/indexed/bundle_spec.rb
|
290
|
+
- spec/lib/indexed/categories_spec.rb
|
291
|
+
- spec/lib/indexed/category_spec.rb
|
292
|
+
- spec/lib/indexed/index_spec.rb
|
293
|
+
- spec/lib/indexed/wrappers/exact_first_spec.rb
|
294
|
+
- spec/lib/indexers/serial_spec.rb
|
297
295
|
- spec/lib/indexing/bundle_partial_generation_speed_spec.rb
|
298
296
|
- spec/lib/indexing/bundle_spec.rb
|
299
|
-
- spec/lib/indexing/categories_spec.rb
|
300
297
|
- spec/lib/indexing/category_spec.rb
|
301
|
-
- spec/lib/indexing/
|
298
|
+
- spec/lib/indexing/index_spec.rb
|
302
299
|
- spec/lib/loader_spec.rb
|
303
300
|
- spec/lib/loggers/search_spec.rb
|
304
301
|
- spec/lib/query/allocation_spec.rb
|
data/lib/picky/bundle.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
class Bundle
|
2
|
-
|
3
|
-
attr_reader :identifier, :files
|
4
|
-
attr_accessor :index, :weights, :similarity, :similarity_strategy
|
5
|
-
|
6
|
-
delegate :[], :[]=, :clear, :to => :index
|
7
|
-
|
8
|
-
def initialize name, category, type, similarity_strategy
|
9
|
-
@identifier = "#{type.name}: #{name} #{category.name}"
|
10
|
-
|
11
|
-
@index = {}
|
12
|
-
@weights = {}
|
13
|
-
@similarity = {}
|
14
|
-
|
15
|
-
@similarity_strategy = similarity_strategy
|
16
|
-
|
17
|
-
# TODO inject files.
|
18
|
-
#
|
19
|
-
# TODO Move Files somewhere. Shared?
|
20
|
-
#
|
21
|
-
# Files and the identifier are parametrized, the rest is not!
|
22
|
-
#
|
23
|
-
@files = Index::Files.new name, category.name, type.name
|
24
|
-
end
|
25
|
-
|
26
|
-
# Get a list of similar texts.
|
27
|
-
#
|
28
|
-
def similar text
|
29
|
-
code = similarity_strategy.encoded text
|
30
|
-
code && @similarity[code] || []
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# TODO Remove?
|
2
|
-
#
|
3
|
-
module Configuration
|
4
|
-
|
5
|
-
# Describes the container for all index configurations.
|
6
|
-
#
|
7
|
-
class Indexes
|
8
|
-
|
9
|
-
attr_reader :types
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@types = []
|
13
|
-
end
|
14
|
-
|
15
|
-
def default_tokenizer options = {}
|
16
|
-
Tokenizers::Index.default = Tokenizers::Index.new(options)
|
17
|
-
end
|
18
|
-
|
19
|
-
# TODO Move this to … where?
|
20
|
-
#
|
21
|
-
# #
|
22
|
-
# #
|
23
|
-
# def take_snapshot *type_names
|
24
|
-
# only_if_included_in type_names do |type|
|
25
|
-
# type.take_snapshot
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
# def index *type_names
|
29
|
-
# only_if_included_in type_names do |type|
|
30
|
-
# type.index
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
# def index_solr *type_names
|
34
|
-
# only_if_included_in type_names do |type|
|
35
|
-
# type.index_solr
|
36
|
-
# end
|
37
|
-
# end
|
38
|
-
#
|
39
|
-
# #
|
40
|
-
# #
|
41
|
-
# def only_if_included_in type_names = []
|
42
|
-
# type_names = types.map(&:name) if type_names.empty?
|
43
|
-
# types.each do |type|
|
44
|
-
# next unless type_names.include?(type.name)
|
45
|
-
# yield type
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|