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/07/22 05:50:06 UTC

svn commit: r1612452 - in /lucene/dev/trunk/lucene/analysis/common/src: java/org/apache/lucene/analysis/hunspell/ test/org/apache/lucene/analysis/hunspell/

Author: rmuir
Date: Tue Jul 22 03:50:05 2014
New Revision: 1612452

URL: http://svn.apache.org/r1612452
Log:
LUCENE-5840: fix parsing of zero-affixes with continuation classes

Added:
    lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestZeroAffix2.java   (with props)
    lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.aff   (with props)
    lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.dic   (with props)
Modified:
    lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java

Modified: lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java?rev=1612452&r1=1612451&r2=1612452&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java (original)
+++ lucene/dev/trunk/lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/Dictionary.java Tue Jul 22 03:50:05 2014
@@ -474,9 +474,10 @@ public class Dictionary {
       
       char flag = flagParsingStrategy.parseFlag(ruleArgs[1]);
       String strip = ruleArgs[2].equals("0") ? "" : ruleArgs[2];
-      String affixArg = ruleArgs[3].equals("0") ? "" : ruleArgs[3];
+      String affixArg = ruleArgs[3];
       char appendFlags[] = null;
       
+      // first: parse continuation classes out of affix
       int flagSep = affixArg.lastIndexOf('/');
       if (flagSep != -1) {
         String flagPart = affixArg.substring(flagSep + 1);
@@ -490,6 +491,10 @@ public class Dictionary {
         Arrays.sort(appendFlags);
         twoStageAffix = true;
       }
+      // zero affix -> empty string
+      if ("0".equals(affixArg)) {
+        affixArg = "";
+      }
       
       String condition = ruleArgs.length > 4 ? ruleArgs[4] : ".";
       // at least the gascon affix file has this issue

Added: lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestZeroAffix2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestZeroAffix2.java?rev=1612452&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestZeroAffix2.java (added)
+++ lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/TestZeroAffix2.java Tue Jul 22 03:50:05 2014
@@ -0,0 +1,32 @@
+package org.apache.lucene.analysis.hunspell;
+
+/*
+ * 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.
+ */
+
+import org.junit.BeforeClass;
+
+public class TestZeroAffix2 extends StemmerTestBase {
+  
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    init("zeroaffix2.aff", "zeroaffix2.dic");
+  }
+  
+  public void testStemming() {
+    assertStemsTo("b", "beer");
+  }
+}

Added: lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.aff
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.aff?rev=1612452&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.aff (added)
+++ lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.aff Tue Jul 22 03:50:05 2014
@@ -0,0 +1,6 @@
+SET UTF-8
+FLAG num
+
+SFX 322 Y 1
+SFX 322 eer 0/100 .
+

Added: lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.dic
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.dic?rev=1612452&view=auto
==============================================================================
--- lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.dic (added)
+++ lucene/dev/trunk/lucene/analysis/common/src/test/org/apache/lucene/analysis/hunspell/zeroaffix2.dic Tue Jul 22 03:50:05 2014
@@ -0,0 +1,2 @@
+1
+beer/322