Class AnnotationType
- java.lang.Object
-
- com.gengoai.EnumValue<T>
-
- com.gengoai.HierarchicalEnumValue<AnnotationType>
-
- com.gengoai.hermes.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 associatedTag
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.gengoai.hermes.AnnotatableType
AnnotatableType.Deserializer, AnnotatableType.KeyDeserializer, AnnotatableType.Serializer
-
-
Field Summary
Fields Modifier and Type Field Description static AnnotationType
ROOT
The constant ROOT representing the base annotation type.static String
TYPE
The constant TYPE name.-
Fields inherited from class com.gengoai.HierarchicalEnumValue
SEPARATOR
-
Fields inherited from interface com.gengoai.hermes.AnnotatableType
ANNOTATOR_PACKAGE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeType<Tag>
getTagAttribute()
static boolean
isDefined(String name)
Determines if the given name is a defined AnnotationTypestatic AnnotationType
make(AnnotationType parent, String name)
Makes a new or retrieves an existing AnnotationType with the given parent and namestatic AnnotationType
make(AnnotationType parent, String name, AttributeType<? extends Tag> tagAttributeType)
Makes a new or retrieves an existing AnnotationType with the given parent and namestatic AnnotationType
make(String name)
Makes a new or retrieves an existing AnnotationType.static AnnotationType
make(String name, AttributeType<? extends Tag> tagAttributeType)
Makes a new or retrieves an existing AnnotationType.protected HierarchicalRegistry<AnnotationType>
registry()
String
type()
static AnnotationType
valueOf(String name)
Determines the correct AnnotatableType from the given name.static Collection<AnnotationType>
values()
-
Methods inherited from class com.gengoai.HierarchicalEnumValue
children, depth, isInstance, isLeaf, isRoot, label, parent, path
-
Methods inherited from class com.gengoai.EnumValue
canonicalName, clone, compareTo, equals, hashCode, main, name, readResolve, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.gengoai.hermes.AnnotatableType
canonicalName, getAnnotator, name
-
Methods inherited from interface com.gengoai.Tag
isInstance
-
-
-
-
Field Detail
-
TYPE
public static final String TYPE
The constant TYPE name.- See Also:
- Constant Field Values
-
ROOT
public static final AnnotationType ROOT
The constant ROOT representing the base annotation type.
-
-
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 AnnotationTypename
- the name of the AnnotationTypetagAttributeType
- 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 AnnotationTypetagAttributeType
- 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 AnnotationTypename
- 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:
- ShorthandTypeName.VALUE
e.g. Annotation.ENTITY - FullyQualifiedClassName.VALUE
e.g. com.gengoai.hermes.morphology.POS.NOUN - Already defined name in the order:
(1) Annotation (2) Attribute (3) Relation
- Parameters:
name
- the name- Returns:
- the AnnotatableType
- ShorthandTypeName.VALUE
-
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.
-
registry
protected HierarchicalRegistry<AnnotationType> registry()
- Specified by:
registry
in classHierarchicalEnumValue<AnnotationType>
-
type
public String type()
- Specified by:
type
in interfaceAnnotatableType
- Returns:
- The type (Annotation, Attribute, Relation)
-
-