private String tableNameByPos(PartOfSpeech pos) { String ret = null; if (simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.VERB) ret = "verbs_200"; else if (simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.NOUN) ret = "nouns_200"; 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 ); } }
@Override public List<LexicalRule<? extends VerbOceanRuleInfo>> getRulesForLeft(String lemma, PartOfSpeech pos) throws LexicalResourceException { if (lemma == null) throw new LexicalResourceException("lemma is null"); List<LexicalRule<? extends VerbOceanRuleInfo>> rules = new Vector<LexicalRule<? extends VerbOceanRuleInfo>>(); if((pos==null || simplerPos(pos.getCanonicalPosTag()) == SimplerCanonicalPosTag.VERB) && mapRulesByEntailingVerb.containsKey(lemma)){ rules.addAll(mapRulesByEntailingVerb.get(lemma)); } return new ArrayList<LexicalRule<? extends VerbOceanRuleInfo>>(rules); }
@Override public List<LexicalRule<? extends VerbOceanRuleInfo>> getRulesForRight(String lemma, PartOfSpeech pos) throws LexicalResourceException { if (lemma == null) throw new LexicalResourceException("lemma is null"); List<LexicalRule<? extends VerbOceanRuleInfo>> rules = new Vector<LexicalRule<? extends VerbOceanRuleInfo>>(); if((pos==null || simplerPos(pos.getCanonicalPosTag()) == SimplerCanonicalPosTag.VERB) && mapRulesByEntailedVerb.containsKey(lemma)){ rules.addAll(mapRulesByEntailedVerb.get(lemma)); } return new ArrayList<LexicalRule<? extends VerbOceanRuleInfo>>(rules); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((simplerPos(pos.getCanonicalPosTag()) == null) ? 0 : simplerPos(pos.getCanonicalPosTag()).hashCode()); result = prime * result + ((word == null) ? 0 : word.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((lemma == null) ? 0 : lemma.hashCode()); result = prime * result + ((simplerPos(pos.getCanonicalPosTag()) == null) ? 0 : simplerPos(pos.getCanonicalPosTag()).hashCode()); return result; }
@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! ); } }
/** * @param partOfSpeechObject * @param partOfSpeechObject2 * @return */ private boolean posMatch(PartOfSpeech textPartOfSpeech, PartOfSpeech rulePartOfSpeech) { return (WildcardPartOfSpeech.isWildCardPOS(rulePartOfSpeech) || simplerPos(textPartOfSpeech.getCanonicalPosTag())==simplerPos(rulePartOfSpeech.getCanonicalPosTag()) ); }
@Override public boolean evaluate(T object) { PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(object); return ( simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.NOUN || simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.PRONOUN ); } }
public static final boolean posEqual(PartOfSpeech textPos, PartOfSpeech hypothesisPos) { if (textPos==hypothesisPos)return true; SimplerCanonicalPosTag canonicalText = (null==textPos)?SimplerCanonicalPosTag.OTHER:simplerPos(textPos.getCanonicalPosTag()); SimplerCanonicalPosTag canonicalhypothesis = (null==hypothesisPos)?SimplerCanonicalPosTag.OTHER:simplerPos(hypothesisPos.getCanonicalPosTag()); if (canonicalText.equals(canonicalhypothesis)) return true; else return false; }
/** * @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()) ); }
@Override public boolean evaluate(T object) { PartOfSpeech pos = InfoGetFields.getPartOfSpeechObject(object); return ( simplerPos(pos.getCanonicalPosTag())==SimplerCanonicalPosTag.VERB ); } }
private boolean isContent(ExtendedNode node) { return contentPoses.contains( SimplerPosTagConvertor.simplerPos( InfoGetFields.getPartOfSpeechObject(node.getInfo()).getCanonicalPosTag())); }
/** * @param partOfSpeech * @return */ private boolean isUnspecifiedPos(PartOfSpeech partOfSpeech) { return simplerPos(partOfSpeech.getCanonicalPosTag()).toString().equals(partOfSpeech.getStringRepresentation()); }
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; }
public CanonicalLemmaAndPos(String lemma, PartOfSpeech pos) throws TeEngineMlException { super(); if (null==lemma) throw new TeEngineMlException("null lemma"); if (null==pos) throw new TeEngineMlException("null pos"); if (null==simplerPos(pos.getCanonicalPosTag())) throw new TeEngineMlException("null canonical pos"); this.lemma = lemma; this.pos = pos; }
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; }
public ChainOfLexicalRules(String lhsLemma, PartOfSpeech lhsPos, String rhsLemma, PartOfSpeech rhsPos, double confidence, ImmutableList<LexicalRuleWithName> chain) throws TeEngineMlException { super(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence); this.chain = chain; if (null==chain) throw new TeEngineMlException("Null chain"); if (chain.size()==0)throw new TeEngineMlException("Empty chain"); if (!chain.get(0).getRule().getLhsLemma().equals(lhsLemma)) throw new TeEngineMlException("Bad chain: expected: "+lhsLemma+" but found: "+chain.get(0).getRule().getLhsLemma()+parametersDescription(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence, chain)); if (!simplerPos(chain.get(0).getRule().getLhsPos().getCanonicalPosTag()).equals(simplerPos(lhsPos.getCanonicalPosTag()))) throw new TeEngineMlException("Bad chain: expected pos: "+simplerPos(lhsPos.getCanonicalPosTag())+", but found: "+simplerPos(chain.get(0).getRule().getLhsPos().getCanonicalPosTag())+parametersDescription(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence, chain)); if (!chain.get(chain.size()-1).getRule().getRhsLemma().equals(rhsLemma)) throw new TeEngineMlException("Bad chain: expected rhsLemma: "+rhsLemma+" but found: "+chain.get(chain.size()-1).getRule().getRhsLemma()+parametersDescription(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence, chain)); if (!simplerPos(chain.get(chain.size()-1).getRule().getRhsPos().getCanonicalPosTag()).equals(simplerPos(rhsPos.getCanonicalPosTag()))) throw new TeEngineMlException("Bad chain: expected rhs pos: "+simplerPos(rhsPos.getCanonicalPosTag())+", but found: "+simplerPos(chain.get(chain.size()-1).getRule().getRhsPos().getCanonicalPosTag())+parametersDescription(lhsLemma, lhsPos, rhsLemma, rhsPos, confidence, chain)); }