0

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.

  • You mean that you tried to run the following code under Matlab right? `import edu.stanford.nlp.util.logging.RedwoodConfiguration; RedwoodConfiguration.current().clear().apply(); pipeline = StanfordCoreNLP(props);` – Tommaso Belluzzo Jan 30 '18 at 10:10
  • @TommasoBelluzzo Yes, I tried that. But props is being interpreted as some variable, so a value would need to be assigned. I don't know what. – József Vass Feb 01 '18 at 03:48

1 Answers1

0

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.

Christopher Manning
  • 9,360
  • 34
  • 46
  • The first one gives the error: `No method 'argsToProperties' with matching signature found for class 'edu.stanford.nlp.util.StringUtils'.` The second one added as: `org.slf4j.simpleLogger.log.edu.stanford.nlp.tagger.maxent.MaxentTagger = warn; javaaddpath('./simplelogger.properties');` gives the error: `Undefined function or variable 'warn'.` – József Vass Feb 01 '18 at 03:51
  • The first solution worked once I added `{ }` around the `StringUtils.argsToProperties` arguments, because it expected an input of type `String[]`. I updated the GitHub package. – József Vass Feb 04 '18 at 02:48
  • Thanks, I edited the answer to include that fix to the first solution! – Christopher Manning Feb 20 '18 at 16:20