How to suppress Stanford CoreNLP Redwood logging in MATLAB?

大城市里の小女人 提交于 2019-12-24 18:45:55

问题


The thread How to shutdown Stanford CoreNLP Redwood logging? supposedly resolved my question in Java. I would like to do the same in MATLAB, but the code(s) given in that thread doesn't work. Please suggest a complete solution, starting with what to import, setting properties, etc.

My code is the following:

import java.io.*;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;

tagger = MaxentTagger('./english-left3words-distsim.tagger');

which logs on the command line:

Reading POS tagger model from ./english-left3words-distsim.tagger ... done [3.6 sec].

taken from CreateTagger.m in my package: https://github.com/jzsfvss/POSTaggerSML.


回答1:


I'm not very up on calling Java from MatLab, but I think it would work and remove the loading message to use instead the following (where the final false argument says to not print loading):

import edu.stanford.nlp.util.StringUtils;

...
tagger = MaxentTagger('./english-left3words-distsim.tagger', StringUtils.argsToProperties({'-model', './english-left3words-distsim.tagger'}), false);

If that doesn't work, perhaps the easiest thing would be to make an slf4j config file simplelogger.properties with the line:

org.slf4j.simpleLogger.log.edu.stanford.nlp.tagger.maxent.MaxentTagger=warn

and to make sure that file is on the Java classpath (presumably with a call to javaaddpath) so that the tagger component no longer prints INFO messages like the file loading.



来源:https://stackoverflow.com/questions/48513078/how-to-suppress-stanford-corenlp-redwood-logging-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!