Apache Solr open-source search software
LUCENE-9764: Hunspell: try title case as FORCEUCASE misspelled word suggestions (#2352)
Peter Gromov01e34f872355
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.javaindex 97dea149a51..11c05406d07 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/SpellChecker.java@@ -430,6 +430,13 @@ public class SpellChecker {}WordCase wordCase = WordCase.caseOf(word);+ if (dictionary.forceUCase != FLAG_UNSET && wordCase == WordCase.LOWER) {+ String title = dictionary.toTitleCase(word);+ if (spell(title)) {+ return Collections.singletonList(title);+ }+ }+SpellChecker suggestionSpeller =new SpellChecker(dictionary) {@Overridediff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/forceucase.sug b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/forceucase.sugnew file mode 100644index 00000000000..6a77cbd06d0--- /dev/null+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/forceucase.sug@@ -0,0 +1,2 @@+Foobaz+Foobarbaz