@Override public boolean contains(Object o) { return realSet.contains(o); }
/** * return true iff this {@link StanfordDepedencyRelationType} is a valid relation between a factive predicate and its arg. * @param relation * @return */ public boolean isFactiveRelation(StanfordDepedencyRelationType relation) { if (!ComplementRelations.COMPLEMENT_RELATIONS.contains(relation)) return false; // the relation isn't argumental. factivity is impossible. switch (this) { case P_P: return true; case P_P_FinP: case P_P_FinP_P_N_InfP: case P_P_FinP_N_P_InfP: case P_P_FinP_P_U_InfP: case P_P_FinP_N_U_InfP: return !ComplementRelations.NON_FINITE_RELATIONS.contains(relation); default: // non factive signature return false; } }
/** * return true iff this {@link StanfordDepedencyRelationType} is a valid relation between a NEGATIVE-factive predicate and its arg. * @param relation * @return */ public boolean isNegativeFactiveRelation(StanfordDepedencyRelationType relation) { if (!ComplementRelations.COMPLEMENT_RELATIONS.contains(relation)) return false; // the relation isn't argumental. factivity is impossible. else return this.equals(N_N); }
/** * return true iff this is a complement of a {@link PredicateSignature#NOT_IN_LEXICON} predicate * @param relation * @return */ public boolean isUnspecifiedRelation(StanfordDepedencyRelationType relation) { return (ComplementRelations.COMPLEMENT_RELATIONS.contains(relation) && this.equals(NOT_IN_LEXICON)); }
/** * return true iff this is a {@link PredicateSignature#U_U}, or the relation isn't argumental * @param relation * @return */ public boolean isUncertainRelation(StanfordDepedencyRelationType relation) { if (!ComplementRelations.COMPLEMENT_RELATIONS.contains(relation)) return true; // the relation isn't argumental. factivity/implicativity is impossible. else return this.equals(U_U); }
public static ArgumentType fromRelation(String relation) { ArgumentType argumentType = null; if (getSemanticSubjectRelations().contains(relation)) { argumentType = ArgumentType.SUBJECT; } else if (getSemanticObjectRelations().contains(relation)) { argumentType = ArgumentType.OBJECT; } else if (getSemanticModifierRelations().contains(relation)) { argumentType = ArgumentType.MODIFIER; } else { argumentType = ArgumentType.UNKNOWN; } return argumentType; }
private boolean relevantAccordingToFilterStopWords(T rule) { boolean ret = true; if (filterLeftStopWords) { if (stopWords.contains(rule.getLhsLemma().toLowerCase())) { ret = false; } } if (true==ret) { if (filterRightStopWords) { if (stopWords.contains(rule.getRhsLemma().toLowerCase())) { ret = false; } } } return ret; }
private boolean checkIfArgument(Predicate<I, S> predicate, List<S> pathFromPredicateToNode, S node) { String relation = InfoGetFields.getRelation(node.getInfo()); if ( (RelationTypes.getSemanticModifierRelations().contains(relation)) || (RelationTypes.getSemanticSubjectRelations().contains(relation)) || (RelationTypes.getSemanticObjectRelations().contains(relation)) ) { return true; } else { return false; } }
private Set<String> contentLemmasOfNodes_lowerCase(Iterable<S> nodes, Set<S> exclude) { Set<String> ret = new LinkedHashSet<>(); for (S node : nodes) { if (!setContains(exclude,node)) { if (InfoObservations.infoIsContentWord(node.getInfo())) { String lemma = InfoGetFields.getLemma(node.getInfo()).toLowerCase(); if (!(stopWords.contains(lemma))) { ret.add(lemma); } } } } return ret; }
private Set<S> getPredicateInternalNodes(S node) { Set<S> ret = new LinkedHashSet<S>(); ret.add(node); if (node.hasChildren()) { for (S child : node.getChildren()) { String relation = InfoGetFields.getRelation(child.getInfo()); if (RelationTypes.getSemanticInternalFacetRelations().contains(relation)) { ret.addAll(getPredicateInternalNodes(child)); } } } return ret; }
private Set<S> getPredicateInternalNodes(S node, Set<S> excludedDirectChildren) { Set<S> ret = new LinkedHashSet<S>(); ret.add(node); if (node.hasChildren()) { for (S child : node.getChildren()) { if (!excludedDirectChildren.contains(child)) { String relation = InfoGetFields.getRelation(child.getInfo()); if (RelationTypes.getSemanticInternalFacetRelations().contains(relation)) { ret.addAll(getPredicateInternalNodes(child)); } } } } return ret; }
public static <I extends Info, S extends AbstractNode<I, S>> Set<S> getInternalNodes(S node) { Set<S> ret = new LinkedHashSet<S>(); ret.add(node); if (node.hasChildren()) { for (S child : node.getChildren()) { String relation = InfoGetFields.getRelation(child.getInfo()); if (RelationTypes.getSemanticInternalFacetRelations().contains(relation)) { ret.addAll(getInternalNodes(child)); } } } return ret; }
/** * Finds the nominal predicates in the parse tree. */ public void identify() { predicateHeads = new LinkedHashSet<S>(); for (S node : TreeIterator.iterableTree(tree.getTree())) { if (SimplerCanonicalPosTag.NOUN.equals(SimplerPosTagConvertor.simplerPos(InfoGetFields.getCanonicalPartOfSpeech(node.getInfo())))) { if (nomlexMap.keySet().contains(InfoGetFields.getLemma(node.getInfo()).trim().toLowerCase(Locale.ENGLISH))) { predicateHeads.add(node); } } } }
private boolean checkIfClausal(NodeAndPathFromPredicateAndArgumentType<I,S> nodePathType) { boolean ret = false; String nodeRelation = InfoGetFields.getRelation(nodePathType.getNode().getInfo()); if (RelationTypes.getSemanticNewClauseRelations().contains(nodeRelation)) { ret = true; } if (false == ret){if (nodePathType.getPathFromPredicateHead()!=null){if (nodePathType.getPathFromPredicateHead().size()>=1) { String pathRelation = InfoGetFields.getRelation(nodePathType.getPathFromPredicateHead().get(0).getInfo()); if (RelationTypes.getSemanticNewClauseRelations().contains(pathRelation)) { ret = true; } }}} return ret; }
if ( (textParent!=null) && (mappedToHypothesisParent.contains(textParent)) )
@SuppressWarnings("unchecked") @Override public List<LexicalRule<? extends RuleInfo>> getRules(String leftLemma, PartOfSpeech leftPos, String rightLemma, PartOfSpeech rightPos) throws LexicalResourceException { if (rightPos==null || simplerPos(rightPos.getCanonicalPosTag())==this.canonicalPartOfSpeech) { if (leftPos==null || simplerPos(leftPos.getCanonicalPosTag())==this.canonicalPartOfSpeech) { ImmutableSet<String> rightLemmas = getMap().get(leftLemma); // NOTE: getMap() is used instead of this.map, to allow overriding in OnlineFileBasedLexicalResource. if (rightLemmas.contains(rightLemma)) { List<LexicalRule<? extends RuleInfo>> theRules = new ArrayList<LexicalRule<? extends RuleInfo>>(); theRules.add(new LexicalRule<RuleInfo>( leftLemma, (leftPos==null? this.partOfSpeech: leftPos), rightLemma, (rightPos==null? this.partOfSpeech: rightPos), relationName, resourceName, EmptyRuleInfo.getInstance())); return theRules; } } } return Collections.EMPTY_LIST; }
private Set<S> findVerbPredicateHeads() { Set<S> verbPredicateHeads = new LinkedHashSet<S>(); for (S node : TreeIterator.iterableTree(tree.getTree())) { if (SimplerCanonicalPosTag.VERB.equals(SimplerPosTagConvertor.simplerPos(InfoGetFields.getCanonicalPartOfSpeech(node.getInfo())))) { String relation = InfoGetFields.getRelation(node.getInfo()); if (!RelationTypes.getSemanticAuxiliaryVerbRelations().contains(relation)) { verbPredicateHeads.add(node); } } } return verbPredicateHeads; }
if (RelationTypes.getSemanticNewClauseRelations().contains(InfoGetFields.getRelation(grandChild.getInfo())))
if (ComplementRelations.PREP_RELATIONS.contains(relationToChild) || ExtendedInfoGetFields.getPredicateSignatureObj(child.getInfo()) != null) ret = child; else if (relationToChild.equals(StanfordDepedencyRelationType.prep))
protected boolean isRelevantRule(T rule) throws RuleBaseException { boolean ret = false; try { if (super.isRelevantRule(rule)) { if (StringUtil.setContainsIgnoreCase(hypothesisLemmasOnly, rule.getRhsLemma())) // if it is in the hypothesis { CanonicalLemmaAndPos original = new CanonicalLemmaAndPos(rule.getLhsLemma(), rule.getLhsPos()); // old if (!DsUtils.containsCanonical(hypothesisLemmasAndPoses, original)) // (old) if (!hypothesisLemmasAndPoses.contains(original)) // if the left hand side is not in the hypothesis if (!hypothesisLemmasAndPoses.contains(original)) { ret = true; } } } } catch(TeEngineMlException e) { throw new RuleBaseException("Problem with the given lemma and part-of-speech",e); } return ret; }