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 Spring数据JPA+Hibernate在不首先找到父实体的情况下保存子实体   php Java:如何从CLI接收命令   spring为java中的导出数据创建访问文件   java在Windows 8.1上安装Play Framework   java Spring启动白标签错误页面(类型=未找到,状态=404)   java如何在单击时从数组中绘制?   java fn:substringAfter()上次出现   java在IFR语句中使用方法返回   java onPause()或onStop()的名称   对关联对象的关联对象具有条件的java HQL查询   java只打印一次总值,无需迭代   java如何使用抽象Uri buildOn()方法?   如何在Java中执行sudo命令并获得错误输出?   java反射:避免对getConstructor(类<?>…)的未经检查的警告调用作为原始类型类的成员   Java:如何从类中创建的对象调用类方法?   java如何在电子邮件中嵌入图像?   java如何在Android上启用详细GC?   java什么是串行版本id?