LUCENE-1320

ShingleMatrixFilter, a multidimensional shingle token filter.

Bug fix, did not support empty input token streams.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@674367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Karl-Johan Wettin 2008-07-07 00:08:41 +00:00
parent dc65b35533
commit ddc7c290d0
2 changed files with 9 additions and 1 deletions

View File

@ -719,7 +719,7 @@ public class ShingleMatrixFilter extends TokenStream {
public boolean hasNext() {
int s = columnRowCounters.length;
return columnRowCounters[s - 1] < columns.get(s - 1).getRows().size();
return s != 0 && columnRowCounters[s - 1] < columns.get(s - 1).getRows().size();
}
public Column.Row[] next() {

View File

@ -22,6 +22,7 @@ import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.miscellaneous.PrefixAndSuffixAwareTokenFilter;
import org.apache.lucene.analysis.miscellaneous.SingleTokenTokenStream;
import org.apache.lucene.analysis.miscellaneous.EmptyTokenStream;
import org.apache.lucene.analysis.payloads.PayloadHelper;
import org.apache.lucene.analysis.shingle.ShingleMatrixFilter.Matrix;
import org.apache.lucene.analysis.shingle.ShingleMatrixFilter.Matrix.Column;
@ -42,7 +43,14 @@ public class TestShingleMatrixFilter extends TestCase {
Token token = new Token(); // for debug use only
TokenStream ts;
ts = new ShingleMatrixFilter(new EmptyTokenStream(), 1, 2, ' ', false, new ShingleMatrixFilter.OneDimensionalNonWeightedTokenSettingsCodec());
assertNull(ts.next());
TokenListStream tls;
LinkedList<Token> tokens;