@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; }
@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
@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; }
public List<LexicalRule<? extends WiktionaryRuleInfo>> getRules(String leftLemma, PartOfSpeech lPos, String rightLemma, PartOfSpeech rPos) throws LexicalResourceException { if (lPos != null && rPos != null && !lPos.equals(rPos)) throw new LexicalResourceException("Both POSs in a Wiktionary rule must be equal or null (even if it's a derivation realation). I got "+lPos+" and "+rPos); return getRules(leftLemma, lPos, rightLemma); }
/** An overloaded method for getRules. In addition to the previous method, this method also matches the relation field of LexicalRule with the argument. * @param leftLemma Lemma to be matched on LHS * @param leftPos POS to be matched on LHS. null means "don't care". * @param rightLemma Lemma to be matched on RHS. * @param rightPos POS to be matched on RHS. null means "don't care". * @param relation The canonical relation of the rule (from LHS to RHS, TERuleRelation.Entailment or .Nonentailment) * @return a list of rules that matches the given condition. Empty list if there's no match. */ public List<LexicalRule<? extends GermanDistSimInfo>> getRules(String leftLemma, PartOfSpeech leftPos, String rightLemma, PartOfSpeech rightPos, TERuleRelation relation) throws LexicalResourceException { // convert cardinals to @card@, ordinals to @ord@ if (leftLemma.matches("\\d+[.]")) leftLemma = "@ord@"; if (leftLemma.matches("\\d+")) leftLemma = "@card@"; if (rightLemma.matches("\\d+[.]")) rightLemma = "@ord@"; if (rightLemma.matches("\\d+")) rightLemma = "@card@"; List<LexicalRule<? extends GermanDistSimInfo>> result = new ArrayList<LexicalRule<? extends GermanDistSimInfo>>(); for (LexicalRule<? extends GermanDistSimInfo> rule : getRulesForLeft(leftLemma, leftPos, relation)) { if (rule.getRLemma().equals(rightLemma) && (rightPos == null || rule.getRPos().equals(rightPos))) { result.add(rule); } } return result; }
protected List<LexicalRule<? extends RuleInfo>> getRulesForSide(String lemma, PartOfSpeech pos, boolean isForRight) throws LexicalResourceException{ List<LexicalRule<? extends RuleInfo>> rules; if(pos == null){ pos = defaultPos; } if(isForRight){ rules = super.getRulesForRight(lemma+POS_SEP+pos, null); if(pos.equals(defaultPos)){ if(rules.isEmpty()){ //rules may be a Collections.EmptyList which is immutable rules = new ArrayList<LexicalRule<? extends RuleInfo>>(); } rules.addAll(super.getRulesForRight(lemma, null)); } }else{ rules = super.getRulesForLeft (lemma+POS_SEP+pos, null); if(pos.equals(defaultPos)){ if(rules.isEmpty()){ //rules may be a Collections.EmptyList which is immutable rules = new ArrayList<LexicalRule<? extends RuleInfo>>(); rules.addAll(super.getRulesForLeft (lemma, null)); } } } return arrangePosTagInRules(rules); }
public ChainOfLexicalRulesMutable(String lhsLemma, PartOfSpeech lhsPos, String rhsLemma, PartOfSpeech rhsPos, double confidence, List<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"); if (!chain.get(0).getRule().getLhsPos().equals(lhsPos)) throw new TeEngineMlException("Bad chain"); if (!chain.get(chain.size()-1).getRule().getRhsLemma().equals(rhsLemma)) throw new TeEngineMlException("Bad chain"); if (!chain.get(chain.size()-1).getRule().getRhsPos().equals(rhsPos)) throw new TeEngineMlException("Bad chain"); }
PartOfSpeech posFromQuery = toPartOfSpeech(rs.getString(3)); // it's possible that pos is null, so we take the POS from the result if (!lemma.equals(otherLemma) || !posFromQuery.equals(otherPos)) // don't create a reflexive rule
if (rule.getRLemma().equals(rightLemma) && (rightPos == null || rule.getRPos().equals(rightPos))) { result.add(rule);
if (rule.getRLemma().equals(rightLemma) && (rightPos == null || rule.getRPos().equals(rightPos))) { result.add(rule);
if ((lPos == null) || (rPos == null) || (lPos.equals(rPos))) // if the pos doesn't match, return an empty list
if (rule.getRLemma().equals(rightLemma) && (rightPos == null || rule.getRPos().equals(rightPosShort))) { result.add(rule);
/** * 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; }