Search code examples
javanlpstanford-nlp

How to use both the lexicalized and the dependency parser in the StanfordCoreNLP pipeline?


Suppose I have defined the following StanfordCoreNLP pipeline:

Properties props = new Properties();

props.put("language", "english");
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, depparse");
props.put("depparse.model", "edu/stanford/nlp/models/parser/nndep/english_SD.gz");
props.put("parse.originalDependencies", true);

StanfordCoreNLP pipeline =  new StanfordCoreNLP(props);

Now, this code will give me the tokens, sentence splitter, POS tags, lemmas, NER and depdencency parse (the NN model). Now, I also want to have a lexicalized parse tree as well.

How can I put this information in the pipeline? Or maybe I have to do it otherwise? What is the optimal way to do this?


Solution

  • Instead of just deparse, add parse to the list of annotators:

    props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, depparse");
    

    For more details, see http://hujiaweibujidao.github.io/blog/2016/03/30/Stanford-NLP/