2016-04-20 10 views
0

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を持っています。

答えて

0

MacBookでサーバーを実行すると、この問題は発生しません。

これは、サーバーを実行しているマシンに問題があるようです。

InetAddress.getLocalHost().getHostName() 

を、例外を取得:サーバーコードが呼び出そうとしています。ここで

は、誰かが同様の問題を持っていたところ私が見つけたスレッドです:

InetAddress.getLocalHost() throws UnknownHostException

サーバーを実行しようとしているマシン上の/ etc/hostsファイルには何?

関連する問題