Skip to content

armgit / solr

Public Imported from GitHub
0

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.java
index 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.aff
index 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 testing
MAXNGRAMSUGS 0
+TRY -
REP 2
REP alot a_lot
REP inspite in_spite
diff --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.sug
index 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 @@ which
Gandhi
McDonald
permanent
-
+in, in a
diff --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.wrong
index 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 @@ Mcdonald
permqnent
permanent-vacation
permqnent-vacation
+ina
\ No newline at end of file