Package com.gengoai.hermes
Interface AnnotatableType
-
- All Known Implementing Classes:
AnnotationType
,AttributeType
,RelationType
public interface AnnotatableType
An annotatable type is one that can be added to a document through annotation either by
Corpus.annotate(AnnotatableType...)
orDocument.annotate(AnnotatableType...)
. The interface exists to unifyAnnotationType
s,AttributeType
s, andRelationType
s.- Author:
- David B. Bracewell
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
AnnotatableType.Deserializer
static class
AnnotatableType.KeyDeserializer
static class
AnnotatableType.Serializer
-
Field Summary
Fields Modifier and Type Field Description static String
ANNOTATOR_PACKAGE
Package to look for default annotator implementations.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
canonicalName()
The canonical name of the type (typically in the form ofPackageName.ClassName.Name
)default Annotator
getAnnotator(@NonNull Language language)
Gets the annotator associated with this type for a given language.String
name()
String
type()
static AnnotatableType
valueOf(String name)
Determines the correct AnnotatableType from the given name.
-
-
-
Field Detail
-
ANNOTATOR_PACKAGE
static final String ANNOTATOR_PACKAGE
Package to look for default annotator implementations.- See Also:
- Constant Field Values
-
-
Method Detail
-
valueOf
static AnnotatableType valueOf(String name)
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
-
canonicalName
String canonicalName()
The canonical name of the type (typically in the form ofPackageName.ClassName.Name
)- Returns:
- the canonical form of the name
-
getAnnotator
default Annotator getAnnotator(@NonNull @NonNull Language language)
Gets the annotator associated with this type for a given language. First, an annotator is checked for in the config usingType.Language.Name.Annotator
(e.g.Annotation.ENGLISH.ENTITY.Annotator
where the language is optional. If not found, it will then check for classes that meet common conventions in the following order:- com.gengoai.hermes.[LANG_CODE_LOWER].[LANG_CODE_UPPER][TYPE_NAME_TITLE_CASE][ANNOTATOR], e.g. com.gengoai.hermes.en.ENEntityAnnotator
- com.gengoai.hermes.annotator.Default[LANG_NAME_TITLE_CASE][TYPE_NAME_TITLE_CASE][ANNOTATOR], e.g. com.gengoai.hermes.annotator.DefaultEnglishEntityAnnotator
- com.gengoai.hermes.annotator.Default[TYPE_NAME_TITLE_CASE][ANNOTATOR], e.g. com.gengoai.hermes.annotator.DefaultEntityAnnotator
- Parameters:
language
- the language for which the annotator is needed.- Returns:
- the annotator for this type and the given language
- Throws:
IllegalStateException
- If no annotator is defined or the defined annotator does not satisfy this type.
-
name
String name()
- Returns:
- The annotatable type's name (e.g. TOKEN, PART_OF_SPEECH)
-
type
String type()
- Returns:
- The type (Annotation, Attribute, Relation)
-
-