2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
* IteratedLovinsStemmer.java
19
* Copyright (C) 2001 University of Waikato, Hamilton, New Zealand
23
package weka.core.stemmers;
26
<!-- globalinfo-start -->
27
* An iterated version of the Lovins stemmer. It stems the word (in case it's longer than 2 characters) until it no further changes.<br/>
29
* For more information about the Lovins stemmer see:<br/>
31
* Julie Beth Lovins (1968). Development of a stemming algorithm. Mechanical Translation and Computational Linguistics. 11:22-31.
33
<!-- globalinfo-end -->
35
<!-- technical-bibtex-start -->
38
* @article{Lovins1968,
39
* author = {Julie Beth Lovins},
40
* journal = {Mechanical Translation and Computational Linguistics},
42
* title = {Development of a stemming algorithm},
48
<!-- technical-bibtex-end -->
50
* @author Eibe Frank (eibe at cs dot waikato dot ac dot nz)
51
* @version $Revision: 1.6 $
54
public class IteratedLovinsStemmer
55
extends LovinsStemmer {
57
/** for serialization */
58
static final long serialVersionUID = 960689687163788264L;
61
* Returns a string describing the stemmer
62
* @return a description suitable for
63
* displaying in the explorer/experimenter gui
65
public String globalInfo() {
67
"An iterated version of the Lovins stemmer. It stems the word (in "
68
+ "case it's longer than 2 characters) until it no further changes.\n\n"
69
+ "For more information about the Lovins stemmer see:\n\n"
70
+ getTechnicalInformation().toString();
74
* Iterated stemming of the given word.
75
* Word is converted to lower case.
77
* @param str the word to stem
78
* @return the stemmed word
80
public String stem(String str) {
82
if (str.length() <= 2) {
85
String stemmed = super.stem(str);
86
while (!stemmed.equals(str)) {
88
stemmed = super.stem(stemmed);
94
* Runs the stemmer with the given options
96
* @param args the options
98
public static void main(String[] args) {
100
Stemming.useStemmer(new IteratedLovinsStemmer(), args);
102
catch (Exception e) {