Stanford parser java error

后端 未结 3 1280
北海茫月
北海茫月 2021-01-12 21:27

I am working on a research about NLP, i woul to use Stanford parser to extract noun phrases from text, the parser version i used is 3.4.1 this is the sample code i used

相关标签:
3条回答
  • 2021-01-12 21:43

    As others have pointed out you have to include the jar files that come along with the CORE-NLP package that is avalaible at the stanford parser page.

    More specifically add these to your class path : stanford-parser-3.4.1-models.jar,stanford-parser-3.4.1-sources.jar,stanford-parser.jar ( these are specific to the version of stanford parser you are using i.e version 3.4.1 )

    You can add it to the class path as follows :

    For Linux : export CLASSPATH=$CLASSPATH:/some_path/stanford-parser-3.4.1-sources.jar:/some_path/stanford-parser-3.4.1-models.jar:/some_path/stanford-parser.jar

    For Windows : set CLASSPATH=%CLASSPATH%;\some_path\stanford-parser-3.4.1-models.jar;\some_path\stanford-parser-3.4.1-sources.jar;\some_path\stanford-parser;

    0 讨论(0)
  • 2021-01-12 21:45

    Yes, You do not have CoreNLP models Jar. Either you can download them from here- http://nlp.stanford.edu/software/corenlp.shtml#Download

    or, you can do this:

    1. Create a Maven project. ( It is easy in eclipse)
    2. In the pom.xml file, add this dependency.

      <dependency> 
        <groupId>edu.stanford.nlp</groupId>
        <artifactId>stanford-corenlp</artifactId>
        <version>3.5.0</version>
      </dependency>
      <dependency>
        <groupId>edu.stanford.nlp</groupId>
        <artifactId>stanford-corenlp</artifactId>
        <version>3.5.0</version>
        <classifier>models</classifier>
      </dependency>
      
    3. Do maven clean, maven update and maven install. The model files will be installed in your .m2 folder automatically.

    I hope you know maven. If not, please post a comment / question. We will answer.

    0 讨论(0)
  • 2021-01-12 21:50

    You need to have the CoreNLP models jar (downloadable from the CoreNLP homepage) on your classpath for the parser to work properly.

    0 讨论(0)
提交回复
热议问题