2014-03-05 3 views
3

http://nlp.stanford.edu/software/corenlp.shtml#Download에서 필요한 jar 파일을 다운로드하여 설치했습니다.StanfordCoreNLP 개체를 만드는 중 오류가 발생했습니다.

나는 스탠포드 psotagger-3.3.1.jar

스탠포드 psotagger-3.3.1.jar - javadoc.jar

Satnford - postagger.jar 다섯 개 jar 파일을 포함했다

스탠포드-3.3.1.jar-src.jar psotagger

스탠포드 corenlp-3.3.1.jar

,

및 코드

public class lemmafirst { 

    protected StanfordCoreNLP pipeline; 

    public lemmafirst() { 
     // Create StanfordCoreNLP object properties, with POS tagging 
     // (required for lemmatization), and lemmatization 
     Properties props; 
     props = new Properties(); 
     props.put("annotators", "tokenize, ssplit, pos, lemma"); 

     /* 
     * This is a pipeline that takes in a string and returns various analyzed linguistic forms. 
     * The String is tokenized via a tokenizer (such as PTBTokenizerAnnotator), 
     * and then other sequence model style annotation can be used to add things like lemmas, 
     * POS tags, and named entities. These are returned as a list of CoreLabels. 
     * Other analysis components build and store parse trees, dependency graphs, etc. 
     * 
     * This class is designed to apply multiple Annotators to an Annotation. 
     * The idea is that you first build up the pipeline by adding Annotators, 
     * and then you take the objects you wish to annotate and pass them in and 
     * get in return a fully annotated object. 
     * 
     * StanfordCoreNLP loads a lot of models, so you probably 
     * only want to do this once per execution 
     */ 
     ***this.pipeline = new StanfordCoreNLP(props);*** 
} 

내 문제는 a를 pipline을 만드는입니다. 내가 가진

오류 :

Exception in thread "main" java.lang.RuntimeException: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model 
    at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:563) 
    at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:81) 
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:262) 
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:129) 
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:125) 
    at lemmafirst.<init>(lemmafirst.java:39) 
    at lemmafirst.main(lemmafirst.java:83) 
Caused by: edu.stanford.nlp.io.RuntimeIOException: Unrecoverable error while loading a tagger model 
    at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:758) 
    at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:289) 
    at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:253) 
    at edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnotator.java:88) 
    at edu.stanford.nlp.pipeline.POSTaggerAnnotator.<init>(POSTaggerAnnotator.java:76) 
    at edu.stanford.nlp.pipeline.StanfordCoreNLP$4.create(StanfordCoreNLP.java:561) 
    ... 6 more 
Caused by: java.io.IOException: Unable to resolve "edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger" as either class path, filename or URL 
    at edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSystem(IOUtils.java:434) 
    at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:753) 
    ... 11 more 

사람이 오류를 수정시겠습니까? 고마워요

답변

12

throw되는 예외는 pos 모델이 누락되어 있기 때문입니다. 이는 모델 파일이 있거나없는 다운로드 가능한 버전이 있기 때문입니다.

은 어느 당신은 추가 스탠포드 - postagger- 전체 다음 페이지 (stanford-postagger-full-2014-01-04.zip)에서 확인하실 수 있습니다 -3.3.1.jar : http://nlp.stanford.edu/software/tagger.shtml .

또는 전체 CoreNLP 패키지에 대해 동일 할 (스탠포드 - corenlp- 전체 .... 항아리) : 는 http://nlp.stanford.edu/software/corenlp.shtml (그럼 당신은 그들이 CoreNLP에 포함 된 모든 postagger 너무 depenedencies 삭제할 수 있습니다)

모델 파일 만 추가하려는 경우 Maven Central을보고 "stanford-corenlp-3.3.1-models.jar"을 다운로드하십시오.

+3

짧은 답변 : 모델을 포함하는 전체 CoreNLP 패키지를 다운로드 파일 : http://nlp.stanford.edu/software/corenlp.shtml –

+0

고마워요. stanford-corenlp-3.3.1-models.jar 파일을 추가했으며 저에게 도움이되었습니다. 감사합니다 Chirtopher .. –

+0

나는 이것을 시도하고 어떤 이유로 작동하지 않았다. 그런 다음 jarsplice를 사용하여 내 항아리와 ..- models.jar를 이어 붙였습니다. – alextsil

6

그 모델 파일을 추가 할 수있는 쉬운 방법은 단순히 당신의 pom.xml에 다음과 종속성을 추가하고 받는다는 당신을 위해 그것을 관리 할 수 ​​있도록하는 것입니다

<dependency> 
    <groupId>edu.stanford.nlp</groupId> 
    <artifactId>stanford-corenlp</artifactId> 
    <version>3.6.0</version> 
</dependency> 
<dependency> 
    <groupId>edu.stanford.nlp</groupId> 
    <artifactId>stanford-corenlp</artifactId> 
    <version>3.6.0</version> 
    <classifier>models</classifier> <!-- will get the dependent model jars --> 
</dependency> 
+2

감사합니다 @Sruthi Poddutur에 대한 의견입니다. 그것은 내 발행을 해결하는 데 도움이됩니다. –

관련 문제