Apache Solr open-source search software
LUCENE-9782: Hunspell suggestions: split by space (but not dash) also before last char (#2387)
Peter Gromov589eefc32b29
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/ModifyingSuggester.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/ModifyingSuggester.javaindex 5017ff28a46..86b6fc5a869 100644--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/ModifyingSuggester.java+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/ModifyingSuggester.java@@ -302,12 +302,12 @@ class ModifyingSuggester {}private void trySplitting(String word) {- for (int i = 1; i < word.length() - 1; i++) {+ for (int i = 1; i < word.length(); i++) {String w1 = word.substring(0, i);String w2 = word.substring(i);if (checkSimpleWord(w1) && checkSimpleWord(w2)) {result.add(w1 + " " + w2);- if (shouldSplitByDash()) {+ if (w1.length() > 1 && w2.length() > 1 && shouldSplitByDash()) {result.add(w1 + "-" + w2);}}diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.aff b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.affindex 8f150cdf4cd..a963c96d43b 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.aff+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.aff@@ -13,6 +13,7 @@# switch off ngram suggestion for testingMAXNGRAMSUGS 0+TRY -REP 2REP alot a_lotREP inspite in_spitediff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.sug b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.sugindex bea54b8f02f..9df0cb5f13b 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.sug+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.sug@@ -11,5 +11,5 @@ whichGandhiMcDonaldpermanent-+in, in adiff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.wrong b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.wrongindex 0093de893ab..470d6f5f766 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.wrong+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/sug.wrong@@ -13,3 +13,4 @@ Mcdonaldpermqnentpermanent-vacationpermqnent-vacation+ina\ No newline at end of file