All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.coref.statistical.Example Maven / Gradle / Ivy

Go to download

Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.

There is a newer version: 4.5.7
Show newest version
package edu.stanford.nlp.coref.statistical;

import java.io.Serializable;

import edu.stanford.nlp.coref.data.Mention;
import edu.stanford.nlp.coref.data.Dictionaries.MentionType;
/**
 * A representation of a mention-pair for training coreference models.
 * @author Kevin Clark
 */
public class Example implements Serializable {
  private static final long serialVersionUID = 1104263558466004590L;
  public final int docId;
  public final double label;
  public final CompressedFeatureVector pairwiseFeatures;

  public final int mentionId1;
  public final int mentionId2;
  public final MentionType mentionType1;
  public final MentionType mentionType2;

  public Example(int docId, Mention m1, Mention m2, double label,
      CompressedFeatureVector pairwiseFeatures) {
    this.docId = docId;
    this.label = label;
    this.pairwiseFeatures = pairwiseFeatures;

    this.mentionId1 = m1.mentionID;
    this.mentionId2 = m2.mentionID;
    this.mentionType1 = m1.mentionType;
    this.mentionType2 = m2.mentionType;
  }

  public Example(Example pair, boolean isPositive) {
    this.docId = pair.docId;
    this.label = isPositive ? 1 : 0;
    this.pairwiseFeatures = null;

    this.mentionId1 = -1;
    this.mentionId2 = pair.mentionId2;
    this.mentionType1 = null;
    this.mentionType2 = pair.mentionType2;
  }

  public boolean isNewLink() {
    return pairwiseFeatures == null;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy