Apache Solr open-source search software
LUCENE-9772: Hunspell: CHECKCOMPOUNDCASE shouldn't prohibit dash-separated uppercase compounds (#2370)
Peter Gromov1ff11dd02c59
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 3286f86c1b0..99884218d25 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@@ -336,7 +336,9 @@ public class Hunspell {private boolean mayBreakIntoCompounds(char[] chars, int offset, int length, int breakPos) {if (dictionary.checkCompoundCase) {- if (Character.isUpperCase(chars[breakPos - 1]) || Character.isUpperCase(chars[breakPos])) {+ char a = chars[breakPos - 1];+ char b = chars[breakPos];+ if ((Character.isUpperCase(a) || Character.isUpperCase(b)) && a != '-' && b != '-') {return false;}}diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.aff b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.affindex 7ac46eeab7c..006739d211f 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.aff+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.aff@@ -1,3 +1,4 @@# forbid upper case letters at word bounds in compoundingCHECKCOMPOUNDCASE+WORDCHARS -COMPOUNDFLAG Adiff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.dic b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.dicindex 80f65d38f60..6bdbbbab945 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.dic+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.dic@@ -1,5 +1,6 @@-4+5foo/ABar/ABAZ/A-/A+prefix-/A\ No newline at end of filediff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.good b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.goodindex 9cbd79064dd..a2dfe5bbdf5 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.good+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/checkcompoundcase.good@@ -3,3 +3,4 @@ foo-Barfoo-BAZBAZ-fooBAZ-Bar+prefix-BAZ\ No newline at end of file