[英]Publishing my HTML into HIT in Mturk sandbox from my local conputer
我正在弄清楚如何使用 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 = "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",
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 文件,因此我得到了一個錯誤。 我該如何修復這個錯誤?
你的 HTML 文件的內容是什么?
它不應該只是 HTML。 Turk 希望 html 被包裝在一個標簽中。
有關示例,請參閱https://docs.aws.amazon.com/AWSMechTurk/latest/AWSMturkAPI/ApiReference_HTMLQuestionArticle.html並查看 html 問題的格式。
很可能您的 HTML 文件格式不正確。 請看下面的例子。
<crowd-form> <crowd-classifier name="sentiment" categories="['Positive', 'Negative', 'Neutral', 'N/A']" header="What sentiment does this text convey?" > <classification-target> Everything is wonderful. </classification-target> <full-instructions header="Sentiment Analysis Instructions"> <p><strong>Positive</strong> sentiment include: joy, excitement, delight</p> <p><strong>Negative</strong> sentiment include: anger, sarcasm, anxiety</p> <p><strong>Neutral</strong>: neither positive or negative, such as stating a fact</p> <p><strong>N/A</strong>: when the text cannot be understood</p> <p>When the sentiment is mixed, such as both joy and sadness, use your judgment to choose the stronger emotion.</p> </full-instructions> <short-instructions> Choose the primary sentiment that is expressed by the text. </short-instructions> </crowd-classifier> </crowd-form> </body> </html> ]]></HTMLContent> <FrameHeight>0</FrameHeight> </HTMLQuestion>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.