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

运行dialogue数据集bug #31

Closed
youdianwangya opened this issue Jul 10, 2024 · 6 comments
Closed

运行dialogue数据集bug #31

youdianwangya opened this issue Jul 10, 2024 · 6 comments

Comments

@youdianwangya
Copy link

你好,我在dialogue数据集上面运行的时候运行python generate_k_shot.py --data_dir ./dataset --k 8 --dataset dialogue这句代码,报下面错误,请问是什莫原因吗,期待你的回复,谢谢!
image

@njcx-ai
Copy link
Contributor

njcx-ai commented Jul 10, 2024

您好,非常感谢您对本工作的关注。感觉您这里应该是读取数据时的报错。建议您可以检查数据格式并在get_labels()函数内debug模式定位具体问题呢。

@youdianwangya
Copy link
Author

谢谢您的回复!是的,默认用的eval处理数据,但是我在运行dialogue数据集的时候,数据集格式是json,需要用json.load进行读取,可是一直报错,上面是默认的,下面是更改的(但不正确的),请问可以提供正确的数据读取吗?谢谢!
Uploading image.png…

@youdianwangya
Copy link
Author

您好,我详细表述一下我的问题,在运行dialogue数据集时,输入python generate_k_shot.py --data_dir ./dataset --k 8 --dataset dialogue显示图片错误
image
查询显示是在generate_k_shot.py文件中的
image
zhe'yi这段代码中 features.append(eval(line))不能很好处理.json文件,我查询之后将上述代码更改为用json.load或者json.loads处理。但是,发现semeval和dialogue两者不仅数据格式不同,而且具体的内容标签也不一样,semeval中的标签是relation 其中 negative_label="no_relation",但是在dialogue数据集中标签是'r',以及负样本是unanswerable,然后我将上述数据加载代码更改为def get_labels(path, name, negative_label="unanswerable"):
count = Counter()
file_path = path + "/" + name
with open(file_path, "r", encoding='utf-8') as f:
features = []
for line in f.readlines():
line = line.rstrip()
if len(line) > 0:
try:
feature = json.loads(line)
features.append(feature)
relation = feature.get('r')
if relation == negative_label:
count[negative_label] += 1
elif relation is not None:
count[relation] += 1
except json.JSONDecodeError as e:
print(f"Error decoding JSON from line: {line}. Error: {e}")
continue
return features
但是显示错误如下
image
我目前的改错思路是这样的,不知道是否正确,麻烦您帮忙看一下,如果可以的话,请麻烦您告知一下数据加载这部分代码要如何更改才能读取到dialogue数据呢?非常感谢您认真阅读我的表述!期待您的回复!

@njcx-ai
Copy link
Contributor

njcx-ai commented Jul 10, 2024

您好,从您的截图来看也比较难定位问题,会不会是操作系统编码或者库版本啥问题。另外dialogueRE数据集的数据格式跟其他数据集确实很不一样,我们在实际使用该数据集的时候主要参考的是基线方法GDPNet(https://github.com/XueFuzhao/GDPNet) 这个项目中的处理方式,也可供您参考。

@youdianwangya
Copy link
Author

好的 非常感谢您的回复。

@zxlzr
Copy link
Contributor

zxlzr commented Jul 13, 2024

请问您还有其他问题吗?

@zxlzr zxlzr closed this as completed Jul 13, 2024
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

3 participants