lemma = UNDERSCORE; 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());
/** * Get a string POS, and return it in a {@link SyntacticInfo} object. If possible, it uses {@link PennPartOfSpeech} instead of * {@link UnspecifiedPartOfSpeech}. * @param partOfSpeech string representation * @return SyntacticInfo object made out of the string * @throws CompilationException */ public static SyntacticInfo stringToSyntacticInfo(String partOfSpeech) throws CompilationException { SyntacticInfo syntacticInfo = null; if (partOfSpeech != null) { PartOfSpeech pos; if (partOfSpeech.equals(WildcardPartOfSpeech.WILDCARD_POS_STR)) pos = WildcardPartOfSpeech.getWildcardPOS(); else { partOfSpeech = partOfSpeech.toUpperCase(); if (BySimplerCanonicalPartOfSpeech.SIMPLER_CANONICAL_POS_TAG_STRINGS.contains(partOfSpeech)) try { pos = new BySimplerCanonicalPartOfSpeech(partOfSpeech); } catch (UnsupportedPosTagStringException e) { throw new CompilationException("Error reading this part of speech: " + partOfSpeech, e); } else try { pos = new PennPartOfSpeech(partOfSpeech); } catch ( UnsupportedPosTagStringException e) { throw new CompilationException("Error reading this part of speech: " + partOfSpeech + ". It's probably neigher a canonical POS nor a Penn POS, and should be conformed to one of them.", e); } } syntacticInfo = new DefaultSyntacticInfo(pos); } return syntacticInfo; }
lemma = UNDERSCORE; PartOfSpeech pos = ExtendedInfoGetFields.getPartOfSpeechObject(info); String canonicalPos = WildcardPartOfSpeech.isWildCardPOS(pos) ? pos.getStringRepresentation() : pos != null ? simplerPos(pos.getCanonicalPosTag()).name() : UNDERSCORE; int antecedentId = mapNodeToId.get(antecedent);
/** * @param partOfSpeechObject * @param partOfSpeechObject2 * @return */ private boolean posMatch(PartOfSpeech textPartOfSpeech, PartOfSpeech rulePartOfSpeech) { return (WildcardPartOfSpeech.isWildCardPOS(rulePartOfSpeech) || simplerPos(textPartOfSpeech.getCanonicalPosTag())==simplerPos(rulePartOfSpeech.getCanonicalPosTag()) ); }
/** * @param partOfSpeechObject * @param partOfSpeechObject2 * @return */ private boolean posMatch(PartOfSpeech textPartOfSpeech, PartOfSpeech rulePartOfSpeech) { return (WildcardPartOfSpeech.isWildCardPOS(rulePartOfSpeech) || simplerPos(textPartOfSpeech.getCanonicalPosTag())==simplerPos(rulePartOfSpeech.getCanonicalPosTag()) ); }
/** * @param partOfSpeechObject * @param partOfSpeechObject2 * @return */ private boolean posMatch(PartOfSpeech textPartOfSpeech, PartOfSpeech rulePartOfSpeech) { return (WildcardPartOfSpeech.isWildCardPOS(rulePartOfSpeech) || simplerPos(textPartOfSpeech.getCanonicalPosTag())==simplerPos(rulePartOfSpeech.getCanonicalPosTag()) ); }
(node.getInfo()!=null) && (!(WildcardPartOfSpeech.isWildCardPOS(InfoGetFields.getPartOfSpeechObject(node.getInfo()))))
/** * Check for wildcard POS, then compare canonical POSs, then compare normal (Penn) POSs!<br> * This method differs from other <code>posMatch()</code> methods by comparing the regular POSs as well. * @param partOfSpeechObject * @param partOfSpeechObject2 * @return */ private boolean posMatch(PartOfSpeech textPartOfSpeech, PartOfSpeech rulePartOfSpeech) { if (WildcardPartOfSpeech.isWildCardPOS(rulePartOfSpeech)) return true; if (textPartOfSpeech.equals(rulePartOfSpeech)) // this covers cases where the rule's and text's POSs are of the same subclass and match return true; // this covers all other cases where the rule uses a canonical POS (and the text may use any other POS type) if (isUnspecifiedPos(rulePartOfSpeech) && simplerPos(textPartOfSpeech.getCanonicalPosTag())==simplerPos(rulePartOfSpeech.getCanonicalPosTag())) return true; return false; }
/** * If rhsInfo has a POS (not {@link WildcardPartOfSpeech}), copy it to treeInfo. Return treeInfo * @param treeInfo * @param rhsInfo * @return */ public static NodeInfo combineNodeInfo(Info treeInfo, Info rhsInfo) { NodeInfo treeNodeInfo = treeInfo.getNodeInfo(); if (rhsInfo != null && rhsInfo.getNodeInfo() != null && rhsInfo.getNodeInfo().getSyntacticInfo() != null && rhsInfo.getNodeInfo().getSyntacticInfo().getPartOfSpeech() != null && !WildcardPartOfSpeech.isWildCardPOS(rhsInfo.getNodeInfo().getSyntacticInfo().getPartOfSpeech())) { // treeInfo with rhsInfo's syntactic info return new DefaultNodeInfo(treeNodeInfo.getWord(), treeNodeInfo.getWordLemma(), treeNodeInfo.getSerial(), treeNodeInfo.getNamedEntityAnnotation(), rhsInfo.getNodeInfo().getSyntacticInfo()); } else return treeNodeInfo; } }