picky 1.1.4 → 1.1.5
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/bundle.rb +5 -1
- data/lib/picky/index_api.rb +2 -0
- data/spec/lib/index/bundle_spec.rb +30 -0
- metadata +4 -2
data/lib/picky/index/bundle.rb
CHANGED
@@ -41,9 +41,13 @@ module Index # :nodoc:all
|
|
41
41
|
|
42
42
|
# Get a list of similar texts.
|
43
43
|
#
|
44
|
+
# Note: Does not return itself.
|
45
|
+
#
|
44
46
|
def similar text
|
45
47
|
code = similarity_strategy.encoded text
|
46
|
-
code && @similarity[code]
|
48
|
+
similar_codes = code && @similarity[code]
|
49
|
+
similar_codes.delete text if similar_codes
|
50
|
+
similar_codes || []
|
47
51
|
end
|
48
52
|
|
49
53
|
end
|
data/lib/picky/index_api.rb
CHANGED
@@ -36,6 +36,8 @@ class IndexAPI # :nodoc:all
|
|
36
36
|
#
|
37
37
|
#
|
38
38
|
def define_location name, options = {}
|
39
|
+
# TODO Make mandatory.
|
40
|
+
#
|
39
41
|
grid = options[:radius] || raise("Option :radius needs to be set on define_location, it defines the search radius.")
|
40
42
|
precision = options[:precision]
|
41
43
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Index::Bundle do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@configuration = stub :configuration, :identifier => 'some_identifier'
|
7
|
+
Index::Files.stub! :new
|
8
|
+
@similarity = Similarity::Phonetic.new 3
|
9
|
+
@bundle = Index::Bundle.new :some_name, @configuration, @similarity
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'similar' do
|
13
|
+
before(:each) do
|
14
|
+
@bundle.similarity = @similarity.generate_from( :dragon => [1,2,3], :dargon => [4,5,6] )
|
15
|
+
end
|
16
|
+
it 'returns the right similars (not itself)' do
|
17
|
+
@bundle.similar(:dragon).should == [:dargon]
|
18
|
+
end
|
19
|
+
it 'returns the right similars' do
|
20
|
+
@bundle.similar(:trkn).should == [:dragon, :dargon]
|
21
|
+
end
|
22
|
+
it 'performs' do
|
23
|
+
performance_of { @bundle.similar(:dragon) }.should < 0.000075
|
24
|
+
end
|
25
|
+
it 'performs' do
|
26
|
+
performance_of { @bundle.similar(:trkn) }.should < 0.00006
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 5
|
9
|
+
version: 1.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Florian Hanke
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- spec/lib/helpers/cache_spec.rb
|
172
172
|
- spec/lib/helpers/gc_spec.rb
|
173
173
|
- spec/lib/helpers/measuring_spec.rb
|
174
|
+
- spec/lib/index/bundle_spec.rb
|
174
175
|
- spec/lib/index/file/basic_spec.rb
|
175
176
|
- spec/lib/index/file/json_spec.rb
|
176
177
|
- spec/lib/index/file/marshal_spec.rb
|
@@ -276,6 +277,7 @@ test_files:
|
|
276
277
|
- spec/lib/helpers/cache_spec.rb
|
277
278
|
- spec/lib/helpers/gc_spec.rb
|
278
279
|
- spec/lib/helpers/measuring_spec.rb
|
280
|
+
- spec/lib/index/bundle_spec.rb
|
279
281
|
- spec/lib/index/file/basic_spec.rb
|
280
282
|
- spec/lib/index/file/json_spec.rb
|
281
283
|
- spec/lib/index/file/marshal_spec.rb
|