LUCENE-5840: fix parsing of zero-affixes with continuation classes

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1612452 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2014-07-22 03:50:05 +00:00
parent 377fab9fd9
commit a265a8ab9c
4 changed files with 46 additions and 1 deletions

View File

@ -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

View File

@ -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");
}
}

View File

@ -0,0 +1,6 @@
SET UTF-8
FLAG num
SFX 322 Y 1
SFX 322 eer 0/100 .