/** Called by {@link #EnglishMPAnalyzer(ZipFile)}. */ private EnglishDerivation getDerivationalRules(Element eDerivation, String type) throws IOException { Element eAffixes = XMLUtils.getFirstElementByTagName(eDerivation, type); return new EnglishDerivation(new EnglishAffixMatcherFactory().createAffixMatchers(eAffixes)); }
public List<AbstractAffixMatcher> createAffixMatchers(Element eAffixes) { List<AbstractAffixMatcher> affixes = new ArrayList<>(); NodeList list = eAffixes.getElementsByTagName(ELEM_AFFIX); int i, size = list.getLength(); Element eAffix; for (i=0; i<size; i++) { eAffix = (Element)list.item(i); affixes.add(createAffixMatcher(eAffix)); } return affixes; }
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; }
/** Called by {@link #EnglishMPAnalyzer(ZipFile)}. */ private EnglishDerivation getDerivationalRules(Element eDerivation, String type) throws IOException { Element eAffixes = XMLUtils.getFirstElementByTagName(eDerivation, type); return new EnglishDerivation(new EnglishAffixMatcherFactory().createAffixMatchers(eAffixes)); }
public List<AbstractAffixMatcher> createAffixMatchers(Element eAffixes) { List<AbstractAffixMatcher> affixes = new ArrayList<>(); NodeList list = eAffixes.getElementsByTagName(ELEM_AFFIX); int i, size = list.getLength(); Element eAffix; for (i=0; i<size; i++) { eAffix = (Element)list.item(i); affixes.add(createAffixMatcher(eAffix)); } return affixes; }
private EnglishInflection getInflection(InputStream baseStream, InputStream exceptionStream, Element eAffixes, String basePOS) throws IOException { Map<String,String> exceptionMap = (exceptionStream != null) ? DSUtils.createStringHashMap(exceptionStream, Splitter.T_SPACE) : null; List<AbstractAffixMatcher> affixMatchers = new EnglishAffixMatcherFactory().createAffixMatchers(eAffixes); Set<String> baseSet = DSUtils.createStringHashSet(baseStream); return new EnglishInflection(basePOS, baseSet, exceptionMap, affixMatchers); }
private EnglishInflection getInflection(InputStream baseStream, InputStream exceptionStream, Element eAffixes, String basePOS) throws IOException { Map<String,String> exceptionMap = (exceptionStream != null) ? DSUtils.createStringHashMap(exceptionStream, Splitter.T_SPACE) : null; List<AbstractAffixMatcher> affixMatchers = new EnglishAffixMatcherFactory().createAffixMatchers(eAffixes); Set<String> baseSet = DSUtils.createStringHashSet(baseStream); return new EnglishInflection(basePOS, baseSet, exceptionMap, affixMatchers); }