- Fixed messed up indentation/tabs

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@657281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2008-05-17 01:57:32 +00:00
parent 1d5ba345cc
commit f5df30327e
1 changed files with 41 additions and 38 deletions

View File

@ -24,37 +24,41 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer;
/** /**
* A ShingleAnalyzerWrapper wraps a ShingleFilter around another analyzer. A shingle is another term for a token based * A ShingleAnalyzerWrapper wraps a ShingleFilter around another analyzer. A
* n-gram. * shingle is another namefor a token based n-gram.
*/ */
public class ShingleAnalyzerWrapper extends Analyzer { public class ShingleAnalyzerWrapper extends Analyzer {
protected Analyzer defaultAnalyzer; protected Analyzer defaultAnalyzer;
protected int maxShingleSize = 2; protected int maxShingleSize = 2;
protected boolean outputUnigrams = true; protected boolean outputUnigrams = true;
public ShingleAnalyzerWrapper(Analyzer defaultAnalyzer) { public ShingleAnalyzerWrapper(Analyzer defaultAnalyzer) {
super(); super();
this.defaultAnalyzer = defaultAnalyzer; this.defaultAnalyzer = defaultAnalyzer;
} }
public ShingleAnalyzerWrapper(Analyzer defaultAnalyzer, int maxShingleSize) { public ShingleAnalyzerWrapper(Analyzer defaultAnalyzer, int maxShingleSize) {
this(defaultAnalyzer); this(defaultAnalyzer);
this.maxShingleSize = maxShingleSize; this.maxShingleSize = maxShingleSize;
} }
public ShingleAnalyzerWrapper() { /**
super(); * Wraps {@link StandardAnalyzer}.
this.defaultAnalyzer = new StandardAnalyzer(); */
} public ShingleAnalyzerWrapper() {
super();
this.defaultAnalyzer = new StandardAnalyzer();
}
public ShingleAnalyzerWrapper(int nGramSize) { public ShingleAnalyzerWrapper(int nGramSize) {
this(); this();
this.maxShingleSize = nGramSize; this.maxShingleSize = nGramSize;
} }
/** /**
* The max shingle (ngram) size * The max shingle (ngram) size
*
* @return The max shingle (ngram) size * @return The max shingle (ngram) size
*/ */
public int getMaxShingleSize() { public int getMaxShingleSize() {
@ -62,14 +66,13 @@ public class ShingleAnalyzerWrapper extends Analyzer {
} }
/** /**
* Set the maximum size of output shingles (default: 2) * Set the maximum size of output shingles
* *
* @param maxShingleSize max shingle size * @param maxShingleSize max shingle size
*/ */
public void setMaxShingleSize(int maxShingleSize) { public void setMaxShingleSize(int maxShingleSize) {
this.maxShingleSize = maxShingleSize; this.maxShingleSize = maxShingleSize;
} }
public boolean isOutputUnigrams() { public boolean isOutputUnigrams() {
return outputUnigrams; return outputUnigrams;
@ -77,20 +80,20 @@ public class ShingleAnalyzerWrapper extends Analyzer {
/** /**
* Shall the filter pass the original tokens (the "unigrams") to the output * Shall the filter pass the original tokens (the "unigrams") to the output
* stream? (default: true) * stream?
* *
* @param outputUnigrams Whether or not the filter shall pass the original * @param outputUnigrams Whether or not the filter shall pass the original
* tokens to the output stream * tokens to the output stream
*/ */
public void setOutputUnigrams(boolean outputUnigrams) { public void setOutputUnigrams(boolean outputUnigrams) {
this.outputUnigrams = outputUnigrams; this.outputUnigrams = outputUnigrams;
} }
public TokenStream tokenStream(String fieldName, Reader reader) { public TokenStream tokenStream(String fieldName, Reader reader) {
ShingleFilter filter ShingleFilter filter = new ShingleFilter(defaultAnalyzer.tokenStream(
= new ShingleFilter(defaultAnalyzer.tokenStream(fieldName, reader)); fieldName, reader));
filter.setMaxShingleSize(maxShingleSize); filter.setMaxShingleSize(maxShingleSize);
filter.setOutputUnigrams(outputUnigrams); filter.setOutputUnigrams(outputUnigrams);
return filter; return filter;
} }
} }