从Boto API中获取Mechanical Turk任务的输入数据(例如图片url)。

问题描述 投票:0回答:1

当从Mechanical Turk的任务中获取结果时,通过 boto 在创建新的批次之前,我怎样才能从CSV中看到输入数据?

我唯一能找到它的方法(除了从原始CSV文件中)是在MTurk网页仪表板的批处理结果CSV中。

也没有 get_assignment() 也不 get_hit() 似乎包括这些数据。

python boto mechanicalturk
1个回答
0
投票

我能够通过API访问这些信息,虽然有些间接。

我应该注意的是,我正在处理一个边界框任务,其中所需的输入是每个问题的图像URL。

当调用 get_hit()响应中包括 Question 字段,该字段包含向工作者显示的问题的XML布局。在这个XML数据中,通过解析可以得到一些输入数据,其中包括我所寻找的图片URL。

我使用BeautifulSoup来解析XML。

# Get the assignment
assignment = client.get_assignment(AssignmentId=assignment_id)
# Load the XML for the question, aka task
question_soup = BeautifulSoup(assignment['HIT']['Question'], 'lxml')
task_input = question_soup.find('crowd-bounding-box')
# Extract the image src
image_url = task_input['src']
© www.soinside.com 2019 - 2024. All rights reserved.