uea-stemmer 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *.tmproj
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.rdoc ADDED
@@ -0,0 +1,73 @@
1
+ = uea-stemmer
2
+
3
+ Similar to other stemmers, UEA-Lite[http://www.uea.ac.uk/cmp/research/graphicsvisionspeech/speech/WordStemming] operates on a set of rules which are used as steps. There are two groups of rules: the first to clean the tokens, and the second to alter suffixes.
4
+
5
+ The first group of rules first avoids a small list of six frequent problem words. An improvement to the stemmer would be to expand this list by adding other problem words which the second rule set cannot deal with. Second, possessive apostrophes are removed and contractions are expanded. All hyphens are removed and tokens containing digits are left untouched. Strings which are all upper case and digits are left untouched unless there is a lower case terminal 's' (i.e. transforming plural forms of acronyms to singular forms).
6
+
7
+ Proper nouns should not usually be stemmed, except to remove possessives; our implementation will respect PoS tags if they are present. If the text is untagged the stemmer uses the simple heuristic that any capitalized token not preceded by sentence breaking punctuation is a proper noun.
8
+
9
+ Many texts, particularly scientific papers, contain sequences of digits, single letters, and other non-word tokens. Our implementation ignores tokens containing digits, single-letter tokens, and tokens with embedded punctuation.
10
+
11
+ The second group of rules contains 139 suffix rules, each testing for a specific type of suffix. The rules are set in a particular order so that the longest suffix applicable is used rather a shorter one which could lead to nonsense words and more words not stemmed entirely to their root form.
12
+
13
+ This is a port to Ruby from the port to Java from the original Perl script by Marie-Claire Jenkins and Dr. Dan J. Smith at the University of East Anglia.
14
+
15
+ == Installation
16
+
17
+ Install the gem via Github:
18
+
19
+ gem sources -a http://gems.github.com # only need to do this once
20
+ sudo gem install ealdent-uea-stemmer
21
+
22
+ Install the gem from source:
23
+
24
+ git clone git://github.com/ealdent/uea-stemmer.git
25
+ cd uea-stemmer
26
+ rake install
27
+
28
+ == Example Usage
29
+
30
+ Typical usage:
31
+
32
+ require 'uea-stemmer'
33
+ stemmer = UEAStemmer.new
34
+
35
+ stemmer.stem('helpers') # helper
36
+ stemmer.stem('dying') # die
37
+ stemmer.stem('scarred') # scar
38
+
39
+ 'buries'.stem # bury
40
+ 'bodies'.stem # body
41
+ 'ordained'.stem # ordain
42
+
43
+ You can also extract the stemmed word along with the rule by using the `stem_with_rule` method.
44
+
45
+ stem = stemmer.stem_with_rule('invited') # Word('invite', Rule #22.3)
46
+ puts stem.rule # rule #22.3 (remove -d when the word ends in -ited)
47
+
48
+ == TODO
49
+
50
+ * test handling of POS tags
51
+ * add tests to mimic methodology used in the paper
52
+
53
+ == Note on Patches/Pull Requests
54
+
55
+ * Fork the project.
56
+ * Make your feature addition or bug fix.
57
+ * Add tests for it. This is important so I don't break it in a
58
+ future version unintentionally.
59
+ * Commit, do not mess with rakefile, version, or history.
60
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
61
+ * Send me a pull request. Bonus points for topic branches.
62
+
63
+ == Relevant Web Pages
64
+
65
+ * http://www.uea.ac.uk/cmp/research/graphicsvisionspeech/speech/WordStemming
66
+ * Stemming[http://en.wikipedia.org/wiki/Stemming]
67
+
68
+ == Copyright
69
+
70
+ Copyright (c) 2005 by the University of East Anglia and authored by Marie-Claire Jenkins and Dr. Dan J Smith. This port to Ruby was done by Jason Adams using the port to Java by Richard Churchill.
71
+
72
+ This project is distributed under the Apache 2.0 License[http://www.apache.org/licenses/LICENSE-2.0]. See LICENSE for details.
73
+
data/Rakefile ADDED
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "uea-stemmer"
8
+ gem.summary = %Q{Port of UEA-Lite Stemmer to Ruby, a conservative stemmer for search and indexing.}
9
+ gem.description = %Q{Port of UEA-Lite Stemmer to Ruby, a conservative stemmer for search and indexing.}
10
+ gem.email = "jasonmadams@gmail.com"
11
+ gem.homepage = "http://github.com/ealdent/uea-stemmer"
12
+ gem.authors = ["Marie-Claire Jenkins", "Dan J. Smith", "Richard Churchill", "Jason Adams"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+
41
+
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ if File.exist?('VERSION.yml')
48
+ config = YAML.load(File.read('VERSION.yml'))
49
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
50
+ else
51
+ version = ""
52
+ end
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "uea-stemmer #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
59
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.9.10
@@ -0,0 +1,108 @@
1
+ #
2
+ # Copyright 2005 University of East Anglia
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ #
17
+ # Authored by Marie-Claire Jenkins and Dr. Dan J. Smith. Ported to Java
18
+ # from Perl by Richard Churchill. Ported from Java to Ruby by Jason M. Adams.
19
+ #
20
+
21
+ require 'uea-stemmer/string_helpers'
22
+
23
+ class UEAStemmer
24
+ class Rule
25
+ include StringHelpers
26
+
27
+ attr_reader :pattern, :suffix_size, :rule_num
28
+
29
+ def initialize(pattern, suffix_size, rule_num)
30
+ @pattern = pattern.dup.freeze
31
+ @suffix_size = suffix_size
32
+ @rule_num = rule_num
33
+ end
34
+
35
+ def handle(word)
36
+ [remove_suffix(word, @suffix_size), @rule_num, self] if word =~ @pattern
37
+ end
38
+
39
+ def to_s
40
+ "rule ##{@rule_num} (remove #{@suffix_size} letters from the end of the word when it matches pattern #{@pattern})"
41
+ end
42
+ end
43
+
44
+ class EndingRule < Rule
45
+ attr_reader :original_pattern
46
+
47
+ def initialize(pattern, suffix_size, rule_num)
48
+ super(/^.*#{pattern}$/, suffix_size, rule_num)
49
+ @original_pattern = pattern.dup.freeze
50
+ end
51
+
52
+ def to_s
53
+ "rule ##{@rule_num} (remove -#{@original_pattern[@original_pattern.size - @suffix_size, @suffix_size]} when the word ends in -#{@original_pattern})"
54
+ end
55
+ end
56
+
57
+ class ConcatenatingEndingRule < EndingRule
58
+ attr_reader :new_suffix
59
+
60
+ def initialize(pattern, suffix_size, rule_num, new_suffix)
61
+ super(pattern, suffix_size, rule_num)
62
+ @new_suffix = new_suffix.dup.freeze
63
+ end
64
+
65
+ def handle(word)
66
+ [remove_suffix(word, @suffix_size) + @new_suffix, @rule_num, self] if word =~ @pattern
67
+ end
68
+
69
+ def to_s
70
+ "rule ##{@rule_num} (remove -#{@original_pattern[@original_pattern.size - @suffix_size, @suffix_size]} and add -#{new_suffix} when the word ends in -#{@original_pattern})"
71
+ end
72
+ end
73
+
74
+ class NonExhaustiveEndingRule < EndingRule
75
+ def handle(word)
76
+ super(word) if word != @original_pattern
77
+ end
78
+
79
+ def to_s
80
+ "rule ##{@rule_num} (remove -#{@original_pattern[@original_pattern.size - @suffix_size, @suffix_size]} when the word ends in -#{@original_pattern} unless the word is #{@original_pattern})"
81
+ end
82
+ end
83
+
84
+ class ExhaustiveConcatenatingEndingRule < ConcatenatingEndingRule
85
+ def handle(word)
86
+ super(word) if word == @original_pattern
87
+ end
88
+ end
89
+
90
+ class CustomRule < Rule
91
+ def initialize(pattern, suffix_size, rule_num)
92
+ super(pattern, suffix_size, rule_num)
93
+ end
94
+
95
+ def handle(word)
96
+ [stem_with_duplicate_character_check(word), @rule_num, self] if word =~ @pattern
97
+ end
98
+
99
+ protected
100
+
101
+ def stem_with_duplicate_character_check(word)
102
+ new_suffix_size = ends_with?(word, 's') ? @suffix_size + 1 : @suffix_size
103
+ stemmed_word = remove_suffix(word, new_suffix_size)
104
+ stemmed_word.chop! if stemmed_word =~ /.*(\w)\1$/
105
+ stemmed_word
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,9 @@
1
+ module StringHelpers
2
+ def remove_suffix(word, suffix_size)
3
+ word[0, word.size - suffix_size]
4
+ end
5
+
6
+ def ends_with?(word, suffix)
7
+ !!(word =~ /#{suffix}$/)
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # Copyright 2005 University of East Anglia
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ #
17
+ # Authored by Marie-Claire Jenkins and Dr. Dan J. Smith. Ported to Java
18
+ # from Perl by Richard Churchill. Ported from Java to Ruby by Jason M. Adams.
19
+ #
20
+
21
+ class UEAStemmer
22
+ class Word
23
+ attr_reader :word, :rule_num, :rule
24
+
25
+ def initialize(word, rule_num, rule = nil)
26
+ @word = word.dup.freeze
27
+ @rule_num = rule_num
28
+ @rule = rule
29
+ end
30
+
31
+ def to_s
32
+ if @rule_num > 0
33
+ "#{@word} (Rule ##{@rule_num} #{@rule})"
34
+ else
35
+ "#{@word} (No rule)"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,354 @@
1
+ #
2
+ # Copyright 2005 University of East Anglia
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ #
17
+ # Authored by Marie-Claire Jenkins and Dr. Dan J. Smith. Ported to Java
18
+ # from Perl by Richard Churchill. Ported from Java to Ruby by Jason M. Adams.
19
+ #
20
+
21
+ require 'uea-stemmer/rule'
22
+ require 'uea-stemmer/word'
23
+ require 'uea-stemmer/string_helpers'
24
+ require 'singleton'
25
+
26
+ class UEAStemmer
27
+ include StringHelpers
28
+
29
+ attr_accessor :max_acronym_length, :max_word_length
30
+ attr_reader :rules
31
+
32
+ def initialize(max_word_length = nil, max_acronym_length = nil)
33
+ @max_word_length = max_word_length || 'deoxyribonucleicacid'.size
34
+ @max_acronym_length = max_acronym_length || 'CAVASSOO'.size
35
+
36
+ @rules = Array.new
37
+ create_rules
38
+ end
39
+
40
+ def stem_with_rule(word)
41
+ stemmed_word = word.dup;
42
+ ruleno = 0;
43
+
44
+ if problem_word?(word)
45
+ Word.new(word, 94)
46
+ elsif (word.size > @max_acronym_length && word =~ /^[A-Z]+$/) || (word.size > (@max_acronym_length + 1) && word =~ /^[A-Z]+s$/)
47
+ Word.new(word, 96) # added by JMA to catch long acronyms
48
+ elsif word.size > @max_word_length
49
+ Word.new(word, 95)
50
+ elsif word.index("'")
51
+ if word =~ /^.*'[s]$/i
52
+ stemmed_word = remove_suffix(stemmed_word, 2)
53
+ elsif word =~ /^.*'$/
54
+ stemmed_word = remove_suffix(stemmed_word, 1)
55
+ end
56
+
57
+ stemmed_word.gsub!(/n't/, ' not')
58
+ stemmed_word.gsub!(/'ve/, ' have')
59
+ stemmed_word.gsub!(/'re/, ' are')
60
+ stemmed_word.gsub!(/'m/, ' am')
61
+
62
+ Word.new(stemmed_word, 93)
63
+ else
64
+ stemmed_word, rule_num, rule = apply_rules(stemmed_word)
65
+ Word.new(stemmed_word, rule_num, rule)
66
+ end
67
+ end
68
+
69
+ def stem(word)
70
+ stem_with_rule(word).word
71
+ end
72
+
73
+ def num_rules
74
+ @rules.map { |r| r.rule_num }.uniq.size + 4 # four rules not covered by the rules array
75
+ end
76
+
77
+ def to_s
78
+ "UEA-Lite Stemmer (#{num_rules} rules)"
79
+ end
80
+
81
+ def add_rule(rule)
82
+ if rule.kind_of?(Rule)
83
+ @rules << rule.dup.freeze
84
+ true
85
+ else
86
+ false
87
+ end
88
+ end
89
+
90
+ private
91
+
92
+ def apply_rules(word)
93
+ @rules.each do |rule|
94
+ stemmed_word, rule_num, tmp_rule = rule.handle(word)
95
+ return [stemmed_word, rule_num, rule] if stemmed_word && rule_num
96
+ end
97
+
98
+ [word, 0, nil]
99
+ end
100
+
101
+ def create_rules
102
+ @rules << Rule.new(/^\d+$/, 0, 90.3)
103
+ @rules << Rule.new(/^\w+-\w+$/, 0, 90.2)
104
+ @rules << Rule.new(/^.*-.*$/, 0, 90.1)
105
+ @rules << Rule.new(/^.*_.*$/, 0, 90)
106
+ @rules << Rule.new(/^[A-Z]+s$/, 1, 91.1)
107
+ @rules << Rule.new(/^[A-Z]+$/, 0, 91)
108
+ @rules << Rule.new(/^((.*[A-Z].*[A-Z])|([A-Z]{1})).*$/, 0, 92)
109
+
110
+ @rules << EndingRule.new('aceous', 6, 1)
111
+ @rules << EndingRule.new('ces', 1, 2)
112
+ @rules << EndingRule.new('cs', 0, 3)
113
+ @rules << EndingRule.new('sis', 0, 4)
114
+ @rules << EndingRule.new('tis', 0, 5)
115
+ @rules << EndingRule.new('ss', 0, 6)
116
+
117
+ # plural change - this differs from Perl v1.03
118
+ @rules << EndingRule.new('eed', 0, 7)
119
+ @rules << EndingRule.new('eeds', 1, 7)
120
+
121
+ @rules << EndingRule.new('ued', 1, 8)
122
+ @rules << EndingRule.new('ues', 1, 9)
123
+ @rules << EndingRule.new('ees', 1, 10)
124
+ @rules << EndingRule.new('iases', 2, 11.4)
125
+ @rules << EndingRule.new('uses', 1, 11.3)
126
+ @rules << EndingRule.new('sses', 2, 11.2)
127
+ @rules << ConcatenatingEndingRule.new('eses', 2, 11.1, 'is')
128
+ @rules << EndingRule.new('ses', 1, 11)
129
+ @rules << EndingRule.new('tled', 1, 12.5)
130
+ @rules << EndingRule.new('pled', 1, 12.4)
131
+ @rules << EndingRule.new('bled', 1, 12.3)
132
+
133
+ @rules << EndingRule.new('eled', 2, 12.2)
134
+ @rules << EndingRule.new('lled', 2, 12.1)
135
+ @rules << EndingRule.new('led', 2, 12)
136
+ @rules << EndingRule.new('ened', 2, 13.7)
137
+ @rules << EndingRule.new('ained', 2, 13.6)
138
+ @rules << EndingRule.new('erned', 2, 13.5)
139
+ @rules << EndingRule.new('rned', 2, 13.4)
140
+ @rules << EndingRule.new('nned', 2, 13.3)
141
+ @rules << EndingRule.new('oned', 2, 13.2)
142
+ @rules << EndingRule.new('gned', 2, 13.1)
143
+ @rules << EndingRule.new('ned', 1, 13)
144
+ @rules << EndingRule.new('ifted', 2, 14)
145
+ @rules << EndingRule.new('ected', 2, 15)
146
+ @rules << EndingRule.new('vided', 1, 16)
147
+ @rules << EndingRule.new('ved', 1, 17)
148
+ @rules << EndingRule.new('ced', 1, 18)
149
+ @rules << EndingRule.new('arred', 3, 19.1)
150
+ @rules << NonExhaustiveEndingRule.new('erred', 3, 19)
151
+ @rules << EndingRule.new('urred', 3, 20.5)
152
+ @rules << EndingRule.new('lored', 2, 20.4)
153
+ @rules << EndingRule.new('eared', 2, 20.3)
154
+ @rules << EndingRule.new('tored', 2, 20.2)
155
+ @rules << EndingRule.new('ered', 2, 20.1)
156
+
157
+ # plural change - this differs from Perl v1.03
158
+ @rules << EndingRule.new('red', 1, 20)
159
+ @rules << EndingRule.new('reds', 2, 20)
160
+ @rules << EndingRule.new('tted', 3, 21)
161
+
162
+ # added some rules to handle invited vs. exited
163
+ @rules << EndingRule.new('noted', 1, 22.6)
164
+ @rules << EndingRule.new('leted', 1, 22.5)
165
+ @rules << Rule.new(/^.*[^vm]ited$/, 2, 22.4)
166
+ @rules << Rule.new(/^.*(ch|[vm])i[td]ed$/, 1, 22.3)
167
+ @rules << EndingRule.new('uted', 1, 22.2)
168
+ @rules << EndingRule.new('ated', 1, 22.1)
169
+ @rules << EndingRule.new('ted', 2, 22)
170
+
171
+ @rules << EndingRule.new('anges', 1, 23)
172
+ @rules << EndingRule.new('aining', 3, 24)
173
+ @rules << EndingRule.new('acting', 3, 25)
174
+
175
+ # plural change - this differs from Perl v1.03
176
+ @rules << EndingRule.new('tting', 4, 26)
177
+ @rules << EndingRule.new('ttings', 5, 26)
178
+
179
+ @rules << EndingRule.new('viding', 3, 27)
180
+ @rules << EndingRule.new('ssed', 2, 28)
181
+ @rules << EndingRule.new('sed', 1, 29)
182
+ @rules << EndingRule.new('titudes', 1, 30)
183
+
184
+ # added some additional rules to handle other vowels and consonants
185
+ # (added by Jason M. Adams)
186
+ @rules << EndingRule.new('oed', 1, 31.3)
187
+ @rules << EndingRule.new('oes', 1, 31.2)
188
+ @rules << EndingRule.new('oked', 1, 31.1)
189
+ @rules << EndingRule.new('aked', 1, 31.1)
190
+ @rules << EndingRule.new('iked', 1, 31.1)
191
+ @rules << EndingRule.new('uked', 1, 31.1)
192
+ @rules << EndingRule.new('amed', 1, 31)
193
+ @rules << EndingRule.new('imed', 1, 31)
194
+ @rules << EndingRule.new('umed', 1, 31)
195
+
196
+ @rules << EndingRule.new('ulted', 2, 32)
197
+ @rules << ConcatenatingEndingRule.new('uming', 3, 33, 'e')
198
+ @rules << EndingRule.new('fulness', 4, 34)
199
+ @rules << EndingRule.new('ousness', 4, 35)
200
+ @rules << EndingRule.new('rabed', 1, 36.1)
201
+ @rules << EndingRule.new('rebed', 1, 36.1)
202
+ @rules << EndingRule.new('ribed', 1, 36.1)
203
+ @rules << EndingRule.new('robed', 1, 36.1)
204
+ @rules << EndingRule.new('rubed', 1, 36.1)
205
+ @rules << EndingRule.new('bed', 2, 36)
206
+ @rules << EndingRule.new('beds', 3, 36)
207
+ @rules << EndingRule.new('ssing', 3, 37)
208
+ @rules << EndingRule.new('ssings', 4, 37)
209
+ @rules << EndingRule.new('ulting', 3, 38)
210
+
211
+ # plural change - this differs from Perl v1.03
212
+ @rules << ConcatenatingEndingRule.new('ving', 3, 39, 'e')
213
+ @rules << ConcatenatingEndingRule.new('vings', 4, 39, 'e')
214
+
215
+ @rules << EndingRule.new('eading', 3, 40.7)
216
+ @rules << EndingRule.new('eadings', 4, 40.7)
217
+ @rules << EndingRule.new('oading', 3, 40.6)
218
+ @rules << EndingRule.new('oadings', 4, 40.6)
219
+ @rules << EndingRule.new('eding', 3, 40.5)
220
+ @rules << EndingRule.new('edings', 4, 40.5)
221
+ @rules << EndingRule.new('dding', 4, 40.4)
222
+ @rules << EndingRule.new('ddings', 5, 40.4)
223
+ @rules << EndingRule.new('lding', 3, 40.3)
224
+ @rules << EndingRule.new('ldings', 4, 40.3)
225
+ @rules << EndingRule.new('rding', 3, 40.2)
226
+ @rules << EndingRule.new('rdings', 4, 40.2)
227
+ @rules << EndingRule.new('nding', 3, 40.1)
228
+ @rules << EndingRule.new('ndings', 4, 40.1)
229
+
230
+ # plural change - this differs from Perl v1.03
231
+ @rules << ConcatenatingEndingRule.new('ding', 3, 40, 'e')
232
+ @rules << ConcatenatingEndingRule.new('dings', 4, 40, 'e')
233
+
234
+ @rules << EndingRule.new('lling', 4, 41)
235
+ @rules << EndingRule.new('llings', 5, 41)
236
+ @rules << EndingRule.new('ealing', 3, 42.4)
237
+ @rules << EndingRule.new('ealings', 4, 42.4)
238
+ @rules << EndingRule.new('oling', 3, 42.3)
239
+ @rules << EndingRule.new('olings', 4, 42.3)
240
+ @rules << EndingRule.new('ailing', 3, 42.2)
241
+ @rules << EndingRule.new('ailings', 4, 42.2)
242
+ @rules << EndingRule.new('eling', 3, 42.1)
243
+ @rules << EndingRule.new('elings', 4, 42.1)
244
+ @rules << ConcatenatingEndingRule.new('ling', 3, 42, 'e')
245
+ @rules << ConcatenatingEndingRule.new('lings', 4, 42, 'e')
246
+ @rules << EndingRule.new('nged', 1, 43.2)
247
+ @rules << EndingRule.new('gged', 3, 43.1)
248
+ @rules << EndingRule.new('ged', 1, 43)
249
+ @rules << EndingRule.new('mming', 4, 44.3)
250
+ @rules << EndingRule.new('mmings', 5, 44.3)
251
+ @rules << EndingRule.new('rming', 3, 44.2)
252
+ @rules << EndingRule.new('lming', 3, 44.1)
253
+
254
+ # plural change - this differs from Perl v1.03
255
+ @rules << ConcatenatingEndingRule.new('ming', 3, 44, 'e')
256
+ @rules << ConcatenatingEndingRule.new('mings', 4, 44, 'e')
257
+
258
+ @rules << EndingRule.new('nging', 3, 45.2)
259
+ @rules << EndingRule.new('ngings', 4, 45.2)
260
+ @rules << EndingRule.new('gging', 4, 45.1)
261
+ @rules << EndingRule.new('ggings', 5, 45.1)
262
+ @rules << EndingRule.new('ging', 3, 45)
263
+ @rules << EndingRule.new('gings', 4, 45)
264
+ @rules << EndingRule.new('aning', 3, 46.6)
265
+ @rules << EndingRule.new('ening', 3, 46.5)
266
+ @rules << EndingRule.new('gning', 3, 46.4)
267
+ @rules << EndingRule.new('nning', 4, 46.3)
268
+ @rules << EndingRule.new('oning', 3, 46.2)
269
+ @rules << EndingRule.new('rning', 3, 46.1)
270
+ @rules << ConcatenatingEndingRule.new('ning', 3, 46, 'e')
271
+
272
+ # plural change - this differs from Perl v1.03
273
+ @rules << EndingRule.new('sting', 3, 47)
274
+ @rules << EndingRule.new('stings', 4, 47)
275
+ @rules << EndingRule.new('eting', 3, 48.4)
276
+ @rules << EndingRule.new('etings', 4, 48.4)
277
+
278
+ @rules << EndingRule.new('pting', 3, 48.3)
279
+ @rules << EndingRule.new('nting', 3, 48.2)
280
+ @rules << EndingRule.new('ntings', 4, 48.2)
281
+ @rules << EndingRule.new('cting', 3, 48.1)
282
+ @rules << ConcatenatingEndingRule.new('ting', 3, 48, 'e')
283
+ @rules << ConcatenatingEndingRule.new('tings', 4, 48, 'e')
284
+
285
+ @rules << EndingRule.new('ssed', 2, 49)
286
+ @rules << EndingRule.new('les', 1, 50)
287
+ @rules << EndingRule.new('tes', 1, 51)
288
+ @rules << EndingRule.new('zed', 1, 52)
289
+ @rules << EndingRule.new('lled', 2, 53)
290
+
291
+ # plural change - this differs from Perl v1.03
292
+ @rules << ConcatenatingEndingRule.new('iring', 3, 54.4, 'e')
293
+ @rules << ConcatenatingEndingRule.new('irings', 4, 54.4, 'e')
294
+ @rules << ConcatenatingEndingRule.new('uring', 3, 54.3, 'e')
295
+ @rules << ConcatenatingEndingRule.new('urings', 4, 54.3, 'e')
296
+ @rules << ConcatenatingEndingRule.new('ncing', 3, 54.2, 'e')
297
+ @rules << ConcatenatingEndingRule.new('ncings', 4, 54.2, 'e')
298
+
299
+ @rules << ConcatenatingEndingRule.new('zing', 3, 54.1, 'e')
300
+
301
+ # plural change - this differs from Perl v1.03
302
+ @rules << ConcatenatingEndingRule.new('sing', 3, 54, 'e')
303
+ @rules << ConcatenatingEndingRule.new('sings', 4, 54, 'e')
304
+
305
+ @rules << EndingRule.new('lling', 3, 55)
306
+ @rules << ConcatenatingEndingRule.new('ied', 3, 56, 'y')
307
+ @rules << ConcatenatingEndingRule.new('ating', 3, 57, 'e')
308
+
309
+ # plural change - this differs from Perl v1.03
310
+ @rules << ConcatenatingEndingRule.new('dying', 4, 58.2, 'ie') # added by JMA
311
+ @rules << ExhaustiveConcatenatingEndingRule.new('lying', 4, 58.2, 'ie') # added by JMA (lying vs flying)
312
+ @rules << ConcatenatingEndingRule.new('tying', 4, 58.2, 'ie') # added by JMA
313
+ @rules << EndingRule.new('thing', 0, 58.1)
314
+ @rules << EndingRule.new('things', 1, 58.1)
315
+ @rules << CustomRule.new(/.*\w\wings?$/, 3, 58)
316
+
317
+ @rules << ConcatenatingEndingRule.new('ies', 3, 59, 'y')
318
+ @rules << ConcatenatingEndingRule.new('lves', 3, 60.1, 'f')
319
+ @rules << EndingRule.new('ves', 1, 60)
320
+ @rules << EndingRule.new('aped', 1, 61.3)
321
+ @rules << EndingRule.new('uded', 1, 61.2)
322
+ @rules << EndingRule.new('oded', 1, 61.1)
323
+ @rules << EndingRule.new('ated', 1, 61)
324
+ @rules << CustomRule.new(/.*\w\weds?$/, 2, 62)
325
+ @rules << EndingRule.new('pes', 1, 63.8)
326
+ @rules << EndingRule.new('mes', 1, 63.7)
327
+ @rules << EndingRule.new('ones', 1, 63.6)
328
+ @rules << EndingRule.new('izes', 1, 63.5)
329
+ @rules << EndingRule.new('ures', 1, 63.4)
330
+ @rules << EndingRule.new('ines', 1, 63.3)
331
+ @rules << EndingRule.new('ides', 1, 63.2)
332
+ @rules << EndingRule.new('kes', 1, 63.1)
333
+ @rules << EndingRule.new('ges', 1, 63.1)
334
+ @rules << EndingRule.new('es', 2, 63)
335
+ @rules << ConcatenatingEndingRule.new('is', 2, 64, 'e')
336
+ @rules << EndingRule.new('ous', 0, 65)
337
+ @rules << EndingRule.new('ums', 0, 66)
338
+ @rules << EndingRule.new('us', 0, 67)
339
+ @rules << EndingRule.new('s', 1, 68)
340
+
341
+ @rules.each { |r| r.freeze }
342
+
343
+ nil
344
+ end
345
+
346
+ def problem_word?(word)
347
+ ['is', 'as', 'this', 'has', 'was', 'during', 'menses'].include?(word)
348
+ end
349
+
350
+ end
351
+
352
+ class DefaultUEAStemmer < UEAStemmer
353
+ include Singleton
354
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'uea-stemmer'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,156 @@
1
+ require 'test_helper'
2
+
3
+ class UeaStemmerTest < Test::Unit::TestCase
4
+ context "A default UEAStemmer instance" do
5
+ setup do
6
+ @stemmer = UEAStemmer.new
7
+ end
8
+
9
+ should "have max word and max acronym sizes equivalent to deoxyribonucleicacid and CAVASSOO respectively" do
10
+ assert @stemmer.max_word_length == 'deoxyribonucleicacid'.size
11
+ assert @stemmer.max_acronym_length == 'CAVASSOO'.size
12
+ end
13
+
14
+ context "stem method" do
15
+ should "stem words as Strings" do
16
+ assert @stemmer.stem('word').is_a?(String)
17
+ end
18
+
19
+ should "stem base words to just the base word" do
20
+ assert_equal @stemmer.stem('man'), 'man'
21
+ assert_equal @stemmer.stem('happiness'), 'happiness'
22
+ end
23
+
24
+ should "stem theses as thesis but not bases as basis" do
25
+ assert_equal @stemmer.stem('theses'), 'thesis'
26
+ assert_not_equal @stemmer.stem('bases'), 'basis'
27
+ end
28
+
29
+ should "stem preterite words ending in -ed without the -ed" do
30
+ assert_equal @stemmer.stem('ordained'), 'ordain'
31
+ assert_equal @stemmer.stem('killed'), 'kill'
32
+ assert_equal @stemmer.stem('liked'), 'like'
33
+ assert_equal @stemmer.stem('helped'), 'help'
34
+ assert_equal @stemmer.stem('scarred'), 'scar'
35
+ assert_equal @stemmer.stem('invited'), 'invite'
36
+ assert_equal @stemmer.stem('exited'), 'exit'
37
+ assert_equal @stemmer.stem('exited'), 'exit'
38
+ assert_equal @stemmer.stem('debited'), 'debit'
39
+ assert_equal @stemmer.stem('smited'), 'smite'
40
+ end
41
+
42
+ should "stem progressive verbs and gerunds without the -ing" do
43
+ assert_equal @stemmer.stem('running'), 'run'
44
+ assert_equal @stemmer.stem('settings'), 'set'
45
+ assert_equal @stemmer.stem('timing'), 'time'
46
+ assert_equal @stemmer.stem('dying'), 'die'
47
+ assert_equal @stemmer.stem('harping'), 'harp'
48
+ assert_equal @stemmer.stem('charring'), 'char'
49
+ end
50
+
51
+ should "stem various plural nouns and 3rd-pres verbs without the -s/-es" do
52
+ assert_equal @stemmer.stem('changes'), 'change'
53
+ assert_equal @stemmer.stem('deaths'), 'death'
54
+ assert_equal @stemmer.stem('shadows'), 'shadow'
55
+ assert_equal @stemmer.stem('flies'), 'fly'
56
+ assert_equal @stemmer.stem('things'), 'thing'
57
+ assert_equal @stemmer.stem('nothings'), 'nothing' # as in 'sweet nothings'
58
+ assert_equal @stemmer.stem('witches'), 'witch'
59
+ assert_equal @stemmer.stem('makes'), 'make'
60
+ assert_equal @stemmer.stem('smokes'), 'smoke'
61
+ end
62
+
63
+ should "stem acronyms when pluralized otherwise they should be left alone" do
64
+ assert_equal @stemmer.stem('USA'), 'USA'
65
+ assert_equal @stemmer.stem('FLOSS'), 'FLOSS'
66
+ assert_equal @stemmer.stem('MREs'), 'MRE'
67
+ assert_equal @stemmer.stem('USAED'), 'USAED'
68
+ end
69
+ end
70
+
71
+ context "stem_with_rule method" do
72
+ should "return a Word instance" do
73
+ assert @stemmer.stem_with_rule('witches').is_a?(UEAStemmer::Word)
74
+ end
75
+
76
+ should "return a rule and the stemmed form" do
77
+ word = @stemmer.stem_with_rule('witches')
78
+ assert !word.rule.nil?
79
+ assert !word.word.nil?
80
+ end
81
+ end
82
+
83
+ context "other functionality" do
84
+ should "return the number of rules the stemmer is currently using" do
85
+ assert @stemmer.num_rules.is_a?(Numeric)
86
+ end
87
+ end
88
+ end
89
+
90
+ context "A modified UEAStemmer instance" do
91
+ setup do
92
+ @stemmer = UEAStemmer.new(5, 3) # max word length = 5, max acronym length = 3
93
+ end
94
+
95
+ should "have modified max word and max acronym sizes" do
96
+ assert @stemmer.max_word_length == 5
97
+ assert @stemmer.max_acronym_length == 3
98
+ end
99
+
100
+ should "reject a longer word with rule 95" do
101
+ word = @stemmer.stem_with_rule('deoxyribonucleicacid')
102
+ assert_equal word.rule_num, 95
103
+ end
104
+
105
+ should "reject a longer acronym with rule 96" do
106
+ word = @stemmer.stem_with_rule('CAVASSOO')
107
+ assert_equal word.rule_num, 96
108
+ end
109
+ end
110
+
111
+ context "A Word instance" do
112
+ setup do
113
+ @word = UEAStemmer::Word.new('helpers', 68, UEAStemmer::EndingRule.new('s', 1, 68)) # sample word
114
+ @stemmer = UEAStemmer.new
115
+ end
116
+
117
+ should "return the rule used to derive the stem" do
118
+ assert @word.rule.kind_of?(UEAStemmer::Rule)
119
+ end
120
+
121
+ should "return the number of the rule used to derive the stem" do
122
+ assert @word.rule_num.kind_of?(Numeric)
123
+ end
124
+
125
+ should "return the stemmed word as a String" do
126
+ assert @word.word.kind_of?(String)
127
+ end
128
+ end
129
+
130
+ context "A Rule instance" do
131
+ setup do
132
+ @rule = UEAStemmer::Rule.new(/.*s$/i, 1, 555)
133
+ end
134
+
135
+ should "return the rule number" do
136
+ assert @rule.rule_num.kind_of?(Numeric)
137
+ end
138
+
139
+ should "return the pattern being matched" do
140
+ assert @rule.pattern.kind_of?(String) || @rule.pattern.kind_of?(Regexp)
141
+ end
142
+
143
+ should "return the size of the suffix that is being removed" do
144
+ assert @rule.suffix_size.kind_of?(Numeric)
145
+ end
146
+
147
+ should "return a stemmed word, a rule number, and a rule on a successful match" do
148
+ word, rule_num, tmp_rule = @rule.handle('helps')
149
+ assert word.is_a?(String) && rule_num.is_a?(Numeric) && tmp_rule.is_a?(UEAStemmer::Rule)
150
+ end
151
+
152
+ should "return nil when match is unsuccessful" do
153
+ assert @rule.handle('help').nil?
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{uea-stemmer}
8
+ s.version = "0.9.10"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Marie-Claire Jenkins", "Dan J. Smith", "Richard Churchill", "Jason Adams"]
12
+ s.date = %q{2009-09-30}
13
+ s.description = %q{Port of UEA-Lite Stemmer to Ruby, a conservative stemmer for search and indexing.}
14
+ s.email = %q{jasonmadams@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/uea-stemmer.rb",
27
+ "lib/uea-stemmer/rule.rb",
28
+ "lib/uea-stemmer/string_helpers.rb",
29
+ "lib/uea-stemmer/word.rb",
30
+ "test/test_helper.rb",
31
+ "test/uea_stemmer_test.rb",
32
+ "uea-stemmer.gemspec"
33
+ ]
34
+ s.homepage = %q{http://github.com/ealdent/uea-stemmer}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.4}
38
+ s.summary = %q{Port of UEA-Lite Stemmer to Ruby, a conservative stemmer for search and indexing.}
39
+ s.test_files = [
40
+ "test/test_helper.rb",
41
+ "test/uea_stemmer_test.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ else
50
+ end
51
+ else
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uea-stemmer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.10
5
+ platform: ruby
6
+ authors:
7
+ - Marie-Claire Jenkins
8
+ - Dan J. Smith
9
+ - Richard Churchill
10
+ - Jason Adams
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2009-09-30 00:00:00 -04:00
16
+ default_executable:
17
+ dependencies: []
18
+
19
+ description: Port of UEA-Lite Stemmer to Ruby, a conservative stemmer for search and indexing.
20
+ email: jasonmadams@gmail.com
21
+ executables: []
22
+
23
+ extensions: []
24
+
25
+ extra_rdoc_files:
26
+ - LICENSE
27
+ - README.rdoc
28
+ files:
29
+ - .document
30
+ - .gitignore
31
+ - LICENSE
32
+ - README.rdoc
33
+ - Rakefile
34
+ - VERSION
35
+ - lib/uea-stemmer.rb
36
+ - lib/uea-stemmer/rule.rb
37
+ - lib/uea-stemmer/string_helpers.rb
38
+ - lib/uea-stemmer/word.rb
39
+ - test/test_helper.rb
40
+ - test/uea_stemmer_test.rb
41
+ - uea-stemmer.gemspec
42
+ has_rdoc: true
43
+ homepage: http://github.com/ealdent/uea-stemmer
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --charset=UTF-8
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.4
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Port of UEA-Lite Stemmer to Ruby, a conservative stemmer for search and indexing.
70
+ test_files:
71
+ - test/test_helper.rb
72
+ - test/uea_stemmer_test.rb