Reputation: 401
I'm using Stanford CoreNLP pipeline, and I wonder whether there is a way to edit basic settings without restarting the whole tool (avoiding the reload of the models).
Now I have:
Properties props = new Properties();
props.setProperty("tokenize.whitespace", "true");
props.setProperty("annotators", "tokenize, ssplit, pos, ...");
StanfordCoreNLP stanfordPipeline = new StanfordCoreNLP(props);
I'd like to change the tokenize.whitespace
setting on the fly, without restarting everything. Is it possible?
Upvotes: 1
Views: 361
Reputation: 4749
You should only create a new instance of StanfordCoreNLP with other properties; all common annotators and their models won't be reloaded, because StanfordCoreNLP uses static AnnotatorPool (see src code, line 103), where AnnotatorPool is:
An object for keeping track of Annotators. Typical use is to allow multiple pipelines to share any Annotators in common.
For example, if multiple pipelines exist, and they both need a ParserAnnotator, it would be bad to load two such Annotators into memory. Instead, an AnnotatorPool will only create one Annotator and allow both pipelines to share it.
(taken from javadoc)
Upvotes: 1