pycorenlpを長いテキストで実行しようとしています。 CoreNLP request timed out. Your document may be too long
エラーメッセージが表示されないように、タイムアウトを指定してStanford CoreNLPを増やしました。ここでpycorenlpでtimeoutが10,000以上になると、Linux上で "java.net.UnknownHostException:server:server:unknown error"(OS X上で正常に動作します)が表示されます。どうして?
は、私が使用するコードは(それがpycorenlpのexample.pyの簡易版です)です:
from pycorenlp import StanfordCoreNLP
if __name__ == '__main__':
nlp = StanfordCoreNLP('http://localhost:9000')
text = (
'Pusheen and Smitha walked along the beach. Pusheen wanted to surf,'
'but fell off the surfboard.')
output = nlp.annotate(text, properties={
'timeout': '10001' # Setting the timeout to 10000 or below "fixes" the issue.
'annotators': 'tokenize,ssplit,pos,depparse,parse',
'outputFormat': 'json'
})
print(output)
それはserver: unknown error
を出力します。サーバーログには含まれていますスタンフォードコアNLP Serverが使用して発足した
java.net.UnknownHostException: server: server: unknown error
at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
at edu.stanford.nlp.pipeline.StanfordCoreNLPServer$CoreNLPHandler.handle(StanfordCoreNLPServer.java:393)
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)
Caused by: java.net.UnknownHostException: server: unknown error
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
... 10 more
:私はセグメントに小さなテキストにテキストを望んでいない
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer 9000
。
タイムアウトを10000以上に設定する方法はありますか。 (つまり、10秒以上)
Mac OS X 10.10(Javaバージョン "1.8.0_60")ではうまく動作します:Ubuntu 14.04(Javaバージョン "1.8.0_77")で問題が発生します。どちらもPython 2.7 pycorenlp 0.2.0とスタンフォードCoreNLPバージョン3.6.0を持っています。