How can I shut down the Stanford CoreNLP messages (see end of post)?
I first tried setting log4j.category.edu.stanford=OFF
in log4j.properties but that didn't help so I found out that apparently it uses a nonstandard logging framework called "Redwood". According to http://nlp.stanford.edu/nlp/javadoc/javanlp/
there is a documentation but it is password protected. I tried RedwoodConfiguration.empty().apply();
but that doesn't help either.
The logging messages:
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Loading default properties from tagger edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [1,2 sec].
P.S.: Redwood.hideAllChannels();
also doesn't work. The following however suppresses my own logging statement (but not the ones from StanfordCoreNLP):
RedwoodConfiguration.empty().apply();
Redwood.log("test redwood");
Solution Ok, StevenC was right, it weren't logging statements after all but the default initialization messages are written to stderr which I was not expecting seeing that Stanford has it's own logging framework and then doesn't use it :-)
Anyways, his hints led me to discover this solution:
// shut off the annoying intialization messages
RedwoodConfiguration.empty().captureStderr().apply();
nlp = new StanfordCoreNLP(myproperties);
// enable stderr again
RedwoodConfiguration.current().clear().apply();
You can also find the Redwood Tutorial PDF on GitHub in the Redwood project.
The url is in this page: https://github.com/gangeli/redwood/blob/master/doc/tutorial.pdf
(Obviously, I can't tell you if the documents are the same, 'cos I don't know the username / password either :-) )
Taking this a bit further, the Tutorial PDF I linked to really just a slide show. If you want documentation of the properties file, the best I could find was the javadocs for the RedwoodConfiguration.parse
method. And in fact, the rest of that classes javadoc is probably the best doc that you will find ... short of reading the source code.
Warning ... there are indications that the free-standing Redwood code on GitHub may be different to the version in the NLP codebase.
StanfordNLP uses Redwood
as logging framework for logging. You have to disable it before initializing StanfordNLP pipeline.
import edu.stanford.nlp.util.logging.RedwoodConfiguration;
RedwoodConfiguration.current().clear().apply();
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
It works for me. It does not show lengthy INFO message in every line, while running program.
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With