Determined22 / zh-NER-TF

A very simple BiLSTM-CRF model for Chinese Named Entity Recognition 中文命名实体识别 (TensorFlow)
2.32k stars 937 forks source link

添加自己的标签没有成功 #111

Open lluckydog opened 4 years ago

lluckydog commented 4 years ago

你好,我按照你写的代码添加了自己的标签但是好像有报错 Traceback (most recent call last): File "main.py", line 121, in DISEASE, LAB, JIEPOU, MEDICINE, SURGERY, IMAGE = get_entity(tag, demo_sent) File "/home/ruoyuzhao/test/utils.py", line 15, in get_entity DISEASE = get_DISEASE_entity(tag_seq, char_seq) File "/home/ruoyuzhao/test/utils.py", line 36, in get_DISEASE_entity disease += char UnboundLocalError: local variable 'disease' referenced before assignment

这是我对应修改的代码 def get_DISEASE_entity(tag_seq, char_seq): length = len(char_seq) DISEASE = [] for i, (char, tag) in enumerate(zip(char_seq, tag_seq)): if tag == 'B-DISEASE': if 'disease' in locals().keys(): DISEASE.append(disease) del disease disease = char if i+1 == length: DISEASE.append(disease) if tag == 'I-DISEASE': disease += char if i+1 == length: DISEASE.append(disease) if tag not in ['I-DISEASE', 'B-DISEASE']: if 'disease' in locals().keys(): DISEASE.append(disease) del disease continue return DISEASE 还有这个报错我不是很明白为什么 unexpected number of features: 4 (3)

Xialei1 commented 4 years ago

请问下 我的word2id文件打开乱码怎么办?

lluckydog commented 4 years ago

请问下 我的word2id文件打开乱码怎么办? 读写用的是二进制方法,你可以用pickle打开,看一下对不对

Xialei1 commented 4 years ago

word2id文件打开就乱码,试了下您说的方法,还是不好使,您能帮忙看看吗?

------------------ 原始邮件 ------------------ 发件人: "lluckydog"<notifications@github.com>; 发送时间: 2019年12月13日(星期五) 上午9:36 收件人: "Determined22/zh-NER-TF"<zh-NER-TF@noreply.github.com>; 抄送: "磊"<1131856062@qq.com>;"Comment"<comment@noreply.github.com>; 主题: Re: [Determined22/zh-NER-TF] 添加自己的标签没有成功 (#111)

请问下 我的word2id文件打开乱码怎么办? 读写用的是二进制方法,你可以用pickle打开,看一下对不对

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

lluckydog commented 4 years ago

word2id文件打开就乱码,试了下您说的方法,还是不好使,您能帮忙看看吗? …

建议看看data.py的代码

Zhenguoshen commented 4 years ago

我是用自己的数据然后也报错了

File "D:\nlp\zhnertf\zh-NER-TF\data.py", line 150, in label = [tag2label[tag] for tag in tag]

KeyError: 'I-job_info'

Yong988 commented 2 years ago

ocalError: local variable 'disease' r

I have the same problem.Have you solved it?

ruomusu commented 12 months ago

ocalError: local variable 'disease' r

I have the same problem.Have you solved it?

你现在弄得怎么样了