public abstract class SPTBase
extends gate.creole.AbstractLanguageAnalyser
Modifier and Type | Class and Description |
---|---|
protected class |
SPTBase.FSMInstance
An instance of the state machine.
|
static class |
SPTBase.MatchMode
Enum for matching modes.
|
protected static class |
SPTBase.State
A state for the finite state machine.
|
protected static class |
SPTBase.Transition
A transition in the state machine.
|
Modifier and Type | Field and Description |
---|---|
protected List<SPTBase.FSMInstance> |
acceptingInstances
The list of FSM instances that have reached a final state.
|
protected gate.jape.ControllerEventBlocksAction |
actionblocks |
protected gate.jape.ActionContext |
actionContext |
protected LinkedList<SPTBase.FSMInstance> |
activeInstances
The list of active FSM instances.
|
protected gate.Annotation[] |
annotation
An array of all the input annotations, sorted by start offset, then inverse
length.
|
protected static int |
ANNOTATION_TYPE_OTHER
The pseudo-type used for annotations that are of a type not mentioned in
the rules.
|
protected int[] |
annotationFollowing
An array that, for each input annotation, points to the first annotation
starting at (or after) the offset where the current annotation ends.
|
protected int[] |
annotationNextOffset
For each annotation, this array holds the index (in the
annotation
array) of the first annotation starting at the next offset (following this
annotation's start offset). |
protected long[][] |
annotationPredicateComputed
Used for the predicates cache.
|
protected long[][] |
annotationPredicateValues
Used for the predicates cache.
|
protected int[] |
annotationType
The type for each annotation in the
annotation array. |
protected String[] |
annotationTypes
An array containing all the annotation types that are relevant to this
transducer (that is, all the types mentioned in rules).
|
protected String[] |
bindingNames
The binding names to be used when a transition of type closing-round-bracket
is consumed during the traversal.
|
protected boolean |
debugMode
Should the transducer log warnings when multiple matches are possible in
Appelt mode?
|
protected boolean |
groupMatchingMode
Should the transducer apply all possible matches when multiple matches are
possible in Appelt mode?
|
protected String[] |
inputAnnotationTypes
An array containing all the annotation types that are listed in the Input
specification.
|
protected gate.AnnotationSet |
inputAS
The actual input annotation set.
|
protected String |
inputASName
The name for the input annotation set.
|
protected SPTBase.MatchMode |
matchMode
The type of matching used for this transducer.
|
protected static int |
NOT_CALCULATED
Value used for int fields whose value was not yet calculated.
|
protected gate.creole.ontology.Ontology |
ontology
The Ontology used during matching.
|
protected String |
outputASName
The name for the output annotation set.
|
protected Transducer |
owner
The
Transducer within which this SPT is running. |
protected NumberFormat |
percentFormat |
protected String |
phaseName |
protected long |
predicateHits
Used for counting the number of predicate hits (cases where checking a
predicate was not needed due to the cache).
|
protected long |
predicateMisses
Used for counting the number of predicate misses (cases where pre-computed
truth value of a predicate was not found in the cache).
|
protected Predicate[][] |
predicatesByType
Stores all the atomic predicates used in this transducer.
|
protected gate.jape.Rule[] |
rules
The set of rules in this transducer.
|
ANNOTATION_COREF_FEATURE_NAME, DATE_ANNOTATION_TYPE, DATE_POSTED_ANNOTATION_TYPE, DEFAULT_FILE, DOCUMENT_COREF_FEATURE_NAME, JOB_ID_ANNOTATION_TYPE, LOCATION_ANNOTATION_TYPE, LOOKUP_ANNOTATION_TYPE, LOOKUP_CLASS_FEATURE_NAME, LOOKUP_INSTANCE_FEATURE_NAME, LOOKUP_LANGUAGE_FEATURE_NAME, LOOKUP_MAJOR_TYPE_FEATURE_NAME, LOOKUP_MINOR_TYPE_FEATURE_NAME, LOOKUP_ONTOLOGY_FEATURE_NAME, MONEY_ANNOTATION_TYPE, ORGANIZATION_ANNOTATION_TYPE, PERSON_ANNOTATION_TYPE, PERSON_GENDER_FEATURE_NAME, PLUGIN_DIR, SENTENCE_ANNOTATION_TYPE, SPACE_TOKEN_ANNOTATION_TYPE, TOKEN_ANNOTATION_TYPE, TOKEN_CATEGORY_FEATURE_NAME, TOKEN_KIND_FEATURE_NAME, TOKEN_LENGTH_FEATURE_NAME, TOKEN_ORTH_FEATURE_NAME, TOKEN_STRING_FEATURE_NAME
Modifier | Constructor and Description |
---|---|
protected |
SPTBase(String phaseName,
String[] bindingNames,
String[] annotationTypes,
boolean debugMode,
boolean groupMatchingMode,
SPTBase.MatchMode matchMode,
gate.jape.Rule[] rules,
Predicate[][] predicatesByType) |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
advanceInstance(SPTBase.FSMInstance instance)
Advances the provided instance according to the transition graph,
generating new active instances as required.
|
protected void |
applyRule(SPTBase.FSMInstance instance) |
protected static int |
binarySearchFromTo(int[] array,
int from,
int to,
cern.colt.function.IntComparator comp) |
protected boolean |
calculatePredicateValue(int annotationId,
int predicateId) |
protected boolean |
checkPredicate(int annotationId,
int predicateId)
Checks whether a predicate matches the annotation at given ID inside the
annotations table.
|
protected gate.jape.Rule[] |
copyRules() |
protected abstract SPTBase |
duplicate()
Create an independent copy of this SPT.
|
protected static List<int[]> |
enumerateCombinations(cern.colt.list.IntArrayList[] candidates)
Calculates all possible N-uples given a set of candidate slot fillers.
|
void |
execute()
Runs the transducer.
|
protected int |
followingAnnotation(int idx)
Returns the index in the
annotation array, where the range of next
annotations for a given annotation starts. |
protected void |
generateAllNewInstances(SPTBase.FSMInstance instance,
int nextState,
cern.colt.list.IntArrayList[] annotsForConstraints) |
String |
getInputASName() |
String |
getOutputASName() |
protected void |
loadAnnotations()
Populates the internal data structures with the input annotations.
|
protected void |
prepareControllerEventBlocksAction(gate.jape.ActionContext ac,
gate.Controller c,
gate.creole.ontology.Ontology o) |
protected void |
runControllerExecutionAbortedBlock(gate.jape.ActionContext ac,
gate.Controller c,
Throwable t,
gate.creole.ontology.Ontology o) |
protected void |
runControllerExecutionFinishedBlock(gate.jape.ActionContext ac,
gate.Controller c,
gate.creole.ontology.Ontology o) |
protected void |
runControllerExecutionStartedBlock(gate.jape.ActionContext ac,
gate.Controller c,
gate.creole.ontology.Ontology o) |
void |
setActionContext(gate.jape.ActionContext ac)
Sets the action context to be used during execution of RHS actions.
|
void |
setControllerEventBlocksAction(gate.jape.ControllerEventBlocksAction abs) |
void |
setInputASName(String inputASName) |
void |
setOntology(gate.creole.ontology.Ontology onto) |
void |
setOutputASName(String outputASName) |
void |
setOwner(Transducer owner) |
getCorpus, getDocument, setCorpus, setDocument
addProgressListener, addStatusListener, cleanup, fireProcessFinished, fireProgressChanged, fireStatusChanged, getRuntimeParameterValues, getRuntimeParameterValues, init, interrupt, isInterrupted, reInit, removeProgressListener, removeStatusListener
checkParameterValues, flushBeanInfoCache, forgetBeanInfo, getBeanInfo, getInitParameterValues, getInitParameterValues, getName, getParameterValue, getParameterValue, getParameterValues, removeResourceListeners, setName, setParameterValue, setParameterValue, setParameterValues, setParameterValues, setResourceListeners, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
protected gate.jape.ActionContext actionContext
protected gate.creole.ontology.Ontology ontology
protected String inputASName
protected gate.AnnotationSet inputAS
protected String outputASName
protected Transducer owner
Transducer
within which this SPT is running.protected String[] inputAnnotationTypes
protected final String[] annotationTypes
protected final Predicate[][] predicatesByType
protected final String phaseName
protected static final int ANNOTATION_TYPE_OTHER
protected static final int NOT_CALCULATED
protected gate.Annotation[] annotation
protected int[] annotationType
annotation
array. The values
in this array are either an index in the annotationTypes
array, or
ANNOTATION_TYPE_OTHER
.protected int[] annotationNextOffset
annotation
array) of the first annotation starting at the next offset (following this
annotation's start offset).protected long[][] annotationPredicateComputed
protected long[][] annotationPredicateValues
annotationPredicateComputed
), then each bit
in this vector stores the result of the previous calculation.protected int[] annotationFollowing
protected final String[] bindingNames
Transducer.SinglePhaseTransducerPDA
.getFSM().getBindingNames().protected long predicateHits
protected long predicateMisses
protected NumberFormat percentFormat
protected final gate.jape.Rule[] rules
protected final SPTBase.MatchMode matchMode
protected final boolean debugMode
protected final boolean groupMatchingMode
protected LinkedList<SPTBase.FSMInstance> activeInstances
protected List<SPTBase.FSMInstance> acceptingInstances
protected gate.jape.ControllerEventBlocksAction actionblocks
protected SPTBase(String phaseName, String[] bindingNames, String[] annotationTypes, boolean debugMode, boolean groupMatchingMode, SPTBase.MatchMode matchMode, gate.jape.Rule[] rules, Predicate[][] predicatesByType)
protected abstract boolean advanceInstance(SPTBase.FSMInstance instance) throws gate.jape.JapeException
instance
- the instance to be processedtrue
if the process should be stopped (e.g. an
accepting instance has been found, and the matching mode is FIRST or ONCE).gate.jape.JapeException
protected abstract SPTBase duplicate() throws gate.creole.ResourceInstantiationException
gate.creole.ResourceInstantiationException
protected gate.jape.Rule[] copyRules()
public void setActionContext(gate.jape.ActionContext ac)
ac
- protected void loadAnnotations()
protected static int binarySearchFromTo(int[] array, int from, int to, cern.colt.function.IntComparator comp)
protected int followingAnnotation(int idx)
annotation
array, where the range of next
annotations for a given annotation starts. This method is used to lazily
fill the annotationFollowing
array (once a value is calculated, it is
stored there; further requests for the same annotation idx will be answered
by directly looking up the previously calculated value).idx
- the index for the annotation whose next should be calculated.annotation
table for the first annotation
whose start offset is greater or equal than the end offset of the
provided annotation.protected boolean checkPredicate(int annotationId, int predicateId) throws gate.jape.JapeException
annotationId
- the ID in the input annotations table for the annotation to be
tested.predicateId
- the ID of the predicate to be tested (i.e. the index inside the
predicatesByType
array corresponding to the type of the
annotation.true
iff the annotation is accepted by the predicate.gate.jape.JapeException
- if a custom predicate generates it while performing
the test.protected boolean calculatePredicateValue(int annotationId, int predicateId) throws gate.jape.JapeException
gate.jape.JapeException
public void execute() throws gate.creole.ExecutionException
execute
in interface gate.Executable
execute
in class gate.creole.AbstractProcessingResource
gate.creole.ExecutionException
protected void generateAllNewInstances(SPTBase.FSMInstance instance, int nextState, cern.colt.list.IntArrayList[] annotsForConstraints)
protected void applyRule(SPTBase.FSMInstance instance) throws gate.jape.JapeException
gate.jape.JapeException
protected static final List<int[]> enumerateCombinations(cern.colt.list.IntArrayList[] candidates)
candidates
- an array on size N, where each row i contains a list of candidates
for the i-th position.public String getInputASName()
public void setInputASName(String inputASName)
inputASName
- the inputASName to setpublic String getOutputASName()
public void setOutputASName(String outputASName)
outputASName
- the outputASName to setpublic void setOwner(Transducer owner)
public void setOntology(gate.creole.ontology.Ontology onto)
public void setControllerEventBlocksAction(gate.jape.ControllerEventBlocksAction abs)
protected void prepareControllerEventBlocksAction(gate.jape.ActionContext ac, gate.Controller c, gate.creole.ontology.Ontology o)
protected void runControllerExecutionStartedBlock(gate.jape.ActionContext ac, gate.Controller c, gate.creole.ontology.Ontology o) throws gate.creole.ExecutionException
gate.creole.ExecutionException
protected void runControllerExecutionFinishedBlock(gate.jape.ActionContext ac, gate.Controller c, gate.creole.ontology.Ontology o) throws gate.creole.ExecutionException
gate.creole.ExecutionException
protected void runControllerExecutionAbortedBlock(gate.jape.ActionContext ac, gate.Controller c, Throwable t, gate.creole.ontology.Ontology o) throws gate.creole.ExecutionException
gate.creole.ExecutionException