From 32fb624ebca6cd627877c69c8836fd3d0549e633 Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Thu, 22 Sep 2005 13:38:58 +0000 Subject: [PATCH] LUCENE-437 - Add position increment pass through on SnowballFilter tokens git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@290943 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 +++ .../analysis/snowball/SnowballFilter.java | 7 +++-- .../analysis/snowball/TestSnowball.java | 28 +++++++++++++++++-- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 4d5979c9308..c1475ea531a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -213,6 +213,10 @@ Bug fixes inside a BooleanQuery. (Hans Hjelm and Scotty Allen via Daniel Naber, Bug #35626) +11. Fixed SnowballFilter to pass through the position increment from + the original token. + (Yonik Seeley via Erik Hatcher, LUCENE-437) + Optimizations 1. Disk usage (peak requirements during indexing and optimization) diff --git a/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java b/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java index bbb39f9b636..5385719ca09 100644 --- a/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java +++ b/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java @@ -69,7 +69,10 @@ public class SnowballFilter extends TokenFilter { } catch (Exception e) { throw new RuntimeException(e.toString()); } - return new Token(stemmer.getCurrent(), - token.startOffset(), token.endOffset(), token.type()); + + Token newToken = new Token(stemmer.getCurrent(), + token.startOffset(), token.endOffset(), token.type()); + newToken.setPositionIncrement(token.getPositionIncrement()); + return newToken; } } diff --git a/contrib/snowball/src/test/org/apache/lucene/analysis/snowball/TestSnowball.java b/contrib/snowball/src/test/org/apache/lucene/analysis/snowball/TestSnowball.java index 581b7898529..f7d9681ce20 100644 --- a/contrib/snowball/src/test/org/apache/lucene/analysis/snowball/TestSnowball.java +++ b/contrib/snowball/src/test/org/apache/lucene/analysis/snowball/TestSnowball.java @@ -55,6 +55,7 @@ package org.apache.lucene.analysis.snowball; */ import java.io.*; + import junit.framework.*; import org.apache.lucene.analysis.*; @@ -65,7 +66,7 @@ public class TestSnowball extends TestCase { String input, String[] output) throws Exception { TokenStream ts = a.tokenStream("dummy", new StringReader(input)); - for (int i=0; i