picky 4.26.0 → 4.26.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 361f560a9705c05e6e4105e283edb8af462f6d12
4
- data.tar.gz: 6e7430ed38b525ed918cfc8633659ce6f978f142
3
+ metadata.gz: 8867cbb7ea1e37c65690e1ad226ba1ba834aa0ee
4
+ data.tar.gz: 06118ee0130e7916835b259d3ba59962c49f5764
5
5
  SHA512:
6
- metadata.gz: d7fd4d1022e3ea493a015579a4020b2d30a6058c0231fe3429e4ca255f697e30e78391afc5591b6f229ad504fed5b3f2b1a35c12e373243a494bb2275c54df80
7
- data.tar.gz: fa28a3b92a92ba1d6668ee52e5dd1c9dfc3802b1cd47e2262b092c6469af9c79a1c56fbfda8838f1e545b1ced50a813dc98b48ea130cb0b735254c85f377d3a5
6
+ metadata.gz: 6ea2f05d4048abfea0b0f8dd33288fbf123ce825544a25050147cec3f22964448faef37fc9818b3a87990d402fb2866eda119cf9072a6f5801bacc3f977e0c2a
7
+ data.tar.gz: ecc9354148631faeb9c970a4199cee50d83e2a6d44507c78d915cc8bda14da86dc4bed57f080fd8ccba5afb103d972da2fb4bbf3f8f0b58b25d2f97985bcb081
@@ -90,7 +90,8 @@ module Picky
90
90
  #
91
91
  def stem tokenizer
92
92
  if stem?
93
- @stem ||= tokenizer.stem(@text)
93
+ @stems ||= {}
94
+ @stems[tokenizer] ||= tokenizer.stem(@text)
94
95
  else
95
96
  @text
96
97
  end
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.26.0
4
+ version: 4.26.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Hanke