public class StanfordCoreNLPClient extends AnnotationPipeline
StanfordCoreNLP
, but
with the backend supported by a web server.TIME
DEFAULT_REQUIREMENTS, STANFORD_CDC_TOKENIZE, STANFORD_CLEAN_XML, STANFORD_COLUMN_DATA_CLASSIFIER, STANFORD_COREF, STANFORD_COREF_MENTION, STANFORD_DEPENDENCIES, STANFORD_DETERMINISTIC_COREF, STANFORD_DOCDATE, STANFORD_ENTITY_MENTIONS, STANFORD_GENDER, STANFORD_KBP, STANFORD_LEMMA, STANFORD_LINK, STANFORD_MWT, STANFORD_NATLOG, STANFORD_NER, STANFORD_OPENIE, STANFORD_PARSE, STANFORD_POS, STANFORD_QUOTE, STANFORD_QUOTE_ATTRIBUTION, STANFORD_REGEXNER, STANFORD_RELATION, STANFORD_SENTIMENT, STANFORD_SSPLIT, STANFORD_TOKENIZE, STANFORD_TOKENSREGEX, STANFORD_TRUECASE, STANFORD_UD_FEATURES
Constructor and Description |
---|
StanfordCoreNLPClient(java.util.Properties properties)
Run the client, pulling credentials from the environment.
|
StanfordCoreNLPClient(java.util.Properties properties,
java.lang.String host,
int port)
Run on a single backend.
|
StanfordCoreNLPClient(java.util.Properties properties,
java.lang.String host,
int port,
int threads)
Run on a single backend, but with k threads on each backend.
|
StanfordCoreNLPClient(java.util.Properties properties,
java.lang.String host,
int port,
int threads,
java.lang.String apiKey,
java.lang.String apiSecret)
Run on a single backend, but with k threads on each backend, and with authentication
|
StanfordCoreNLPClient(java.util.Properties properties,
java.lang.String host,
int port,
java.lang.String apiKey,
java.lang.String apiSecret)
Run on a single backend, with authentication
|
StanfordCoreNLPClient(java.util.Properties properties,
java.lang.String host,
java.lang.String apiKey,
java.lang.String apiSecret)
Run on a single backend, with authentication
|
Modifier and Type | Method and Description |
---|---|
void |
annotate(Annotation annotation)
Run the pipeline on an input annotation.
|
void |
annotate(Annotation annotation,
java.util.function.Consumer<Annotation> callback)
The canonical entry point of the client annotator.
|
void |
annotate(java.lang.Iterable<Annotation> annotations,
int numThreads,
java.util.function.Consumer<Annotation> callback)
This method fires off a request to the server.
|
boolean |
checkStatus(java.net.URL serverURL)
Return true if the referenced server is alive and returns a non-error response code.
|
static void |
main(java.lang.String[] args)
Client that runs data through a StanfordCoreNLPServer either just for testing or for command-line text processing.
|
Annotation |
process(java.lang.String text)
Runs the entire pipeline on the content of the given text passed in.
|
void |
run()
The implementation of what to run on a command-line call of CoreNLPWebClient
|
void |
setTimeoutMilliseconds(int timeout) |
void |
shutdown()
Good practice to call after you are done with this object.
|
addAnnotator, annotate, annotate, annotate, getTotalTime, requirementsSatisfied, requires, timingInformation
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exactRequirements, unmount
public StanfordCoreNLPClient(java.util.Properties properties) throws java.lang.IllegalStateException
java.lang.IllegalStateException
- Thrown if we could not read the required environment variables.public StanfordCoreNLPClient(java.util.Properties properties, java.lang.String host, int port)
(Properties, List)
public StanfordCoreNLPClient(java.util.Properties properties, java.lang.String host, int port, java.lang.String apiKey, java.lang.String apiSecret)
(Properties, List)
public StanfordCoreNLPClient(java.util.Properties properties, java.lang.String host, java.lang.String apiKey, java.lang.String apiSecret)
(Properties, List)
public StanfordCoreNLPClient(java.util.Properties properties, java.lang.String host, int port, int threads)
(Properties, List)
public StanfordCoreNLPClient(java.util.Properties properties, java.lang.String host, int port, int threads, java.lang.String apiKey, java.lang.String apiSecret)
(Properties, List)
public void setTimeoutMilliseconds(int timeout)
public void annotate(Annotation annotation)
annotate
in interface Annotator
annotate
in class AnnotationPipeline
annotation
- The input annotation, usually a raw documentpublic void annotate(java.lang.Iterable<Annotation> annotations, int numThreads, java.util.function.Consumer<Annotation> callback)
annotate
in class AnnotationPipeline
annotations
- The input annotations to processnumThreads
- The number of threads to run on. IGNORED in this class.callback
- A function to be called when an annotation finishes.public void annotate(Annotation annotation, java.util.function.Consumer<Annotation> callback)
annotation
- The annotation to annotate.callback
- Called when the server has returned an annotated document.
The input to this callback is the same as the passed Annotation object.public boolean checkStatus(java.net.URL serverURL)
serverURL
- The server (running CoreNLP) to checkpublic Annotation process(java.lang.String text)
text
- The text to processpublic void run() throws java.io.IOException
java.io.IOException
- If any IO problempublic void shutdown() throws java.lang.InterruptedException
Good practice to call after you are done with this object. Shuts down the queue of annotations to run and the associated threads.
If this is not called, any job which has been scheduled but not run will be cancelled.
java.lang.InterruptedException
public static void main(java.lang.String[] args) throws java.io.IOException
Options:
args
- List of required propertiesjava.io.IOException
- If IO problem