You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2014/02/28 08:16:40 UTC
svn commit: r1572842 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/analysis/
lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/
Author: rmuir
Date: Fri Feb 28 07:16:39 2014
New Revision: 1572842
URL: http://svn.apache.org/r1572842
Log:
LUCENE-5480: add the tests i have so far... (not including this bug yet though)
Added:
lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java
- copied unchanged from r1572841, lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/StemmerTestBase.java
lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestMorph.java
- copied unchanged from r1572841, lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestMorph.java
lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestTwoFold.java
- copied unchanged from r1572841, lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestTwoFold.java
lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/morph.aff
- copied unchanged from r1572841, lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/morph.aff
lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/morph.dic
- copied unchanged from r1572841, lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/morph.dic
lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/twofold.aff
- copied unchanged from r1572841, lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/twofold.aff
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/ (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestCaseInsensitive.java
lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestStemmer.java
Modified: lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestCaseInsensitive.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestCaseInsensitive.java?rev=1572842&r1=1572841&r2=1572842&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestCaseInsensitive.java (original)
+++ lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestCaseInsensitive.java Fri Feb 28 07:16:39 2014
@@ -17,37 +17,13 @@ package org.apache.lucene.analysis.hunsp
* limitations under the License.
*/
-import org.apache.lucene.analysis.hunspell.Dictionary;
-import org.apache.lucene.analysis.hunspell.Stemmer;
-import org.apache.lucene.util.CharsRef;
-import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.LuceneTestCase;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class TestCaseInsensitive extends LuceneTestCase {
- private static Stemmer stemmer;
+public class TestCaseInsensitive extends StemmerTestBase {
@BeforeClass
public static void beforeClass() throws Exception {
- InputStream affixStream = TestCaseInsensitive.class.getResourceAsStream("simple.aff");
- InputStream dictStream = TestCaseInsensitive.class.getResourceAsStream("mixedcase.dic");
- try {
- Dictionary dictionary = new Dictionary(affixStream, Collections.singletonList(dictStream), true);
- stemmer = new Stemmer(dictionary);
- } finally {
- IOUtils.closeWhileHandlingException(affixStream, dictStream);
- }
- }
-
- @AfterClass
- public static void afterClass() {
- stemmer = null;
+ init(true, "simple.aff", "mixedcase.dic");
}
public void testCaseInsensitivity() {
@@ -98,17 +74,4 @@ public class TestCaseInsensitive extends
assertStemsTo("lucenee");
assertStemsTo("solre");
}
-
- private void assertStemsTo(String s, String... expected) {
- Arrays.sort(expected);
-
- List<CharsRef> stems = stemmer.stem(s);
- String actual[] = new String[stems.size()];
- for (int i = 0; i < actual.length; i++) {
- actual[i] = stems.get(i).toString();
- }
- Arrays.sort(actual);
-
- assertArrayEquals(expected, actual);
- }
}
Modified: lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestStemmer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestStemmer.java?rev=1572842&r1=1572841&r2=1572842&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestStemmer.java (original)
+++ lucene/dev/branches/branch_4x/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestStemmer.java Fri Feb 28 07:16:39 2014
@@ -17,37 +17,13 @@ package org.apache.lucene.analysis.hunsp
* limitations under the License.
*/
-import org.apache.lucene.analysis.hunspell.Dictionary;
-import org.apache.lucene.analysis.hunspell.Stemmer;
-import org.apache.lucene.util.CharsRef;
-import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.LuceneTestCase;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class TestStemmer extends LuceneTestCase {
- private static Stemmer stemmer;
+public class TestStemmer extends StemmerTestBase {
@BeforeClass
public static void beforeClass() throws Exception {
- InputStream affixStream = TestCaseInsensitive.class.getResourceAsStream("simple.aff");
- InputStream dictStream = TestCaseInsensitive.class.getResourceAsStream("simple.dic");
- try {
- Dictionary dictionary = new Dictionary(affixStream, Collections.singletonList(dictStream), true);
- stemmer = new Stemmer(dictionary);
- } finally {
- IOUtils.closeWhileHandlingException(affixStream, dictStream);
- }
- }
-
- @AfterClass
- public static void afterClass() {
- stemmer = null;
+ init("simple.aff", "simple.dic");
}
public void testSimpleSuffix() {
@@ -96,17 +72,4 @@ public class TestStemmer extends LuceneT
assertStemsTo("lucenee");
assertStemsTo("solre");
}
-
- private void assertStemsTo(String s, String... expected) {
- Arrays.sort(expected);
-
- List<CharsRef> stems = stemmer.stem(s);
- String actual[] = new String[stems.size()];
- for (int i = 0; i < actual.length; i++) {
- actual[i] = stems.get(i).toString();
- }
- Arrays.sort(actual);
-
- assertArrayEquals(expected, actual);
- }
}