Class AnnotationType

  • All Implemented Interfaces:
    AnnotatableType, Tag, Serializable, Cloneable, Comparable<AnnotationType>

    public final class AnnotationType
    extends HierarchicalEnumValue<AnnotationType>
    implements AnnotatableType

    An AnnotationType defines an Annotation, which is a typed (e.g. token, sentence, phrase chunk) span of text on a document having a defined set of attributes and relations. AnnotationTypes are hierarchical meaning that each type has a parent (ANNOTATION by default) and can have subtypes.Additionally, each AnnotationType has an associated Tag attribute type, which represents the central attribute of the annotation type (e.g. entity type for entities and part-of-speech for tokens.). By default, an annotation's tag type is inherited from the parent or defined as being a StringTag.

    The following code snippet illustrates creating a simple AnnotationType with the default parent and a and an AnnotationType whose parent is ENTITY.:

     
     // Assume that SENSE_TAG is a predefined AttributeType
     AnnotationType WORD_SENSE=AnnotationType.make("WORD_SENSE",SENSE_TAG);
     // MY_ENTITY will be a type of ENTITY and have an ENTITY_TYPE tag attribute inherited from ENTITY
     AnnotationType MY_ENTITY=AnnotationType.make(ENTITY,"MY_ENTITY");
     
     

    See Also:
    Serialized Form
    • Method Detail

      • isDefined

        public static boolean isDefined​(String name)
        Determines if the given name is a defined AnnotationType
        Parameters:
        name - the name
        Returns:
        True if the name is a defined AnnotationType, False otherwise
      • make

        public static AnnotationType make​(AnnotationType parent,
                                          String name,
                                          AttributeType<? extends Tag> tagAttributeType)
        Makes a new or retrieves an existing AnnotationType with the given parent and name
        Parameters:
        parent - the parent AnnotationType
        name - the name of the AnnotationType
        tagAttributeType - the tag attribute type
        Returns:
        the AnnotationType
      • make

        public static AnnotationType make​(String name,
                                          AttributeType<? extends Tag> tagAttributeType)
        Makes a new or retrieves an existing AnnotationType.
        Parameters:
        name - the name of the AnnotationType
        tagAttributeType - the tag attribute type
        Returns:
        the AnnotationType
      • make

        public static AnnotationType make​(AnnotationType parent,
                                          String name)
        Makes a new or retrieves an existing AnnotationType with the given parent and name
        Parameters:
        parent - the parent AnnotationType
        name - the name of the AnnotationType
        Returns:
        the AnnotationType
      • make

        public static AnnotationType make​(String name)
        Makes a new or retrieves an existing AnnotationType.
        Parameters:
        name - the name of the AnnotationType
        Returns:
        the AnnotationType
      • valueOf

        public static AnnotationType valueOf​(String name)
        Description copied from interface: AnnotatableType

        Determines the correct AnnotatableType from the given name. Checks are made in the following order:

        1. ShorthandTypeName.VALUE
          e.g. Annotation.ENTITY
        2. FullyQualifiedClassName.VALUE
          e.g. com.gengoai.hermes.morphology.POS.NOUN
        3. Already defined name in the order:
          (1) Annotation (2) Attribute (3) Relation
        Parameters:
        name - the name
        Returns:
        the AnnotatableType
      • values

        public static Collection<AnnotationType> values()
        Returns:
        the collection of all currently registered AnnotationType
      • getTagAttribute

        public AttributeType<Tag> getTagAttribute()
        Returns:
        the attribute associated with the tag of this annotation.
      • type

        public String type()
        Specified by:
        type in interface AnnotatableType
        Returns:
        The type (Annotation, Attribute, Relation)