2016-02-09 15 views
5

के लिए भावनाओं को वापस करने के लिए विंडोज पर एक स्टैनफोर्ड कोरएनएलपी सर्वर कैसे स्थापित करूं? मैं 1 एम लेख और वीडियो ग्रंथों के लिए भावना स्कोर की गणना करने के लिए स्टैनफोर्ड कोरएनएलपी के साथ विंडोज पर एक स्थानीय सर्वर स्थापित करने का प्रयास कर रहा हूं। मुझे जावा नहीं पता, इसलिए मुझे कुछ मदद की ज़रूरत होगी।मैं

मैं सफलतापूर्वक स्टैनफोर्ड CoreNLP 3.6.0 स्थापित है, और मैं एक सर्वर के साथ चल रहा है: मेरे अन्य कंप्यूटर कार्यों से इस http पोस्ट रनिंग

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer 

, और मैं एक उम्मीद प्रतिक्रिया (xxx.xxx.xxx मिल .xxx सर्वर का आईपी पता है):

wget --post-data 'the quick brown fox jumped over the lazy dog' 'xxx.xxx.xxx.xxx:9000/?properties={"tokenize.whitespace": "true", "annotators": "tokenize,ssplit,pos,lemma,parse", "outputFormat": "json"}' -O - 

हालांकि, प्रतिक्रिया में भावना नहीं है।

wget --post-data 'the quick brown fox jumped over the lazy dog' 'xxx.xxx.xxx.xxx:9000/?properties={"tokenize.whitespace": "true", "annotators": "tokenize,ssplit,pos,lemma,parse,sentiment", "outputFormat": "json"}' -O - 

हालांकि, सर्वर साइड पर, मैं इस त्रुटि मिलती है:

java.lang.IllegalArgumentException: Unknown annotator: sentiment 
at edu.stanford.nlp.pipeline.StanfordCoreNLP.ensurePrerequisiteAnnotators(StanfordCoreNLP.java:281) 
at edu.stanford.nlp.pipeline.StanfordCoreNLPServer$CoreNLPHandler.getProperties(StanfordCoreNLPServer.java:476) 
at edu.stanford.nlp.pipeline.StanfordCoreNLP$CoreNLPHandler.handle(StanfordCoreNLPServer.java:350) 
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) 
at sun.net.httpserver.AuthFilter.doFilter(Unknown Source) 
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) 
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source) 
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source) 
at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
at java.lang.thread.run(Unknown Source) 

अगले स्पष्ट समाधान सर्वर शुरू करने के लिए एक पैरामीटर जोड़ने के लिए किया जाएगा स्पष्ट समाधान एक व्याख्याकार जोड़ा जाए , जो चलता है:

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -annotators "tokenize,ssplit,pos,lemma,parse,sentiment" 

पहले से ही उसी http पोस्ट को चलाने से वही सटीक परिणाम और त्रुटि मिलती है।

क्या मैं कुछ गलत कर रहा हूं, या क्या कोर कोड में कुछ संशोधन है जिसे इसे काम करने की ज़रूरत है? मुझे जावा नहीं पता, इसलिए मैं उन बदलावों को करने में असमर्थ हूं।

एक तरफ ध्यान दें के रूप में, यह समान आदेश एक कंसोल शुरू होता है, और सही ढंग से भावना लोड करने के लिए लगता है:

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators "tokenize,ssplit,pos,lemma,parse,sentiment" 

[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator tokenize 
[main] INFO edu.stanford.nlp.pipeline.TokenizerAnnotator - TokenizerAnnotator: No tokenizer type provided. Defaulting to PTBTokenizer. 
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ssplit 
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator pos 
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [0.5 sec]. 
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator lemma 
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator parse 
[main] INFO edu.stanford.nlp.parser.common.ParserGrammar - Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... done [0.4 sec]. 
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator sentiment 

Entering interactive shell. Type q RETURN or EOF to quit. 
NLP> _ 

उत्तर

5

कोड की GitHub version साथ चलाने की कोशिश करें। आपका पहला समाधान सही है - तथ्य यह है कि यह भावना व्याख्याकार नहीं पा सके कोड में एक बग है:

wget --post-data 'the quick brown fox jumped over the lazy dog' 'xxx.xxx.xxx.xxx:9000/?properties={"annotators": "tokenize,ssplit,pos,lemma,parse,sentiment", "outputFormat": "json"}' -O - 

(ए साइड नोट: tokenize.whitespace संपत्ति दिखाने के लिए कि आप में पारित कर सकते हैं दस्तावेज में है मनमानी गुण, लेकिन मैं इसे उत्पादन में उपयोग करने के खिलाफ अनुशंसा करता हूं)।

+0

गिटहब संस्करण डाउनलोड करना बहुत उपयोगी नहीं है, क्योंकि इसका उपयोग करने के लिए कोई दस्तावेज़ीकरण नहीं है। वे सिर्फ अपनी वेबसाइट पर डाउनलोड के लिए प्रलेखन को इंगित करते हैं, जो अलग-अलग स्थापित होते हैं। मैं अभी तक इसके साथ सफल नहीं रहा हूं। – Eric

+0

बस 'चींटी जार' चलाएं और इसे एक जार फ़ाइल बनाना चाहिए जिसका उपयोग आप आधिकारिक रिलीज के स्थान पर कर सकते हैं। –

+0

यह मेरे लिए काम किया। (पहले 'एंटी' चल रहा है और फिर 'चींटी जार'।) ध्यान दें कि जिथब संस्करण में सभी मॉडल नहीं हैं, इसलिए आपको उन्हें [यहां] डाउनलोड करना होगा (http://nlp.stanford.edu/software/ स्टैनफोर्ड-अंग्रेज़ी-corenlp-मॉडल-current.jar)। इसके अलावा, मैं जावा से बहुत परिचित नहीं हूं, इसलिए मुझे चींटी को समझने में कठिनाई हुई थी जिसमें जार फ़ाइल को शामिल किया गया था और मॉडल जार और जार 'lib' में शामिल थे। अगर दूसरों के पास समस्याएं हैं, तो यहां मेरे लिए क्या काम किया गया है: 'जावा-एमएक्स 4 जी-सीपी "javanlp-core.jar: स्टैनफोर्ड-इंग्लिश-कोरनलमोडेल-वर्तमान.जर: lib/*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer' – Erin