boto and the 'In' comparator

 ̄綄美尐妖づ 提交于 2019-12-08 01:39:19

问题


I'm trying to use the 'In' comparator with boto for specifying multiple locales on Mechanical Turk jobs. This answer says it's possible, as do the AMT docs.

I tried:

min_qualifications.add(
    LocaleRequirement(
        comparator='In',
        required_to_preview=False,
        locale=['US', 'CA', 'GB', 'IE', 'AU']))

I also tried, variously:

locale='US, CA, GB, IE, AU'
locale='US|CA|GB|IE|AU'
locale='US CA GB IE AU'

How is it done?


回答1:


Just because something is possible in the mTurk API does not mean that Boto will support it. Boto has not been updated for this yet.

Here's how to do it with mturk-python:

import mturk
m = mturk.MechanicalTurk()

question = """
<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
  <Question>
    <QuestionIdentifier>answer</QuestionIdentifier>
    <QuestionContent>
      <Text>Hello world :^)</Text>
    </QuestionContent>
    <AnswerSpecification>
      <FreeTextAnswer/>
    </AnswerSpecification>
  </Question>
</QuestionForm>
"""

qual = [
        {'QualificationTypeId' : mturk.LOCALE,
         'Comparator' : 'In',
         'LocaleValue' : [{'Country':'GB'},{'Country':'US'},{'Country':'AU'}]},
]

reward = {'Amount' : 0, 'CurrencyCode' : 'USD'}

createhit = {"Title" : "Multiple locales",
                   "Description" : "https://github.com/ctrlcctrlv/mturk-python",
                   "Keywords" : "testing, one, two, three",
                   "Reward" : reward,
                   "Question" : question,
                   "QualificationRequirement" : qual,
                   "AssignmentDurationInSeconds" : 90,
                   "LifetimeInSeconds" : (60*60*24)}

r = m.create_request('CreateHIT', createhit)
print r
print m.flattened_parameters



来源:https://stackoverflow.com/questions/25304061/boto-and-the-in-comparator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!