Traceback (most recent call last): File "parser_tree.py", line 145, inmain() File "parser_tree.py", line 141, in main convert_file(input_dir,output_dir) File "parser_tree.py", line 21, in convert_file l1 = nlp.parse(text) File "/home/jsj201-5/anaconda3/envs/parser_tree/lib/python3.6/site-packages/stanfordcorenlp/corenlp.py", line 205, in parse r_dict = self._request('pos,parse', sentence) File "/home/jsj201-5/anaconda3/envs/parser_tree/lib/python3.6/site-packages/stanfordcorenlp/corenlp.py", line 239, in _request r_dict = json.loads(r.text) File "/home/jsj201-5/anaconda3/envs/parser_tree/lib/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/home/jsj201-5/anaconda3/envs/parser_tree/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/home/jsj201-5/anaconda3/envs/parser_tree/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSonDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
使用Stanfordcorenlp生成短语解析树时报错如上,解决方法如下:
进入你的Python中stanfordnlp安装包中corenlp.py文件,将第232行参数properties中超时时长加长即可。
properties = {'timeout': '500000','annotators': annotators, 'outputFormat': 'json'}



