Class Entity

All Implemented Interfaces:
Serializable

public class Entity extends BaseAttribute implements Serializable
A reference to a "real world" entity. Each entity in a document is the result of resolving one or more Mentions -- a Mention is a span of text that mentions an entity, while an Entity describes the entity itself.

Each Entity provides:

  • a list of Mentions
  • the index of the head Mention in the mentions' list
  • the type of the entity, e.g. PERSON
  • (optionally) a salience score
  • (optionally) an ID that associates the entity some external knowledge base, e.g. Q23 from Wikidata.
  • (optionally) a sentiment category associated with it (e.g. "positive", "negative", "neutral").
Entities are not spans of text. The mentions in an entity are in document order.
See Also:
  • Constructor Details

  • Method Details

    • getEntityId

      public String getEntityId()
      Returns the unique identifier of this entity.
      Returns:
      the unique identifier of this entity
    • getMentions

      public List<Mention> getMentions()
      Returns:
      the list of mentions that support this entity.
    • getHeadMentionIndex

      public Integer getHeadMentionIndex()
      Return the head mention index, if any. The head mention is the mention judged to be the best representation of the entity itself. This returns null if no mention is designated as head.
      Returns:
      the index of the head mention.
    • getConfidence

      public Double getConfidence()
      Returns the confidence for this resolved entity, or null if there is none.
      Returns:
      the confidence for this resolved entity, or null if there is none
    • getSentiment

      public List<CategorizerResult> getSentiment()
      Returns the sentiment of this entity, or null if not computed.
      Returns:
      the sentiment of this entity, or null if not computed.
    • getType

      public String getType()
      If there is a type established for the entity, return the type.
      Returns:
      the entity type, or null if none was established.
    • getSalience

      public Double getSalience()
      If salience was computed for this entity, return it.
      Returns:
      the salience value, or null if none was calculated.
    • toStringHelper

      protected com.google.common.base.MoreObjects.ToStringHelper toStringHelper()
      Overrides:
      toStringHelper in class BaseAttribute