Class Annotation

  • All Implemented Interfaces:
    Serializable

    public class Annotation
    extends Object
    implements Serializable
    An Annotation represents additional data associated with words in the sentences, e.g. data generated by NER, POS taggers, etc. An Annotation has a name and is associated with a sentence via the sentence's index in the list of sentences. It also holds a set of indices of the sentences words to which it is associated. It also stores a map of arbitrary variables.

    An equality operation is defined for Annotations, see method equals for details.

    • Constructor Detail

      • Annotation

        public Annotation​(String _sName,
                          int _iSentenceIndex,
                          Set<Integer> _zWordIndices,
                          Map<String,​Object> _mVariables)
        Creates a new annotation with the given data. The given word indices set and variables map are stored as unmodifiable copies.
        Parameters:
        _sName - the name of the annotation
        _iSentenceIndex - the index in the List<SentenceI> passed into InputProcessor.process to which this annotation belongs (the first sentence has index 0)
        _zWordIndices - the indices in the SentenceI's List<WordData> to which this annotation belongs; the set may be empty (the first word has index 0)
        _mVariables - an arbitrary collection of key/value pairs; if null an empty map is used
        Throws:
        NullPointerException - if the name is null or the word indices map is null
        IllegalArgumentException - if the name is empty, the sentence index is negative, the word indices map contains a negative index, or the variables map contains a null key
    • Method Detail

      • getName

        public final String getName()
        Returns the name of this annotation.
      • getSentenceIndex

        public final int getSentenceIndex()
        Returns the index in the List<SentenceI> passed into InputProcessor.process to which this annotation belongs (the first sentence has index 0).
      • getWordIndices

        public final Set<Integer> getWordIndices()
        Returns an immutable set of indices into the List<WordData> contained in a SentenceI. The first word has index 0.
      • getVariables

        public final Map<String,​Object> getVariables()
        Returns an immutable map of the variables associated with this annotation.
      • equals

        public final boolean equals​(Object _other)
        Compares this Annotation to the specified object. The result is true if and only if the argument is not null and is an Annotation with equal name, sentence index, and word indices. The annotation variables are not taken into account.
        Overrides:
        equals in class Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object