picky 4.26.0 → 4.26.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/picky/query/token.rb +2 -1
- data/spec/functional/stemming_spec.rb +59 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8867cbb7ea1e37c65690e1ad226ba1ba834aa0ee
|
4
|
+
data.tar.gz: 06118ee0130e7916835b259d3ba59962c49f5764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ea2f05d4048abfea0b0f8dd33288fbf123ce825544a25050147cec3f22964448faef37fc9818b3a87990d402fb2866eda119cf9072a6f5801bacc3f977e0c2a
|
7
|
+
data.tar.gz: ecc9354148631faeb9c970a4199cee50d83e2a6d44507c78d915cc8bda14da86dc4bed57f080fd8ccba5afb103d972da2fb4bbf3f8f0b58b25d2f97985bcb081
|
data/lib/picky/query/token.rb
CHANGED
@@ -107,6 +107,65 @@ describe 'stemming' do
|
|
107
107
|
|
108
108
|
try = Picky::Search.new index
|
109
109
|
|
110
|
+
try.search("stemming").ids.should == [1, 2]
|
111
|
+
try.search("stemmin").ids.should == []
|
112
|
+
try.search("stemmi").ids.should == []
|
113
|
+
try.search("stemm").ids.should == []
|
114
|
+
try.search("stem").ids.should == [1]
|
115
|
+
|
116
|
+
try.search("ios").ids.should == [2, 1]
|
117
|
+
try.search("io").ids.should == [2]
|
118
|
+
try.search("i").ids.should == []
|
119
|
+
|
120
|
+
try.search("text1:stemming").ids.should == [1]
|
121
|
+
try.search("text2:ios").ids.should == [1]
|
122
|
+
|
123
|
+
try.search("text1:ios").ids.should == [2]
|
124
|
+
try.search("text2:stemming").ids.should == [2]
|
125
|
+
|
126
|
+
try.search("text1:stem").ids.should == [1]
|
127
|
+
try.search("text2:io").ids.should == []
|
128
|
+
|
129
|
+
try.search("text1:io").ids.should == [2]
|
130
|
+
try.search("text2:stem").ids.should == []
|
131
|
+
end
|
132
|
+
end
|
133
|
+
describe 'multiple stemmers' do
|
134
|
+
it 'caching works' do
|
135
|
+
do_nothing_stemmer = Class.new do
|
136
|
+
def stem text
|
137
|
+
text
|
138
|
+
end
|
139
|
+
end.new
|
140
|
+
|
141
|
+
index = Picky::Index.new :stemming do
|
142
|
+
# Be aware that if !s are not removed from
|
143
|
+
# eg. Lemming!, then stemming won't work.
|
144
|
+
#
|
145
|
+
indexing removes_characters: /[^a-z\s]/i
|
146
|
+
category :text1,
|
147
|
+
partial: Picky::Partial::None.new,
|
148
|
+
indexing: { stems_with: Lingua::Stemmer.new }
|
149
|
+
category :text2,
|
150
|
+
partial: Picky::Partial::None.new,
|
151
|
+
indexing: { stems_with: do_nothing_stemmer }
|
152
|
+
end
|
153
|
+
|
154
|
+
index.replace_from id: 1, text1: 'stemming', text2: 'ios'
|
155
|
+
index.replace_from id: 2, text1: 'ios', text2: 'stemming'
|
156
|
+
|
157
|
+
try = Picky::Search.new index
|
158
|
+
|
159
|
+
try.search("stemming").ids.should == [1, 2]
|
160
|
+
try.search("stemmin").ids.should == []
|
161
|
+
try.search("stemmi").ids.should == []
|
162
|
+
try.search("stemm").ids.should == []
|
163
|
+
try.search("stem").ids.should == [1]
|
164
|
+
|
165
|
+
try.search("ios").ids.should == [2, 1]
|
166
|
+
try.search("io").ids.should == [2]
|
167
|
+
try.search("i").ids.should == []
|
168
|
+
|
110
169
|
try.search("text1:stemming").ids.should == [1]
|
111
170
|
try.search("text2:ios").ids.should == [1]
|
112
171
|
|