Apache Lucene open-source search software
don't lookup empty stems after stripping the whole word
Peter Gromove69390b268e3
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.javaindex 40ad17c609f..488adfd2b44 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Stemmer.java@@ -488,6 +488,8 @@ final class Stemmer {int stripEnd = dictionary.stripOffsets[stripOrd + 1];int stripLen = stripEnd - stripStart;+ if (stripLen + deAffixedLen == 0) return null;+char[] stripData = dictionary.stripData;int condition = dictionary.getAffixCondition(affix);if (condition != 0) {diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestFullStrip.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestFullStrip.javaindex 3634a83c9fa..7f48d7d6285 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestFullStrip.java+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestFullStrip.java@@ -26,5 +26,7 @@ public class TestFullStrip extends StemmerTestBase {public void testStemming() {assertStemsTo("tasty", "beer");+ assertStemsTo("as", "a");+ assertStemsTo("s");}}diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/fullstrip.aff b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/fullstrip.affindex 9c2de7f7cff..2cf00cd9d30 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/fullstrip.aff+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/fullstrip.aff@@ -4,3 +4,6 @@ FULLSTRIPSFX A Y 1SFX A beer tasty .++SFX S Y 1+SFX S 0 s .\ No newline at end of filediff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/fullstrip.dic b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/fullstrip.dicindex c948f184635..8f594e355af 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/fullstrip.dic+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/fullstrip.dic@@ -1,2 +1,3 @@-1+2beer/A+a/S\ No newline at end of file