public AbstractAffixMatcher createAffixMatcher(Element eAffix) { String type = XMLUtils.getTrimmedAttribute(eAffix, ATTR_TYPE); String form = XMLUtils.getTrimmedAttribute(eAffix, ATTR_FORM); String pos = XMLUtils.getTrimmedAttribute(eAffix, ATTR_POS); String orgPOS = XMLUtils.getTrimmedAttribute(eAffix, ATTR_ORG_POS); Pattern oPOS = orgPOS.equals(StringConst.EMPTY) ? null : Pattern.compile("^("+orgPOS+")$"); boolean bSuffix = type.equals(VAL_SUFFIX); AbstractAffixMatcher matcher; if (bSuffix) matcher = new EnglishSuffixMatcher(form, pos, oPOS); else throw new IllegalArgumentException("Invalid affix type: "+type); NodeList list = eAffix.getElementsByTagName(ELEM_RULE); AbstractAffixReplacer replacer; int i, size = list.getLength(); for (i=0; i<size; i++) { replacer = getAffixReplacer(bSuffix, (Element)list.item(i)); if (replacer != null) matcher.addReplacer(replacer); } return matcher; }
public AbstractAffixMatcher createAffixMatcher(Element eAffix) { String type = XMLUtils.getTrimmedAttribute(eAffix, ATTR_TYPE); String form = XMLUtils.getTrimmedAttribute(eAffix, ATTR_FORM); String pos = XMLUtils.getTrimmedAttribute(eAffix, ATTR_POS); String orgPOS = XMLUtils.getTrimmedAttribute(eAffix, ATTR_ORG_POS); Pattern oPOS = orgPOS.equals(StringConst.EMPTY) ? null : Pattern.compile("^("+orgPOS+")$"); boolean bSuffix = type.equals(VAL_SUFFIX); AbstractAffixMatcher matcher; if (bSuffix) matcher = new EnglishSuffixMatcher(form, pos, oPOS); else throw new IllegalArgumentException("Invalid affix type: "+type); NodeList list = eAffix.getElementsByTagName(ELEM_RULE); AbstractAffixReplacer replacer; int i, size = list.getLength(); for (i=0; i<size; i++) { replacer = getAffixReplacer(bSuffix, (Element)list.item(i)); if (replacer != null) matcher.addReplacer(replacer); } return matcher; }