Basic and enhanced dependencies give different results in Stanford coreNLP

703 views Asked by At

I am using dependency parsing of coreNLP for a project of mine. The basic and enhanced dependencies are different result for a particular dependency. I used the following code to get enhanced dependencies.

val lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
lp.setOptionFlags("-maxLength", "80")
val rawWords = edu.stanford.nlp.ling.Sentence.toCoreLabelList(tokens_arr:_*)
val parse = lp.apply(rawWords)
val tlp = new PennTreebankLanguagePack()
val gsf:GrammaticalStructureFactory = tlp.grammaticalStructureFactory()
val gs:GrammaticalStructure = gsf.newGrammaticalStructure(parse)
val tdl = gs.typedDependenciesCCprocessed()

For the following example,

Account name of ramkumar.

I use simple API to get basic dependencies. The dependency i get between (account,name) is (compound). But when i use the above code to get enhanced dependency i get the relation between (account,name) as (dobj).

What is the fix to this? Is this a bug or am i doing something wrong?

1

There are 1 answers

0
StanfordNLPHelp On BEST ANSWER

When I run this command:

java -Xmx8g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse -file example.txt -outputFormat json

With your example text in the file example.txt, I see compound as the relationship between both of those words for both types of dependencies.

I also tried this with the simple API and got the same results.

You can see what simple produces with this code:

package edu.stanford.nlp.examples;

import edu.stanford.nlp.semgraph.SemanticGraphFactory;
import edu.stanford.nlp.simple.*;

import java.util.*;

public class SimpleDepParserExample {

  public static void main(String[] args) {
    Sentence sent = new Sentence("...example text...");
    Properties props = new Properties();
    // use sent.dependencyGraph() or sent.dependencyGraph(props, SemanticGraphFactory.Mode.ENHANCED) to see enhanced dependencies
    System.out.println(sent.dependencyGraph(props, SemanticGraphFactory.Mode.BASIC));
  }

}

I don't know anything about any Scala interfaces for Stanford CoreNLP. I should also note my results are using the latest code from GitHub, though I presume Stanford CoreNLP 3.8.0 would also produce similar results. If you are using an older version of Stanford CoreNLP that could be a potential cause of the error.

But running this example in various ways using Java I don't see the issue you are encountering.