Created
November 25, 2009 09:41
-
-
Save j2labs/242603 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import uuid | |
from boto.mturk.connection import MTurkConnection | |
from boto.mturk.question import Question, QuestionForm | |
from boto.mturk.question import QuestionContent, ExternalQuestion | |
from boto.mturk.question import AnswerSpecification, FreeTextAnswer | |
from boto.mturk.question import SelectionAnswer | |
from boto.mturk.question import Overview | |
from boto.mturk.qualification import * | |
aws_access_key_id = 'private' | |
aws_secret_access_key = 'doubleprivate' | |
aws_host = 'mechanicalturk.sandbox.amazonaws.com' | |
#aws_host = 'mechanicalturk.amazonaws.com' | |
mtc = MTurkConnection(aws_access_key_id=aws_access_key_id, | |
aws_secret_access_key=aws_secret_access_key, | |
host=aws_host) | |
### Create a hit | |
################ | |
# formatted_content does NOT like | |
overview_content = """<p>Your task is to translate the Urdu sentences into English. Please make sure that your English translation:</p> | |
<ul> | |
<li>Is faithful to the original in both meaning and style</li> | |
<li>Is grammatical, fluent, and natural-sounding English</li> | |
<li>Does not add or delete information from the original text</li> | |
<li>Does not contain any spelling errors</li> | |
</ul> | |
<p>When creating your translation, please follow these guidelines:</p> | |
<ul> | |
<li><b>Do not use any machine translation systems (like translation.babylon.com)</b></li> | |
<li><b>You may</b> look up a word on <a href="http://www.urduword.com/">an online dictionary</a> if you do not know its translation</li></ul> | |
<p>Afterwards, we'll ask you a few quick questions about your language abilities.</p> | |
""" | |
overview = Overview() | |
overview.append('Title', 'Translate these sentences') | |
overview.append('FormattedContent', overview_content) | |
qc = QuestionContent() | |
urdu_text = u'\u06a9\u0645\u06cc\u0679\u06cc \u06a9\u06d2 \u0686\u06cc\u0626\u0631\u0645\u06cc\u0646 \u0645\u0634\u0627\u06c1\u062f \u062d\u0633\u06cc\u0646 \u0633\u06cc\u062f \u06a9\u06cc \u0633\u0631\u0628 \u0631\u0627\u06c1\u06cc \u0645\u06cc\u06ba \u06c1\u0648\u0627 \u062c\u0633 \u0645\u06cc\u06ba \u062d\u06a9\u0648 \u0645\u062a \u06a9\u0648 \u06cc\u06c1 \u062a\u062c\u0648\u06cc\u0632 \u062f\u06cc \u06af\u0626\u06cc \u06a9\u06c1 \u0648\u06c1 \u0627\u0645\u062f\u0627\u062f\u06cc' | |
qc.append('FormattedContent', u'<table><tr><td></td><td align="right" width="538">%s</td></tr></table>' % urdu_text) | |
# construct an answer field | |
fta = FreeTextAnswer() | |
ansp = AnswerSpecification(fta) | |
# construct question | |
q = Question(identifier=str(uuid.uuid4()), | |
content=qc, | |
answer_spec=ansp) | |
# put question(s) in a list | |
ql = [q,q,q,q] # repeat question four times | |
# build question form with question list | |
qf = QuestionForm(ql, overview=overview) | |
# create the hit | |
# returns result_set consisting of one item. | |
# created hit can be found as hit_set[0] | |
hit_set = mtc.create_hit(question=qf, | |
max_assignments=3, | |
title='Translate these sentences', | |
description='Help us research language translations by translating sentences', | |
reward=0.1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment