mirror of https://github.com/apache/lucene.git
LUCENE-2012: add remaining @overrides (contrib,demo)
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@833867 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9bec958bf0
commit
786eb6ce0d
|
@ -152,6 +152,7 @@ public final class ArabicAnalyzer extends Analyzer {
|
|||
* {@link LowerCaseFilter}, {@link StopFilter}, {@link ArabicNormalizationFilter}
|
||||
* and {@link ArabicStemFilter}.
|
||||
*/
|
||||
@Override
|
||||
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result = new ArabicLetterTokenizer( reader );
|
||||
result = new LowerCaseFilter(result);
|
||||
|
@ -177,6 +178,7 @@ public final class ArabicAnalyzer extends Analyzer {
|
|||
* {@link LowerCaseFilter}, {@link StopFilter}, {@link ArabicNormalizationFilter}
|
||||
* and {@link ArabicStemFilter}.
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -47,6 +47,7 @@ public class ArabicLetterTokenizer extends LetterTokenizer {
|
|||
* Allows for Letter category or NonspacingMark category
|
||||
* @see org.apache.lucene.analysis.LetterTokenizer#isTokenChar(char)
|
||||
*/
|
||||
@Override
|
||||
protected boolean isTokenChar(char c) {
|
||||
return super.isTokenChar(c) || Character.getType(c) == Character.NON_SPACING_MARK;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public final class ArabicNormalizationFilter extends TokenFilter {
|
|||
termAtt = addAttribute(TermAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
int newlen = normalizer.normalize(termAtt.termBuffer(), termAtt.termLength());
|
||||
|
|
|
@ -39,6 +39,7 @@ public final class ArabicStemFilter extends TokenFilter {
|
|||
termAtt = addAttribute(TermAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
int newlen = stemmer.stem(termAtt.termBuffer(), termAtt.termLength());
|
||||
|
|
|
@ -146,6 +146,7 @@ public final class BrazilianAnalyzer extends Analyzer {
|
|||
* {@link LowerCaseFilter}, {@link StandardFilter}, {@link StopFilter}, and
|
||||
* {@link BrazilianStemFilter}.
|
||||
*/
|
||||
@Override
|
||||
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result = new StandardTokenizer( matchVersion, reader );
|
||||
result = new LowerCaseFilter( result );
|
||||
|
@ -169,6 +170,7 @@ public final class BrazilianAnalyzer extends Analyzer {
|
|||
* {@link LowerCaseFilter}, {@link StandardFilter}, {@link StopFilter}, and
|
||||
* {@link BrazilianStemFilter}.
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -48,6 +48,7 @@ public final class BrazilianStemFilter extends TokenFilter {
|
|||
this.exclusions = exclusiontable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
String term = termAtt.term();
|
||||
|
|
|
@ -89,6 +89,7 @@ public class CJKAnalyzer extends Analyzer {
|
|||
* @return A {@link TokenStream} built from {@link CJKTokenizer}, filtered with
|
||||
* {@link StopFilter}
|
||||
*/
|
||||
@Override
|
||||
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new StopFilter(StopFilter.getEnablePositionIncrementsVersionDefault(matchVersion),
|
||||
new CJKTokenizer(reader), stopTable);
|
||||
|
@ -108,6 +109,7 @@ public class CJKAnalyzer extends Analyzer {
|
|||
* @return A {@link TokenStream} built from {@link CJKTokenizer}, filtered with
|
||||
* {@link StopFilter}
|
||||
*/
|
||||
@Override
|
||||
public final TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
|
||||
/* tokenStream() is final, no back compat issue */
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -145,6 +145,7 @@ public final class CJKTokenizer extends Tokenizer {
|
|||
* happened in the InputStream
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
clearAttributes();
|
||||
/** how many character(s) has been stored in buffer */
|
||||
|
@ -297,12 +298,14 @@ public final class CJKTokenizer extends Tokenizer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void end() {
|
||||
// set final offset
|
||||
final int finalOffset = offset;
|
||||
this.offsetAtt.setOffset(finalOffset, finalOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
offset = bufferIndex = dataLen = 0;
|
||||
|
@ -310,6 +313,7 @@ public final class CJKTokenizer extends Tokenizer {
|
|||
tokenType = WORD_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(Reader reader) throws IOException {
|
||||
super.reset(reader);
|
||||
reset();
|
||||
|
|
|
@ -40,6 +40,7 @@ public class ChineseAnalyzer extends Analyzer {
|
|||
* @return A {@link TokenStream} built from a {@link ChineseTokenizer}
|
||||
* filtered with {@link ChineseFilter}.
|
||||
*/
|
||||
@Override
|
||||
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result = new ChineseTokenizer(reader);
|
||||
result = new ChineseFilter(result);
|
||||
|
@ -58,6 +59,7 @@ public class ChineseAnalyzer extends Analyzer {
|
|||
* @return A {@link TokenStream} built from a {@link ChineseTokenizer}
|
||||
* filtered with {@link ChineseFilter}.
|
||||
*/
|
||||
@Override
|
||||
public final TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
/* tokenStream() is final, no back compat issue */
|
||||
|
|
|
@ -67,6 +67,7 @@ public final class ChineseFilter extends TokenFilter {
|
|||
termAtt = addAttribute(TermAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
|
||||
while (input.incrementToken()) {
|
||||
|
|
|
@ -111,6 +111,7 @@ public final class ChineseTokenizer extends Tokenizer {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
clearAttributes();
|
||||
|
||||
|
@ -158,17 +159,20 @@ public final class ChineseTokenizer extends Tokenizer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void end() {
|
||||
// set final offset
|
||||
final int finalOffset = offset;
|
||||
this.offsetAtt.setOffset(finalOffset, finalOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
offset = bufferIndex = dataLen = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(Reader input) throws IOException {
|
||||
super.reset(input);
|
||||
reset();
|
||||
|
|
|
@ -137,6 +137,7 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter {
|
|||
payloadAtt.setPayload(token.getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (tokens.size() > 0) {
|
||||
setToken((Token)tokens.removeFirst());
|
||||
|
@ -205,6 +206,7 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter {
|
|||
|
||||
protected abstract void decomposeInternal(final Token token);
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
tokens.clear();
|
||||
|
|
|
@ -81,6 +81,7 @@ public class DictionaryCompoundWordTokenFilter extends CompoundWordTokenFilterBa
|
|||
super(input, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decomposeInternal(final Token token) {
|
||||
// Only words longer than minWordSize get processed
|
||||
if (token.termLength() < this.minWordSize) {
|
||||
|
|
|
@ -149,6 +149,7 @@ public class HyphenationCompoundWordTokenFilter extends
|
|||
return tree;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decomposeInternal(final Token token) {
|
||||
// get the hyphenation points
|
||||
Hyphenation hyphens = hyphenator.hyphenate(token.termBuffer(), 0, token
|
||||
|
|
|
@ -81,6 +81,7 @@ public class CharVector implements Cloneable, Serializable {
|
|||
n = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
CharVector cv = new CharVector((char[]) array.clone(), blockSize);
|
||||
cv.n = this.n;
|
||||
|
|
|
@ -51,6 +51,7 @@ public class Hyphen implements Serializable {
|
|||
postBreak = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (noBreak == null && postBreak == null && preBreak != null
|
||||
&& preBreak.equals("-")) {
|
||||
|
|
|
@ -466,6 +466,7 @@ public class HyphenationTree extends TernaryTree implements PatternConsumer,
|
|||
insert(pattern, (char) k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStats() {
|
||||
System.out.println("Value space size = "
|
||||
+ Integer.toString(vspace.length()));
|
||||
|
|
|
@ -266,6 +266,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
|
|||
//
|
||||
// EntityResolver methods
|
||||
//
|
||||
@Override
|
||||
public InputSource resolveEntity(String publicId, String systemId) {
|
||||
return HyphenationDTDGenerator.generateDTD();
|
||||
}
|
||||
|
@ -278,6 +279,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
|
|||
* @see org.xml.sax.ContentHandler#startElement(java.lang.String,
|
||||
* java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String uri, String local, String raw,
|
||||
Attributes attrs) {
|
||||
if (local.equals("hyphen-char")) {
|
||||
|
@ -307,6 +309,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
|
|||
* @see org.xml.sax.ContentHandler#endElement(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String local, String raw) {
|
||||
|
||||
if (token.length() > 0) {
|
||||
|
@ -343,6 +346,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
|
|||
/**
|
||||
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
StringBuffer chars = new StringBuffer(length);
|
||||
chars.append(ch, start, length);
|
||||
|
@ -376,6 +380,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
|
|||
/**
|
||||
* @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
|
||||
*/
|
||||
@Override
|
||||
public void warning(SAXParseException ex) {
|
||||
errMsg = "[Warning] " + getLocationString(ex) + ": " + ex.getMessage();
|
||||
}
|
||||
|
@ -383,6 +388,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
|
|||
/**
|
||||
* @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
|
||||
*/
|
||||
@Override
|
||||
public void error(SAXParseException ex) {
|
||||
errMsg = "[Error] " + getLocationString(ex) + ": " + ex.getMessage();
|
||||
}
|
||||
|
@ -390,6 +396,7 @@ public class PatternParser extends DefaultHandler implements PatternConsumer {
|
|||
/**
|
||||
* @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
|
||||
*/
|
||||
@Override
|
||||
public void fatalError(SAXParseException ex) throws SAXException {
|
||||
errMsg = "[Fatal Error] " + getLocationString(ex) + ": " + ex.getMessage();
|
||||
throw ex;
|
||||
|
|
|
@ -348,6 +348,7 @@ public class TernaryTree implements Cloneable, Serializable {
|
|||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
TernaryTree t = new TernaryTree();
|
||||
t.lo = (char[]) this.lo.clone();
|
||||
|
@ -483,6 +484,7 @@ public class TernaryTree implements Cloneable, Serializable {
|
|||
child = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new Item(parent, child);
|
||||
}
|
||||
|
|
|
@ -140,6 +140,7 @@ public final class CzechAnalyzer extends Analyzer {
|
|||
* @return A {@link TokenStream} built from a {@link StandardTokenizer} filtered with
|
||||
* {@link StandardFilter}, {@link LowerCaseFilter}, and {@link StopFilter}
|
||||
*/
|
||||
@Override
|
||||
public final TokenStream tokenStream( String fieldName, Reader reader ) {
|
||||
TokenStream result = new StandardTokenizer( matchVersion, reader );
|
||||
result = new StandardFilter( result );
|
||||
|
@ -161,6 +162,7 @@ public final class CzechAnalyzer extends Analyzer {
|
|||
* @return A {@link TokenStream} built from a {@link StandardTokenizer} filtered with
|
||||
* {@link StandardFilter}, {@link LowerCaseFilter}, and {@link StopFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -149,6 +149,7 @@ public class GermanAnalyzer extends Analyzer {
|
|||
* {@link StandardFilter}, {@link LowerCaseFilter}, {@link StopFilter}, and
|
||||
* {@link GermanStemFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result = new StandardTokenizer(matchVersion, reader);
|
||||
result = new StandardFilter(result);
|
||||
|
@ -172,6 +173,7 @@ public class GermanAnalyzer extends Analyzer {
|
|||
* {@link StandardFilter}, {@link LowerCaseFilter}, {@link StopFilter}, and
|
||||
* {@link GermanStemFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
|
||||
if (overridesTokenStreamMethod) {
|
||||
// LUCENE-1678: force fallback to tokenStream() if we
|
||||
|
|
|
@ -61,6 +61,7 @@ public final class GermanStemFilter extends TokenFilter
|
|||
/**
|
||||
* @return Returns true for next token in the stream, or false at EOS
|
||||
*/
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
String term = termAtt.term();
|
||||
|
|
|
@ -99,6 +99,7 @@ public final class GreekAnalyzer extends Analyzer
|
|||
* @return A {@link TokenStream} built from a {@link StandardTokenizer} filtered with
|
||||
* {@link GreekLowerCaseFilter} and {@link StopFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader)
|
||||
{
|
||||
TokenStream result = new StandardTokenizer(matchVersion, reader);
|
||||
|
@ -120,6 +121,7 @@ public final class GreekAnalyzer extends Analyzer
|
|||
* @return A {@link TokenStream} built from a {@link StandardTokenizer} filtered with
|
||||
* {@link GreekLowerCaseFilter} and {@link StopFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -37,6 +37,7 @@ public final class GreekLowerCaseFilter extends TokenFilter
|
|||
termAtt = addAttribute(TermAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
char[] chArray = termAtt.termBuffer();
|
||||
|
|
|
@ -152,6 +152,7 @@ public final class PersianAnalyzer extends Analyzer {
|
|||
* {@link ArabicNormalizationFilter},
|
||||
* {@link PersianNormalizationFilter} and Persian Stop words
|
||||
*/
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result = new ArabicLetterTokenizer(reader);
|
||||
result = new LowerCaseFilter(result);
|
||||
|
@ -181,6 +182,7 @@ public final class PersianAnalyzer extends Analyzer {
|
|||
* {@link ArabicNormalizationFilter},
|
||||
* {@link PersianNormalizationFilter} and Persian Stop words
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -40,6 +40,7 @@ public final class PersianNormalizationFilter extends TokenFilter {
|
|||
termAtt = addAttribute(TermAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
final int newlen = normalizer.normalize(termAtt.termBuffer(), termAtt
|
||||
|
|
|
@ -78,6 +78,7 @@ public final class ElisionFilter extends TokenFilter {
|
|||
/**
|
||||
* Increments the {@link TokenStream} with a {@link TermAttribute} without elisioned start
|
||||
*/
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
char[] termBuffer = termAtt.termBuffer();
|
||||
|
|
|
@ -155,6 +155,7 @@ public final class FrenchAnalyzer extends Analyzer {
|
|||
* filtered with {@link StandardFilter}, {@link StopFilter},
|
||||
* {@link FrenchStemFilter} and {@link LowerCaseFilter}
|
||||
*/
|
||||
@Override
|
||||
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result = new StandardTokenizer(matchVersion, reader);
|
||||
result = new StandardFilter(result);
|
||||
|
@ -179,6 +180,7 @@ public final class FrenchAnalyzer extends Analyzer {
|
|||
* filtered with {@link StandardFilter}, {@link StopFilter},
|
||||
* {@link FrenchStemFilter} and {@link LowerCaseFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -59,6 +59,7 @@ public final class FrenchStemFilter extends TokenFilter {
|
|||
/**
|
||||
* @return Returns true for the next token in the stream, or false at EOS
|
||||
*/
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
String term = termAtt.term();
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.io.IOException;
|
|||
*/
|
||||
public final class EmptyTokenStream extends TokenStream {
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -216,6 +216,7 @@ public class PatternAnalyzer extends Analyzer {
|
|||
* the reader delivering the text
|
||||
* @return a new token stream
|
||||
*/
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
if (reader instanceof FastStringReader) { // fast path
|
||||
return tokenStream(fieldName, ((FastStringReader)reader).getString());
|
||||
|
@ -236,6 +237,7 @@ public class PatternAnalyzer extends Analyzer {
|
|||
* the reference object with which to compare.
|
||||
* @return true if equal, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) return true;
|
||||
if (this == DEFAULT_ANALYZER && other == EXTENDED_ANALYZER) return false;
|
||||
|
@ -256,6 +258,7 @@ public class PatternAnalyzer extends Analyzer {
|
|||
*
|
||||
* @return the hash code.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (this == DEFAULT_ANALYZER) return -1218418418; // fast path
|
||||
if (this == EXTENDED_ANALYZER) return 1303507063; // fast path
|
||||
|
@ -335,6 +338,7 @@ public class PatternAnalyzer extends Analyzer {
|
|||
this.toLowerCase = toLowerCase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() {
|
||||
if (matcher == null) return false;
|
||||
clearAttributes();
|
||||
|
@ -361,6 +365,7 @@ public class PatternAnalyzer extends Analyzer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void end() {
|
||||
// set final offset
|
||||
final int finalOffset = str.length();
|
||||
|
@ -394,6 +399,7 @@ public class PatternAnalyzer extends Analyzer {
|
|||
this.stopWords = stopWords;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() {
|
||||
clearAttributes();
|
||||
// cache loop instance vars (performance)
|
||||
|
@ -442,6 +448,7 @@ public class PatternAnalyzer extends Analyzer {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void end() {
|
||||
// set final offset
|
||||
final int finalOffset = str.length();
|
||||
|
|
|
@ -35,11 +35,13 @@ public class PrefixAndSuffixAwareTokenFilter extends TokenStream {
|
|||
public PrefixAndSuffixAwareTokenFilter(TokenStream prefix, TokenStream input, TokenStream suffix) {
|
||||
super(suffix);
|
||||
prefix = new PrefixAwareTokenFilter(prefix, input) {
|
||||
@Override
|
||||
public Token updateSuffixToken(Token suffixToken, Token lastInputToken) {
|
||||
return PrefixAndSuffixAwareTokenFilter.this.updateInputToken(suffixToken, lastInputToken);
|
||||
}
|
||||
};
|
||||
this.suffix = new PrefixAwareTokenFilter(prefix, suffix) {
|
||||
@Override
|
||||
public Token updateSuffixToken(Token suffixToken, Token lastInputToken) {
|
||||
return PrefixAndSuffixAwareTokenFilter.this.updateSuffixToken(suffixToken, lastInputToken);
|
||||
}
|
||||
|
@ -59,15 +61,18 @@ public class PrefixAndSuffixAwareTokenFilter extends TokenStream {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
return suffix.incrementToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
suffix.reset();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
suffix.close();
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ public class PrefixAwareTokenFilter extends TokenStream {
|
|||
|
||||
private boolean prefixExhausted;
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (!prefixExhausted) {
|
||||
Token nextToken = getNextPrefixInputToken(reusableToken);
|
||||
|
@ -156,11 +157,13 @@ public class PrefixAwareTokenFilter extends TokenStream {
|
|||
return suffixToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
prefix.close();
|
||||
suffix.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
if (prefix != null) {
|
||||
|
|
|
@ -45,6 +45,7 @@ public final class SingleTokenTokenStream extends TokenStream {
|
|||
assert (tokenAtt instanceof Token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (exhausted) {
|
||||
return false;
|
||||
|
@ -56,6 +57,7 @@ public final class SingleTokenTokenStream extends TokenStream {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
exhausted = false;
|
||||
}
|
||||
|
|
|
@ -39,10 +39,16 @@ public final class EdgeNGramTokenFilter extends TokenFilter {
|
|||
public static enum Side {
|
||||
|
||||
/** Get the n-gram from the front of the input */
|
||||
FRONT { public String getLabel() { return "front"; } },
|
||||
FRONT {
|
||||
@Override
|
||||
public String getLabel() { return "front"; }
|
||||
},
|
||||
|
||||
/** Get the n-gram from the end of the input */
|
||||
BACK { public String getLabel() { return "back"; } };
|
||||
BACK {
|
||||
@Override
|
||||
public String getLabel() { return "back"; }
|
||||
};
|
||||
|
||||
public abstract String getLabel();
|
||||
|
||||
|
@ -117,6 +123,7 @@ public final class EdgeNGramTokenFilter extends TokenFilter {
|
|||
this(input, Side.getSide(sideLabel), minGram, maxGram);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
while (true) {
|
||||
if (curTermBuffer == null) {
|
||||
|
@ -144,6 +151,7 @@ public final class EdgeNGramTokenFilter extends TokenFilter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
curTermBuffer = null;
|
||||
|
|
|
@ -44,10 +44,16 @@ public final class EdgeNGramTokenizer extends Tokenizer {
|
|||
public static enum Side {
|
||||
|
||||
/** Get the n-gram from the front of the input */
|
||||
FRONT { public String getLabel() { return "front"; } },
|
||||
FRONT {
|
||||
@Override
|
||||
public String getLabel() { return "front"; }
|
||||
},
|
||||
|
||||
/** Get the n-gram from the end of the input */
|
||||
BACK { public String getLabel() { return "back"; } };
|
||||
BACK {
|
||||
@Override
|
||||
public String getLabel() { return "back"; }
|
||||
};
|
||||
|
||||
public abstract String getLabel();
|
||||
|
||||
|
@ -174,6 +180,7 @@ public final class EdgeNGramTokenizer extends Tokenizer {
|
|||
}
|
||||
|
||||
/** Returns the next token in the stream, or null at EOS. */
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
clearAttributes();
|
||||
// if we are just starting, read the whole input
|
||||
|
@ -205,17 +212,20 @@ public final class EdgeNGramTokenizer extends Tokenizer {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void end() {
|
||||
// set final offset
|
||||
final int finalOffset = inLen;
|
||||
this.offsetAtt.setOffset(finalOffset, finalOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(Reader input) throws IOException {
|
||||
super.reset(input);
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
started = false;
|
||||
|
|
|
@ -72,6 +72,7 @@ public final class NGramTokenFilter extends TokenFilter {
|
|||
}
|
||||
|
||||
/** Returns the next token in the stream, or null at EOS. */
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
while (true) {
|
||||
if (curTermBuffer == null) {
|
||||
|
@ -98,6 +99,7 @@ public final class NGramTokenFilter extends TokenFilter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
curTermBuffer = null;
|
||||
|
|
|
@ -101,6 +101,7 @@ public final class NGramTokenizer extends Tokenizer {
|
|||
}
|
||||
|
||||
/** Returns the next token in the stream, or null at EOS. */
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
clearAttributes();
|
||||
if (!started) {
|
||||
|
@ -128,17 +129,20 @@ public final class NGramTokenizer extends Tokenizer {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void end() {
|
||||
// set final offset
|
||||
final int finalOffset = inLen;
|
||||
this.offsetAtt.setOffset(finalOffset, finalOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(Reader input) throws IOException {
|
||||
super.reset(input);
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
started = false;
|
||||
|
|
|
@ -188,6 +188,7 @@ public class DutchAnalyzer extends Analyzer {
|
|||
* filtered with {@link StandardFilter}, {@link StopFilter},
|
||||
* and {@link DutchStemFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result = new StandardTokenizer(matchVersion, reader);
|
||||
result = new StandardFilter(result);
|
||||
|
@ -210,6 +211,7 @@ public class DutchAnalyzer extends Analyzer {
|
|||
* filtered with {@link StandardFilter}, {@link StopFilter},
|
||||
* and {@link DutchStemFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
if (overridesTokenStreamMethod) {
|
||||
|
|
|
@ -69,6 +69,7 @@ public final class DutchStemFilter extends TokenFilter {
|
|||
/**
|
||||
* Returns the next token in the stream, or null at EOS
|
||||
*/
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
String term = termAtt.term();
|
||||
|
|
|
@ -59,6 +59,7 @@ public final class DelimitedPayloadTokenFilter extends TokenFilter {
|
|||
this.encoder = encoder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
boolean result = false;
|
||||
if (input.incrementToken()) {
|
||||
|
|
|
@ -48,6 +48,7 @@ public class NumericPayloadTokenFilter extends TokenFilter {
|
|||
typeAtt = addAttribute(TypeAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
if (typeAtt.type().equals(typeMatch))
|
||||
|
|
|
@ -43,6 +43,7 @@ public class TokenOffsetPayloadTokenFilter extends TokenFilter {
|
|||
payAtt = addAttribute(PayloadAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
byte[] data = new byte[8];
|
||||
|
|
|
@ -44,6 +44,7 @@ public class TypeAsPayloadTokenFilter extends TokenFilter {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
String type = typeAtt.type();
|
||||
|
|
|
@ -62,6 +62,7 @@ public final class PositionFilter extends TokenFilter {
|
|||
this.positionIncrement = positionIncrement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
if (firstTokenPositioned) {
|
||||
|
@ -75,6 +76,7 @@ public final class PositionFilter extends TokenFilter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
firstTokenPositioned = false;
|
||||
|
|
|
@ -169,6 +169,7 @@ public class QueryAutoStopWordAnalyzer extends Analyzer {
|
|||
return stopWords.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result;
|
||||
try {
|
||||
|
@ -195,6 +196,7 @@ public class QueryAutoStopWordAnalyzer extends Analyzer {
|
|||
TokenStream withStopFilter;
|
||||
};
|
||||
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
if (overridesTokenStreamMethod) {
|
||||
|
|
|
@ -88,6 +88,7 @@ public final class ReverseStringFilter extends TokenFilter {
|
|||
termAtt = addAttribute(TermAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
int len = termAtt.termLength();
|
||||
|
|
|
@ -97,6 +97,7 @@ public final class RussianAnalyzer extends Analyzer
|
|||
* {@link RussianLowerCaseFilter}, {@link StopFilter},
|
||||
* and {@link RussianStemFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader)
|
||||
{
|
||||
TokenStream result = new RussianLetterTokenizer(reader);
|
||||
|
@ -121,6 +122,7 @@ public final class RussianAnalyzer extends Analyzer
|
|||
* {@link RussianLowerCaseFilter}, {@link StopFilter},
|
||||
* and {@link RussianStemFilter}
|
||||
*/
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -49,6 +49,7 @@ public class RussianLetterTokenizer extends CharTokenizer
|
|||
* Collects only characters which satisfy
|
||||
* {@link Character#isLetter(char)}.
|
||||
*/
|
||||
@Override
|
||||
protected boolean isTokenChar(char c)
|
||||
{
|
||||
if (Character.isLetter(c) || (c >= '0' && c <= '9'))
|
||||
|
|
|
@ -39,6 +39,7 @@ public final class RussianLowerCaseFilter extends TokenFilter
|
|||
termAtt = addAttribute(TermAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException
|
||||
{
|
||||
if (input.incrementToken()) {
|
||||
|
|
|
@ -51,6 +51,7 @@ public final class RussianStemFilter extends TokenFilter
|
|||
/**
|
||||
* Returns the next token in the stream, or null at EOS
|
||||
*/
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException
|
||||
{
|
||||
if (input.incrementToken()) {
|
||||
|
|
|
@ -98,6 +98,7 @@ public class ShingleAnalyzerWrapper extends Analyzer {
|
|||
this.outputUnigrams = outputUnigrams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream wrapped;
|
||||
try {
|
||||
|
@ -116,6 +117,7 @@ public class ShingleAnalyzerWrapper extends Analyzer {
|
|||
ShingleFilter shingle;
|
||||
};
|
||||
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
|
||||
if (overridesTokenStreamMethod) {
|
||||
// LUCENE-1678: force fallback to tokenStream() if we
|
||||
|
|
|
@ -163,6 +163,7 @@ public final class ShingleFilter extends TokenFilter {
|
|||
/* (non-Javadoc)
|
||||
* @see org.apache.lucene.analysis.TokenStream#next()
|
||||
*/
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
while (true) {
|
||||
if (nextToken == null) {
|
||||
|
@ -328,6 +329,7 @@ public final class ShingleFilter extends TokenFilter {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
nextToken = null;
|
||||
|
|
|
@ -345,6 +345,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
private Set<List<Token>> shinglesSeen = new HashSet<List<Token>>();
|
||||
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
permutations = null;
|
||||
shinglesSeen.clear();
|
||||
|
@ -355,6 +356,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
|
||||
private Token reusableToken = new Token();
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (matrix == null) {
|
||||
matrix = new Matrix();
|
||||
|
@ -743,6 +745,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
return Matrix.this.columns.indexOf(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Column{" +
|
||||
"first=" + first +
|
||||
|
@ -807,6 +810,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
// return ret;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Row{" +
|
||||
"index=" + getIndex() +
|
||||
|
@ -863,6 +867,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Matrix{" +
|
||||
"columns=" + columns +
|
||||
|
@ -920,17 +925,21 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
*/
|
||||
public static class OneDimensionalNonWeightedTokenSettingsCodec extends TokenSettingsCodec {
|
||||
|
||||
@Override
|
||||
public TokenPositioner getTokenPositioner(Token token) throws IOException {
|
||||
return TokenPositioner.newColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTokenPositioner(Token token, TokenPositioner tokenPositioner) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWeight(Token token) {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeight(Token token, float weight) {
|
||||
}
|
||||
|
||||
|
@ -944,6 +953,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
*/
|
||||
public static class TwoDimensionalNonWeightedSynonymTokenSettingsCodec extends TokenSettingsCodec {
|
||||
|
||||
@Override
|
||||
public TokenPositioner getTokenPositioner(Token token) throws IOException {
|
||||
if (token.getPositionIncrement() == 0) {
|
||||
return TokenPositioner.newRow;
|
||||
|
@ -952,14 +962,17 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTokenPositioner(Token token, TokenPositioner tokenPositioner) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWeight(Token token) {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeight(Token token, float weight) {
|
||||
}
|
||||
|
||||
|
@ -981,6 +994,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
* @return the token flags int value as TokenPosition
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public TokenPositioner getTokenPositioner(Token token) throws IOException {
|
||||
switch (token.getFlags()) {
|
||||
case 0:
|
||||
|
@ -999,6 +1013,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
* @param token
|
||||
* @param tokenPositioner
|
||||
*/
|
||||
@Override
|
||||
public void setTokenPositioner(Token token, TokenPositioner tokenPositioner) {
|
||||
token.setFlags(tokenPositioner.getIndex());
|
||||
}
|
||||
|
@ -1009,6 +1024,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
* @param token
|
||||
* @return 32 bit float
|
||||
*/
|
||||
@Override
|
||||
public float getWeight(Token token) {
|
||||
if (token.getPayload() == null || token.getPayload().getData() == null) {
|
||||
return 1f;
|
||||
|
@ -1022,6 +1038,7 @@ public final class ShingleMatrixFilter extends TokenStream {
|
|||
* @param token
|
||||
* @param weight
|
||||
*/
|
||||
@Override
|
||||
public void setWeight(Token token, float weight) {
|
||||
if (weight == 1f) {
|
||||
token.setPayload(null);
|
||||
|
|
|
@ -49,6 +49,7 @@ public class DateRecognizerSinkFilter extends SinkFilter {
|
|||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(AttributeSource source) {
|
||||
if (termAtt == null) {
|
||||
termAtt = source.addAttribute(TermAttribute.class);
|
||||
|
|
|
@ -37,6 +37,7 @@ public class TokenRangeSinkFilter extends SinkFilter {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean accept(AttributeSource source) {
|
||||
try {
|
||||
if (count >= lower && count < upper){
|
||||
|
@ -48,6 +49,7 @@ public class TokenRangeSinkFilter extends SinkFilter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
count = 0;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class TokenTypeSinkFilter extends SinkFilter {
|
|||
this.typeToMatch = typeToMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(AttributeSource source) {
|
||||
if (typeAtt == null) {
|
||||
typeAtt = source.addAttribute(TypeAttribute.class);
|
||||
|
|
|
@ -43,6 +43,7 @@ public class ThaiAnalyzer extends Analyzer {
|
|||
this.matchVersion = matchVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream ts = new StandardTokenizer(matchVersion, reader);
|
||||
ts = new StandardFilter(ts);
|
||||
|
@ -57,6 +58,7 @@ public class ThaiAnalyzer extends Analyzer {
|
|||
TokenStream result;
|
||||
};
|
||||
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
|
||||
if (overridesTokenStreamMethod) {
|
||||
// LUCENE-1678: force fallback to tokenStream() if we
|
||||
|
|
|
@ -48,6 +48,7 @@ public final class ThaiWordFilter extends TokenFilter {
|
|||
offsetAtt = addAttribute(OffsetAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (thaiState != null) {
|
||||
int start = breaker.current();
|
||||
|
@ -82,6 +83,7 @@ public final class ThaiWordFilter extends TokenFilter {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
thaiState = null;
|
||||
|
|
|
@ -65,6 +65,7 @@ public class TestChineseTokenizer extends BaseTokenStreamTestCase
|
|||
* convenience to show the behavior of the tokenizer
|
||||
*/
|
||||
private class JustChineseTokenizerAnalyzer extends Analyzer {
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new ChineseTokenizer(reader);
|
||||
}
|
||||
|
@ -75,6 +76,7 @@ public class TestChineseTokenizer extends BaseTokenStreamTestCase
|
|||
* convenience to show the behavior of the filter.
|
||||
*/
|
||||
private class JustChineseFilterAnalyzer extends Analyzer {
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new ChineseFilter(new WhitespaceTokenizer(reader));
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ public class TestCompoundWordTokenFilter extends BaseTokenStreamTestCase {
|
|||
|
||||
private static byte[] patternsFileContent;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
getHyphenationPatternFileContents();
|
||||
|
|
|
@ -51,6 +51,7 @@ public class TestCzechAnalyzer extends BaseTokenStreamTestCase {
|
|||
* An input stream that always throws IOException for testing.
|
||||
*/
|
||||
private class UnreliableInputStream extends InputStream {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
throw new IOException();
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public class TestGermanStemFilter extends BaseTokenStreamTestCase {
|
|||
super(matchVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new WhitespaceTokenizer(reader);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.io.StringReader;
|
|||
public class EdgeNGramTokenFilterTest extends BaseTokenStreamTestCase {
|
||||
private TokenStream input;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
input = new WhitespaceTokenizer(new StringReader("abcde"));
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.lucene.analysis.BaseTokenStreamTestCase;
|
|||
public class EdgeNGramTokenizerTest extends BaseTokenStreamTestCase {
|
||||
private StringReader input;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
input = new StringReader("abcde");
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.io.StringReader;
|
|||
public class NGramTokenFilterTest extends BaseTokenStreamTestCase {
|
||||
private TokenStream input;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
input = new WhitespaceTokenizer(new StringReader("abcde"));
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.lucene.analysis.BaseTokenStreamTestCase;
|
|||
public class NGramTokenizerTest extends BaseTokenStreamTestCase {
|
||||
private StringReader input;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
input = new StringReader("abcde");
|
||||
|
|
|
@ -134,6 +134,7 @@ public class TestDutchStemmer extends BaseTokenStreamTestCase {
|
|||
public DutchSubclassAnalyzer(Version matchVersion) {
|
||||
super(matchVersion);
|
||||
}
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new WhitespaceTokenizer(reader);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public class NumericPayloadTokenFilterTest extends BaseTokenStreamTestCase {
|
|||
typeAtt = addAttribute(TypeAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
if (termAtt.term().equals("dogs"))
|
||||
|
|
|
@ -65,6 +65,7 @@ public class TypeAsPayloadTokenFilterTest extends BaseTokenStreamTestCase {
|
|||
typeAtt = addAttribute(TypeAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (input.incrementToken()) {
|
||||
typeAtt.setType(String.valueOf(Character.toUpperCase(termAtt.termBuffer()[0])));
|
||||
|
|
|
@ -38,6 +38,7 @@ public class PositionFilterTest extends BaseTokenStreamTestCase {
|
|||
termAtt = addAttribute(TermAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
clearAttributes();
|
||||
if (index < testToken.length) {
|
||||
|
@ -47,6 +48,7 @@ public class PositionFilterTest extends BaseTokenStreamTestCase {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void reset() {
|
||||
index = 0;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public class QueryAutoStopWordAnalyzerTest extends BaseTokenStreamTestCase {
|
|||
IndexReader reader;
|
||||
QueryAutoStopWordAnalyzer protectedAnalyzer;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
dir = new RAMDirectory();
|
||||
|
@ -66,6 +67,7 @@ public class QueryAutoStopWordAnalyzerTest extends BaseTokenStreamTestCase {
|
|||
protectedAnalyzer = new QueryAutoStopWordAnalyzer(Version.LUCENE_CURRENT, appAnalyzer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
reader.close();
|
||||
super.tearDown();
|
||||
|
@ -154,6 +156,7 @@ public class QueryAutoStopWordAnalyzerTest extends BaseTokenStreamTestCase {
|
|||
super(matchVersion, new WhitespaceAnalyzer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new WhitespaceTokenizer(reader);
|
||||
}
|
||||
|
@ -172,6 +175,7 @@ public class QueryAutoStopWordAnalyzerTest extends BaseTokenStreamTestCase {
|
|||
*/
|
||||
private class NonreusableAnalyzer extends Analyzer {
|
||||
int invocationCount = 0;
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
if (++invocationCount % 2 == 0)
|
||||
return new WhitespaceTokenizer(reader);
|
||||
|
|
|
@ -42,6 +42,7 @@ public class TestRussianAnalyzer extends BaseTokenStreamTestCase
|
|||
|
||||
private File dataDir;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
|
|
@ -37,6 +37,7 @@ public class TestRussianStem extends LuceneTestCase
|
|||
/**
|
||||
* @see TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
@ -73,6 +74,7 @@ public class TestRussianStem extends LuceneTestCase
|
|||
/**
|
||||
* @see TestCase#tearDown()
|
||||
*/
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
|
|
|
@ -221,6 +221,7 @@ public class ShingleAnalyzerWrapperTest extends BaseTokenStreamTestCase {
|
|||
super(org.apache.lucene.util.Version.LUCENE_CURRENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new WhitespaceTokenizer(reader);
|
||||
}
|
||||
|
@ -240,6 +241,7 @@ public class ShingleAnalyzerWrapperTest extends BaseTokenStreamTestCase {
|
|||
*/
|
||||
private class NonreusableAnalyzer extends Analyzer {
|
||||
int invocationCount = 0;
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
if (++invocationCount % 2 == 0)
|
||||
return new WhitespaceTokenizer(reader);
|
||||
|
|
|
@ -48,6 +48,7 @@ public class ShingleFilterTest extends BaseTokenStreamTestCase {
|
|||
this.typeAtt = addAttribute(TypeAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
clearAttributes();
|
||||
if (index < testToken.length) {
|
||||
|
@ -201,6 +202,7 @@ public class ShingleFilterTest extends BaseTokenStreamTestCase {
|
|||
};
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
testTokenWithHoles = new Token[] {
|
||||
|
|
|
@ -537,6 +537,7 @@ public class TestShingleMatrixFilter extends BaseTokenStreamTestCase {
|
|||
|
||||
private Iterator iterator;
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (iterator == null) {
|
||||
iterator = tokens.iterator();
|
||||
|
@ -556,6 +557,7 @@ public class TestShingleMatrixFilter extends BaseTokenStreamTestCase {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
iterator = null;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public class TokenTypeSinkTokenizerTest extends BaseTokenStreamTestCase {
|
|||
typeAtt = addAttribute(TypeAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean incrementToken() throws IOException {
|
||||
if (!input.incrementToken()) return false;
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ public class TestThaiAnalyzer extends BaseTokenStreamTestCase {
|
|||
public ThaiSubclassAnalyzer(Version matchVersion) {
|
||||
super(matchVersion);
|
||||
}
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new WhitespaceTokenizer(reader);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ public final class SentenceTokenizer extends Tokenizer {
|
|||
typeAtt = addAttribute(TypeAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
clearAttributes();
|
||||
buffer.setLength(0);
|
||||
|
@ -122,11 +123,13 @@ public final class SentenceTokenizer extends Tokenizer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
tokenStart = tokenEnd = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(Reader input) throws IOException {
|
||||
super.reset(input);
|
||||
reset();
|
||||
|
|
|
@ -144,6 +144,7 @@ public class SmartChineseAnalyzer extends Analyzer {
|
|||
this.matchVersion = matchVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
TokenStream result = new SentenceTokenizer(reader);
|
||||
result = new WordTokenFilter(result);
|
||||
|
@ -163,6 +164,7 @@ public class SmartChineseAnalyzer extends Analyzer {
|
|||
TokenStream filteredTokenStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TokenStream reusableTokenStream(String fieldName, Reader reader)
|
||||
throws IOException {
|
||||
SavedStreams streams = (SavedStreams) getPreviousTokenStream();
|
||||
|
|
|
@ -61,6 +61,7 @@ public final class WordTokenFilter extends TokenFilter {
|
|||
typeAtt = addAttribute(TypeAttribute.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean incrementToken() throws IOException {
|
||||
if (tokenIter == null || !tokenIter.hasNext()) {
|
||||
// there are no remaining tokens from the current sentence... are there more sentences?
|
||||
|
@ -88,6 +89,7 @@ public final class WordTokenFilter extends TokenFilter {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
super.reset();
|
||||
tokenIter = null;
|
||||
|
|
|
@ -221,6 +221,7 @@ class BiSegGraph {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Collection<ArrayList<SegTokenPair>> values = tokenPairListTable.values();
|
||||
|
|
|
@ -45,6 +45,7 @@ class PathNode implements Comparable<PathNode> {
|
|||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
|
@ -58,6 +59,7 @@ class PathNode implements Comparable<PathNode> {
|
|||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
|
|
@ -136,6 +136,7 @@ class SegGraph {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
List<SegToken> tokenList = this.toTokenList();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
|
@ -80,6 +80,7 @@ public class SegToken {
|
|||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
|
@ -97,6 +98,7 @@ public class SegToken {
|
|||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
|
|
@ -53,6 +53,7 @@ class SegTokenPair {
|
|||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
|
@ -70,6 +71,7 @@ class SegTokenPair {
|
|||
/**
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
|
|
@ -53,10 +53,12 @@ public class DocumentHandlerException extends Exception {
|
|||
return cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace() {
|
||||
printStackTrace(System.err);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace(PrintStream ps) {
|
||||
synchronized (ps) {
|
||||
super.printStackTrace(ps);
|
||||
|
@ -67,6 +69,7 @@ public class DocumentHandlerException extends Exception {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace(PrintWriter pw) {
|
||||
synchronized (pw) {
|
||||
super.printStackTrace(pw);
|
||||
|
|
|
@ -220,6 +220,7 @@ public class IndexTask extends Task {
|
|||
*@exception BuildException If an error occurs indexing the
|
||||
* fileset
|
||||
*/
|
||||
@Override
|
||||
public void execute() throws BuildException {
|
||||
|
||||
// construct handler and analyzer dynamically
|
||||
|
@ -426,6 +427,7 @@ public class IndexTask extends Task {
|
|||
/**
|
||||
* @see EnumeratedAttribute#getValues
|
||||
*/
|
||||
@Override
|
||||
public String[] getValues() {
|
||||
Set keys = analyzerLookup.keySet();
|
||||
return (String[]) keys.toArray(new String[0]);
|
||||
|
|
|
@ -30,6 +30,7 @@ public class HtmlDocumentTest extends DocumentTestCase
|
|||
|
||||
HtmlDocument doc;
|
||||
|
||||
@Override
|
||||
public void setUp() throws IOException {
|
||||
doc = new HtmlDocument(getFile("test.html"));
|
||||
}
|
||||
|
@ -39,6 +40,7 @@ public class HtmlDocumentTest extends DocumentTestCase
|
|||
assertTrue("Body", doc.getBody().startsWith("This is some test"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() {
|
||||
doc = null;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ public class IndexTaskTest extends TestCase {
|
|||
*
|
||||
*@exception IOException Description of Exception
|
||||
*/
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
Project project = new Project();
|
||||
|
||||
|
@ -86,6 +87,7 @@ public class IndexTaskTest extends TestCase {
|
|||
* The teardown method for JUnit
|
||||
* TODO: remove indexDir?
|
||||
*/
|
||||
@Override
|
||||
public void tearDown() throws IOException {
|
||||
searcher.close();
|
||||
dir.close();
|
||||
|
|
|
@ -30,6 +30,7 @@ public class TextDocumentTest extends DocumentTestCase
|
|||
|
||||
TextDocument doc;
|
||||
|
||||
@Override
|
||||
public void setUp() throws IOException {
|
||||
doc = new TextDocument(getFile("test.txt"));
|
||||
}
|
||||
|
@ -38,6 +39,7 @@ public class TextDocumentTest extends DocumentTestCase
|
|||
assertEquals("Contents", "Test Contents", doc.getContents());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() {
|
||||
doc = null;
|
||||
}
|
||||
|
|
|
@ -174,10 +174,12 @@ public class DirContentSource extends ContentSource {
|
|||
return dfi.df.parse(dateStr.trim(), dfi.pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
inputFiles = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocData getNextDocData(DocData docData) throws NoMoreDataException, IOException {
|
||||
File f = null;
|
||||
String name = null;
|
||||
|
@ -219,12 +221,14 @@ public class DirContentSource extends ContentSource {
|
|||
return docData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void resetInputs() throws IOException {
|
||||
super.resetInputs();
|
||||
inputFiles = new Iterator(dataDir);
|
||||
iteration = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(Config config) {
|
||||
super.setConfig(config);
|
||||
|
||||
|
|
|
@ -103,10 +103,12 @@ public class EnwikiContentSource extends ContentSource {
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) {
|
||||
contents.append(ch, start, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String namespace, String simple, String qualified)
|
||||
throws SAXException {
|
||||
int elemType = getElementType(qualified);
|
||||
|
@ -197,6 +199,7 @@ public class EnwikiContentSource extends ContentSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String namespace, String simple, String qualified,
|
||||
Attributes attributes) {
|
||||
int elemType = getElementType(qualified);
|
||||
|
@ -257,6 +260,7 @@ public class EnwikiContentSource extends ContentSource {
|
|||
private InputStream is;
|
||||
private Parser parser = new Parser();
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
synchronized (EnwikiContentSource.this) {
|
||||
if (is != null) {
|
||||
|
@ -266,6 +270,7 @@ public class EnwikiContentSource extends ContentSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized DocData getNextDocData(DocData docData) throws NoMoreDataException, IOException {
|
||||
String[] tuple = parser.next();
|
||||
docData.clear();
|
||||
|
@ -276,11 +281,13 @@ public class EnwikiContentSource extends ContentSource {
|
|||
return docData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetInputs() throws IOException {
|
||||
super.resetInputs();
|
||||
is = getInputStream(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(Config config) {
|
||||
super.setConfig(config);
|
||||
keepImages = config.get("keep.image.only.docs", true);
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.lucene.benchmark.byTask.utils.Config;
|
|||
* @deprecated Please use {@link DocMaker} instead, with content.source=EnwikiContentSource
|
||||
*/
|
||||
public class EnwikiDocMaker extends DocMaker {
|
||||
@Override
|
||||
public void setConfig(Config config) {
|
||||
super.setConfig(config);
|
||||
// Override whatever content source was set in the config
|
||||
|
|
|
@ -122,6 +122,7 @@ public class EnwikiQueryMaker extends AbstractQueryMaker implements
|
|||
return queries.toArray(new Query[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Query[] prepareQueries() throws Exception {
|
||||
// analyzer (default is standard analyzer)
|
||||
Analyzer anlzr = NewAnalyzerTask.createAnalyzer(config.get("analyzer", StandardAnalyzer.class.getName()));
|
||||
|
|
|
@ -44,6 +44,7 @@ import java.util.List;
|
|||
public class FileBasedQueryMaker extends AbstractQueryMaker implements QueryMaker{
|
||||
|
||||
|
||||
@Override
|
||||
protected Query[] prepareQueries() throws Exception {
|
||||
|
||||
Analyzer anlzr = NewAnalyzerTask.createAnalyzer(config.get("analyzer",
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.lucene.benchmark.byTask.utils.Config;
|
|||
* @deprecated Please use {@link DocMaker} instead, with content.source=LineDocSource
|
||||
*/
|
||||
public class LineDocMaker extends DocMaker {
|
||||
@Override
|
||||
public void setConfig(Config config) {
|
||||
super.setConfig(config);
|
||||
source = new LineDocSource();
|
||||
|
|
|
@ -61,6 +61,7 @@ public class LineDocSource extends ContentSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
|
@ -68,6 +69,7 @@ public class LineDocSource extends ContentSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocData getNextDocData(DocData docData) throws NoMoreDataException, IOException {
|
||||
String line;
|
||||
synchronized(this) {
|
||||
|
@ -100,11 +102,13 @@ public class LineDocSource extends ContentSource {
|
|||
return docData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetInputs() throws IOException {
|
||||
super.resetInputs();
|
||||
openFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(Config config) {
|
||||
super.setConfig(config);
|
||||
String fileName = config.get("docs.file", null);
|
||||
|
|
|
@ -53,6 +53,7 @@ public class ReutersContentSource extends ContentSource {
|
|||
private int nextFile = 0;
|
||||
private int iteration = 0;
|
||||
|
||||
@Override
|
||||
public void setConfig(Config config) {
|
||||
super.setConfig(config);
|
||||
File workDir = new File(config.get("work.dir", "work"));
|
||||
|
@ -89,10 +90,12 @@ public class ReutersContentSource extends ContentSource {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// TODO implement?
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocData getNextDocData(DocData docData) throws NoMoreDataException, IOException {
|
||||
File f = null;
|
||||
String name = null;
|
||||
|
@ -138,6 +141,7 @@ public class ReutersContentSource extends ContentSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void resetInputs() throws IOException {
|
||||
super.resetInputs();
|
||||
nextFile = 0;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue