You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2017/01/14 19:45:58 UTC

opennlp git commit: OPENNLP-696: Add test for Snowball stemmers

Repository: opennlp
Updated Branches:
  refs/heads/master 027c193cf -> 3e2685014


OPENNLP-696: Add test for Snowball stemmers

Thanks to Ajay Bhat for providing a patch!


Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo
Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/3e268501
Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/3e268501
Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/3e268501

Branch: refs/heads/master
Commit: 3e2685014a3b02938488718fbd2218d849e3fdb7
Parents: 027c193
Author: J�rn Kottmann <jo...@apache.org>
Authored: Sat Jan 14 20:37:32 2017 +0100
Committer: J�rn Kottmann <jo...@apache.org>
Committed: Sat Jan 14 20:39:16 2017 +0100

----------------------------------------------------------------------
 .../tools/stemmer/SnowballStemmerTest.java      | 143 +++++++++++++++++++
 1 file changed, 143 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/opennlp/blob/3e268501/opennlp-tools/src/test/java/opennlp/tools/stemmer/SnowballStemmerTest.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/stemmer/SnowballStemmerTest.java b/opennlp-tools/src/test/java/opennlp/tools/stemmer/SnowballStemmerTest.java
new file mode 100644
index 0000000..765bc38
--- /dev/null
+++ b/opennlp-tools/src/test/java/opennlp/tools/stemmer/SnowballStemmerTest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package opennlp.tools.stemmer;
+
+import static org.junit.Assert.assertEquals;
+import junit.framework.TestCase;
+import opennlp.tools.stemmer.snowball.SnowballStemmer;
+import opennlp.tools.stemmer.snowball.SnowballStemmer.ALGORITHM;
+
+import org.junit.Test;
+
+public class SnowballStemmerTest {
+
+  @Test
+  public void testDanish() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.DANISH);
+    assertEquals(stemmer.stem("aabenbaringen"), "aabenbaring");
+    assertEquals(stemmer.stem("skuebr�dsbordene"), "skuebr�dsbord");
+    assertEquals(stemmer.stem("skr�beligheder"), "skr�b");
+  }
+
+  @Test
+  public void testDutch() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.DUTCH);
+    assertEquals(stemmer.stem("vliegtuigtransport"), "vliegtuigtransport");
+    assertEquals(stemmer.stem("sterlabcertificaat"), "sterlabcertificat");
+    assertEquals(stemmer.stem("vollegrondsgroenteteelt"),
+        "vollegrondsgroenteteelt");
+
+  }
+
+  @Test
+  public void testEnglish() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.ENGLISH);
+    assertEquals(stemmer.stem("accompanying"), "accompani");
+    assertEquals(stemmer.stem("malediction"), "maledict");
+    assertEquals(stemmer.stem("softeners"), "soften");
+
+  }
+
+  @Test
+  public void testFinnish() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.FINNISH);
+    assertEquals(stemmer.stem("esiintymispaikasta"), "esiintymispaik");
+    assertEquals(stemmer.stem("esiintyvi�taiteilijayst�vi��n"),
+        "esiintyvi�taiteilijayst�vi�");
+    assertEquals(stemmer.stem("hellbergi�"), "hellberg");
+
+  }
+
+  @Test
+  public void testFrench() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.FRENCH);
+    assertEquals(stemmer.stem("accomplissaient"), "accompl");
+    assertEquals(stemmer.stem("examinateurs"), "examin");
+    assertEquals(stemmer.stem("pr�voyant"), "pr�voi");
+  }
+
+  @Test
+  public void testGerman() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.GERMAN);
+    assertEquals(stemmer.stem("buchbindergesellen"), "buchbindergesell");
+    assertEquals(stemmer.stem("mindere"), "mind");
+    assertEquals(stemmer.stem("mitverursacht"), "mitverursacht");
+
+  }
+
+  @Test
+  public void testHungarian() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.HUNGARIAN);
+    assertEquals(stemmer.stem("abbahagyn�m"), "abbahagyna");
+    assertEquals(stemmer.stem("konstrukci�j�b�l"), "konstrukci�");
+    assertEquals(stemmer.stem("lopta"), "lopt");
+
+  }
+
+  @Test
+  public void testItalian() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.ITALIAN);
+    assertEquals(stemmer.stem("abbattimento"), "abbatt");
+    assertEquals(stemmer.stem("dancer"), "dancer");
+    assertEquals(stemmer.stem("dance"), "danc");
+
+  }
+
+  @Test
+  public void testPortuguese() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.PORTUGUESE);
+    assertEquals(stemmer.stem("aborrecimentos"), "aborrec");
+    assertEquals(stemmer.stem("ach�"), "ach�");
+    assertEquals(stemmer.stem("ache"), "ache");
+
+  }
+
+  @Test
+  public void testRomanian() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.ROMANIAN);
+    assertEquals(stemmer.stem("absurdit\u0103\u0163ilor"), "absurd");
+    assertEquals(stemmer.stem("la\u015fi"), "la\u015f");
+    assertEquals(stemmer.stem("sechsunddreissig"), "sechsunddreissig");
+
+  }
+
+  @Test
+  public void testSpanish() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.SPANISH);
+    assertEquals(stemmer.stem("bes�"), "bes");
+    assertEquals(stemmer.stem("important�simas"), "importantisim");
+    assertEquals(stemmer.stem("incidental"), "incidental");
+  }
+
+  @Test
+  public void testSwedish() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.SWEDISH);
+    assertEquals(stemmer.stem("aftonringningen"), "aftonringning");
+    assertEquals(stemmer.stem("andedrag"), "andedrag");
+    assertEquals(stemmer.stem("andedr�gt"), "andedr�g");
+
+  }
+
+  @Test
+  public void testTurkish() {
+    SnowballStemmer stemmer = new SnowballStemmer(ALGORITHM.TURKISH);
+    assertEquals(stemmer.stem("ab'yle"), "ab'yle");
+    assertEquals(stemmer.stem("ka�mamaktad\u0131r"), "ka�mamak");
+    assertEquals(stemmer.stem("saray\u0131'n\u0131"), "saray\u0131'n\u0131");
+  }
+}