@Override public boolean evaluate(T object) { PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(object); return ( simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.VERB ); } }
/** * @param info a node information (including lemma and pos) * @param withLemma If true, the component is made of the lemma and the POS, for example: v:use:v, n:keyboard:n, p:against:p * If false, the component is made of POS only, for example: v, n, a * @return a DIRT-like dependency path component for the given parse tree node. */ //AS I don't understand your explanations in the JavaDoc. protected static String toDependencyPathComponent(NodeInfo info, boolean withLemma) { PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(info); char posChar = toChar(pos); if (withLemma) { String lemma = InfoGetFields.getLemma(info); return posChar+":"+lemma+":"+posChar; } else { return String.valueOf(posChar); } }
private boolean isContent(ExtendedNode node) { return contentPoses.contains( SimplerPosTagConvertor.simplerPos( InfoGetFields.getPartOfSpeechObject(node.getInfo()).getCanonicalPosTag())); }
(InfoGetFields.getLemma(mainInfo).equalsIgnoreCase(InfoGetFields.getLemma(testInfo))) && posMatch(InfoGetFields.getPartOfSpeechObject(mainInfo), InfoGetFields.getPartOfSpeechObject(testInfo)) if (posMatch(InfoGetFields.getPartOfSpeechObject(mainInfo), InfoGetFields.getPartOfSpeechObject(testInfo))
(InfoGetFields.getLemma(mainInfo).equalsIgnoreCase(InfoGetFields.getLemma(testInfo))) && posMatch(InfoGetFields.getPartOfSpeechObject(mainInfo), InfoGetFields.getPartOfSpeechObject(testInfo)) if (posMatch(InfoGetFields.getPartOfSpeechObject(mainInfo), InfoGetFields.getPartOfSpeechObject(testInfo))) ret = true; else
private static boolean isVerb(Info info) { boolean ret = false; if (InfoObservations.infoHasLemma(info)) { PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(info); if (simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.VERB) ret = true; } return ret; }
public static boolean areEqualNodes(Info info1, Info info2) { if ((info1==null) && (info2==null))return true; else if ((info1==null) || (info2==null))return false; String lemma1 = InfoGetFields.getLemma(info1); String lemma2 = InfoGetFields.getLemma(info2); SimplerCanonicalPosTag canonicalPos1 = simplerPos(InfoGetFields.getPartOfSpeechObject(info1).getCanonicalPosTag()); SimplerCanonicalPosTag canonicalPos2 = simplerPos(InfoGetFields.getPartOfSpeechObject(info2).getCanonicalPosTag()); if ( (lemma1.equalsIgnoreCase(lemma2)) && (canonicalPos1.equals(canonicalPos2))) return true; else return false; }
if (lemma.isEmpty()) lemma = UNDERSCORE; PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(info); String canonicalPos = WildcardPartOfSpeech.isWildCardPOS(pos) ? pos.getStringRepresentation() : pos != null ? simplerPos(pos.getCanonicalPosTag()).name() : UNDERSCORE;
(InfoGetFields.getLemma(mainInfo).equalsIgnoreCase(InfoGetFields.getLemma(testInfo))) && posMatch(InfoGetFields.getPartOfSpeechObject(mainInfo), InfoGetFields.getPartOfSpeechObject(testInfo)) && additionalNodeInformationMatch(mainInfo, testInfo) if (posMatch(InfoGetFields.getPartOfSpeechObject(mainInfo), InfoGetFields.getPartOfSpeechObject(testInfo)) && additionalNodeInformationMatch(mainInfo, testInfo)
(InfoGetFields.getLemma(mainInfo).equalsIgnoreCase(InfoGetFields.getLemma(testInfo))) && posMatch(InfoGetFields.getPartOfSpeechObject(mainInfo), InfoGetFields.getPartOfSpeechObject(testInfo)) && additionalNodeInformationMatch(mainInfo, testInfo) if (posMatch(InfoGetFields.getPartOfSpeechObject(mainInfo), InfoGetFields.getPartOfSpeechObject(testInfo)) && additionalNodeInformationMatch(mainInfo, testInfo)
@Override public boolean evaluate(T object) { PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(object); return ( simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.NOUN || simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.PRONOUN ); } }
private static boolean isPronoun(ExtendedNode node) { boolean ret = true; PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(node.getInfo()); if (pos!=null) { if (!SimplerCanonicalPosTag.PRONOUN.equals(simplerPos(pos.getCanonicalPosTag()))) { ret = false; } } return ret; }
private void constructSetOfLemmas() throws TeEngineMlException { lemmas = new LinkedHashSet<LemmaAndPos>(); for (ExtendedNode node : AbstractNodeUtils.treeToSet(treeAndParentMap.getTree())) { if (InfoObservations.infoHasLemma(node.getInfo())) { String lemma = InfoGetFields.getLemma(node.getInfo()); PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(node.getInfo()); LemmaAndPos lemmaAndPos = new LemmaAndPos(lemma, pos); lemmas.add(lemmaAndPos); } } }
public static boolean infoIsContentWord(Info info) { boolean ret = false; if (infoHasLemma(info)) { String lemma = InfoGetFields.getLemma(info); if (!NON_CONTENT_WORDS.contains(lemma)) { PartOfSpeech posObject = InfoGetFields.getPartOfSpeechObject(info); SimplerCanonicalPosTag canonicalPos = SimplerCanonicalPosTag.OTHER; if (posObject!=null) canonicalPos=simplerPos(posObject.getCanonicalPosTag()); if (SimplerCanonicalPosTag.VERB.equals(canonicalPos)) { return infoIsContentVerb(info); } else if (CONTENT_CANONICAL_PART_OF_SPEECH.contains(canonicalPos)) { ret = true; } } } return ret; }
public static Set<LemmaAndPos> lemmasAndPosesInTree(ExtendedNode tree) throws TeEngineMlException { Set<LemmaAndPos> ret = new LinkedHashSet<LemmaAndPos>(); Set<ExtendedNode> setNodes = AbstractNodeUtils.treeToLinkedHashSet(tree); for (ExtendedNode node : setNodes) { if (InfoObservations.infoHasLemma(node.getInfo())) { String lemma = InfoGetFields.getLemma(node.getInfo()); PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(node.getInfo()); ret.add(new LemmaAndPos(lemma, pos)); for (String oneLemma : StringUtil.stringToWords(lemma)) { ret.add(new LemmaAndPos(oneLemma, pos)); } } } return ret; }
/** * Returns <tt>true</tt> if lemma and pos are equal. * @param textNode * @param hypothesisNode * @return */ public static boolean nodesSimilarIgnoreAnnotations(ExtendedInfo textNode, ExtendedInfo hypothesisNode) { boolean ret = false; String textLemma = InfoGetFields.getLemma(textNode); String hypothesisLemma = InfoGetFields.getLemma(hypothesisNode); SimplerCanonicalPosTag textPos = simplerPos(InfoGetFields.getPartOfSpeechObject(textNode).getCanonicalPosTag()); SimplerCanonicalPosTag hypothesisPos = simplerPos(InfoGetFields.getPartOfSpeechObject(hypothesisNode).getCanonicalPosTag()); if (lemmasEqual(textLemma, hypothesisLemma)) { if (textPos.equals(hypothesisPos)) { ret = true; } } return ret; }
@Override public boolean evaluate(T object) { PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(object); return ( simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.ADJECTIVE || simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.ADVERB || simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.NOUN || simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.PRONOUN || "VBN".equals(pos.getStringRepresentation()) // a passive noun is also considered an adjective! ); } }
public static boolean infoIsContentVerb(Info info) { boolean ret = false; if (infoHasLemma(info)) { PartOfSpeech posObject = InfoGetFields.getPartOfSpeechObject(info); if (simplerPos(posObject.getCanonicalPosTag())==SimplerCanonicalPosTag.VERB) { String lemma = InfoGetFields.getLemma(info); if (!StringUtil.setContainsIgnoreCase(NON_CONTENT_VERBS, lemma)) { if (!StringUtil.setContainsIgnoreCase(NON_CONTENT_VERBS_VERBS_ONLY, lemma)) { ret = true; } } } } return ret; }
@Override public boolean evaluate(T object) { PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(object); return ( simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.VERB || simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.ADJECTIVE || simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.NOUN || simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.PRONOUN ); } }
private void findSpecs() throws TeEngineMlException, RuleBaseException { this.specs = new LinkedHashSet<RuleSubstituteNodeSpecification<T>>(); for (ExtendedNode node : TreeIterator.iterableTree(treeAndParentMap.getTree())) { if (isRelevantNode(node)) { if (InfoObservations.infoHasLemma(node.getInfo())) { LemmaAndPos lemmaAndPos = new LemmaAndPos(InfoGetFields.getLemma(node.getInfo()), InfoGetFields.getPartOfSpeechObject(node.getInfo())); ImmutableSet<T> rules = getRulesForLemmaAndPos(lemmaAndPos); for (T rule : rules) { if (isRelevantRule(rule)) { NodeInfo newNodeInfo = new DefaultNodeInfo(rule.getRhsLemma(), rule.getRhsLemma(), node.getInfo().getNodeInfo().getSerial(), node.getInfo().getNodeInfo().getNamedEntityAnnotation(), new DefaultSyntacticInfo(rule.getRhsPos())); RuleSubstituteNodeSpecification<T> spec = createSpec(node, newNodeInfo,ruleBaseName, rule); // new RuleSubstituteNodeSpecification<T>(node, newNodeInfo, node.getInfo().getAdditionalNodeInformation(), rule.getConfidence(), ruleBaseName, rule); addAdditionalDescription(spec,rule); specs.add(spec); } } } } } }