String ruleArgs[] = line.split("\\s+"); HunspellAffix affix = new HunspellAffix(); affix.setFlag(flagParsingStrategy.parseFlag(ruleArgs[1])); affix.setStrip(ruleArgs[2].equals("0") ? "" : ruleArgs[2]); affix.setAppendFlags(appendFlags); affix.setAppend(affixArg.substring(0, flagSep)); } else { affix.setAppend(affixArg); affix.setCondition(condition, String.format(conditionPattern, condition)); affix.setCrossProduct(crossProduct); List<HunspellAffix> list = affixes.get(affix.getAppend()); if (list == null) { list = new ArrayList<HunspellAffix>(); affixes.put(affix.getAppend(), list);
/** * Prints the results of the stemming of a word * * @param originalWord Word that has been stemmed * @param stems Stems of the word */ private static void printStemResults(String originalWord, List<Stem> stems) { StringBuilder builder = new StringBuilder().append("stem(").append(originalWord).append(")").append("\n"); for (Stem stem : stems) { builder.append("- ").append(stem.getStem()).append(": "); for (HunspellAffix prefix : stem.getPrefixes()) { builder.append(prefix.getAppend()).append("+"); if (hasText(prefix.getStrip())) { builder.append(prefix.getStrip()).append("-"); } } builder.append(stem.getStem()); for (HunspellAffix suffix : stem.getSuffixes()) { if (hasText(suffix.getStrip())) { builder.append("-").append(suffix.getStrip()); } builder.append("+").append(suffix.getAppend()); } builder.append("\n"); } System.out.println(builder); }
if (!affix.checkCondition(segment)) { return Collections.EMPTY_LIST; if (words != null) { for (HunspellWord hunspellWord : words) { if (hunspellWord.hasFlag(affix.getFlag())) { stems.add(new Stem(strippedWord, length)); if (affix.isCrossProduct() && recursionDepth < RECURSION_CAP) { stems.addAll(stem(strippedWord, length, affix.getAppendFlags(), ++recursionDepth));
if (hasCrossCheckedFlag(suffix.getFlag(), flags)) { int deAffixedLength = length - suffix.getAppend().length(); String strippedWord = new StringBuilder().append(word, 0, deAffixedLength).append(suffix.getStrip()).toString(); if (hasCrossCheckedFlag(prefix.getFlag(), flags)) { int deAffixedStart = prefix.getAppend().length(); int deAffixedLength = length - deAffixedStart; String strippedWord = new StringBuilder().append(prefix.getStrip()) .append(word, deAffixedStart, deAffixedLength) .toString();