public String toString() { return lemma+"/"+ (pos!=null?pos.name():"null"); }
protected static String createDescription(ChainOfLexicalRules chain) { try { StringBuilder sb = new StringBuilder(); for (LexicalRuleWithName realLexicalRule : chain.getChain()) { sb.append("[").append( realLexicalRule.getRule().getLhsLemma()).append("/").append( simplerPos(realLexicalRule.getRule().getLhsPos().getCanonicalPosTag()).name() ).append("==>").append( realLexicalRule.getRule().getRhsLemma() ).append("/").append(simplerPos(realLexicalRule.getRule().getRhsPos().getCanonicalPosTag()).name()).append("] "); } return sb.toString(); } catch(Exception e) // I stop the exception, since it is only a log-message, but failure in retrieving the description does not imply any bug in the rule itself. { return "[Could not create chain description due to exception"+e.getClass().getSimpleName()+" - "+e.getMessage()+"]"; } }
@Override protected void addAdditionalDescription(RuleSubstituteNodeSpecification<ChainOfLexicalRules> spec,ChainOfLexicalRules rule) { StringBuilder sb = new StringBuilder(); for (LexicalRuleWithName realRule : rule.getChain()) { sb.append("[").append(realRule.getRuleBaseName()).append(" "); sb.append(realRule.getRule().getLhsLemma()); sb.append("/").append(simplerPos(realRule.getRule().getLhsPos().getCanonicalPosTag()).name()); sb.append("==>"); sb.append(realRule.getRule().getRhsLemma()); sb.append("/").append(simplerPos(realRule.getRule().getRhsPos().getCanonicalPosTag()).name()); sb.append(" "); sb.append(String.format("%-4.4f", realRule.getRule().getConfidence())); sb.append("] "); } spec.addDescription(sb.toString()); }
private void displayRules(List<LexicalRule<? extends EmptyRuleInfo>> rules) { if (rules.size()==0) { System.out.println("No rules"); } else { for (LexicalRule<? extends EmptyRuleInfo> rule : rules) { System.out.println( rule.getLLemma()+"/"+simplerPos(rule.getLPos().getCanonicalPosTag()).name()+ " ==> "+ rule.getRLemma()+"/"+simplerPos(rule.getRPos().getCanonicalPosTag()).name()); } } }
PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(info); String canonicalPos = WildcardPartOfSpeech.isWildCardPOS(pos) ? pos.getStringRepresentation() : pos != null ? simplerPos(pos.getCanonicalPosTag()).name() : UNDERSCORE; int antecedentId = mapNodeToId.get(node.getAntecedent()); String relation = antecedentId == TreeConllStringConverter.ROOT_ID ? TreeConllStringConverter.ROOT :
PartOfSpeech pos = ExtendedInfoGetFields.getPartOfSpeechObject(info); String canonicalPos = WildcardPartOfSpeech.isWildCardPOS(pos) ? pos.getStringRepresentation() : pos != null ? simplerPos(pos.getCanonicalPosTag()).name() : UNDERSCORE; int antecedentId = mapNodeToId.get(antecedent); String relation = antecedentId == ROOT_ID ? ROOT : ExtendedInfoGetFields.getRelation(info, ROOT);
System.out.println("--------------------"); PartOfSpeech pos = new FakePartOfSpeech("n"); System.out.println(simplerPos(pos.getCanonicalPosTag()).name()); lemmatizer.set("children",pos); lemmatizer.process();