2016-11-05 2 views
4

명령 줄을 통해 CoreNLP를 사용할 때 TokensRegex 규칙 색 주석 자 (stanford-corenlp-full-2016-10-31/tokensregex/color.rules.txt)는 성공적으로로드되지만 java.lang.IllegalArgumentException: Unknown annotator: color 인 웹 서버에서는 실패합니다.스탠포드 CoreNLP 서버에서 사용자 정의 TokensRegex 규칙 어노 테이터를 사용하는 방법은 무엇입니까?

설정

# custom.properties 
annotators=tokenize,ssplit,pos,lemma,ner,regexner,color 
customAnnotatorClass.color = edu.stanford.nlp.pipeline.TokensRegexAnnotator 
color.rules = tokensregex/color.rules.txt 

명령 줄

$ java -cp "*" -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -props custom.properties -file ./tokensregex/color.input.txt -outputFormat text 
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Registering annotator color with class edu.stanford.nlp.pipeline.TokensRegexAnnotator 
... 
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator color 
[main] INFO edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor - Reading TokensRegex rules from tokensregex/color.rules.txt 
[main] INFO edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor - Read 7 rules 

# color.input.txt.output 
Sentence #1 (9 tokens): 
Both blue and light blue are nice colors. 
[Text=Both CharacterOffsetBegin=0 CharacterOffsetEnd=4 PartOfSpeech=CC Lemma=both NamedEntityTag=O] 
[Text=blue CharacterOffsetBegin=5 CharacterOffsetEnd=9 PartOfSpeech=JJ Lemma=blue NamedEntityTag=COLOR NormalizedNamedEntityTag=#0000FF] 
... 

서버

  1. java -mx2g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -c custom.properties
  2. wget --post-data 'Both blue and light blue are nice colors.' 'localhost:9000/?properties={"annotators":"tokenize,ssplit,pos,lemma,ner,regexner,color","outputFormat":"json"}' -O -

    HTTP request sent, awaiting response... 500 Internal Server Error 
        2016-11-05 14:41:27 ERROR 500: Internal Server Error. 
    
    java.lang.IllegalArgumentException: Unknown annotator: color 
        at edu.stanford.nlp.pipeline.StanfordCoreNLP.ensurePrerequisiteAnnotators(StanfordCoreNLP.java:304) 
        at edu.stanford.nlp.pipeline.StanfordCoreNLPServer$CoreNLPHandler.getProperties(StanfordCoreNLPServer.java:713) 
        at edu.stanford.nlp.pipeline.StanfordCoreNLPServer$CoreNLPHandler.handle(StanfordCoreNLPServer.java:540) 
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79) 
        at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83) 
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82) 
        at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675) 
        at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79) 
        at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
        at java.lang.Thread.run(Thread.java:745) 
    

솔루션

는 요청에 사용자 정의 주석 자 속성을 포함합니다 : wget --post-data 'Both blue and light blue are nice colors.' 'localhost:9000/?properties={"color.rules":"tokensregex/color.rules.txt","customAnnotatorClass.color":"edu.stanford.nlp.pipeline.TokensRegexAnnotator","annotators":"tokenize,ssplit,pos,lemma,ner,regexner,color","enforceRequirements":"false","outputFormat":"json"}' -O -

+0

모두'ner','regexner' 및'color'가 당신에게 효과가 있습니까? –

답변

4

추가

"enforceRequirements":"false" 

을 요청하면이 오류가 발생하지 않습니다.

+1

감사합니다. 그 결과 새로운 java.lang.IllegalArgumentException : no annotator color라는 이름의 새 에러가 발생했습니다. 그러나 일부 검색 후에 CoreNLP 서버가 [전달 된 속성 파일] (https://github.com)을로드하지 않는다는 것을 발견했습니다./stanfordnlp/CoreNLP/issues/165). 요청에 color annotator 속성을 포함해야합니다. –

관련 문제