私はオーバー1Mの記事やビデオテキストに感情スコアを計算するためにスタンフォードCoreNLPでWindows上でローカルサーバーをセットアップしようとしていますのために感情を返すために、Windows上でスタンフォードCoreNLPサーバーを設定するにはどうすればよいです。私はJavaを知らないので、いくつかの助けが必要です。は、私は、テキスト
私が正常にスタンフォードCoreNLP 3.6.0をインストールし、私は実行しているサーバーを持っている:
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer
は私の他のコンピュータの作品からこのHTTP POSTを実行し、私が予想される応答(xxx.xxx.xxxを取得.xxxはサーバーのIPアドレス):
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を知らないので、変更することはできません。サイドノートとして
、このようなコマンドは、コンソールを起動し、正しく感情をロードするようだ:
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> _
GitHubバージョンのダウンロードは、それを使用する方法に関するドキュメントがないためあまり役に立ちません。彼らはちょうど異なって設定されている彼らのウェブサイト上のダウンロードのためのドキュメントを指しています。私はまだそれで成功していない。 – Eric
'ant jar'を実行するだけで、公式リリースの代わりに使用できるjarファイルが作成されます。 –
これは私のために働いた。 (最初に 'ant'を実行し、次に' ant jar'を実行する)githubのバージョンにはすべてのモデルが含まれているわけではないので、それらをダウンロードする必要があるかもしれないことに注意してください(http://nlp.stanford.edu/software/ stanford-english-corenlp-models-current.jar)。また、私はJavaにあまり慣れていないので、antで作ったjarファイルとモデルjarと 'lib'のjarファイルをインクルードするようにコマンドを実行するのは難しいです。場合には他の人が問題を抱えている、ここでは私のために働いていたものです: 'Javaの-mx4g -cp "javanlp-core.jar:スタンフォード・英語・corenlmodels-current.jar:LIB/*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer' – Erin