Search code examples
javadependenciesnlpstanford-nlp

Can not figure out how Stanford Dependencies works


My task is to parse text and find out the main characters in sentences. I need a Stanford Dependencies Parser, but i can't figure out, how and where can i get it. I downloaded CoreNLP as SD is a part of it. What should I do next? Didn't find any tutorials about how SDP works. I will be very grateful if someone explains me, what i should do. Thanks!


Solution

  • You can run CoreNLP with the following command to generate dependency parses for all the sentences in INPUT.txt. Make sure that you are running this from the CoreNLP directory or otherwise adjust the classpath (-cp)

    java -cp "*" -Xmx3g edu.stanford.nlp.pipeline.StanfordCoreNLP \
      -annotators "tokenize,ssplit,pos,depparse" -file INPUT.txt -outputFormat conllu
    

    This will parse your sentences to English Universal Dependencies (a newer dependency representation, based on Stanford Dependencies) and output them in CoNLL-U format.

    If you want to parse the sentences to the old Stanford Dependencies representation, use the following command.

    java -cp "*" -Xmx3g edu.stanford.nlp.pipeline.StanfordCoreNLP \
      -annotators "tokenize,ssplit,pos,depparse" -file INPUT.txt -outputFormat conllu\
      -depparse.model edu/stanford/nlp/models/parser/nndep/PTB_Stanford_params.txt.gz
    

    You can find more information on how to run CoreNLP on the CoreNLP website.