/** * Checks if a posTag matches against this TokenTypeDefinition * @param posTag the posTag to check * @return <code>true</code> in case of a match. Otherwise <code>false</code> * @throws NullPointerException if the parsed posTag is <code>null</code> */ public boolean matches(PosTag posTag){ //check against incldues categories, posTags and tags boolean matches = (!Collections.disjoint(posTag.getCategories(), categories)) || (!Collections.disjoint(posTag.getPosHierarchy(), posTags)) || tags.contains(posTag.getTag()); //if there is a match we need still to check for excluded POS tags return matches ? Collections.disjoint(posTag.getPosHierarchy(),excludedPosTags) : false; }
private boolean isSectionBorder(Token token, String language) { Value<PosTag> posAnnotation = token.getAnnotation(NlpAnnotations.POS_ANNOTATION); if(posAnnotation != null && !Collections.disjoint(sectionBorderPosTags, posAnnotation.value().getPosHierarchy())){ return true; } else { return false; } }
private boolean isCoordinatingConjuction(Token token, String language) { Value<PosTag> posAnnotation = token.getAnnotation(NlpAnnotations.POS_ANNOTATION); return posAnnotation == null ? false : posAnnotation.value().getPosHierarchy().contains(Pos.CoordinatingConjunction); }
private boolean isPronoun(Token token, String language) { Value<PosTag> posAnnotation = token.getAnnotation(NlpAnnotations.POS_ANNOTATION); return posAnnotation == null ? false : posAnnotation.value().getPosHierarchy().contains(Pos.Pronoun); }
/** * Checks if the parsed {@link Token} represents an negation * @param token the word * @param language the language * @return <code>true</code> if the {@link Token} represents a negation. * Otherwise <code>false</code> */ private boolean isNegation(Token token, String language) { Value<PosTag> posAnnotation = token.getAnnotation(NlpAnnotations.POS_ANNOTATION); if(posAnnotation != null && !Collections.disjoint(negativePosTags, posAnnotation.value().getPosHierarchy())){ return true; } else { return false; } }
/** * Checks if the parsed {@link Token} represents an negation * @param token the word * @param index the index of the token relative to the sentence | section * @param language the language * @return <code>true</code> if the {@link Token} represents a negation. * Otherwise <code>false</code> */ private boolean isNoun(Token token, boolean firstTokenInSentence, String language) { String word = token.getSpan(); if(!firstTokenInSentence && !word.isEmpty() && Character.isUpperCase(word.charAt(0))){ return true; //assume all upper case tokens are Nouns } Value<PosTag> posAnnotation = token.getAnnotation(NlpAnnotations.POS_ANNOTATION); if(posAnnotation != null && (posAnnotation.value().hasCategory(LexicalCategory.Noun) || posAnnotation.value().getPosHierarchy().contains(Pos.CardinalNumber))){ return true; } return false; } /**
PosTag pos = sentiment.getPosTag(); boolean isPredicative; if(pos != null && pos.getPosHierarchy().contains(Pos.PredicativeAdjective)){ isPredicative = true; } else if(pos != null && pos.hasCategory(LexicalCategory.Adjective) &&
(!disjoint(tpc.getLinkedPos(), posTag.getPosHierarchy())) || tpc.getLinkedPosTags().contains(posTag.getTag())){ if(posAnnotation.probability() == Value.UNKNOWN_PROBABILITY || if(posTag.isMapped()){ if((!Collections.disjoint(tpc.getMatchedLexicalCategories(), posTag.getCategories())) || (!Collections.disjoint(tpc.getMatchedPos(), posTag.getPosHierarchy())) || tpc.getMatchedPosTags().contains(posTag.getTag())){ if(posAnnotation.probability() == Value.UNKNOWN_PROBABILITY || if((!disjoint(ProcessingState.SUB_SENTENCE_START_POS,posTag.getPosHierarchy()))){ if(posAnnotation.probability() == Value.UNKNOWN_PROBABILITY || posAnnotation.probability() >= tpc.getMinPosAnnotationProbability()){
(!disjoint(tpc.getLinkedPos(), posTag.getPosHierarchy())) || tpc.getLinkedPosTags().contains(posTag.getTag())){ if(posAnnotation.probability() == Value.UNKNOWN_PROBABILITY || if(posTag.isMapped()){ if((!Collections.disjoint(tpc.getMatchedLexicalCategories(), posTag.getCategories())) || (!Collections.disjoint(tpc.getMatchedPos(), posTag.getPosHierarchy())) || tpc.getMatchedPosTags().contains(posTag.getTag())){ if(posAnnotation.probability() == Value.UNKNOWN_PROBABILITY || if((!disjoint(ProcessingState.SUB_SENTENCE_START_POS,posTag.getPosHierarchy()))){ if(posAnnotation.probability() == Value.UNKNOWN_PROBABILITY || posAnnotation.probability() >= tpc.getMinPosAnnotationProbability()){