@CreoleResource(name="JAPE-Plus Transducer",
comment="An optimised, JAPE-compatible transducer.",
icon="JapePlus")
public class Transducer
extends gate.creole.AbstractLanguageAnalyser
implements gate.creole.ControllerAwarePR, gate.event.ProgressListener, gate.gui.ActionsPublisher
LanguageAnalyser
interface.Modifier and Type | Class and Description |
---|---|
protected class |
Transducer.AnnotationComparator
A comparator for annotations based on start offset and inverse length.
|
protected class |
Transducer.AnnSetListener
A listener for the input annotation set, which invalidates the pre-built
lists of sorted annotation when they change due to the execution of one of
the phases.
|
protected class |
Transducer.SerialiseTransducerAction |
protected static class |
Transducer.SinglePhaseTransducerPDA
Modified version of SPT that produces a different type of FSM data.
|
static class |
Transducer.SPTData
Class used for storing binary representations of JAPE Plus transducers.
|
Modifier and Type | Field and Description |
---|---|
protected gate.jape.DefaultActionContext |
actionContext |
protected List<Action> |
actions |
protected List<String> |
annotationAccessors
List of class names for any custom
AnnotationAccessor s. |
protected Transducer.AnnotationComparator |
annotationComparator
Instance of
Transducer.AnnotationComparator used for sorting annots for the
phases. |
protected URL |
binaryGrammarURL
The URL to the serialised jape file used as grammar by this transducer.
|
protected Set<String> |
changedTypes
A set of annotation types that were modified during the latest execution of
a pahse.
|
protected int |
currentSptIndex
The index in
singlePhaseTransducers for the SPT currently being
executed, if any, -1 otherwise. |
protected Boolean |
enableDebugging |
protected String |
encoding |
protected URL |
grammarURL
The source from which this transducer is created.
|
protected gate.event.AnnotationSetListener |
inputASListener
The listener that keeps track of the annotation types that have changed.
|
protected String |
inputASName |
protected gate.creole.ontology.Ontology |
ontology |
protected List<String> |
operators
List of class names for any custom
ConstraintPredicate . |
protected String |
outputASName |
protected SPTBase[] |
singlePhaseTransducers
The list of phases used in this transducer.
|
protected Transducer.SPTData[] |
singlePhaseTransducersData |
protected Map<String,gate.Annotation[]> |
sortedAnnotations
The sets of annotations (of a given type) that have already been sorted.
|
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
Constructor and Description |
---|
Transducer() |
Modifier and Type | Method and Description |
---|---|
void |
cleanup() |
void |
controllerExecutionAborted(gate.Controller c,
Throwable t) |
void |
controllerExecutionFinished(gate.Controller c) |
void |
controllerExecutionStarted(gate.Controller c) |
void |
execute() |
List<Action> |
getActions() |
List<String> |
getAnnotationAccessors()
Gets the list of class names for any custom
AnnotationAccessor s. |
URL |
getBinaryGrammarURL() |
gate.util.GateClassLoader |
getClassLoader()
This method is public only for the benefit of
Factory.duplicate(gate.Resource)
and should not be called directly |
AtomicInteger |
getClassLoaderRefCount()
This method is public only for the benefit of
Factory.duplicate(gate.Resource)
and should not be called directly |
Boolean |
getEnableDebugging() |
String |
getEncoding() |
Transducer |
getExistingTransducer()
This method is public only for the benefit of
Factory.duplicate(gate.Resource)
and should not be called directly |
URL |
getGrammarURL() |
String |
getInputASName() |
gate.creole.ontology.Ontology |
getOntology() |
List<String> |
getOperators()
Gets the list of class names for any custom boolean operators.
|
String |
getOutputASName() |
gate.Annotation[] |
getSortedAnnotations(String type)
Get the set of annotations, of a given type, sorted by start offset and
inverse length, obtained from the input annotation set of the current
document.
|
gate.Resource |
init() |
protected gate.jape.DefaultActionContext |
initActionContext()
Method that initialises the ActionContext.
|
protected void |
initCustomConstraints()
Loads any custom operators and annotation accessors into the ConstraintFactory.
|
static void |
main(String[] args)
This is testing code used during development.
|
protected void |
parseJape() |
void |
processFinished() |
void |
progressChanged(int i) |
void |
reInit() |
void |
setAnnotationAccessors(List<String> annotationAccessors)
Sets the list of class names for any custom
AnnotationAccessor s. |
void |
setBinaryGrammarURL(URL binaryGrammarURL) |
void |
setClassLoader(gate.util.GateClassLoader classLoader)
This method is public only for the benefit of
Factory.duplicate(gate.Resource)
and should not be called directly |
void |
setClassLoaderRefCount(AtomicInteger classLoaderRefCount)
This method is public only for the benefit of
Factory.duplicate(gate.Resource)
and should not be called directly |
void |
setEnableDebugging(Boolean enableDebugging) |
void |
setEncoding(String encoding) |
void |
setExistingTransducer(Transducer existingTransducer)
This method is public only for the benefit of
Factory.duplicate(gate.Resource)
and should not be called directly |
void |
setGrammarURL(URL source) |
void |
setInputASName(String inputASName) |
void |
setOntology(gate.creole.ontology.Ontology onto) |
void |
setOperators(List<String> operators)
Sets the list of class names for any custom boolean operators.
|
void |
setOutputASName(String outputASName) |
getCorpus, getDocument, setCorpus, setDocument
addProgressListener, addStatusListener, fireProcessFinished, fireProgressChanged, fireStatusChanged, getRuntimeParameterValues, getRuntimeParameterValues, interrupt, isInterrupted, 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 URL grammarURL
protected List<String> annotationAccessors
AnnotationAccessor
s.protected Boolean enableDebugging
protected String encoding
protected String inputASName
protected String outputASName
protected gate.jape.DefaultActionContext actionContext
protected URL binaryGrammarURL
protected Transducer.AnnotationComparator annotationComparator
Transducer.AnnotationComparator
used for sorting annots for the
phases.protected Map<String,gate.Annotation[]> sortedAnnotations
protected Set<String> changedTypes
protected gate.event.AnnotationSetListener inputASListener
protected Transducer.SPTData[] singlePhaseTransducersData
protected transient SPTBase[] singlePhaseTransducers
protected int currentSptIndex
singlePhaseTransducers
for the SPT currently being
executed, if any, -1 otherwise.protected gate.creole.ontology.Ontology ontology
public URL getGrammarURL()
@CreoleParameter(comment="URL for the data from which this transducer should be built.", suffixes=".jape", disjunction="grammar", priority=1) public void setGrammarURL(URL source)
public gate.util.GateClassLoader getClassLoader()
Factory.duplicate(gate.Resource)
and should not be called directly@Sharable public void setClassLoader(gate.util.GateClassLoader classLoader)
Factory.duplicate(gate.Resource)
and should not be called directlypublic AtomicInteger getClassLoaderRefCount()
Factory.duplicate(gate.Resource)
and should not be called directly@Sharable public void setClassLoaderRefCount(AtomicInteger classLoaderRefCount)
Factory.duplicate(gate.Resource)
and should not be called directlypublic List<String> getOperators()
ConstraintPredicate
.@Optional @CreoleParameter(comment="Class names that implement gate.jape.constraint.ConstraintPredicate.") public void setOperators(List<String> operators)
ConstraintPredicate
.public List<String> getAnnotationAccessors()
AnnotationAccessor
s.public List<Action> getActions()
getActions
in interface gate.gui.ActionsPublisher
@Optional @CreoleParameter(comment="Class names that implement gate.jape.constraint.AnnotationAccessor.") public void setAnnotationAccessors(List<String> annotationAccessors)
AnnotationAccessor
s.public Boolean getEnableDebugging()
@RunTime @CreoleParameter(defaultValue="false") public void setEnableDebugging(Boolean enableDebugging)
public String getEncoding()
@CreoleParameter(defaultValue="UTF-8", comment="The encoding used for the input .jape files.") public void setEncoding(String encoding)
public Transducer getExistingTransducer()
Factory.duplicate(gate.Resource)
and should not be called directly@Sharable public void setExistingTransducer(Transducer existingTransducer)
Factory.duplicate(gate.Resource)
and should not be called directlypublic void reInit() throws gate.creole.ResourceInstantiationException
reInit
in interface gate.ProcessingResource
reInit
in class gate.creole.AbstractProcessingResource
gate.creole.ResourceInstantiationException
public gate.Resource init() throws gate.creole.ResourceInstantiationException
init
in interface gate.Resource
init
in class gate.creole.AbstractProcessingResource
gate.creole.ResourceInstantiationException
protected gate.jape.DefaultActionContext initActionContext()
protected void initCustomConstraints() throws gate.creole.ResourceInstantiationException
gate.creole.ResourceInstantiationException
protected void parseJape() throws IOException, gate.jape.parser.ParseException, gate.creole.ResourceInstantiationException
IOException
gate.jape.parser.ParseException
gate.creole.ResourceInstantiationException
public void cleanup()
cleanup
in interface gate.Resource
cleanup
in class gate.creole.AbstractProcessingResource
public void execute() throws gate.creole.ExecutionException
execute
in interface gate.Executable
execute
in class gate.creole.AbstractProcessingResource
gate.creole.ExecutionException
public void progressChanged(int i)
progressChanged
in interface gate.event.ProgressListener
public void processFinished()
processFinished
in interface gate.event.ProgressListener
public gate.Annotation[] getSortedAnnotations(String type)
type
- the type of annotations requested.Annotation
values.public URL getBinaryGrammarURL()
@CreoleParameter(comment="The URL to the binary grammar file.", suffixes=".jplus.z", disjunction="grammar", priority=100) public void setBinaryGrammarURL(URL binaryGrammarURL)
public String getInputASName()
@CreoleParameter(comment="The name of the input annotation set.") @Optional @RunTime public void setInputASName(String inputASName)
inputASName
- the inputASName to setpublic String getOutputASName()
@CreoleParameter(comment="The name of the output annotation set.") @Optional @RunTime public void setOutputASName(String outputASName)
outputASName
- the outputASName to set@CreoleParameter(comment="The ontology LR to be used by this transducer") @Optional @RunTime public void setOntology(gate.creole.ontology.Ontology onto)
public gate.creole.ontology.Ontology getOntology()
public void controllerExecutionStarted(gate.Controller c) throws gate.creole.ExecutionException
controllerExecutionStarted
in interface gate.creole.ControllerAwarePR
gate.creole.ExecutionException
public void controllerExecutionFinished(gate.Controller c) throws gate.creole.ExecutionException
controllerExecutionFinished
in interface gate.creole.ControllerAwarePR
gate.creole.ExecutionException
public void controllerExecutionAborted(gate.Controller c, Throwable t) throws gate.creole.ExecutionException
controllerExecutionAborted
in interface gate.creole.ControllerAwarePR
gate.creole.ExecutionException
public static void main(String[] args)