Skip to content

Apache Lucene open-source search software

LUCENE-9833: Hunspell: AssertionError in WordStorage.lookupWord (#13)

Peter Gromove784721e6973
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 e135fb6ed0f..8f90a416bb4 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
@@ -132,6 +132,7 @@ class ModifyingSuggester {
int before = result.size();
for (RepEntry entry : speller.dictionary.repTable) {
for (String candidate : entry.substitute(word)) {
+ candidate = candidate.trim();
if (trySuggestion(candidate)) {
continue;
}
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.aff b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.aff
index 485755c8983..ff5f395c5b2 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.aff
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.aff
@@ -3,7 +3,7 @@
# switch off ngram suggestion for testing
MAXNGRAMSUGS 0
-REP 8
+REP 9
REP f ph
REP ph f
REP shun$ tion
@@ -12,7 +12,9 @@ REP ^foo$ bar
REP ' _ # "un'alunno" -> "un alunno"
REP ^vinte�n$ vinte_e_un
REP s 's
+REP - _ # art-nouveau -> art nouveau
+BREAK 0
SFX A Y 1
SFX A 0 's .
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.dic b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.dic
index f9a4c008b0a..8d6be3416b9 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.dic
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.dic
@@ -1,4 +1,4 @@
-10
+15
form
phantom
vacation
@@ -13,3 +13,5 @@ vinte
e
un
auto/A
+art nouveau
+nouveau
\ No newline at end of file
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.sug b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.sug
index b48a5b80eb0..ec15195da6a 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.sug
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.sug
@@ -6,3 +6,5 @@ un alunno
bar
vinte e un
auto's, auto
+art nouveau
+nouveau
\ No newline at end of file
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.wrong b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.wrong
index b3254ac064e..1184a385572 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.wrong
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/rep.wrong
@@ -9,3 +9,5 @@ foobars
barfoos
vinteún
autos
+art-nouveau
+-nouveau
\ No newline at end of file