Lynten / stanford-corenlp

Python wrapper for Stanford CoreNLP.
MIT License
919 stars 200 forks source link

requests.exceptions.HTTPError for long sentences. #82

Open SydneyWu-2401 opened 5 years ago

SydneyWu-2401 commented 5 years ago

I use CoreNLPParser to parsing Chinese text sentence by sentence but got requests.exceptions.HTTPError. when meet long sentences.

my code is: from nltk.parse import CoreNLPParser parser = CoreNLPParser('http://localhost:9001') for seg_sent in sentences: tree = parser.raw_parse(seg_sent)

when the sentence is long, the error will raise:

File "Parser.py", line 222, in BuildTree tree = parser.raw_parse(seg_sent) File "/usr/local/lib/python3.5/dist-packages/nltk/parse/corenlp.py", line 229, in raw_parse [sentence], properties=default_properties, *args, **kwargs File "/usr/local/lib/python3.5/dist-packages/nltk/parse/corenlp.py", line 284, in raw_parse_sents parsed_data = self.api_call('\n'.join(sentences), properties=default_properties) File "/usr/local/lib/python3.5/dist-packages/nltk/parse/corenlp.py", line 250, in api_call response.raise_for_status() File "/usr/lib/python3/dist-packages/requests/models.py", line 840, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:9001/?properties=%7B%22annotators%22%3A+%22tokenize%2Cpo2Clemma%2Cssplit%2Cparse%22%2C+%22ssplit.ssplit.eolonly%22%3A+%22true%22%2C+%22outputFormat%22%3A+%22json%22%2C+%22tokenize.whitespace%22%3A+%22false%22%

I notice that the official documentation said: long sentences blow out processing time and memory. Is this why the requests.exceptions.HTTPError arise?

What should I do when I want to parsing these long sentences?

I am a new to programming, so please explain the reason in simpler way. I will very appreciate for your reply. Thank you~