从我的本地计算机将我的 HTML 发布到 Mturk 沙箱中的 HIT

我正在研究如何使用 python 将 HTML 文件从本地计算机发布到沙箱中的 HIT。我将 python 和 HTML 放在同一目录中,并使用给定教程中的模板。https://docs.aws.amazon.com/AWSMechTurk/latest/AWSMechanicalTurkRequester/Welcome.html

 1 import boto3

      2 MTURK_SANDBOX = 'https://mturk-requester-sandbox.us-east-1.amazonaws.com'

      3 mturk = boto3.client('mturk',

      4    aws_access_key_id = "AKIAWMEANKTGFT3M57VI",

      5    aws_secret_access_key = "HhzM8VKe7flOEeSkh4uHeJ7l333Ud3UxnArL/lB0",

      6    region_name='us-east-1',

      7    endpoint_url = MTURK_SANDBOX

      8 )

      9 print("I have $" + mturk.get_account_balance()['AvailableBalance'] + " in my Sandbox account")

     10

     11 html_layout = open('./HTML_template.html', 'r').read()

     12 new_hit = mturk.create_hit(

     13     Title = 'Finish all tasks',

     14     Description = 'Please follow the instructions described in the webpage',

     15     Keywords = 'multiple choice',

     16     Reward = '0.01',

     17     MaxAssignments = 1,

     18     LifetimeInSeconds = 172800,

     19     AssignmentDurationInSeconds = 600,

     20     AutoApprovalDelayInSeconds = 14400,

     21     Question = html_layout,

     22 )

     23 print("A new HIT has been created. You can preview it here:" )

     24 print("https://workersandbox.mturk.com/mturk/preview?groupId=" + new_hit['HIT']['HITGroupId'])

     25 print("HITID = " + new_hit['HIT']['HITId'] + " (Use to Get Results)")

     26 # Remember to modify the URL above when you're publishing

     27 # HITs to the live marketplace.

     28 # Use: https://worker.mturk.com/mturk/preview?groupId=

这是我运行命令时的错误消息python3 create_tasks.py

botocore.exceptions.ClientError: An error occurred (ParameterValidationError) when calling the CreateHIT operation: There was an error parsing the XML question or answer data in your request.  Please make sure the data is well-formed and validates against the appropriate schema. Details: Scanner State 24 not Recognized  (1602359732641 s)

这是我的想法:第 11 行有一个错误。该函数open无法接受 HTML 文件,因此我收到错误。我该如何修复这个错误?


喵喔喔
浏览 137回答 2
2回答

慕虎7371278

您的 HTML 文件的格式很可能不正确。请看下面的例子。&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <crowd-form>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <crowd-classifier&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name="sentiment"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; categories="['Positive', 'Negative', 'Neutral', 'N/A']"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header="What sentiment does this text convey?"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; >&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <classification-target>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Everything is wonderful.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </classification-target>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <full-instructions header="Sentiment Analysis Instructions">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p><strong>Positive</strong>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sentiment include: joy, excitement, delight</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p><strong>Negative</strong> sentiment include:&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; anger, sarcasm, anxiety</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p><strong>Neutral</strong>: neither positive or&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; negative, such as stating a fact</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p><strong>N/A</strong>: when the text cannot be&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; understood</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <p>When the sentiment is mixed, such as both joy and sadness,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; use your judgment to choose the stronger emotion.</p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </full-instructions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <short-instructions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Choose the primary sentiment that is expressed by the text.&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </short-instructions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </crowd-classifier>&nbsp; &nbsp; &nbsp; &nbsp; </crowd-form>&nbsp; &nbsp; &nbsp; </body>&nbsp; &nbsp; </html>&nbsp; ]]></HTMLContent>&nbsp; <FrameHeight>0</FrameHeight></HTMLQuestion>

萧十郎

您的 HTML 文件的内容是什么?它不应该只是 HTML。Turk 希望 html 包含在标签中。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python