public abstract class AbstractSemanticAnnotationHelper extends Object implements SemanticAnnotationHelper
documentStart(Document)
documentEnd()
getMentions(String, Map, QueryEngine)
,
which simply calls SemanticAnnotationHelper.getMentions(String, List, QueryEngine)
after
creating the appropriate constraints.#init(Indexer)
and #init(QueryEngine)
methods, they must first call super.init(...).
If a particular helper does not support certain feature types it should
use the concatenateArrays(java.lang.String[]...)
method to combine those features with
another kind that it can support, during the init(Indexer) call. For example,
helpers that do not have access to a full semantic repository may choose to
treat URI features as if they were simply text features with no semantics.
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractSemanticAnnotationHelper.MentionDescriber
Interface for supporting classes used by
AbstractSemanticAnnotationHelper and its sub-classes to provide a
pluggable implementation for
SemanticAnnotationHelper.describeMention(String) . |
SemanticAnnotationHelper.Mode
Modifier and Type | Field and Description |
---|---|
protected String |
annotationType
The type of the annotations handled by this helper.
|
protected String[] |
descriptiveFeatures
The list of names for all the features that should be used when describing
an annotation mention (see
describeMention(String) ). |
protected String[] |
floatFeatureNames
The list of names for the numeric features.
|
protected String[] |
integerFeatureNames
The list of names for the numeric features.
|
protected AbstractSemanticAnnotationHelper.MentionDescriber |
mentionDescriber |
protected SemanticAnnotationHelper.Mode |
mode
The working mode for this helper (defaults to
Mode#ANNOTATION ). |
protected String[] |
nominalFeatureNames
The list of names for the nominal features.
|
protected String[] |
textFeatureNames
The list of names for the text features.
|
protected String[] |
uriFeatureNames
The list of names for the URI features.
|
Constructor and Description |
---|
AbstractSemanticAnnotationHelper() |
Modifier and Type | Method and Description |
---|---|
protected static String[] |
concatenateArrays(String[]... arrays)
Helper method to concatenate a number of arrays into one, for helpers
that don't support all the feature types and want to combine some of
them together.
|
String |
describeMention(String mentionUri)
Provides a human-friendly representation of a mention, specified by the
given URI.
|
void |
documentEnd()
Notifies this helper that the current document has finished.
|
void |
documentStart(gate.Document document)
Prepares this helper for running on a new document.
|
String |
getAnnotationType() |
protected String[] |
getDescriptiveFeatures()
Gets the names of features that should be used when describing an
annotation mention.
|
protected String[] |
getDescriptiveFeatureValues(String mentionUri)
Calculates the textual representations for the values of features that are
part of the description of an annotation mention.
|
String[] |
getFloatFeatures() |
String[] |
getIntegerFeatures() |
AbstractSemanticAnnotationHelper.MentionDescriber |
getMentionDescriber() |
List<Mention> |
getMentions(String annotationType,
Map<String,String> constraints,
QueryEngine engine)
Convenience method: variant of
SemanticAnnotationHelper.getMentions(String, List, QueryEngine) , where all constraints are
of type ConstraintType.EQ . |
SemanticAnnotationHelper.Mode |
getMode()
Checks whether this helper is configured to work in
SemanticAnnotationHelper.Mode.ANNOTATION
or SemanticAnnotationHelper.Mode.DOCUMENT mode. |
String[] |
getNominalFeatures() |
String[] |
getTextFeatures() |
String[] |
getUriFeatures() |
void |
init(AtomicAnnotationIndex index)
Called by the containing
MimirIndex when this helper is first
created. |
protected boolean |
isInited() |
void |
setAnnotationType(String annotationType) |
void |
setAnnType(String annotationType) |
void |
setDescriptiveFeatures(String[] descriptiveFeatures)
Sets the names of features that should be used when describing an
annotation mention.
|
void |
setFloatFeatures(String[] floatFeatureNames) |
void |
setIntegerFeatures(String[] integerFeatureNames) |
void |
setMentionDescriber(AbstractSemanticAnnotationHelper.MentionDescriber mentionDescriber)
Sets the
AbstractSemanticAnnotationHelper.MentionDescriber to be used as the implementation of
SemanticAnnotationHelper.describeMention(String) . |
void |
setMode(SemanticAnnotationHelper.Mode mode) |
void |
setNominalFeatures(String[] nominalFeatureNames) |
void |
setTextFeatures(String[] textFeatureNames) |
void |
setUriFeatures(String[] uriFeatureNames) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, close, getMentions, getMentionUris, isMentionUri
protected String[] nominalFeatureNames
protected String[] integerFeatureNames
protected String[] floatFeatureNames
protected String[] textFeatureNames
protected String[] uriFeatureNames
protected String annotationType
protected String[] descriptiveFeatures
describeMention(String)
).protected AbstractSemanticAnnotationHelper.MentionDescriber mentionDescriber
protected SemanticAnnotationHelper.Mode mode
Mode#ANNOTATION
).protected final boolean isInited()
public SemanticAnnotationHelper.Mode getMode()
SemanticAnnotationHelper
SemanticAnnotationHelper.Mode.ANNOTATION
or SemanticAnnotationHelper.Mode.DOCUMENT
mode.getMode
in interface SemanticAnnotationHelper
public void setMode(SemanticAnnotationHelper.Mode mode)
public String getAnnotationType()
public void setAnnotationType(String annotationType)
public void setAnnType(String annotationType)
public String[] getNominalFeatures()
public void setNominalFeatures(String[] nominalFeatureNames)
public String[] getIntegerFeatures()
public void setIntegerFeatures(String[] integerFeatureNames)
public String[] getFloatFeatures()
public void setFloatFeatures(String[] floatFeatureNames)
public String[] getTextFeatures()
public void setTextFeatures(String[] textFeatureNames)
public String[] getUriFeatures()
public void setUriFeatures(String[] uriFeatureNames)
protected String[] getDescriptiveFeatures()
public void setDescriptiveFeatures(String[] descriptiveFeatures)
#init(QueryEngine)
).
If no custom value has been set before #init(QueryEngine)
is
called, then all features are used as descriptive features.descriptiveFeatures
- the descriptiveFeatures to setpublic AbstractSemanticAnnotationHelper.MentionDescriber getMentionDescriber()
public void setMentionDescriber(AbstractSemanticAnnotationHelper.MentionDescriber mentionDescriber)
AbstractSemanticAnnotationHelper.MentionDescriber
to be used as the implementation of
SemanticAnnotationHelper.describeMention(String)
.
If set to null
, then an instance of
DefaultMentionDescriber
is automatically created and used.mentionDescriber
- the custom mentionDescriber to usepublic void documentEnd()
SemanticAnnotationHelper
documentEnd
in interface SemanticAnnotationHelper
public void documentStart(gate.Document document)
SemanticAnnotationHelper
documentStart
in interface SemanticAnnotationHelper
document
- the new document.public List<Mention> getMentions(String annotationType, Map<String,String> constraints, QueryEngine engine)
SemanticAnnotationHelper
SemanticAnnotationHelper.getMentions(String, List, QueryEngine)
, where all constraints are
of type ConstraintType.EQ
.getMentions
in interface SemanticAnnotationHelper
annotationType
- the annotation type.constraints
- constraints on the annotation's feature values.engine
- the QueryEngine
in which this query will be
running.public String describeMention(String mentionUri)
SemanticAnnotationHelper
describeMention
in interface SemanticAnnotationHelper
mentionUri
- the mention URI, a string identical to the one that would
be returned by one of the getMentions() methods. There is no requirement
that the actual string value was previously obtained from a getMentions()
call.protected String[] getDescriptiveFeatureValues(String mentionUri)
descriptiveFeatures
.
This implementation always returns null
as the abstract class
has no way of accessing the actual feature values. Subclasses should
provide an actual implementation to support proper mention descriptions.mentionUri
- the URI for the mention that needs to be described.descriptiveFeatures
, or
null if the feature values are not known.protected static String[] concatenateArrays(String[]... arrays)
public void init(AtomicAnnotationIndex index)
SemanticAnnotationHelper
MimirIndex
when this helper is first
created.init
in interface SemanticAnnotationHelper
index
- the AtomicAnnotationIndex
this helpers is used by.Copyright © 2021 GATE. All rights reserved.