buppt/ChineseNER

出错

UPWHY opened this issue · 4 comments

UPWHY commented

用TensorFlow训练Bosondata.pkl时出错。
File "E:/ChineseNER-master/tensorflow/train.py", line 121, in
entityall = calculate(x_batch,y_batch,id2word,id2tag,entityall)
File "E:\ChineseNER-master\tensorflow\resultCal.py", line 9, in calculate
if id2tag[y[i][j]][0]=='B':
IndexError: string index out of range

buppt commented

你能打印一下出错前的id2tag和y[i][j]吗?因为我测试还是没有出错。。

UPWHY commented

今天又运行了一遍又可以了

UPWHY commented

我用的Windows系统,python3,处理数据的模块from compiler.ast import flatten已经不能用,我在网上找到如下自定义函数替代
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

buppt commented

确实。。python2和python3好多不一样的地方。。