buppt / ChineseNER

中文命名实体识别,实体抽取,tensorflow,pytorch,BiLSTM+CRF
1.39k stars 394 forks source link

关于 train2.pkl 中from compiler.ast import flatten的问题 #41

Open YuQuankun opened 4 years ago

YuQuankun commented 4 years ago

报错信息为: Traceback (most recent call last): File "train2pkl.py", line 94, in from compiler.ast import flatten ImportError: No module named 'compiler.ast' 网上查阅资料说是因为在python3以后这段话就被废除了,请问如何解决呢?

jkx1206 commented 4 years ago

用下面函数替换就行 import collections

def flatten(x): result = [] for el in x: if isinstance(x, collections.Iterable) and not isinstance(el, str): result.extend(flatten(el)) else: result.append(el) return result