DennisDeSwart / php-stanford-corenlp-adapter

PHP adapter for Stanford CoreNLP
26 stars 4 forks source link

Problem: function OpenIE "long document" #3

Closed sangyao closed 7 years ago

sangyao commented 7 years ago

hello Mr. Swart,

I am using functional OpenIE for English from your adapter, but when I enter a long English article, the following error occurred:

Fatal error: Uncaught GuzzleHttp\Exception\ServerException: Server error:POST http://localhost:9000/resulted in a500 Internal Server Errorresponse: CoreNLP request timed out. Your document may be too long. in D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 Stack trace: #0 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\promises\src\TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #4 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\prom in D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 113

so i have re-set the java server response time, like this: java -mx8g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000

the following error occurred:

Fatal error: Uncaught RuntimeException: Error creating resource: [message] fopen(http://localhost:9000/): failed to open stream: HTTP request failed! [file] D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php [line] 324 in D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php:252 Stack trace: #0 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php(335): GuzzleHttp\Handler\StreamHandler->createResource(Object(Closure)) #1 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php(52): GuzzleHttp\Handler\StreamHandler->createStream(Object(GuzzleHttp\Psr7\Request), Array) #2 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\PrepareBodyMiddleware.php(66): GuzzleHttp\Handler\StreamHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array) #3 D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Middleware.php(30): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array) # in D:\Apache24\htdocs\stanford1\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 52

**how can i solve this problem?

Thank you and best regards**

Yao

DennisDeSwart commented 7 years ago

Looks like a timeout of the NLP server. It is probably because the text is long.

  1. Check if a short text works
  2. Try running NLP server without "-timeout". Only this: java -mx8g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000
  3. Remember that the speed may only be 100 words per second. That is about 4 sentences to 6 sentences per second. So it can take minutes to do a long text
  4. Also check if the PHP.ini execution time is long enough

Greetings, Dennis

sangyao commented 7 years ago

Hello, thank you for your answer,

  1. Check if a short text works. (it works) 2.Try running NLP server without "-timeout". Only this: java -mx8g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 (I have tried it, but it works only for short text (like 50 words))
  2. Remember that the speed may only be 100 words per second. That is about 4 sentences to 6 sentences per second. So it can take minutes to do a long text 4.Also check if the PHP.ini execution time is long enough (also tried, but didn't work)

I used the code you uploaded for testing, and didn't change anything. There will be an error for more than 50 words of article.

thank you

Best regards

Yao

DennisDeSwart commented 7 years ago

In the file "bootstrap.php" find this line: define('USE_GUZZLE', TRUE);

Try setting: define('USE_GUZZLE', FALSE);

Normally CoreNLP_adapter uses "Guzzle" but maybe this is causing a problem for you. By setting it off, it will do a cURL call. Maybe this will solve the problem

DennisDeSwart commented 7 years ago

Also, in "bootstrap.php" there is this line: define('ONLINE_API', FALSE);

If you set: define('ONLINE_API', TRUE);

Then you can use the online version of CoreNLP. If that works, the way that you setup the Java server is the problem.

sangyao commented 7 years ago

thank you for your answer, it works, if the text max. 500 word. But it is ok for my projekt.

sangyao commented 7 years ago

hello, I still have a question,every time i must start the CoreNLP serve from the command line. just like you write "java -mx8g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000"

How can my system automatically connect java server,can Apache achieve this function?

thank you very much

yao