python - 从 Boto API 获取 Mechanical Turk 任务输入数据(例如示例图像 url)
问题描述
当通过 Mechanical Turk 任务检索结果时boto
,如何查看在创建新批次之前提供的 CSV 中的输入数据?
我能够找到它的唯一方法(除了原始 CSV 文件)是来自 MTurk 网络仪表板的批处理结果 CSV。
既不get_assignment()
也不get_hit()
似乎包括这些数据。
解决方案
我能够通过 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']
推荐阅读
- r - 如何让 R IML FeatureImp() 函数工作?
- batch-file - 如何在wmic进程的like子句中传递变量?
- angular - 将 Angular 4 服务重写为 Angular 7 导致 Rxjs 问题
- scala - Spark中的saveAsTextFile与每个部分文件的标题?
- javascript - 如何通过数据属性在 iframe 内的元素上使用 insertBefore
- bash - 如何在awk中使用变量
- python - 我们可以在 keras 中更改经过训练的神经网络结构(.json 或 .h5 文件)及其权重(.h5 文件)吗?
- amazon-web-services - “aws dynamodb list-tables”不适用于 ec2 实例
- java - 通过 stmt.executeUpdate 更新 access 数据库中的整数
- php - 如何在会话变量中保存从数据库中提取的数组以将其发送到 php 中的其他网页