public abstract class DelegatingSemanticAnnotationHelper extends AbstractSemanticAnnotationHelper
SemanticAnnotationHelper
that simply delegates all method calls to
another helper object. Use this as a base class for helpers that provide
search enhancements (converting higher-level search expressions into
appropriate low-level constraints) on top of any generic helper.
The default implementation of the "business" methods init/close, documentStart/End and getMentions/getMentionUris is to simply call the delegate's equivalent method. The logic for the "info" methods getNominal/Integer/Float/Text/UriFeatureNames is:
AbstractSemanticAnnotationHelper
(which can supply appropriate
information), then the value is obtained from the delegate, stored
locally, and returned. Future calls to the same method will use the locally
stored value.null
is returned.Note this class does not override the convenience method
AbstractSemanticAnnotationHelper.getMentions(String, Map, QueryEngine)
,
so this method is implemented as a call to
this.getMentions(String, List<Constraint>, QueryEngine)
,
not to delegate.getMentions(String, Map, QueryEngine)
.
AbstractSemanticAnnotationHelper.MentionDescriber
SemanticAnnotationHelper.Mode
Modifier and Type | Field and Description |
---|---|
protected SemanticAnnotationHelper |
delegate |
static String |
DELEGATE_KEY
Map key for the Groovy-friendly constructor in subclasses.
|
annotationType, descriptiveFeatures, floatFeatureNames, integerFeatureNames, mentionDescriber, mode, nominalFeatureNames, textFeatureNames, uriFeatureNames
Constructor and Description |
---|
DelegatingSemanticAnnotationHelper() |
Modifier and Type | Method and Description |
---|---|
void |
close(AtomicAnnotationIndex index)
Closes this annotation helper.
|
void |
close(QueryEngine qEngine)
Closes this annotation helper.
|
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() |
SemanticAnnotationHelper |
getDelegate() |
String[] |
getFloatFeatures() |
String[] |
getIntegerFeatures() |
List<Mention> |
getMentions(String annotationType,
List<Constraint> constraints,
QueryEngine engine)
This method supports searching for annotation mentions.
|
String[] |
getMentionUris(gate.Annotation annotation,
int length,
AtomicAnnotationIndex index)
This method converts an annotation into the corresponding semantic metadata
and returns the mention URIs corresponding to the original annotation.
|
SemanticAnnotationHelper.Mode |
getMode()
Always return the delegate's mode, as it makes no sense for a delegating
helper to operate in a different mode from its underlying delegate.
|
String[] |
getNominalFeatures() |
String[] |
getTextFeatures() |
String[] |
getUriFeatures() |
void |
init(AtomicAnnotationIndex index)
Called by the containing
MimirIndex when this helper is first
created. |
boolean |
isMentionUri(String mentionUri)
Checks whether the supplied string looks like a valid
mention URI that may have been returned by a call to
SemanticAnnotationHelper.getMentions(String, List, QueryEngine) or
SemanticAnnotationHelper.getMentions(String, Map, QueryEngine) . |
void |
setDelegate(SemanticAnnotationHelper delegate) |
concatenateArrays, getDescriptiveFeatures, getDescriptiveFeatureValues, getMentionDescriber, getMentions, isInited, setAnnotationType, setAnnType, setDescriptiveFeatures, setFloatFeatures, setIntegerFeatures, setMentionDescriber, setMode, setNominalFeatures, setTextFeatures, setUriFeatures
public static final String DELEGATE_KEY
protected SemanticAnnotationHelper delegate
public SemanticAnnotationHelper getDelegate()
public void setDelegate(SemanticAnnotationHelper delegate)
public String getAnnotationType()
getAnnotationType
in class AbstractSemanticAnnotationHelper
public String[] getNominalFeatures()
getNominalFeatures
in class AbstractSemanticAnnotationHelper
public String[] getIntegerFeatures()
getIntegerFeatures
in class AbstractSemanticAnnotationHelper
public String[] getFloatFeatures()
getFloatFeatures
in class AbstractSemanticAnnotationHelper
public String[] getTextFeatures()
getTextFeatures
in class AbstractSemanticAnnotationHelper
public String[] getUriFeatures()
getUriFeatures
in class AbstractSemanticAnnotationHelper
public SemanticAnnotationHelper.Mode getMode()
getMode
in interface SemanticAnnotationHelper
getMode
in class AbstractSemanticAnnotationHelper
public void init(AtomicAnnotationIndex index)
SemanticAnnotationHelper
MimirIndex
when this helper is first
created.init
in interface SemanticAnnotationHelper
init
in class AbstractSemanticAnnotationHelper
index
- the AtomicAnnotationIndex
this helpers is used by.public void documentStart(gate.Document document)
SemanticAnnotationHelper
documentStart
in interface SemanticAnnotationHelper
documentStart
in class AbstractSemanticAnnotationHelper
document
- the new document.public String[] getMentionUris(gate.Annotation annotation, int length, AtomicAnnotationIndex index)
SemanticAnnotationHelper
annotation
- the input annotation.length
- the length of the annotation (given as number of tokens).public List<Mention> getMentions(String annotationType, List<Constraint> constraints, QueryEngine engine)
SemanticAnnotationHelper
annotationType
- the type of annotation required.constraints
- a list of constraints that the sough annotation should
satisfy.engine
- the QueryEngine
in which this query will be running.public String describeMention(String mentionUri)
SemanticAnnotationHelper
describeMention
in interface SemanticAnnotationHelper
describeMention
in class AbstractSemanticAnnotationHelper
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.public boolean isMentionUri(String mentionUri)
SemanticAnnotationHelper
SemanticAnnotationHelper.getMentions(String, List, QueryEngine)
or
SemanticAnnotationHelper.getMentions(String, Map, QueryEngine)
.
Note that this is a superficial test that may be able to distinguish a URI
produced by this helper from one produced by another. It will not actually
access any data structure to check that the URI really is valid. The main
use case for this call is to distinguish different URIs indexed in the same
annotations index, but produced by different helpers.mentionUri
- the URI to test.true
if this URI looks like an URI produced by this
helper.public void documentEnd()
SemanticAnnotationHelper
documentEnd
in interface SemanticAnnotationHelper
documentEnd
in class AbstractSemanticAnnotationHelper
public void close(AtomicAnnotationIndex index)
SemanticAnnotationHelper
public void close(QueryEngine qEngine)
SemanticAnnotationHelper
Copyright © 2021 GATE. All rights reserved.