Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lluckydog opened this issue Dec 12, 2019 · 7 comments
Open

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

lluckydog opened this issue Dec 12, 2019 · 7 comments

Comments

@lluckydog
Copy link

你好,我按照你写的代码添加了自己的标签但是好像有报错
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
Copy link

Xialei1 commented Dec 13, 2019

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

@lluckydog
Copy link
Author

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

@Xialei1
Copy link

Xialei1 commented Dec 13, 2019 via email

@lluckydog
Copy link
Author

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

建议看看data.py的代码

@Zhenguoshen
Copy link

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

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

KeyError: 'I-job_info'

@Yong988
Copy link

Yong988 commented Mar 25, 2022

ocalError: local variable 'disease' r

I have the same problem.Have you solved it?

@ruomusu
Copy link

ruomusu commented Oct 6, 2023

ocalError: local variable 'disease' r

I have the same problem.Have you solved it?

你现在弄得怎么样了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants