@CreoleResource(name="Groovy scripting PR",
comment="Runs a Groovy script as a processing resource",
helpURL="http://gate.ac.uk/userguide/sec:api:groovy",
icon="/gate/groovy/script-pr")
public class ScriptPR
extends gate.creole.AbstractLanguageAnalyser
implements gate.ProcessingResource, gate.creole.ControllerAwarePR
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 |
---|
ScriptPR() |
Modifier and Type | Method and Description |
---|---|
protected void |
callControllerAwareMethod(String methodName,
gate.Controller c)
Check whether the script declares a method with the given name that takes a
corpus parameter, and if so, call it passing the corpus from the given
controller.
|
void |
cleanup() |
void |
controllerExecutionAborted(gate.Controller c,
Throwable t) |
void |
controllerExecutionFinished(gate.Controller c) |
void |
controllerExecutionStarted(gate.Controller c) |
void |
execute()
Execute method.
|
String |
getEncoding()
Get the character encoding used to load the script.
|
String |
getGroovySrc()
Return the source of the loaded groovy script
|
String |
getInputASName()
gets name of the input annotation set
|
String |
getOutputASName()
gets name of the output annotation set
|
gate.FeatureMap |
getScriptParams()
Get Map of parameters for the Groovy script
|
URL |
getScriptURL()
gets URL of the Groovy script
|
gate.Resource |
init()
Initialise this resource, and return it.
|
void |
reInit() |
void |
setDocument(gate.Document doc) |
void |
setEncoding(String encoding)
Set the character encoding used to load the script.
|
void |
setInputASName(String inputAS)
sets name of the input annotaiton set
|
void |
setOutputASName(String outputAS)
sets name of the output annotaiton set
|
void |
setScriptParams(gate.FeatureMap params)
Set Map of parameters for the Groovy script
|
void |
setScriptURL(URL script)
sets File of the Groovy script
|
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
public gate.Resource init() throws gate.creole.ResourceInstantiationException
init
in interface gate.Resource
init
in class gate.creole.AbstractProcessingResource
gate.creole.ResourceInstantiationException
public void reInit() throws gate.creole.ResourceInstantiationException
reInit
in interface gate.ProcessingResource
reInit
in class gate.creole.AbstractProcessingResource
gate.creole.ResourceInstantiationException
public void cleanup()
cleanup
in interface gate.Resource
cleanup
in class gate.creole.AbstractProcessingResource
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
protected void callControllerAwareMethod(String methodName, gate.Controller c) throws gate.creole.ExecutionException
gate.creole.ExecutionException
- if the script method throws an ExecutionException we re-throw itpublic void execute() throws gate.creole.ExecutionException
execute
in interface gate.Executable
execute
in class gate.creole.AbstractProcessingResource
gate.creole.ExecutionException
public String getOutputASName()
@Optional @RunTime @CreoleParameter public void setOutputASName(String outputAS)
outputAS
- public String getInputASName()
@Optional @RunTime @CreoleParameter public void setInputASName(String inputAS)
inputAS
- public URL getScriptURL()
@CreoleParameter(comment="Location of the Groovy script that will be run for each document") public void setScriptURL(URL script)
script
- public String getEncoding()
@CreoleParameter(defaultValue="UTF-8", comment="Character encoding used to read the script") public void setEncoding(String encoding)
public gate.FeatureMap getScriptParams()
@Optional @RunTime @CreoleParameter(comment="Optional additional parameters to pass to the script.") public void setScriptParams(gate.FeatureMap params)
public String getGroovySrc()
@Optional @RunTime @CreoleParameter(comment="The document to process") public void setDocument(gate.Document doc)
setDocument
in interface gate.LanguageAnalyser
setDocument
in class gate.creole.AbstractLanguageAnalyser