public class PythonSlave extends Object
| Modifier and Type | Field and Description |
|---|---|
boolean |
keepRunning
Indicate if the slave should be kept running.
|
boolean |
logActions
If we want to log all commands.
|
org.slf4j.Logger |
LOGGER
Logger
|
protected gate.gui.ResourceHelper |
rhBdocApi |
protected py4j.GatewayServer |
server |
| Constructor and Description |
|---|
PythonSlave()
Create an instance.
|
| Modifier and Type | Method and Description |
|---|---|
gate.Document |
createDocument(String content)
Create a new document from the text.
|
void |
deleteResource(gate.Resource res)
Delete a GATE resource and release memory.
|
gate.creole.Plugin.Maven |
findMavenPlugin(String group,
String artifact)
Find and return a loaded Maven plugin instance.
|
String |
gate_build()
Return build (short commit id) of GATE.
|
String |
gate_version()
Return version of GATE.
|
String |
getBdocJson(gate.Document doc)
Get the JSON serialization of the Bdoc representation of a document.
|
gate.Corpus |
getCorpus4Name(String name)
Return the corpus with the given name.
|
List<String> |
getCorpusNames()
Return list of all known corpus names.
|
gate.Document |
getDocument4BdocJson(String bdocjson)
Create a new GATE document from the Bdoc JSON serialization.
|
gate.Document |
getDocument4Name(String name)
Return the document with the given name.
|
List<String> |
getDocumentNames()
Return list of all known document names.
|
gate.CorpusController |
getPipeline4Name(String name)
Return the pipeline with the given name.
|
List<String> |
getPipelineNames()
Return list of all known pipeline names.
|
gate.ProcessingResource |
getPr4Name(String name)
Return the processing resource with the given name.
|
List<String> |
getPrNames()
Return list of all known processing resource names.
|
List<gate.Resource> |
getResources4Name(String name)
Return a list of all resources with the given name.
|
List<gate.Resource> |
getResources4Name(String name,
String clazz)
Return a list of all resources with the given name and class.
|
boolean |
isClosable()
Check if the slave is closable.
|
String |
jsonAnnsets4Doc(gate.Document doc) |
String |
jsonAnnsets4Doc(gate.Document doc,
List<List<String>> annsets) |
void |
kill()
Kill the slave.
|
gate.Document |
loadDocumentFromFile(String path)
Load document from the file.
|
gate.Document |
loadDocumentFromFile(String path,
String mimeType)
Load document from the file, using mime type
|
void |
loadMavenPlugin(String group,
String artifact,
String version)
Load a maven plugin.
|
gate.CorpusController |
loadPipelineFromFile(String path)
Load a pipeline from a file.
|
gate.CorpusController |
loadPipelineFromPlugin(String group,
String artifact,
String path)
Load a pipeline from the maven plugin resources.
|
void |
logActions(boolean flag)
Enable or disable logging the actions.
|
gate.Corpus |
newCorpus()
Create a new corpus.
|
String |
pluginBuild()
Return build (short commit id) of Python plugin.
|
String |
pluginVersion()
Return version of the Python plugin.
|
void |
print2err(String txt)
Copy string to standard error.
|
void |
print2out(String txt)
Copy string to standard output.
|
void |
run4Corpus(gate.CorpusController pipeline,
gate.Corpus corpus)
Run the pipeline on the given corpus.
|
void |
run4Document(gate.CorpusController pipeline,
gate.Document doc)
Run a pipeline for a single document.
|
void |
runExecutionFinished(gate.CorpusController pipeline)
Invoke the controller execution finished code.
|
void |
runExecutionStarted(gate.CorpusController pipeline)
Invoke the controller execution started code.
|
void |
saveDocumentToFile(gate.Document doc,
String path,
String mimetype)
Save document to a file.
|
void |
showGui()
Activate the GUI.
|
public final transient org.slf4j.Logger LOGGER
protected py4j.GatewayServer server
public boolean logActions
public boolean keepRunning
protected gate.gui.ResourceHelper rhBdocApi
public PythonSlave()
throws gate.creole.ResourceInstantiationException
gate.creole.ResourceInstantiationException - errorpublic void loadMavenPlugin(String group, String artifact, String version) throws gate.util.GateException
group - maven groupartifact - maven artifactversion - maven versiongate.util.GateException - if errorpublic gate.CorpusController loadPipelineFromFile(String path)
path - gapp/xgapp filepublic gate.creole.Plugin.Maven findMavenPlugin(String group, String artifact)
group - plugin groupartifact - plugin artifactpublic gate.CorpusController loadPipelineFromPlugin(String group, String artifact, String path) throws URISyntaxException
group - the plugin groupartifact - the plugin artifactpath - the path in the plugin resourcesURISyntaxException - exceptionpublic gate.Document loadDocumentFromFile(String path)
path - file path of the document to loadpublic gate.Document createDocument(String content)
content - the document contentpublic gate.Corpus newCorpus()
public void deleteResource(gate.Resource res)
res - the resource to removepublic void run4Document(gate.CorpusController pipeline,
gate.Document doc)
pipeline - the pipeline to rundoc - the document to processpublic void runExecutionStarted(gate.CorpusController pipeline)
pipeline - pipelinepublic void runExecutionFinished(gate.CorpusController pipeline)
pipeline - pipelinepublic void run4Corpus(gate.CorpusController pipeline,
gate.Corpus corpus)
pipeline - the pipelinecorpus - the corpuspublic gate.Document loadDocumentFromFile(String path, String mimeType)
path - filemimeType - mime typepublic void saveDocumentToFile(gate.Document doc,
String path,
String mimetype)
throws IOException,
XMLStreamException
path - filemimetype - mime typeIOException - if something goes wrong savingXMLStreamException - if something goes wrong when savingpublic String getBdocJson(gate.Document doc)
doc - documentpublic gate.Document getDocument4BdocJson(String bdocjson) throws gate.creole.ResourceInstantiationException
bdocjson - the JSONgate.creole.ResourceInstantiationException - should never occurpublic void print2out(String txt)
txt - the string to copypublic void print2err(String txt)
txt - the string to copypublic void showGui()
public List<gate.Resource> getResources4Name(String name) throws gate.util.GateException
name - resource namegate.util.GateExceptionpublic List<gate.Resource> getResources4Name(String name, String clazz) throws gate.util.GateException
name - resource nameclazz - resource class namegate.util.GateExceptionpublic gate.Document getDocument4Name(String name) throws gate.util.GateException
name - the document namegate.util.GateExceptionpublic gate.Corpus getCorpus4Name(String name) throws gate.util.GateException
name - the corpus namegate.util.GateExceptionpublic gate.CorpusController getPipeline4Name(String name) throws gate.util.GateException
name - the pipeline namegate.util.GateExceptionpublic gate.ProcessingResource getPr4Name(String name) throws gate.util.GateException
name - the pr namegate.util.GateExceptionpublic List<String> getDocumentNames() throws gate.util.GateException
gate.util.GateExceptionpublic List<String> getCorpusNames() throws gate.util.GateException
gate.util.GateExceptionpublic List<String> getPipelineNames() throws gate.util.GateException
gate.util.GateExceptionpublic List<String> getPrNames() throws gate.util.GateException
gate.util.GateExceptionpublic String jsonAnnsets4Doc(gate.Document doc)
public void logActions(boolean flag)
flag - true or falsepublic void kill()
public boolean isClosable()
public String pluginVersion()
public String pluginBuild()
public String gate_version()
public String gate_build()
Copyright © 2021 GATE Team. All rights reserved.