Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stanford CoreNLP remove/stop red information print outs

I'm using Stanford's CoreNLP Java API and while running it prints out information in red. It just fills up the command lines when i don't want to see it. is there anyway of disabling this feature?

Example of the red info lines:

Searching for resource: StanfordCoreNLP.properties
Searching for resource: edu/stanford/nlp/pipeline/StanfordCoreNLP.properties
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [1.2 sec].
Adding annotator lemma
Adding annotator ner
Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [3.0 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [2.7 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [2.0 sec].
Initializing JollyDayHoliday for sutime
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/defs.sutime.txt
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.sutime.txt
Jan 03, 2014 3:52:37 PM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules
INFO: Ignoring inactive rule: temporal-composite-8:ranges
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.holidays.sutime.txt
Adding annotator parse
Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... done [0.8 sec].
Adding annotator dcoref
Searching for resource: StanfordCoreNLP.properties
Searching for resource: edu/stanford/nlp/pipeline/StanfordCoreNLP.properties
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Adding annotator lemma
Adding annotator ner
Adding annotator parse
Adding annotator dcoref
Searching for resource: StanfordCoreNLP.properties
Searching for resource: edu/stanford/nlp/pipeline/StanfordCoreNLP.properties
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Adding annotator lemma
Adding annotator ner
Adding annotator parse
Adding annotator dcoref
like image 720
Greg Avatar asked Jan 03 '14 16:01

Greg


1 Answers

Depending on your program context, you can just drop all text from the error stream's output during corenlp execution.

// this is your print stream, store the reference
PrintStream err = System.err;

// now make all writes to the System.err stream silent 
System.setErr(new PrintStream(new OutputStream() {
    public void write(int b) {
    }
}));

// YOUR CODE HERE

// set everything bck to its original state afterwards
System.setErr(err);         
like image 68
Christopher Schröder Avatar answered Nov 11 '22 23:11

Christopher Schröder