使用BOTO将AnswerFormatRegex约束添加到Mechanical Turk项目

时间:2014-07-09 19:00:01

标签: python boto mechanicalturk

我正在尝试使用boto在Amazon Mechanical Turk中创建一些自动化的HIT,并且我有兴趣在问题中添加AnswerFormatRegex限制。如何将此约束添加到问题中?下面是我编写问题的代码片段。

from boto.mturk.connection import MTurkConnection
from boto.mturk.question import QuestionContent,Question,QuestionForm, 
Overview,AnswerSpecification,SelectionAnswer,FormattedContent,FreeTextAnswer

### JUMPING TO RELEVANT CODE ###

qc1 = QuestionContent()
qc1.append_field('Title','Question 1')

fta1 = FreeTextAnswer(num_lines=1)

q1 = Question(identifier="question1",
              content=qc1,
              answer_spec=AnswerSpecification(fta1))

1 个答案:

答案 0 :(得分:0)

很抱歉回答我自己的问题,但最终能够绕过它。这是我用过的似乎在起作用的东西:

qc1 = QuestionContent()
qc1.append_field('Title','DATE:')

constraints1 = [RegExConstraint("***REGEX HERE****",
                                error_text="ERROR.",
                                flags='i')]

fta1 = FreeTextAnswer(constraints=constraints, default="", num_lines=1)

q1 = Question(identifier="date",
              content=qc1,
              answer_spec=AnswerSpecification(fta1))