提示错误RecursionError: maximum recursion depth exceeded while calling a Python object,是在我写了个脚本自动分析语料的时候发生的,因此不知道具体是哪一句话出现了错误。何老师或其他同学不知道可以看看吗~
以下是完整报错信息。72~76行是我的脚本,其余都是hanlp包内的代码,不知道是hanlp的代码出了问题吗?
in count_syntax_information(input_path)
72 res = re.search('[^\u4E00-\u9FA5“︰<?。(;‘’)?">﹒〈”:。》(,、)…——.~〉·!《!・]', i) #寻找有没有汉字及汉语标点以外的字符
73 if len(i) != 0 and len(i) > 4 and res == None:
---> 74 hanlp_result=HanLP(i)
75 else:
76 continue
/usr/local/lib/python3.8/dist-packages/hanlp/components/pipeline.py in call(self, doc, **kwargs)
144 doc = Document(**kwargs)
145 for component in self:
--> 146 doc = component(doc)
147 return doc
148
/usr/local/lib/python3.8/dist-packages/hanlp/common/component.py in call(self, *args, **kwargs)
34
35 """
---> 36 return self.predict(*args, **kwargs)
/usr/local/lib/python3.8/dist-packages/hanlp/components/pipeline.py in predict(self, doc, **kwargs)
50 if unpack:
51 kwargs['_hanlp_unpack'] = True
---> 52 output = self.component(input, **kwargs)
53 if isinstance(output, types.GeneratorType):
54 output = list(output)
/usr/local/lib/python3.8/dist-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs)
25 def decorate_context(*args, **kwargs):
26 with self.clone():
---> 27 return func(*args, **kwargs)
28 return cast(F, decorate_context)
29
/usr/local/lib/python3.8/dist-packages/hanlp/common/torch_component.py in call(self, *args, **kwargs)
636 **kwargs: Used in sub-classes.
637 """
--> 638 return super().__call__(*args, **merge_dict(self.config, overwrite=True, **kwargs))
/usr/local/lib/python3.8/dist-packages/hanlp/common/component.py in call(self, *args, **kwargs)
34
35 """
---> 36 return self.predict(*args, **kwargs)
/usr/local/lib/python3.8/dist-packages/hanlp/components/parsers/biaffine/biaffine_dep.py in predict(self, data, batch_size, batch_max_tokens, conll, **kwargs)
61 for batch in dataloader:
62 arc_scores, rel_scores, mask, puncts = self.feed_batch(batch)
---> 63 self.collect_outputs(arc_scores, rel_scores, mask, batch, predictions, order, data, use_pos,
64 build_data)
65 outputs = self.post_outputs(predictions, data, order, use_pos, build_data, conll=conll)
/usr/local/lib/python3.8/dist-packages/hanlp/components/parsers/biaffine/biaffine_dep.py in collect_outputs(self, arc_scores, rel_scores, mask, batch, predictions, order, data, use_pos, build_data)
127 build_data):
128 lens = [len(token) - 1 for token in batch['token']]
--> 129 arc_preds, rel_preds = self.decode(arc_scores, rel_scores, mask, batch)
130 self.collect_outputs_extend(predictions, arc_preds, rel_preds, lens, mask)
131 order.extend(batch[IDX])
/usr/local/lib/python3.8/dist-packages/hanlp/components/parsers/biaffine/biaffine_dep.py in decode(self, arc_scores, rel_scores, mask, batch)
544 tree, proj = self.config.tree, self.config.get('proj', False)
545 if tree:
--> 546 arc_preds = decode_dep(arc_scores, mask, tree, proj)
547 else:
548 arc_preds = arc_scores.argmax(-1)
/usr/local/lib/python3.8/dist-packages/hanlp/components/parsers/alg.py in decode_dep(s_arc, mask, tree, proj)
757 alg = mst
758 s_arc.diagonal(0, 1, 2)[1:].fill_(float('-inf'))
--> 759 arc_preds[bad] = alg(s_arc[bad], mask[bad])
760
761 return arc_preds
/usr/local/lib/python3.8/dist-packages/hanlp/components/parsers/alg.py in eisner(scores, mask)
187 for i, length in enumerate(lens.tolist()):
188 heads = p_c.new_zeros(length + 1, dtype=torch.long)
--> 189 backtrack(p_i[i], p_c[i], heads, 0, length, True)
190 preds.append(heads.to(mask.device))
191
/usr/local/lib/python3.8/dist-packages/hanlp/components/parsers/alg.py in backtrack(p_i, p_c, heads, i, j, complete)
174 if complete:
175 r = p_c[i, j]
--> 176 backtrack(p_i, p_c, heads, i, r, False)
177 backtrack(p_i, p_c, heads, r, j, True)
178 else:
/usr/local/lib/python3.8/dist-packages/hanlp/components/parsers/alg.py in backtrack(p_i, p_c, heads, i, j, complete)
180 i, j = sorted((i, j))
181 backtrack(p_i, p_c, heads, i, r, True)
--> 182 backtrack(p_i, p_c, heads, j, r + 1, True)
183
184 preds = []
… last 2 frames repeated, from the frame below …
/usr/local/lib/python3.8/dist-packages/hanlp/components/parsers/alg.py in backtrack(p_i, p_c, heads, i, j, complete)
174 if complete:
175 r = p_c[i, j]
--> 176 backtrack(p_i, p_c, heads, i, r, False)
177 backtrack(p_i, p_c, heads, r, j, True)
178 else:
RecursionError: maximum recursion depth exceeded while calling a Python object