Apache Solr open-source search software
LUCENE-9785: Hunspell: don't check case in compound middle and end (#2398)
Peter Gromov31a64927a46f
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.javaindex 1f1f9ba77d5..76db921dbb4 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Hunspell.java@@ -160,6 +160,7 @@ public class Hunspell {private Root<CharsRef> findStem(char[] wordChars, int offset, int length, WordCase originalCase, WordContext context) {checkCanceled.run();+ boolean checkCase = context != COMPOUND_MIDDLE && context != COMPOUND_END;@SuppressWarnings({"rawtypes", "unchecked"})Root<CharsRef>[] result = new Root[1];stemmer.doStem(@@ -168,7 +169,7 @@ public class Hunspell {length,context,(stem, formID, morphDataId) -> {- if (!acceptCase(originalCase, formID, stem)) {+ if (checkCase && !acceptCase(originalCase, formID, stem)) {return dictionary.hasFlag(formID, Dictionary.HIDDEN_FLAG);}if (acceptsStem(formID)) {diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.aff b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.affindex 4b569503842..215e53cc521 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.aff+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.aff@@ -4,3 +4,5 @@ KEEPCASE ZSFX X Y 1SFX X 0 s . +s++COMPOUNDFLAG Cdiff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.dic b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.dicindex 4d497dc5d46..07c826dba43 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.dic+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.dic@@ -1,4 +1,4 @@-9+11drink/Xwalk/XZtest/Z@@ -8,3 +8,6 @@ baz./ZQuux./Zway/Xways/Z+tvv/ZC+school/C+uni/ZCdiff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.good b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.goodindex 795112ed313..bb8c7888bbf 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.good+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.good@@ -5,4 +5,8 @@ Quux.wayWayWAY-ways\ No newline at end of file+ways+schooltvv+Schooltvv+SCHOOLTVV+unitvv\ No newline at end of filediff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.sug b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.sugindex e4cb7fad151..3052b2d7360 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.sug+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.sug@@ -6,4 +6,6 @@ baz.baz.Quux.Quux.-Way\ No newline at end of file+Way+unitvv, Uni tvv, uni+unitvv, UNI TVV, uni\ No newline at end of filediff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.wrong b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.wrongindex 1986f6d49f8..9807992ce8d 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.wrong+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/keepcase.wrong@@ -7,3 +7,5 @@ BAZ.quux.QUUX.Ways+Unitvv+UNITVV