|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgate.jape.Transducer
gate.jape.SinglePhaseTransducer
public class SinglePhaseTransducer
Represents a complete CPSL grammar, with a phase name, options and rule set (accessible by name and by sequence). Implements a transduce method taking a Document as input. Constructs from String or File.
| Nested Class Summary | |
|---|---|
private static class |
SinglePhaseTransducer.FSMMatcherResult
|
protected static class |
SinglePhaseTransducer.SearchState
|
| Field Summary | |
|---|---|
private static AtomicInteger |
actionClassNumber
|
protected List<FSMInstance> |
activeFSMInstances
A list of FSM instances that haven't blocked yet, used during matching. |
private String |
controllerAbortedEventBlock
|
private Object |
controllerEventBlocksActionClass
|
private String |
controllerEventBlocksActionClassName
|
private static String |
controllerEventBlocksActionClassSourceTemplate
|
private String |
controllerFinishedEventBlock
|
private String |
controllerStartedEventBlock
|
protected boolean |
finishedAlready
Whether the finish method has been called or not. |
protected FSM |
fsm
|
Set |
input
Defines the types of input annotations that this transducer reads. |
private String |
javaImportsBlock
|
protected static org.apache.log4j.Logger |
log
|
private static String |
nl
|
private Map<String,String> |
optionSettings
The values of any option settings given. |
private Vector |
progressListeners
|
protected int |
ruleApplicationStyle
Type of rule application (constants defined in JapeConstants). |
protected PrioritisedRuleList |
rules
The list of rules in this transducer. |
private static long |
serialVersionUID
|
private SourceInfo |
sourceInfo
|
| Fields inherited from class gate.jape.Transducer |
|---|
actionContext, benchmarkFeatures, benchmarkID, enableDebugging, interrupted, name, ontology |
| Fields inherited from interface gate.jape.JapeConstants |
|---|
ALL_STYLE, APPELT_STYLE, BRILL_STYLE, DEFAULT_PRIORITY, FIRST_STYLE, INDENT_PADDING, KLEENE_PLUS, KLEENE_QUERY, KLEENE_STAR, MULTI_SPAN_BINDING, NO_BINDING, NO_KLEENE_OP, ONCE_STYLE, SINGLE_SPAN_BINDING |
| Constructor Summary | |
|---|---|
SinglePhaseTransducer(String name)
Construction from name. |
|
| Method Summary | |
|---|---|
private void |
addAnnotationsByOffset(SimpleSortedSet keys,
Set annotations)
|
void |
addInput(String ident)
Adds a new type of input annotations used by this transducer. |
void |
addProgressListener(ProgressListener l)
|
void |
addRule(Rule rule)
Add a rule. |
private SinglePhaseTransducer.FSMMatcherResult |
attemptAdvance(FSMInstance currentInstance,
SimpleSortedSet offsets,
SimpleSortedSet annotationsByOffset,
Document document,
AnnotationSet inputAS)
Try to advance the activeFSMInstances. |
void |
cleanUp()
Clean up (delete action class files, for e.g.). |
private static List<List<Annotation>> |
combine(List<List<Annotation>> sourceLists,
int maxTupleSize,
List<Annotation> incompleteTuple)
Computes all tuples (x1, x2, ..., xn) resulting from the linear combination of the elements of n lists, where x1 comes from the 1st list, x2 comes from the second, etc. |
private void |
compileEventBlocksActionClass()
|
protected FSM |
createFSM()
|
void |
finish()
Finish: replace dynamic data structures with Java arrays; called after parsing. |
protected void |
fireProcessFinished()
|
protected void |
fireProgressChanged(int e)
This property affects the Appelt style of rules application. |
protected boolean |
fireRule(List<FSMInstance> acceptingFSMInstances,
SinglePhaseTransducer.SearchState state,
long lastNodeOff,
SimpleSortedSet offsets,
AnnotationSet inputAS,
AnnotationSet outputAS,
Document doc,
SimpleSortedSet annotationsByOffset)
Fire the rule that matched. |
String |
generateControllerEventBlocksCode(String started,
String finished,
String aborted,
String javaimports)
|
ControllerEventBlocksAction |
getControllerEventBlocksActionClass()
This returns any compiled controller event blocks action class that may exist at the time of calling or null. |
FSM |
getFSM()
|
String |
getOption(String name)
Get the value for a particular option. |
protected Annotation |
getRightMostAnnotation(Collection<Annotation> annots)
Return the annotation with the right-most end node |
int |
getRuleApplicationStyle()
|
PrioritisedRuleList |
getRules()
|
boolean |
hasInput(String ident)
Checks if this Phase has the annotation type as input. |
boolean |
isInputRestricted()
Check if there is a restriction on the input annotation types for this SPT, i.e. if there were annotation types specified for the "Input:" declaration of this phase. |
private void |
readObject(ObjectInputStream in)
|
void |
removeProgressListener(ProgressListener l)
|
void |
runControllerExecutionAbortedBlock(ActionContext ac,
Controller c,
Throwable t,
Ontology o)
|
void |
runControllerExecutionFinishedBlock(ActionContext ac,
Controller c,
Ontology o)
|
void |
runControllerExecutionStartedBlock(ActionContext ac,
Controller c,
Ontology o)
|
void |
setControllerEventBlocks(String started,
String finished,
String aborted,
String javaimports)
|
void |
setOption(String name,
String setting)
Add an option setting. |
void |
setRuleApplicationStyle(int style)
Set the type of rule application (types defined in JapeConstants). |
String |
toString()
A string representation of this object. |
String |
toString(String pad)
A string representation of this object. |
void |
transduce(Document doc,
AnnotationSet inputAS,
AnnotationSet outputAS)
Transduce a document using the annotation set provided and the current rule application style. |
private void |
updateRuleTime(FSMInstance currentInstance,
long startTime)
Increment the time spent by the rule associated with the FSM |
private void |
writeObject(ObjectOutputStream out)
|
| Methods inherited from class gate.jape.Transducer |
|---|
addStatusListener, fireStatusChanged, getBaseURL, getBenchmarkId, getName, getOntology, interrupt, isDebugMode, isEnableDebugging, isInterrupted, isMatchGroupMode, removeStatusListener, setActionContext, setBaseURL, setBenchmarkId, setDebugMode, setEnableDebugging, setMatchGroupMode, setOntology |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
protected static final org.apache.log4j.Logger log
private static AtomicInteger actionClassNumber
protected int ruleApplicationStyle
protected PrioritisedRuleList rules
protected FSM fsm
protected List<FSMInstance> activeFSMInstances
private Map<String,String> optionSettings
protected boolean finishedAlready
public Set input
private transient Vector progressListeners
private transient SourceInfo sourceInfo
private String controllerStartedEventBlock
private String controllerFinishedEventBlock
private String controllerAbortedEventBlock
private String javaImportsBlock
private Object controllerEventBlocksActionClass
private String controllerEventBlocksActionClassName
private static final String nl
private static final String controllerEventBlocksActionClassSourceTemplate
| Constructor Detail |
|---|
public SinglePhaseTransducer(String name)
| Method Detail |
|---|
public void setRuleApplicationStyle(int style)
public FSM getFSM()
public void addRule(Rule rule)
public void setOption(String name,
String setting)
public String getOption(String name)
public void finish()
finish in class Transducerprotected FSM createFSM()
private void addAnnotationsByOffset(SimpleSortedSet keys,
Set annotations)
public void transduce(Document doc,
AnnotationSet inputAS,
AnnotationSet outputAS)
throws JapeException,
ExecutionException
transduce in class TransducerJapeException
ExecutionException
private SinglePhaseTransducer.FSMMatcherResult attemptAdvance(FSMInstance currentInstance,
SimpleSortedSet offsets,
SimpleSortedSet annotationsByOffset,
Document document,
AnnotationSet inputAS)
private void updateRuleTime(FSMInstance currentInstance,
long startTime)
currentInstance - The FSMInstance which has been running since startTimestartTime - The time that the FSMInstance started runningprotected Annotation getRightMostAnnotation(Collection<Annotation> annots)
annots -
private static List<List<Annotation>> combine(List<List<Annotation>> sourceLists,
int maxTupleSize,
List<Annotation> incompleteTuple)
sourceLists - an array of n lists whose elements will be
combinedmaxTupleSize - the number of elements per tupleincompleteTuple - an empty list
protected boolean fireRule(List<FSMInstance> acceptingFSMInstances,
SinglePhaseTransducer.SearchState state,
long lastNodeOff,
SimpleSortedSet offsets,
AnnotationSet inputAS,
AnnotationSet outputAS,
Document doc,
SimpleSortedSet annotationsByOffset)
throws JapeException,
ExecutionException
JapeException
ExecutionExceptionpublic void cleanUp()
cleanUp in class Transducerpublic String toString()
toString in class Objectpublic String toString(String pad)
toString in class Transducerpublic PrioritisedRuleList getRules()
public void addInput(String ident)
public boolean hasInput(String ident)
ident - the type of an annotation to be checked
public boolean isInputRestricted()
public void removeProgressListener(ProgressListener l)
removeProgressListener in class Transducerpublic void addProgressListener(ProgressListener l)
addProgressListener in class Transducerprotected void fireProgressChanged(int e)
Transducer
fireProgressChanged in class Transducerprotected void fireProcessFinished()
fireProcessFinished in class Transducerpublic int getRuleApplicationStyle()
public void setControllerEventBlocks(String started,
String finished,
String aborted,
String javaimports)
public String generateControllerEventBlocksCode(String started,
String finished,
String aborted,
String javaimports)
public void runControllerExecutionStartedBlock(ActionContext ac,
Controller c,
Ontology o)
throws ExecutionException
runControllerExecutionStartedBlock in class TransducerExecutionException
public void runControllerExecutionFinishedBlock(ActionContext ac,
Controller c,
Ontology o)
throws ExecutionException
runControllerExecutionFinishedBlock in class TransducerExecutionException
public void runControllerExecutionAbortedBlock(ActionContext ac,
Controller c,
Throwable t,
Ontology o)
throws ExecutionException
runControllerExecutionAbortedBlock in class TransducerExecutionException
private void writeObject(ObjectOutputStream out)
throws IOException
IOException
private void readObject(ObjectInputStream in)
throws IOException,
ClassNotFoundException
IOException
ClassNotFoundExceptionprivate void compileEventBlocksActionClass()
public ControllerEventBlocksAction getControllerEventBlocksActionClass()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||