/
regression_spec.rb
63 lines (52 loc) · 1.74 KB
/
regression_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# encoding: utf-8
#
require 'spec_helper'
describe "Regression" do
it 'does not get confused' do
index = Picky::Index.new :dynamic_weights do
category :text1
category :text2
category :text3
category :text4
end
try = Picky::Search.new index
try.search('hello hello hello').allocations.size.should == 0
thing = Struct.new(:id, :text1, :text2, :text3, :text4)
index.add thing.new(1, 'hello', 'hello', 'hello', 'world')
try.search('hello hello hello').allocations.size.should == 27
index.add thing.new(2, 'hello', 'hello', 'hello', 'world')
index.add thing.new(3, 'hello', 'hello', 'hello', 'world')
index.add thing.new(4, 'hello', 'hello', 'hello', 'world')
index.add thing.new(5, 'hello', 'hello', 'hello', 'world')
try.search('hello hello hello').allocations.size.should == 27
index.add thing.new(6, 'world', 'world', 'world', 'hello')
try.search('hello hello world').allocations.size.should == 64
end
# # This was described by Niko
# # and references a case where
# # an attribute and the id referenced
# # to the same String.
# #
# context 'fun cases' do
# it 'stopwords destroy ids (final: id reference on attribute)' do
# index = Picky::Index.new :stopwords do
# key_format :to_sym
# indexing splits_text_on: /[\\\/\s\"\'\&_,;:]+/i,
# stopwords: /\b(and|the|or|on|of|in|der|die|das|und|oder)\b/i
# category :text
# end
#
# referenced = "this and that"
#
# require 'ostruct'
#
# thing = OpenStruct.new id: referenced, text: referenced
#
# index.add thing
#
# try = Picky::Search.new index
#
# try.search("this").ids.should == ["this that"]
# end
# end
end