EssentialAnnotationUtil - apache/ctakes GitHub Wiki

final public class EssentialAnnotationUtil

Utility to fetch integrated, coordinated collections of entities, events, and coreferences in a CAS.

  • Author: SPF , chip-nlp
  • Version: %I%
  • Since: 12/29/2017

static private Collection<IdentifiedAnnotation> getEssentialAnnotations( final Collection<IdentifiedAnnotation> annotations )

From a collection of annotations, get the events, times, and entities.

  • Parameters:
    • annotations all IdentifiedAnnotations, regardless of type.
  • Returns: Collection of EventMentions, TimeMentions, and EntityMentions.

static private void cullToEssentialAnnotations( final Collection<Collection<IdentifiedAnnotation>> annotationCollections )

From multiple collections of annotations, remove everything that isn't an event, time, or entity.

  • Parameters:
    • annotationCollections all IdentifiedAnnotations, regardless of type.

static private Collection<IdentifiedAnnotation> getNonEssentialAnnotations( final Collection<IdentifiedAnnotation> allAnnotations, final Collection<IdentifiedAnnotation> unwantedAnnotations )

From a collection of annotations, get everything that is not in the collection of essential annotations.

  • Parameters:
    • allAnnotations all IdentifiedAnnotations, regardless of type.
    • unwantedAnnotations unwanted annotations.
  • Returns: Collection of EventMentions, TimeMentions, and EntityMentions.

static public Collection<IdentifiedAnnotation> getRequiredAnnotations( final JCas jCas, final Map<IdentifiedAnnotation, Collection<Integer>> corefIndexed )

To allow fulfilled relations and coreference chains, we need essential annotations and related non-essential annotations.

  • Parameters:
    • jCas ye olde ...
    • corefIndexed map of identified annotations to coreference chains containing them.
  • Returns: all events, times, and entities, plus annotations that are required for coreferences and relations.

static public Collection<IdentifiedAnnotation> getRequiredAnnotations( final JCas jCas, final Collection<IdentifiedAnnotation> allAnnotations, final Map<IdentifiedAnnotation, Collection<Integer>> corefIndexed )

To allow fulfilled relations and coreference chains, we need essential annotations and related non-essential annotations.

  • Parameters:
    • jCas ye olds ...
    • allAnnotations all IdentifiedAnnotations, regardless of type.
    • corefIndexed map of identified annotations to coreference chains containing them.
  • Returns: all events, times, and entities, plus annotations that are required for coreferences and relations.

static public Collection<IdentifiedAnnotation> getRequiredAnnotations( final Collection<IdentifiedAnnotation> allAnnotations, final Map<IdentifiedAnnotation, Collection<Integer>> corefIndexed, final Collection<BinaryTextRelation> relations )

To allow fulfilled relations and coreference chains, we need essential annotations and related non-essential annotations.

  • Parameters:
    • allAnnotations all IdentifiedAnnotations, regardless of type.
    • corefIndexed map of identified annotations to coreference chains containing them.
    • relations relations between annotations.
  • Returns: all events, times, and entities, plus annotations that are required for coreferences and relations.

static public Map<IdentifiedAnnotation, Collection<Integer>> createMarkableCorefs( final JCas jCas )

  • Parameters:
    • jCas ye olde ...
  • Returns: a map of coreferent annotations to indexed chain numbers.

static public Map<IdentifiedAnnotation, Collection<Integer>> createMarkableCorefs( final Collection<CollectionTextRelation> corefs, final Map<Markable, IdentifiedAnnotation> markableAnnotations )

  • Parameters:
    • corefs coreference chains.
    • markableAnnotations annotations that should be allowed in coreferences.
  • Returns: a map of coreferent annotations to indexed chain numbers.

static public Map<IdentifiedAnnotation, Collection<Integer>> createMarkableAssertedCorefs( final Collection<CollectionTextRelation> corefs, final Map<Markable, IdentifiedAnnotation> markableAnnotations )

Sometimes there will be two overlapping annotations, 1 affirmed 1 negated. Use this for matching assertions in coreference chains.

  • Parameters:
    • corefs coreference chains.
    • markableAnnotations annotations that should be allowed in coreferences.
  • Returns: a map of annotations to indexed chain numbers, separated by assertion status.

static public Map<IdentifiedAnnotation, Collection<Integer>> createAllMarkableAssertedCorefs( final JCas jCas )

Sometimes there will be two overlapping annotations, 1 affirmed 1 negated. Use this for matching assertions in coreference chains.

  • Parameters:
    • jCas ye olde ...
  • Returns: a map of annotations to indexed chain numbers, separated by assertion status.

static public Map<IdentifiedAnnotation, Collection<Integer>> createAllMarkableAssertedCorefs( final Collection<CollectionTextRelation> corefs, final Map<Markable, Collection<IdentifiedAnnotation>> markableAnnotations )

Sometimes there will be two overlapping annotations, 1 affirmed 1 negated. Use this for matching assertions in coreference chains.

  • Parameters:
    • corefs coreference chains.
    • markableAnnotations annotations that should be allowed in coreferences.
  • Returns: a map of annotations to indexed chain numbers, separated by assertion status.

static private String getAssertion( final IdentifiedAnnotation annotation )

  • Parameters:
    • annotation -
  • Returns: string of concatenated assertion values: AFFIRMED, NEGATED, UNCERTAIN, GENERIC, CONDITIONAL.

static private Map<Markable, IdentifiedAnnotation> mapMarkableAnnotations( final JCas jCas, final Collection<CollectionTextRelation> corefs )

We can create a map of "best fit" single identified annotations for each coreference markable.

  • Parameters:
    • jCas ye olde ...
    • corefs collection of coref relations.
  • Returns: map of each coref markable to an identified annotation.

static public Map<Markable, Collection<IdentifiedAnnotation>> mapAllMarkableAnnotations( final JCas jCas, final Collection<CollectionTextRelation> corefs )

We can create a map of multiple overlapping identified annotations for each coreference markable.

  • Parameters:
    • jCas ye olde ...
    • corefs collection of coref relations.
  • Returns: map of each coref markable to an identified annotation.

static public ConllDependencyNode getNominalHeadNode( final List<ConllDependencyNode> nodes )

Finds the head node out of a few ConllDependencyNodes. Biased toward nouns.

  • Parameters:

    • nodes dependency nodes.
  • Returns: best head node.



static public Collection<IdentifiedAnnotation> getRelationAnnotations( final Collection<BinaryTextRelation> relations )

  • Parameters:
    • relations -
  • Returns: all annotations in relations.

static private Collection<IdentifiedAnnotation> getEventMentions( final Collection<IdentifiedAnnotation> annotations )

  • Parameters:
    • annotations all IdentifiedAnnotations, regardless of type.
  • Returns: collection of events in the annotations.

static private Map<IdentifiedAnnotation, Collection<IdentifiedAnnotation>> getAnnotationEvents( final Map<TextSpan, Collection<IdentifiedAnnotation>> annotationMap )

  • Parameters:
    • annotationMap map of TextSpans for IdentifiedAnnotations with those text spans.
  • Returns: map of annotations to events.

static private String createSectionName( final Segment section )

There may be multiple sections with the same preferred name. We want unique names for each section.

  • Parameters:
    • section -
  • Returns: Section Name + section ID or section ID or section Name or "Unknown Section".
⚠️ **GitHub.com Fallback** ⚠️