mturk crowd rest api的客户端

mturk-crowd-beta-client的Python项目详细描述


先决条件

要使用这个库,首先需要遵循我们的account set-up instructions 设置您的机械土库克和AWS帐户以调用API。

实例化客户端需要使用从boto3到 验证。boto3 docs描述了如何在 细节。

快速启动

首先,安装库:

$ pip install mturk-crowd-beta-client

然后,从python解释器或脚本创建第一个任务:

frommturk_crowd_beta_clientimportMTurkCrowdClientfromboto3.sessionimportSessionimportuuid# This examples assume you have a local AWS profile called# 'mturk-crowd-caller', but you can authenticate however you like,# including by directly passing in your access key and secret key.session=Session(profile_name='mturk-crowd-caller')# Create the clientcrowd_client=MTurkCrowdClient(session)# For this example, we'll give our task a random, unique name. For real# work, you'll probably want to pick a name based on your input source.task_name='my-test-task-'+uuid.uuid4().hexfunction_name='sentiment-analysis-test'# Create the taskput_result=crowd_client.put_task(function_name,task_name,{'text':'Everything is wonderful.'})print('PUT response: {}'.format({'status_code':put_result.status_code,'task':put_result.json()}))# => PUT response: {#  'status_code': 201,#  'task': {'input': {'text': 'Everything is wonderful.'},#           'problemDetails': None,#           'result': None,#           'state': 'processing',#           'taskName': 'my-test-task-73fbfb29f2bc451d9696d11103dcaf0e'}#   }# Get the task we just created. Note that for a production (i.e., non-test)# task, we'd have to poll periodically until the task completed.get_result=crowd_client.get_task(function_name,task_name)print('GET response: {}'.format({'status_code':get_result.status_code,'task':get_result.json()}))# => GET response: {#  'status_code': 200,#  'task': {'input': {'text': 'Everything is wonderful.'},#           'problemDetails': None,#           'result': {'sentiment': 'positive'}#           'state': 'completed',#           'taskName': 'my-test-task-73fbfb29f2bc451d9696d11103dcaf0e'}#   }

进一步阅读

查看我们的usage instructionsAPI documentation了解更多详细信息 关于如何使用api和这个客户机。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java集合属性值   java字符串==运算符是否比较引用?   java是否存在过太多的ListView或适配器?   json获取java中类路径中下载的文件   我可以用java代码解决数据库并发问题吗?   在多个线程中使用forEach()或使用forEach()和lambdas进行java集合迭代   java输出JFrame中的整个循环   java禁用高度详细的日志记录   java在没有特定属性的对象中访问模型的值   java Smack xmpp建立连接   处理过时域对象引起的并发问题的java策略(Grails/GORM/Hibernate)   java从ObservableList中提取元素   使用图像进行java相似图像搜索   java ListView和图像:我快疯了   在Java中,如何从毫秒时间戳中提取一天的周期?   java我需要这样的设计,但我面临两个问题   java如何获取JGoodies FormLayout中的单元格大小   Spring引导生成的java War文件未部署到Weblogic 12c