/** * checks whether the given PartOfSpeech is valid * * @param pos * @return true: valid, false: not valid */ private boolean isValidPos(PartOfSpeech pos) { switch(pos.getCanonicalPosTag()) { case ADJ: case N: case NN: case V: case NP: // Named Entities return true; default: return false; } }
/** * @param partOfSpeech * @return */ private boolean isUnspecifiedPos(PartOfSpeech partOfSpeech) { return simplerPos(partOfSpeech.getCanonicalPosTag()).toString().equals(partOfSpeech.getStringRepresentation()); }
/** * 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; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; LemmaAndPos other = (LemmaAndPos) obj; if (lemma == null) { if (other.lemma != null) return false; } else if (!lemma.equals(other.lemma)) return false; if (partOfSpeech == null) { if (other.partOfSpeech != null) return false; } else if (!partOfSpeech.equals(other.partOfSpeech)) return false; return true; }
/** * POS tag this term, and return a determiner, or "to", according to the POS tag * @param term * @param gloss * @return * @throws JwktlException */ private String determineFirstWord(String term, String gloss) throws JwktlException { String prefixWord = ""; { // if the last word is a noun-singular. it's a noun phrase, and needs an 'a' // must pos tag the term even though wiki already has, cos the wiki POS don't tell us if the noun is singular List<PosTaggedToken> tags = posTag(term); // note that term may have several words. if (tags.get(tags.size()-1).getPartOfSpeech().getStringRepresentation().equals(PennPosTag.NN.name())) prefixWord = "a"; } return prefixWord; }
if (rightPos.toString().startsWith("V")) { rightPosShort = new GermanPartOfSpeech ("V"); } else if (rightPos.toString().startsWith("N")) { rightPosShort = new GermanPartOfSpeech ("N"); } else if (rightPos.toString().equals("ADJ")) { rightPosShort = new GermanPartOfSpeech ("ADJ"); if (rule.getRLemma().equals(rightLemma) && (rightPos == null || rule.getRPos().equals(rightPosShort))) { result.add(rule);
@Override public int hashCode() { if (hashCodeSet) return hashCodeValue; final int prime = 31; int result = 1; result = prime * result + ((partOfSpeech == null) ? 0 : partOfSpeech.hashCode()); result = prime * result + ((token == null) ? 0 : token.hashCode()); hashCodeValue = result; hashCodeSet = true; return result; }
public void process() throws LemmatizerException { String pos = null; if (partOfSpeech != null) { pos = partOfSpeech.toString(); } ArrayList<String> tmpLemmas = GenerateLemmaFromWord.get(word, pos, command); lemmas = new ImmutableListWrapper<String>(tmpLemmas); }
protected BasicNode getBasicNodeFromConll(String[] toks) throws Exception { /* * items[0]: ID * items[1]: word form * items[2]: lemma * items[4]: POS * items[6]: head ID * items[7]: dependency label */ if (toks.length < 8) throw new Exception("Number of columns for each word should be at least 8: " + toks); String lemma = toks[2]; if (lemma.equals(UNKNOWN)) lemma = toks[1]; NodeInfo nodeInfo = new DefaultNodeInfo(toks[1],lemma,Integer.parseInt(toks[0]),null, new DefaultSyntacticInfo(pos.createNewPartOfSpeech(toks[4]))); EdgeInfo edgeInfo = new DefaultEdgeInfo(new DependencyRelation(toks[7],null)); Info info = new DefaultInfo(null,nodeInfo,edgeInfo); return new BasicNode(info); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PosTaggedToken other = (PosTaggedToken) obj; if (partOfSpeech == null) { if (other.partOfSpeech != null) return false; } else if (!partOfSpeech.equals(other.partOfSpeech)) return false; if (token == null) { if (other.token != null) return false; } else if (!token.equals(other.token)) return false; return true; }
pos = node.getInfo().getNodeInfo().getSyntacticInfo().getPartOfSpeech().getStringRepresentation(); sbPos.append(pos); sbWords.append(word);
@Override public int hashCode() { if (hashCodeSet)return hashCodeValue; final int prime = 31; int result = 1; result = prime * result + ((lemma == null) ? 0 : lemma.hashCode()); result = prime * result + ((partOfSpeech == null) ? 0 : partOfSpeech.hashCode()); // This is thread-safe - think about it. hashCodeValue=result; hashCodeSet=true; return result; }
String derivbasePos = pos.toString().substring(0, 1); result = getDerivRelatedRules(lemma, derivbasePos, result, pos);
/** * Checks if the POS is valid for the DErivBase resource, i.e., if it is * either a noun, verb, or adjective. * * @param pos the POS to check * @return true if POS is noun/verb/adjective, else false */ private boolean isValidPos(PartOfSpeech pos) { switch(pos.getCanonicalPosTag()) { case ADJ: case N: case NN: case V: return true; default: return false; } }
@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! ); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; TokenInfo other = (TokenInfo) obj; if (posTag == null) { if (other.posTag != null) return false; } else if (!posTag.equals(other.posTag)) return false; return true; } @Override
pos = node.getInfo().getNodeInfo().getSyntacticInfo().getPartOfSpeech().getStringRepresentation();
@Override public int hashCode() { final int prime = 31; int result = 1; long temp; temp = Double.doubleToLongBits(confidence); result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + ((lhsLemma == null) ? 0 : lhsLemma.hashCode()); result = prime * result + ((lhsPos == null) ? 0 : lhsPos.hashCode()); result = prime * result + ((rhsLemma == null) ? 0 : rhsLemma.hashCode()); result = prime * result + ((rhsPos == null) ? 0 : rhsPos.hashCode()); return result; }