首页 > 解决方案 > 从 Boto API 获取 Mechanical Turk 任务输入数据(例如示例图像 url)

问题描述

当通过 Mechanical Turk 任务检索结果时boto,如何查看在创建新批次之前提供的 CSV 中的输入数据?

我能够找到它的唯一方法(除了原始 CSV 文件)是来自 MTurk 网络仪表板的批处理结果 CSV。

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

标签: pythonbotomechanicalturk

解决方案


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

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

调用get_hit()时,响应中包含一个Question字段,该字段包含向工作人员显示的问题的 XML 布局。一些输入数据(包括我正在寻找的图像 URL)可通过解析此 XML 数据获得。

我使用 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']

推荐阅读