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

justhalf.nlp.reader.acereader.ACEEntityMention Maven / Gradle / Ivy

package justhalf.nlp.reader.acereader;

import java.io.Serializable;

import edu.stanford.nlp.util.Comparators;

/**
 * Represents an entity mention.
 * A mention maybe discontiguous, in which case there will be more than one {@link Span} objects.
 * @author Aldrian Obaja ([email protected])
 *
 */
public class ACEEntityMention extends ACEObjectMention implements Comparable, Serializable{
	
	public static enum ACEMentionType {
		/**
		 * A proper name reference to an entity
* Examples: *
    *
  1. Defence secretary [William Cohen]
  2. *
  3. The [house of representative]
  4. *
*/ NAM("Name", true, true), /** * A common noun reference to an entity
* Examples: *
    *
  1. The [lawyer]
  2. *
  3. this year's [Miss America]
  4. *
*/ NOM("Nominal", true, true), /** * A pronominal reference to an entity
* Examples: *
    *
  1. [He] went there
  2. *
  3. [That]'s not mine
  4. *
*/ PRO("Pronominal", true, true), /** * Premodifier mentions are those mentions which occur in a modifying position before another word(s)
* Examples: *
    *
  1. [He] went there
  2. *
  3. [That]'s not mine
  4. *
*/ PRE("Premodifier", true, false), ; public final String text; public final boolean in2004; public final boolean in2005; private ACEMentionType(String text, boolean in2004, boolean in2005){ this.text = text; this.in2004 = in2004; this.in2005 = in2005; } } public static enum LDCMentionType { /** * A proper name reference to an entity
* Examples: *
    *
  1. Defence secretary [William Cohen]
  2. *
  3. The [house of representative]
  4. *
*/ NAM("Name"), /** * Premodifier mentions are those mentions which occur in a modifying position before another word(s)
* Examples: *
    *
  1. [Israeli] troops
  2. *
  3. [Republican] voters
  4. *
*/ NAMPRE("Name Premodifier"), /** * Premodifier mentions are those mentions which occur in a modifying position before another word(s)
* Examples: *
    *
  1. [He] went there
  2. *
  3. [That]'s not mine
  4. *
*/ PRE("Premodifier", true, false), /** * Premodifier mentions are those mentions which occur in a modifying position before another word(s)
* Examples: *
    *
  1. [union] leaders
  2. *
  3. [Mr.] Clinton
  4. *
*/ NOMPRE("Nominal Premodifier"), /** * A common noun reference to an entity
* Examples: *
    *
  1. The [lawyer]
  2. *
  3. this year's [Miss America]
  4. *
*/ NOM("Quantified Nominal Mention"), /** * A pronominal reference to an entity
* Examples: *
    *
  1. [He] went there
  2. *
  3. [That]'s not mine
  4. *
*/ PRO("Pronouns"), /** * A construction in which two or more heads that share the same premodifiers or postmodifiers
* Examples: *
    *
  1. [20 angry _men and women_]
  2. *
  3. [The _movers and shakers_ in Washington]
  4. *
*/ MWH("Nominal Mentions with Multiple-word Heads", true, false), /** * An unquantified nominal construction. Both singular and plural constructions may be BAR.
* Examples: *
    *
  1. [lawyers]
  2. *
  3. [Americans] eagerly await the result of the election
  4. *
*/ BAR("Unquantified Nominal Mention"), /** * WH-question words and the specifier 'that'
* Examples: *
    *
  1. the executive, [who] spoke on the condition of anonymity
  2. *
  3. [Who] is the president of Brazil?
  4. *
  5. [Whose] underwear is this?
  6. *
*/ WHQ("WH-Question Words and Specifiers"), /** * Headless mentions are constructions in which the nominal head is not overtly expressed.
* Although these mentions are technically headless, we will assign as * head the right most premodifier that falls directly before the spot * where the head would be
* Examples: *
    *
  1. [the _toughest_]
  2. *
  3. [60_%_] said
  4. *
  5. They will [each] pay $5.
  6. *
*/ HLS("Headless Mentions"), /** * Partitive constructions have two elements: the part and the whole.
* The first element of a partitive construction lacks a head and * quantifies over the second element.
* Just as in Headless mentions, we will tag the right most premodifier of * the first element as the head of the partitive construction
* Examples: *
    *
  1. [_some_ of the lawyers]
  2. *
  3. [sixty _percent_ of the participants]
  4. *
* There are some constructions with prepositional phrase that greatly resemble partitives, * but should not be tagged as partitives.
* The first element of these constructions is a nominal that can function as a head.
* Examples: *
    *
  1. two members of the team
  2. *
  3. a stockpile of weapons
  4. *
*/ PTV("Partitive Constructions"), ; public final String text; public final boolean in2004; public final boolean in2005; private LDCMentionType(String text){ this(text, true, true); } private LDCMentionType(String text, boolean in2004, boolean in2005){ this.text = text; this.in2004 = in2004; this.in2005 = in2005; } } public static enum ACEGPEMentionRole { ORG, PER, LOC, GPE, } private static final long serialVersionUID = -3442499301550024781L; public SpanLabel label; public Span headSpan; public ACEEntity entity; public ACEMentionType mentionType; public LDCMentionType ldcMentionType; public String ldcAttribute; public ACEGPEMentionRole gpeMentionRole; public String headText; /** * Perform a deep copy of another entity mention * @param mention */ public ACEEntityMention(ACEEntityMention mention){ super(mention.id, new Span(mention.span.start, mention.span.end), mention.text, mention.parent); this.label = mention.label; this.headSpan = new Span(mention.headSpan.start, mention.headSpan.end); this.entity = mention.entity; this.mentionType = mention.mentionType; this.ldcMentionType = mention.ldcMentionType; this.ldcAttribute = mention.ldcAttribute; this.gpeMentionRole = mention.gpeMentionRole; this.headText = mention.headText; } public ACEEntityMention(String id, String mentionType, String ldcMentionType, String ldcAttribute, ACEEntity entity, Span span, Span headSpan, String text, String headText, SpanLabel label){ super(id, span, text, entity); this.mentionType = ACEMentionType.valueOf(mentionType); this.ldcMentionType = LDCMentionType.valueOf(ldcMentionType); this.ldcAttribute = ldcAttribute; this.entity = entity; this.headSpan = headSpan; this.headText = headText; this.label = label; } public boolean overlapsWith(ACEEntityMention mention){ return (span.start < mention.span.end && span.start >= mention.span.start) || (mention.span.start < span.end && mention.span.start >= span.start); } /** * Two {@link ACEEntityMention}s are the same iff the span, headSpan, and the label are the same */ public boolean equals(Object o){ if(o instanceof ACEEntityMention){ ACEEntityMention s = (ACEEntityMention)o; if(!span.equals(s.span)) return false; if(!headSpan.equals(s.headSpan)) return false; return label.equals(s.label); } return false; } @Override public int compareTo(ACEEntityMention o) { int result = Comparators.nullSafeCompare(span, o.span); if(result != 0) return result; result = Comparators.nullSafeCompare(headSpan, o.headSpan); if(result != 0) return result; result = Comparators.nullSafeCompare(label, o.label); if(result != 0) return result; return Comparators.nullSafeCompare(getFullID(), o.getFullID()); } public String toString(){ StringBuilder result = new StringBuilder(); result.append("["+span.toString()+"]"); result.append("[Label="+label.form+"]"); result.append("[ID="+id+"]"); result.append("[Type="+mentionType+"]"); result.append("[LDCType="+ldcMentionType+"]"); result.append("[LDCAttr="+ldcAttribute+"]"); return result.toString(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy