picky 4.6.6 → 4.7.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.rb +9 -2
- data/spec/functional/stemming_spec.rb +34 -2
- metadata +4 -4
data/lib/picky.rb
CHANGED
@@ -23,11 +23,18 @@ module Picky
|
|
23
23
|
# Check if platform specific modifiers need to be installed.
|
24
24
|
#
|
25
25
|
|
26
|
-
# Note: We don't use require_relative because MacRuby
|
27
|
-
# have it.
|
26
|
+
# Note: We don't use require_relative yet because MacRuby
|
27
|
+
# doesn't have it.
|
28
28
|
#
|
29
29
|
require File.expand_path '../picky/platforms/macruby', __FILE__
|
30
30
|
|
31
|
+
# Modify/configure the external libraries.
|
32
|
+
#
|
33
|
+
|
34
|
+
# By default, MultiJson uses Yajl.
|
35
|
+
#
|
36
|
+
MultiJson.use :yajl if defined? ::Yajl
|
37
|
+
|
31
38
|
# Require the constants.
|
32
39
|
#
|
33
40
|
require_relative 'picky/constants'
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
require 'stemmer'
|
6
|
+
require 'lingua/stemmer'
|
6
7
|
|
7
8
|
describe 'stemming' do
|
8
9
|
let(:stemmer) {
|
@@ -30,9 +31,9 @@ describe 'stemming' do
|
|
30
31
|
tokenizer.stem('computer').should == 'comput'
|
31
32
|
end
|
32
33
|
|
33
|
-
# This tests the
|
34
|
+
# This tests the stems_with option.
|
34
35
|
#
|
35
|
-
it 'stems right' do
|
36
|
+
it 'stems right (API conform Stemmer)' do
|
36
37
|
# Fix the Stemmer API.
|
37
38
|
#
|
38
39
|
module Stemmer
|
@@ -70,5 +71,36 @@ describe 'stemming' do
|
|
70
71
|
try.search("text:stemming").ids.should == [2, 1]
|
71
72
|
try.search("text:lem").ids.should == [2]
|
72
73
|
end
|
74
|
+
|
75
|
+
# This tests the stems_with option.
|
76
|
+
#
|
77
|
+
it 'stems right (Lingua::Stemmer.new)' do
|
78
|
+
index = Picky::Index.new :stemming do
|
79
|
+
# Be aware that if !s are not removed from
|
80
|
+
# eg. Lemming!, then stemming won't work.
|
81
|
+
#
|
82
|
+
indexing removes_characters: /[^a-z\s]/i,
|
83
|
+
stems_with: Lingua::Stemmer.new
|
84
|
+
category :text
|
85
|
+
end
|
86
|
+
|
87
|
+
index.replace_from id: 1, text: "Hello good Sirs, these things here need stems to work!"
|
88
|
+
index.replace_from id: 2, text: "Stemming Lemming!"
|
89
|
+
|
90
|
+
try = Picky::Search.new index
|
91
|
+
|
92
|
+
# If you don't stem in the search, it should not be found!
|
93
|
+
#
|
94
|
+
try.search("text:stemming").ids.should == []
|
95
|
+
|
96
|
+
try = Picky::Search.new index do
|
97
|
+
searching stems_with: Lingua::Stemmer.new
|
98
|
+
end
|
99
|
+
|
100
|
+
# With stemming in search AND indexing, it works :)
|
101
|
+
#
|
102
|
+
try.search("text:stemming").ids.should == [2, 1]
|
103
|
+
try.search("text:lem").ids.should == [2]
|
104
|
+
end
|
73
105
|
end
|
74
106
|
end
|
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.
|
4
|
+
version: 4.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 4.
|
37
|
+
version: 4.7.0
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 4.
|
45
|
+
version: 4.7.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: text
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|