Package opennlp.tools.coref.mention

Examples of opennlp.tools.coref.mention.MentionContext


    List<String> features = new ArrayList<String>();
    features.addAll(super.getFeatures(mention,entity));
    //features.add("eid="+pc.id);
    if (entity != null) { //generate pronoun w/ referent features
      features.addAll(ResolverUtils.getPronounMatchFeatures(mention,entity));
      MentionContext cec = entity.getLastExtent();
      features.addAll(ResolverUtils.getDistanceFeatures(mention,entity));
      features.addAll(ResolverUtils.getContextFeatures(cec));
      features.add(ResolverUtils.getMentionCountFeature(entity));
      /*
      //lexical features
View Full Code Here


    }
    return (features);
  }

  protected boolean outOfRange(MentionContext mention, DiscourseEntity entity) {
    MentionContext cec = entity.getLastExtent();
    //System.err.println("MaxentPluralPronounResolver.outOfRange: ["+ec.toText()+" ("+ec.id+")] ["+cec.toText()+" ("+cec.id+")] ec.sentenceNumber=("+ec.sentenceNumber+")-cec.sentenceNumber=("+cec.sentenceNumber+") > "+NUM_SENTS_BACK_PRONOUNS);
    return (mention.getSentenceNumber() - cec.getSentenceNumber() > NUM_SENTS_BACK_PRONOUNS);
  }
View Full Code Here

  protected boolean excluded(MentionContext ec, DiscourseEntity de) {
    if (super.excluded(ec, de)) {
      return true;
    }
    else {
      MentionContext cec = de.getLastExtent();
      return !canResolve(cec) || super.excluded(ec, de);
    }
  }
View Full Code Here

  protected boolean excluded(MentionContext mention, DiscourseEntity entity) {
    if (super.excluded(mention,entity)) {
      return true;
    }
    else {
      MentionContext cec = entity.getLastExtent();
      return (!cec.getHeadTokenTag().equals("NNS") || super.excluded(mention, entity));
    }
  }
View Full Code Here

  protected List<String> getFeatures(MentionContext mention, DiscourseEntity entity) {
    List<String> features = new ArrayList<String>();
    features.addAll(super.getFeatures(mention, entity));
    if (entity != null) { //generate pronoun w/ referent features
      MentionContext cec = entity.getLastExtent();
      //String gen = getPronounGender(pronoun);
      features.addAll(ResolverUtils.getPronounMatchFeatures(mention,entity));
      features.addAll(ResolverUtils.getContextFeatures(cec));
      features.addAll(ResolverUtils.getDistanceFeatures(mention,entity));
      features.add(ResolverUtils.getMentionCountFeature(entity));
View Full Code Here

      return (true);
    }
    String mentionGender = null;

    for (Iterator<MentionContext> ei = entity.getMentions(); ei.hasNext();) {
      MentionContext entityMention = ei.next();
      String tag = entityMention.getHeadTokenTag();
      if (tag != null && tag.startsWith("PRP") && ResolverUtils.singularThirdPersonPronounPattern.matcher(mention.getHeadTokenText()).matches()) {
        if (mentionGender == null) { //lazy initialization
          mentionGender = ResolverUtils.getPronounGender(mention.getHeadTokenText());
        }
        String entityGender = ResolverUtils.getPronounGender(entityMention.getHeadTokenText());
        if (!entityGender.equals("u") && !mentionGender.equals(entityGender)) {
          return (true);
        }
      }
    }
View Full Code Here

    }
    return (false);
  }

  protected boolean outOfRange(MentionContext mention, DiscourseEntity entity) {
    MentionContext cec = entity.getLastExtent();
    //System.err.println("MaxentSingularPronounresolve.outOfRange: ["+entity.getLastExtent().toText()+" ("+entity.getId()+")] ["+mention.toText()+" ("+mention.getId()+")] entity.sentenceNumber=("+entity.getLastExtent().getSentenceNumber()+")-mention.sentenceNumber=("+mention.getSentenceNumber()+") > "+numSentencesBack);
    return (mention.getSentenceNumber() - cec.getSentenceNumber() > numSentencesBack);
  }
View Full Code Here

    List<String> features = new ArrayList<String>();
    features.addAll(super.getFeatures(mention, entity));
    if (entity != null) {
      features.addAll(ResolverUtils.getPronounMatchFeatures(mention,entity));
      List<String> contexts = ResolverUtils.getContextFeatures(mention);
      MentionContext cec = entity.getLastExtent();
      if (mention.getHeadTokenTag().startsWith("PRP") && cec.getHeadTokenTag().startsWith("PRP")) {
        features.add(mention.getHeadTokenText() + "," + cec.getHeadTokenText());
      }
      else if (mention.getHeadTokenText().startsWith("NNP")) {
        for (int ci = 0, cl = contexts.size(); ci < cl; ci++) {
          features.add(contexts.get(ci));
        }
        features.add(mention.getNameType() + "," + cec.getHeadTokenText());
      }
      else {
        List<String> ccontexts = ResolverUtils.getContextFeatures(cec);
        for (int ci = 0, cl = ccontexts.size(); ci < cl; ci++) {
          features.add(ccontexts.get(ci));
        }
        features.add(cec.getNameType() + "," + mention.getHeadTokenText());
      }
    }
    return (features);
  }
View Full Code Here

    }
    return (features);
  }

  protected boolean outOfRange(MentionContext mention, DiscourseEntity entity) {
    MentionContext cec = entity.getLastExtent();
    return (mention.getSentenceNumber() - cec.getSentenceNumber() > numSentencesBack);
  }
View Full Code Here

  protected boolean excluded(MentionContext mention, DiscourseEntity entity) {
    if (super.excluded(mention, entity)) {
      return true;
    }
    MentionContext cec = entity.getLastExtent();
    if (!canResolve(cec)) {
      return true;
    }
    if (mention.getHeadTokenTag().startsWith("NNP")) { //mention is a propernoun
      if (cec.getHeadTokenTag().startsWith("NNP")) {
        return true; // both NNP
      }
      else {
        if (entity.getNumMentions() > 1) {
          return true;
        }
        return !canResolve(cec);
      }
    }
    else if (mention.getHeadTokenTag().startsWith("PRP")){ // mention is a speech pronoun
      // cec can be either a speech pronoun or a propernoun
      if (cec.getHeadTokenTag().startsWith("NNP")) {
        //exclude antecedents not in the same sentence when they are not pronoun
        return (mention.getSentenceNumber() - cec.getSentenceNumber() != 0);
      }
      else if (cec.getHeadTokenTag().startsWith("PRP")){
        return false;
      }
      else {
        System.err.println("Unexpected candidate exluded: "+cec.toText());
        return true;
      }
    }
    else {
      System.err.println("Unexpected mention exluded: "+mention.toText());
View Full Code Here

TOP

Related Classes of opennlp.tools.coref.mention.MentionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.