mirror of https://github.com/apache/lucene.git
Improved javadoc for Snowball stemmer code.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150869 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
88f7c967bd
commit
c2340adae8
|
@ -27,8 +27,6 @@
|
||||||
<!-- Stuff needed by all targets -->
|
<!-- Stuff needed by all targets -->
|
||||||
<!-- ====================================================== -->
|
<!-- ====================================================== -->
|
||||||
<target name="init">
|
<target name="init">
|
||||||
<mkdir dir="${bin.dir}"/>
|
|
||||||
|
|
||||||
<mkdir dir="${build.dir}"/>
|
<mkdir dir="${build.dir}"/>
|
||||||
<mkdir dir="${build.classes}"/>
|
<mkdir dir="${build.classes}"/>
|
||||||
|
|
||||||
|
@ -134,7 +132,7 @@
|
||||||
<javadoc
|
<javadoc
|
||||||
sourcepath="${src.dir}"
|
sourcepath="${src.dir}"
|
||||||
overview="${src.dir}/overview.html"
|
overview="${src.dir}/overview.html"
|
||||||
packagenames="${javadoc.packages}"
|
packagenames="*"
|
||||||
destdir="${build.javadoc}"
|
destdir="${build.javadoc}"
|
||||||
author="true"
|
author="true"
|
||||||
version="true"
|
version="true"
|
||||||
|
|
|
@ -14,7 +14,6 @@ test.build.classes = ${test.build.dir}/classes
|
||||||
|
|
||||||
javadoc.link.java=http://java.sun.com/j2se/1.4.1/docs/api/
|
javadoc.link.java=http://java.sun.com/j2se/1.4.1/docs/api/
|
||||||
javadoc.link.lucene=http://jakarta.apache.org/lucene/docs/api/
|
javadoc.link.lucene=http://jakarta.apache.org/lucene/docs/api/
|
||||||
javadoc.packages=org.apache.lucene.analysis.snowball.*
|
|
||||||
|
|
||||||
snowball.cvsroot=:pserver:cvsuser@cvs.tartarus.org:/home/cvs
|
snowball.cvsroot=:pserver:cvsuser@cvs.tartarus.org:/home/cvs
|
||||||
snowball.root=snowball/website
|
snowball.root=snowball/website
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
Snowball generated stemmer classes.
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
Snowball system classes.
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -57,23 +57,30 @@ package org.apache.lucene.analysis.snowball;
|
||||||
import org.apache.lucene.analysis.*;
|
import org.apache.lucene.analysis.*;
|
||||||
import org.apache.lucene.analysis.standard.*;
|
import org.apache.lucene.analysis.standard.*;
|
||||||
|
|
||||||
|
import net.sf.snowball.ext.*;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
/** Filters {@link StandardTokenizer} with {@link StandardFilter}, {@link
|
/** Filters {@link StandardTokenizer} with {@link StandardFilter}, {@link
|
||||||
* LowerCaseFilter}, {@link SnowballFilter} and {@link StopFilter}. */
|
* LowerCaseFilter}, {@link StopFilter} and {@link SnowballFilter}.
|
||||||
|
*
|
||||||
|
* Available stemmers are listed in {@link net.sf.snowball.ext}. The name of a
|
||||||
|
* stemmer is the part of the class name before "Stemmer", e.g., the stemmer in
|
||||||
|
* {@link EnglishStemmer} is named "English".
|
||||||
|
*/
|
||||||
public class SnowballAnalyzer extends Analyzer {
|
public class SnowballAnalyzer extends Analyzer {
|
||||||
private String language;
|
private String name;
|
||||||
private Hashtable stopTable;
|
private Hashtable stopTable;
|
||||||
|
|
||||||
/** Builds an analyzer with the given stop words. */
|
/** Builds the named analyzer with no stop words. */
|
||||||
public SnowballAnalyzer(String language) {
|
public SnowballAnalyzer(String name) {
|
||||||
this.language = language;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Builds an analyzer with the given stop words. */
|
/** Builds the named analyzer with the given stop words. */
|
||||||
public SnowballAnalyzer(String language, String[] stopWords) {
|
public SnowballAnalyzer(String name, String[] stopWords) {
|
||||||
this(language);
|
this(name);
|
||||||
stopTable = StopFilter.makeStopTable(stopWords);
|
stopTable = StopFilter.makeStopTable(stopWords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +92,7 @@ public class SnowballAnalyzer extends Analyzer {
|
||||||
result = new LowerCaseFilter(result);
|
result = new LowerCaseFilter(result);
|
||||||
if (stopTable != null)
|
if (stopTable != null)
|
||||||
result = new StopFilter(result, stopTable);
|
result = new StopFilter(result, stopTable);
|
||||||
result = new SnowballFilter(result, language);
|
result = new SnowballFilter(result, name);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,13 +59,18 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import net.sf.snowball.SnowballProgram;
|
import net.sf.snowball.SnowballProgram;
|
||||||
|
import net.sf.snowball.ext.*;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.Token;
|
import org.apache.lucene.analysis.Token;
|
||||||
import org.apache.lucene.analysis.TokenFilter;
|
import org.apache.lucene.analysis.TokenFilter;
|
||||||
import org.apache.lucene.analysis.TokenStream;
|
import org.apache.lucene.analysis.TokenStream;
|
||||||
|
|
||||||
/**
|
/** A filter that stems words using a Snowball-generated stemmer.
|
||||||
*/
|
*
|
||||||
|
* Available stemmers are listed in {@link net.sf.snowball.ext}. The name of a
|
||||||
|
* stemmer is the part of the class name before "Stemmer", e.g., the stemmer in
|
||||||
|
* {@link EnglishStemmer} is named "English".
|
||||||
|
*/
|
||||||
|
|
||||||
public class SnowballFilter extends TokenFilter {
|
public class SnowballFilter extends TokenFilter {
|
||||||
private static final Object [] EMPTY_ARGS = new Object[0];
|
private static final Object [] EMPTY_ARGS = new Object[0];
|
||||||
|
@ -73,11 +78,16 @@ public class SnowballFilter extends TokenFilter {
|
||||||
private SnowballProgram stemmer;
|
private SnowballProgram stemmer;
|
||||||
private Method stemMethod;
|
private Method stemMethod;
|
||||||
|
|
||||||
public SnowballFilter(TokenStream in, String language) {
|
/** Construct the named stemming filter.
|
||||||
|
*
|
||||||
|
* @param in the input tokens to stem
|
||||||
|
* @param in the name of a stemmer
|
||||||
|
*/
|
||||||
|
public SnowballFilter(TokenStream in, String name) {
|
||||||
this.input = in;
|
this.input = in;
|
||||||
try {
|
try {
|
||||||
Class stemClass =
|
Class stemClass =
|
||||||
Class.forName("net.sf.snowball.ext." + language + "Stemmer");
|
Class.forName("net.sf.snowball.ext." + name + "Stemmer");
|
||||||
stemmer = (SnowballProgram) stemClass.newInstance();
|
stemmer = (SnowballProgram) stemClass.newInstance();
|
||||||
stemMethod = stemClass.getMethod("stem", new Class[0]);
|
stemMethod = stemClass.getMethod("stem", new Class[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
Lucene analyzer that uses Snowball stemmers.
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
Snowball stemmers for Lucene
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue