Skip to content

Apache Lucene open-source search software

SOLR-4452: Fix test for case insensitive mode

Jan Høydahl7790f8e09218
diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellDictionary.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellDictionary.java
index 95a6aed665a..ccb53f57d29 100644
--- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellDictionary.java
+++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellDictionary.java
@@ -378,11 +378,11 @@ public class HunspellDictionary {
wordForm = new HunspellWord(flagParsingStrategy.parseFlags(flagPart));
Arrays.sort(wordForm.getFlags());
entry = line.substring(0, flagSep);
- if(ignoreCase) {
- entry = entry.toLowerCase(Locale.ROOT);
- }
}
-
+ if(ignoreCase) {
+ entry = entry.toLowerCase(Locale.ROOT);
+ }
+
List<HunspellWord> entries = new ArrayList<HunspellWord>();
entries.add(wordForm);
words.put(entry, entries);
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellStemmerTest.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellStemmerTest.java
index 82a9b84040a..66a9410c27a 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellStemmerTest.java
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellStemmerTest.java
@@ -94,17 +94,21 @@ public class HunspellStemmerTest extends LuceneTestCase {
assertEquals(1, stems.size());
assertEquals("foo", stems.get(0).getStemString());
- stems = stemmer.stem("food");
+ stems = stemmer.stem("mood");
assertEquals(1, stems.size());
- assertEquals("foo", stems.get(0).getStemString());
+ assertEquals("moo", stems.get(0).getStemString());
stems = stemmer.stem("Foos");
assertEquals(1, stems.size());
assertEquals("foo", stems.get(0).getStemString());
-
+
+ // The "Foo" rule gets overridden by the "foo" rule, and we don't merge
stems = stemmer.stem("Food");
+ assertEquals(0, stems.size());
+
+ stems = stemmer.stem("Mood");
assertEquals(1, stems.size());
- assertEquals("foo", stems.get(0).getStemString());
+ assertEquals("moo", stems.get(0).getStemString());
}
@Test
diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/test.dic b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/test.dic
index cefc96c1eff..12efd8fccb2 100644
--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/test.dic
+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/test.dic
@@ -1,9 +1,10 @@
-8
+9
lucen/A
lucene
mahout/A
olr/B
ab/C
Apach/A
+Foo/E
foo/D
-Foo/E
\ No newline at end of file
+Moo/E
\ No newline at end of file