コード例 #1
0
def createHits(question, answers, params):
	if SANDBOX:
		mturk_url = 'mechanicalturk.sandbox.amazonaws.com'
		preview_url = 'https://workersandbox.mturk.com/mturk/preview?groupId='
	else:
		mturk_url = 'mechanicalturk.amazonaws.com'
		preview_url = 'https://mturk.com/mturk/preview?groupId='

	#Create Hit Form Structure	
	overview  = Overview()
	overview.append_field('Title', 'We want to know the crowds opinion!')
	overview.append(FormattedContent('<a href="http://programthecrowd.com/">Visit us here</a>'))
	questionContent = QuestionContent()
	questionContent.append_field('Title', question);
	answerChoices = SelectionAnswer(min=1, max=1, style='checkbox', selections=answers, type='text', other=False)
	q = Question(identifier='Help', content=questionContent, answer_spec=AnswerSpecification(answerChoices), is_required=True)
	questionForm = QuestionForm();
	questionForm.append(overview)
	questionForm.append(q)
	hitIdList = []
	global conn
	# key = params['aws_access_key']
	# secret = params['aws_secret_key']
	conn = MTurkConnection(aws_access_key_id='AKIAJBTEJI2RGTJH7OBA', aws_secret_access_key='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', host=mturk_url)
	
	#For Loop to create and post hits
	for i in range(0, NUMBER_OF_HITS):
		create_hit_rs = conn.create_hit(questions=questionForm, lifetime=LIFETIME, max_assignments=NUMBER_OF_ASSIGNMENTS, title=TITLE, keywords=KEYWORDS, reward=REWARD, duration=DURATION, approval_delay=APPROVAL_DELAY, annotation=DESCRIPTION)
		#print(preview_url + create_hit_rs[0].HITTypeId)
		#print("HIT ID: " + create_hit_rs[0].HITId)
		hitIdList.append(create_hit_rs[0].HITId);

	return hitIdList
コード例 #2
0
    def make_question_form_HIT(self,audio_clip_urls,hit_title,question_title,description,keywords,
                               duration=DEFAULT_DURATION,reward=DEFAULT_REWARD):
        overview = Overview()        
        overview.append_field("Title",hit_title)
        #overview.append(FormattedContent('<a target = "_blank" href="url">hyperlink</a>'))
        question_form = QuestionForm()
        question_form.append(overview)
        for ac in audio_clip_urls:
            audio_html = self.transcription_question.replace(self.audio_url_tag,ac)
            qc = QuestionContent()
            qc.append_field("Title",question_title)            
            qc.append(FormattedContent(audio_html))
            fta = FreeTextAnswer()
            q = Question(identifier="transcription",
                         content=qc,
                         answer_spec=AnswerSpecification(fta))
            question_form.append(q)
        try:
            response = self.conn.create_hit(questions=question_form,
                             max_assignments=1,
                             title=hit_title,
                             description=description,
                             keywords=keywords,
                             duration=duration,
                             reward=reward)
        except MTurkRequestError as e:
            if e.reason != "OK":
                raise 

        return question_form, response
コード例 #3
0
  def generate_hit(self, num_assignments, hit_duration, hit_reward):
    """
    Purpose: Generate and publish the HIT
    Parameters: num_assignments is the number of avaliable assignments for hit, 
                hit_duration is the duration of the hit in seconds (60*5 for 5 minutes),
                hit_reward is the reward given per hit in dollars (0.05 is 5 cents)
    """
    # CONNECT TO MTURK

    mtc = MTurkConnection(aws_access_key_id = self.access_id,
                      aws_secret_access_key = self.secret_key,
                      host = self.host)

    # BUILD OVERVIEW 
     
    overview = Overview()

    overview.append_field('Title', 'The following one or more sentences constitute an incomplete story.')
    story = ""
    for sentence in self.story_sentences:
      story += sentence + " "
    overview.append(FormattedContent(story))
  
    # BUILD QUESTION 1: Copy the first sentence of the story 
     
    qc1 = QuestionContent()
    qc1.append_field('Title','Copy verbatim the first sentence of the provided incomplete story. Please keep all capitalization and punctuation as given. Your sumbission will automatically be rejected if any character is incorrect.')
    fta1 = FreeTextAnswer()
    q1 = Question(identifier='verify_sentence', content = qc1, answer_spec = AnswerSpecification(fta1), is_required = True)

    # BUILD QUESTION 2: Vote on the best sentence to continue the story
    
    sentence_options = []
    for i, sentence in enumerate (self.vote_sentences):
      selection = (sentence, str(i))
      sentence_options.append(selection)
    qc2 = QuestionContent()
    qc2.append_field('Title','Choose the best sentence to continue the story.')
    fta2 = SelectionAnswer(min=1, max=1,style='radiobutton',
                      selections=sentence_options,
                      type='text',
                      other=False)
    q2 = Question(identifier='vote_sentence', content = qc2, answer_spec = AnswerSpecification(fta2), is_required = True)

    # BUILD THE QUESTION FORM 
     
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
     
    # CREATE THE HIT 
     
    mtc.create_hit(questions = question_form,
                   max_assignments = num_assignments,
                   title = self.title,
                   description = self.description,
                   keywords = self.keywords,
                   duration = hit_duration,
                   reward = hit_reward)
コード例 #4
0
ファイル: mturk.py プロジェクト: gpaulu/mTurkTranslation
def createHIT2(possibleAnswers,sentence, context):
	title = 'Pick the best translation!'
	description = ('Pick the best translation!')
	keywords = 'translate, language'

	ratingsDic = {}
	ratings = []
	i = 0
	for answer in possibleAnswers:
		ratings.append((answer,i))
		ratingsDic[i] = answer
		i = i + 1
	 
	#---------------  BUILD OVERVIEW -------------------
	 
	overview = Overview()
	overview.append_field('Title', title)
	overview.append(FormattedContent('<p>' + context + '</p>' + '<p><b>' + sentence + '</b></p>'))
	 
	 
	#---------------  BUILD QUESTION 2 -------------------
	 
	qc1 = QuestionContent()
	qc1.append_field('Title','Please pick the best translation for the bolded sentence above.')
	 
	fta1 = SelectionAnswer(min=1, max=1,style='radiobutton',
                      selections=ratings,
                      type='text',
                      other=False)
 
	q1 = Question(identifier='pick',
              content=qc1,
              answer_spec=AnswerSpecification(fta1),
              is_required=True)
	 
	#--------------- BUILD THE QUESTION FORM -------------------
	 
	question_form = QuestionForm()
	question_form.append(overview)
	question_form.append(q1)

	#--------------- CREATE QUALIFICATION REQUIREMENT -------------------
	qual_req = Requirement(qualification_type_id=QUALIFICATION_ID,
					comparator="Exists")
	
	quals = Qualifications(requirements=[qual_req]) 
	#--------------- CREATE THE HIT -------------------
	 
	resultSet = mtc.create_hit(questions=question_form,
				   max_assignments=HIT2_MAX_ASSIGN,
				   title=title,
				   description=description,
				   keywords=keywords,
				   duration = 60*5,
				   reward=0.50,
				   qualifications=quals)

	
	return (resultSet[0].HITId,ratingsDic)
コード例 #5
0
ファイル: boto_wrapper.py プロジェクト: tvkwoodlands/ddos
def launchHIT(mtc, drawing_id, payment, title):

  #title = 'Add a single line to this drawing: easy!'
  description = ('We need your help to make the best art possible!')
  keywords = 'drawing, web, art, research, paint, creative, easy, simple, fast'
  choices = [('done','done')]
  drawing_id = "http://2.distributeddrawing.appspot.com/" + drawing_id
  #------------------- Overview ---------------------
  overview_content = ("<p>Your task is to follow the link and draw a single line stroke in the box shown.  It's Easy! Just left-click in the box and drag your cursor around to create your stroke (just like in MS Paint).</p>"
                      '<p>BUT...try to add something to the picture.  If the square is blank, start off the image with something cool.  If there is already an image going, add something that makes it better.</p>'
                      '<p>Help us make some great drawings!</p>'
                      '<ul>'
                      '<li><b>Get started: </b>  <a href=" ' + drawing_id + '" target="_blank">Click here</a> </li>'
                      '</ul>')


  overview = Overview()
  overview.append_field('Title', 'Draw a line in the box to complete the task.')
  overview.append(FormattedContent( overview_content))

  #------------------- Question test ---------------------

  #urlContent = '<a target="_blank" href="http://www.toforge.com"> Canvas </a>'

  qc1 = QuestionContent()
  qc1.append_field('Title','Click on the submit button once you have finished the task.')
  qc1.append(FormattedContent('The payment will not be authorized if you have not completed the task.  Also, you can only complete this task once (all subsequent submissions will be rejected).'))

  answers = SelectionAnswer(min=1, max=1,style='dropdown',
                        selections=choices,
                        type='text',
                        other=False)

  #question1 = ExternalQuestion(external_url='http://distributeddrawing.appspot.com/',frame_height=400)

  q1 = Question(identifier='task',
                content=qc1,
                answer_spec=AnswerSpecification(answers),
                is_required=True)

  #------------------- Question form creation ---------------------

  questionForm = QuestionForm()
  questionForm.append(overview)
  questionForm.append(q1)

  #------------------- HIT creation ---------------------

  return mtc.create_hit(question=questionForm,
                 max_assignments=1,
                 lifetime=datetime.timedelta(days=1),
                 title=title,
                 description=description,
                 keywords=keywords,
                 duration = 60*5,
                 reward=payment,
                 response_groups=['Minimal'])
コード例 #6
0
ファイル: mturk.py プロジェクト: pmn/docsift-old
def create_question_form(title, description, keywords):
    """ 
    Create an overview for an MTurk HIT 
    """
    overview = Overview()
    overview.append_field('Title', title)
    question_form = QuestionForm() 
    question_form.append(overview)
    return question_form
コード例 #7
0
def create_question_form(mtc, uuid, url):
    title = 'Bovid Labs HIT v2017.07.31 - %(uuid)s' % vars()
    description = ('Help us extract a polygon from this research image.')
    keywords = 'image, extraction, gimp'

    overview = Overview()
    overview.append_field('Title', 'Instructions')

    # Overview text is where we'll put the details about the HIT
    # img previews the tooth image
    # a allows user to download the image and save as

    text = """
      <p>Your job is to extract the outline of the tooth in the following image.</p>
      
      <p>You need to install the current version of Gimp on your computer. It can
      be downloaded from
      <a href="https://www.gimp.org/downloads/">https://www.gimp.org/downloads/</a></p>

      <p>We have prepared a video at <a href="https://www.youtube.com/watch?v=nzxZqIp3XZY">
      https://www.youtube.com/watch?v=nzxZqIp3XZY</a> showing how to do the task. Once you have extracted
      the outline, you will upload the final result (file) to this HIT.
      </p>
      
      <p>For the HIT to be complete, you must upload a the black polygon against
      a white background. The image size must match the original image size.</p>

      <p>Image download URL: <br/>
         <a href="%(url)s">
            <img src="%(url)s" alt="direct link to image %(uuid)s"/>
         </a>
      </p>
      """ % vars()

    overview.append(FormattedContent(text))

    qc1 = QuestionContent()
    qc1.append_field('Title', 'File Upload Question')

    fu1 = FileUploadAnswer(1024, 1024 * 1024 * 10)

    q1 = Question(identifier="fileupload",
                  content=qc1,
                  answer_spec=AnswerSpecification(fu1))

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)

    # TODO: We want to separate creation of form from uploading the hit
    # need to factor out arguments....
    # duration and lifetime are in seconds.
    # we will give 30 minutes duration (30 * 60) to complete the task
    # we will keep these hits around for 14 days (14 * 24 * 60 * 60)
    print(question_form.get_as_xml())
    mtc.create_hit(questions=question_form, max_assignments=3, title=title, description=description, keywords=keywords,
                   duration=60 * 30, lifetime=3 * 24 * 60 * 60, reward=0.10)
コード例 #8
0
ファイル: tasks.py プロジェクト: dangan249/karmaworld
def submit_extract_keywords_hit(note):
    """Create a Mechanical Turk HIT that asks a worker to
    choose keywords and definitions from the given note."""

    try:
        MTURK_HOST = os.environ['MTURK_HOST']
    except:
        logger.warn('Could not find Mechanical Turk secrets, not running submit_extract_keywords_hit')
        return

    connection = MTurkConnection(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY,
                                 host=MTURK_HOST)

    if note.course.school:
        title = KEYWORDS_HIT_TITLE_TEMPLATE.format(course=note.course.name, school=note.course.school.name)
    else:
        title = KEYWORDS_HIT_TITLE_TEMPLATE.format(course=note.course.name, school=note.course.department.school.name)

    overview = Overview()
    overview.append(FormattedContent(KEYWORDS_HIT_OVERVIEW_TEMPLATE.format(domain=Site.objects.get_current(),
                                                                  link=note.get_absolute_url())))

    keyword_fta = FreeTextAnswer()
    keyword_fta.num_lines = 1

    definition_fta = FreeTextAnswer()
    definition_fta.num_lines = 3

    question_form = QuestionForm()
    question_form.append(overview)

    for i in range(min(len(KEYWORDS_HIT_KEYWORD_FIELDS), len(KEYWORDS_HIT_DEFINITION_FIELDS))):
        keyword_content = QuestionContent()
        keyword_content.append_field('Title', KEYWORDS_HIT_KEYWORD_FIELDS[i][1])
        keyword_question = Question(identifier=KEYWORDS_HIT_KEYWORD_FIELDS[i][0],
                                    content=keyword_content,
                                    answer_spec=AnswerSpecification(keyword_fta),
                                    is_required=True if i <= 10 else False)
        question_form.append(keyword_question)

        definition_content = QuestionContent()
        definition_content.append_field('Title', KEYWORDS_HIT_DEFINITION_FIELDS[i][1])
        definition_question = Question(identifier=KEYWORDS_HIT_DEFINITION_FIELDS[i][0],
                                       content=definition_content,
                                       answer_spec=AnswerSpecification(definition_fta),
                                       is_required=False)
        question_form.append(definition_question)

    hit = connection.create_hit(questions=question_form, max_assignments=1,
                          title=title, description=KEYWORDS_HIT_DESCRIPTION,
                          keywords=KEYWORDS_HIT_KEYWORDS, duration=KEYWORDS_HIT_DURATION,
                          reward=KEYWORDS_HIT_REWARD, qualifications=KEYWORDS_HIT_QUALIFICATION,
                          annotation=str(note.id))[0]

    HIT.objects.create(HITId=hit.HITId, note=note, processed=False)
コード例 #9
0
	def __generate_qualification_test(self, question_data, num_correct, title):
		'''
		Returns a QuestionForm and AnswerKey for a qualification test from a list of sentence dictionaries
		'''

		# Get question and answer data
		questions = map(lambda (i,x): self.__generate_qualification_question(x,i), enumerate(question_data))
		answers = map(lambda (i,x): x["answer_key_"+str(i)], enumerate(questions))
		answer_key = self.__generate_answer_key(answers, num_correct, len(question_data))

		# Create form setup
		qual_overview = Overview()
		qual_overview.append_field("Title",title)

		# Instructions
		qual_overview.append(FormattedContent("<h1>You must correctly code "+str(num_correct)+" out of the "+str(len(question_data))+" test sentences below.</h1>"))
		qual_overview.append(FormattedContent("<h2>Coding instructions are listed below. Please read through these carefully before continuing on to the coding task.</h2>"))
		inst_url = "https://s3.amazonaws.com/aws.drewconway.com/mt/experiments/cmp/html/instructions.html"
		qual_overview.append(FormattedContent('<iframe src="'+inst_url+'" frameborder="0" width="1280" height="300" scrolling="auto">This text is necessary to ensure proper XML validation</iframe>'))

		# Create question form and append contents
		qual_form = QuestionForm()
		qual_form.append(qual_overview)
		for q in questions:
			i = q["question_num"]
			qual_form.append(q["policy_area_"+str(i)])
			qual_form.append(q["econ_scale_"+str(i)])
			qual_form.append(q["soc_scale_"+str(i)])

		return (qual_form, answer_key)
コード例 #10
0
ファイル: amt_voting.py プロジェクト: baykovr/AMT
def create_HIT(mturk_conn, letter, imgur_links):
    # Given a char and set of links
    # create and push HIT
    try:
        canary = mturk_conn.get_account_balance()
    except Exception as e1:
        print "[Error Connecting]", e1
        print "[Exiting]"
        exit(1)

    hit = None
    # -HIT Properties
    title = "Select the Best Character"
    description = (
        "Of the available options below, please select the best representation of the following chracter: "
        + letter
        + "\n Your vote will help determine which character gets selected to be used in a collaborative typeface."
    )
    keywords = "image, voting, opinions"

    # -Question Overview
    overview = Overview()
    overview.append_field("Title", "Choose the best looking letter")

    # -Question
    qc1 = QuestionContent()
    qc1.append_field("Title", "Select Letter")

    # Generate Awnsers 1 per imgur_links[]
    choices = boto_injector(imgur_links)

    # -Awnser Choices
    fta1 = SelectionAnswer(min=1, max=1, style="radiobutton", selections=choices, type="binary", other=False)

    q1 = Question(identifier="design", content=qc1, answer_spec=AnswerSpecification(fta1), is_required=True)

    # -Question Form
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)

    # Put the HIT up
    try:
        mturk_conn.create_hit(
            questions=question_form,
            max_assignments=5,
            title=title,
            description=description,
            keywords=keywords,
            duration=60 * HIT_TIME,
            reward=0.01,
        )
        print "Hit issued for item:", letter
    except Exception as e1:
        print "Could not issue hit", e1
コード例 #11
0
ファイル: mturk.py プロジェクト: gpaulu/mTurkTranslation
def createQualification(language): #returns the qualType
	title = "English to " + language + " Translator Qualification"
	descrip = "Obtain a qualification to complete tasks requiring translation from English to " + language
	status = 'Active'
	keywords = "qualification, translation"
	retry_delay = 10 #small for testing, should be alot bigger or not specified
	test_duration = 300 #5 minutes
	answer_key=None 
	answer_key_xml=None 
	auto_granted=False 
	auto_granted_value=1
	#string to check for translation:
	test_trans = "Siempre como huevos para desayuno cuando me despierto." #"I always eat eggs for breakfast when I wake up"
	#---------------  BUILD OVERVIEW -------------------
	 
	qual_overview = Overview()
	qual_overview.append_field('Title', title)
	qual_overview.append_field('Text' , descrip)
	
	#---------------  BUILD FREE TEXT ANSWER -------------------
	
	
	#---------------  BUILD QUESTION -------------------
	qual_qc = QuestionContent()
	qual_qc.append_field('Title','Please translate the sentence')
	qual_qc.append_field('Text', test_trans)		#This is where the actual question is printed
	
	qual_fta = FreeTextAnswer()
	 
	qual_q1 = Question(identifier="translation",
	              content=qual_qc,
	              answer_spec=AnswerSpecification(qual_fta))
	 
	#--------------- BUILD THE QUESTION FORM -------------------
	 
	qual_question_form = QuestionForm()
	qual_question_form.append(qual_overview)
	qual_question_form.append(qual_q1)
	
	#--------------- CREATE THE QUALIFICATION TYPE -------------------
	
	qualType = mtc.create_qualification_type(title, 
					descrip, 
					status, 
					keywords, 
					retry_delay,
					qual_question_form,	#the "test" value
					answer_key,
					answer_key_xml,
					test_duration,
					auto_granted,
					auto_granted_value)
					
	return qualType
コード例 #12
0
    def make_question_form_elicitation_HIT(self,prompt_list,hit_title,prompt_title,keywords,
                                  duration=DEFAULT_DURATION,reward_per_clip=DEFAULT_REWARD,max_assignments=DEFAULT_MAX_ASSIGNMENTS):
        overview = Overview()        
        overview.append_field("Title",hit_title)
        #overview.append(FormattedContent('<a target = "_blank" href="url">hyperlink</a>'))
        question_form = QuestionForm()
        
        descriptions = ["The following prompts are in English.",
                        "Approve the flash permissions to record audio.",                        
                        "Click the red circle to record yourself.",
                        "Read the words after 'prompt:'",
                        "Click 'Click to Stop'",
                        "Play the clip back to verify sound quality.",
                        "After you are happy with your recording, click 'Click here to save >>'",
                        "Copy & paste the URL under 'Sharing options' into the text field for the prompt.",
                        "You will NEVER be asked to divulge any personal or identifying information."
                        ]
        keywords = "audio, recording, elicitation, English"
        
#         for i, description in enumerate(descriptions):            
#             overview.append_field("%dDescription"%i, description)
#         flash_xml = FlashXml(self.flash_xml.replace(self.html_tags["flash_url"],self.vocaroo_url))
#         overview.append(flash_xml)
        question_form.append(overview)
        
        qc = QuestionContent()
#        qc.append(FormattedContent(flash_xml))
           
        qc.append_field("Title","Please select the type of microphone you are using.")
#         qc.append(Flash(self.vocaroo_url,525,450))
#         
        #answer = FreeTextAnswer()
        answer = SelectionAnswer(max=1,style="radiobutton",selections=self.mic_selections)
        q = Question(identifier="MIC",
                     content=qc,
                     answer_spec=AnswerSpecification(answer))
        question_form.append(q)

        qual = qualification.LocaleRequirement("in","USA")
        reward = reward_per_clip * len(prompt_list)
        xml = question_form.get_as_xml()
        try:
            response = self.conn.create_hit(questions=question_form,
                             max_assignments=1,
                             title=hit_title,
                             qualification= qual,
                             description=descriptions[0],
                             keywords=keywords,
                             duration=duration,
                             reward=reward)
        except MTurkRequestError as e:
            if e.reason != "OK":
                raise 
        return True
コード例 #13
0
def make_poll(title, question, description, keywords, poll_price, ratings):
    """Take submitted request and answers.

    Resubmit for polling to ensure validity."""

    ACCESS_ID = mtkey.ACCESS_KEY
    SECRET_KEY = mtkey.SECRET_KEY

    HOST = 'mechanicalturk.amazonaws.com'
    # link to HITs: https://requester.mturk.com/mturk/manageHITs

    # HOST = 'mechanicalturk.sandbox.amazonaws.com'
    # link to HITs: https://requestersandbox.mturk.com/mturk/manageHITs

    mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                          aws_secret_access_key=SECRET_KEY,
                          host=HOST)

    #---------------  BUILD OVERVIEW -------------------

    overview = Overview()
    overview.append_field('Title', title)

    #---------------  BUILD POLL  -------------------

    qc2 = QuestionContent()
    qc2.append_field('Title', question)

    fta2 = SelectionAnswer(min=1, max=4, style='checkbox',
                           selections=ratings,
                           type='text',
                           other=False)

    q2 = Question(identifier='selection',
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2),
                  is_required=True)

    #--------------- BUILD THE POLL FORM -------------------

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q2)    

    #--------------- CREATE THE HIT -------------------

    return mtc.create_hit(questions=question_form,
                          max_assignments=8,
                          title=title,
                          description=description,
                          keywords=keywords,
                          duration=60*5,
                          reward=poll_price)
コード例 #14
0
ファイル: mturk.py プロジェクト: gpaulu/mTurkTranslation
def createHIT1(to_trans,context):

	
	
	title = 'Translate a sentence into spanish!'
	description = ('For realz. Just translate this sentence.')
	keywords = 'translate, language'
	#qualifications = Qualificatiosn(qualificationType)
	
	#---------------  BUILD OVERVIEW -------------------
	 
	overview = Overview()
	overview.append_field('Title', title)
	overview.append(FormattedContent('<p>' + context + '</p>' + '<p><b>' + to_trans + '</b></p>'))
	 
	 
	#---------------  BUILD QUESTION 2 -------------------
	 
	qc1 = QuestionContent()
	qc1.append_field('Title','Please translate the bolded sentence')
	 
	fta1 = FreeTextAnswer()
	 
	q1 = Question(identifier="translation",
				  content=qc1,
				  answer_spec=AnswerSpecification(fta1))
	 
	#--------------- BUILD THE QUESTION FORM -------------------
	 
	question_form = QuestionForm()
	question_form.append(overview)
	question_form.append(q1)
	 
	#--------------- CREATE QUALIFICATION REQUIREMENT -------------------
	qual_req = Requirement(qualification_type_id=QUALIFICATION_ID,
					comparator="Exists")
	
	quals = Qualifications(requirements=[qual_req])
	#--------------- CREATE THE HIT ------------------- 
	resultSet = mtc.create_hit(questions=question_form,
				   max_assignments=HIT1_MAX_ASSIGN,
				   title=title,
				   description=description,
				   keywords=keywords,
				   duration = 60*5,
	               reward=0.50,
				   qualifications=quals)

	
	return resultSet[0].HITId
コード例 #15
0
  def generate_hit(self, num_assignments, hit_duration, hit_reward):
    """
    Purpose: Generate and publish the HIT
    Parameters: num_assignments is the number of avaliable assignments for hit, 
                hit_duration is the duration of the hit in seconds (60*5 for 5 minutes),
                hit_reward is the reward given per hit in dollars (0.05 is 5 cents)
    """
    # CONNECT TO MTURK

    mtc = MTurkConnection(aws_access_key_id = self.access_id,
                      aws_secret_access_key = self.secret_key,
                      host = self.host)

    # BUILD OVERVIEW 
     
    overview = Overview()
    overview.append_field('Title', 'The sentence below constitues the beginning of a story.')
    overview.append(FormattedContent(self.starter_sentence))
     
    # BUILD QUESTION 1: Copy given sentence 
     
    qc1 = QuestionContent()
    qc1.append_field('Title','Copy verbatim the provided sentence. Please keep all capitalization and punctuation as given. Your sumbission will automatically be rejected if any character is incorrect.')
    fta1 = FreeTextAnswer()
    q1 = Question(identifier='verify_sentence', content = qc1, answer_spec = AnswerSpecification(fta1), is_required = True)

    # BUILD QUESTION 2: Create new sentence 

    qc2 = QuestionContent()
    qc2.append_field('Title','Type a single sentence to continue the story begun by the given sentence, and please ensure the sentence ends with a period.')
    fta2 = FreeTextAnswer()
    q2 = Question(identifier='create_sentence', content = qc2, answer_spec = AnswerSpecification(fta2), is_required = True)

    # BUILD THE QUESTION FORM 
     
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
     
    # CREATE THE HIT 
     
    mtc.create_hit(questions = question_form,
                   max_assignments = num_assignments,
                   title = self.title,
                   description = self.description,
                   keywords = self.keywords,
                   duration = hit_duration,
                   reward = hit_reward)
コード例 #16
0
def create_question(batch, examples):
	"""
	Creates a QuestionForm for a batch of strings

	Args:
		batch (list) : List of pairs of strings to be matched
		examples (tuple) : Input examples for which HTML is to be generated

	Returns:
		question_form : QuestionForm object containing all question fields

	"""

	question_id = []
	question_form = QuestionForm()


	overview = Overview()
	overview.append_field('Title', title)
	
	#examples = ("(abc, aabc) - not match", "(abc, abc) - match")
	overview.append(FormattedContent(utils.gen_html_for_instruction(examples)))

	question_form.append(overview)

	for i in range(0,len(batch)):
		#print 'String 1  = ' + batch[i][0]
		#print 'String 2  = ' + batch[i][1]

		question_content = QuestionContent()
		text = 'String 1 = ' + batch[i][0] + '\n'
		text = text + 'String 2 = ' + batch[i][1] + '\n'
		question_content.append_field('Text', text)

		q_id = 'q' + str(i) + str(i+1)
		question_id.append(q_id)
		selection_answer = SelectionAnswer(min=1, max=1,style='radiobutton',
	                      selections=matches,
	                      type='text',
	                      other=False)
	 
		question = Question(identifier=q_id,
	              content=question_content,
	              answer_spec=AnswerSpecification(selection_answer),
	              is_required=True)

		question_form.append(question)

	return question_form
コード例 #17
0
ファイル: phillyTechMturk.py プロジェクト: vgoklani/mturk
def make_question(url, selections):
    """Build a formatted question to be posted on mechanical turk.

    :param urls: Images to be displayed in mc question.
    :param selections: Answer selections.
    :param fta: True if the question includes a FreeTextAnswer.

    """
    mc_overview = Overview()
    mc_overview.append_field('Title', title)

    question_form = QuestionForm()
    question_form.append(mc_overview)
    question_form.append(make_mc_question(url, selections))
    return question_form
コード例 #18
0
def make_question(title, question, description, keywords, price, num_ppl_to_ask):
    """Make a question to send to MTurk in the correct formatting."""

    ACCESS_ID = mtkey.ACCESS_KEY
    SECRET_KEY = mtkey.SECRET_KEY

    HOST = 'mechanicalturk.amazonaws.com'
    #link to HITs: https://requester.mturk.com/mturk/manageHITs

    #HOST = 'mechanicalturk.sandbox.amazonaws.com'
    #link to HITs: https://requestersandbox.mturk.com/mturk/manageHITs

    mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                          aws_secret_access_key=SECRET_KEY,
                          host=HOST)

    #---------------  BUILD OVERVIEW -------------------
     
    overview = Overview()
    overview.append_field('Title', title)

    #---------------  BUILD QUESTION -------------------
     
    qc2 = QuestionContent()
    qc2.append_field('Title', question)
     
    fta2 = FreeTextAnswer()
     
    q2 = Question(identifier="comments",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))
     
    #--------------- BUILD THE QUESTION FORM -------------------
     
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q2)
     
    #--------------- CREATE THE HIT -------------------
     
    return mtc.create_hit(title=title,
                          description=description,
                          questions=question_form,
                          keywords=keywords,
                          max_assignments=num_ppl_to_ask,
                          duration=60*5,
                          reward=price)
コード例 #19
0
ファイル: mTurk.py プロジェクト: dennyabrain/deard
class mTurk:
    def __init__(self):
        self.ACCESS_ID = os.environ["ACCESS_KEY_ID"]
        self.SECRET_KEY = os.environ["SECRET_ACCESS_KEY"]
        self.HOST = "mechanicalturk.sandbox.amazonaws.com"
        self.title = "Please respond as a therapist to this question"
        self.description = "Read this diary entry and give a thoughtful advice to this person"
        self.keywords = "diary,therapist,friend,advice"
        self.connectMTurk()

    def connectMTurk(self):
        self.mtc = MTurkConnection(
            aws_access_key_id=self.ACCESS_ID, aws_secret_access_key=self.SECRET_KEY, host=self.HOST
        )
        # print(self.mtc.get_account_balance())

    def buildOverview(self):
        self.overview = Overview()
        self.overview.append_field("Title", "Deard Response")
        self.overview.append(FormattedContent("<h2>DearD User Post</h2>"))

    def buildQuestion(self, diaryEntry):
        self.qc = QuestionContent()
        self.qc.append_field("Title", diaryEntry)
        self.fta = FreeTextAnswer()
        self.q1 = Question(identifier="comments", content=self.qc, answer_spec=AnswerSpecification(self.fta))

    def buildQuestionForm(self):
        self.question_form = QuestionForm()
        self.question_form.append(self.overview)
        self.question_form.append(self.q1)

    def createHit(self, diaryEntry):
        self.buildOverview()
        self.buildQuestion(diaryEntry)
        self.buildQuestionForm()
        id = self.mtc.create_hit(
            questions=self.question_form,
            max_assignments=1,
            title=self.title,
            description=self.description,
            duration=60 * 5,
            reward=0.50,
        )
        return id[0].HITId
コード例 #20
0
ファイル: tweetbeats.py プロジェクト: clowetz/TweetBeats
	def createHit(self,text):
		mtc = MTurkConnection(aws_access_key_id=self.ACCESS_ID,
                      aws_secret_access_key=self.SECRET_KEY,
                      host=self.HOST)
		overview = Overview()
		overview.append_field('Title','Rate this Tweet! (WARNING: This HIT may contain adult content. Worker discretion is advised.)')

		qc = QuestionContent()
		qc.append_field('Title','Please read the following: ')
		qc.append_field('Text', "\"" + text + "\"" +'\n')
		qc.append_field('Text','After reading the above tweet, please choose the mood which matches best with the content.')
		selectionAns = SelectionAnswer(min = 1, max = 1, style='radiobutton',
									   selections = self.moodList,
									   type="text",
									   other = False)
		q = Question(identifier='mood',
					 content = qc,
					 answer_spec = AnswerSpecification(selectionAns),
					 is_required=True)

		qc2 = QuestionContent()
		
		qc2.append_field('Text','Choose an intesity for the mood chosen.\n (1 - lowest | 10 - highest)')
		selectionAns2 = SelectionAnswer(min = 1, max = 1, style='radiobutton', #dropdown
									   selections = self.moodIntensity,
									   type="text",
									   other = False)
		q2 = Question(identifier='intensity',
					 content = qc2,
					 answer_spec = AnswerSpecification(selectionAns2),
					 is_required=True)

		question_form = QuestionForm()
		question_form.append(overview)
		question_form.append(q)
		question_form.append(q2)
		
		my_hit= mtc.create_hit(questions=question_form,
						max_assignments=1,
						title='Rate this Tweet! (WARNING: This HIT may contain adult content. Worker discretion is advised.)',
						description='Easy! Read a single tweet and rate choose a mood and intensity',
						keywords='rate, tweet',
						duration = 60*5, #60 seconds * 5
						reward = 0.01)
		return my_hit[0].HITTypeId 
コード例 #21
0
    def __generate_qualification_test(self, question_data, num_correct, title):
        '''
            Returns a QuestionForm and AnswerKey for a qualification test from a list of sentence dictionaries.
                question_data : json object containing all the questions.
        '''

        # Get question and answer data
        questions = map(lambda (i,x): self.__generate_qualification_question(x,i), enumerate(question_data))
        answers = map(lambda (i,x): x["answer_key_"+str(i)], enumerate(questions))

        answer_key = self.__generate_answer_key(answers, num_correct, len(question_data))

        # Create form setup
        qual_overview = Overview()
        qual_overview.append_field("Title", title)

        # Instructions
        qual_overview.append(FormattedContent("<h1>Please answer all the questions below.</h1>"))
        qual_overview.append(FormattedContent("<h2>For each question, please choose either the left or right image \
            which you think is more beautiful in terms of its composition. Hints: Please make your decision based on\
            several 'rules of thumb' in photography, such as rule of thirds, visual balance and golden ratio. \
            You may also make your decision by judging which image contains less unimportant or distracting contents.</h2>"))

        # Create question form and append contents
        qual_form = QuestionForm()
        qual_form.append(qual_overview)

        for q in questions:
            i = q["question_num"]
            qual_form.append(q["question_"+str(i)])

        return (qual_form, answer_key)
コード例 #22
0
ファイル: amt_voting.py プロジェクト: baykovr/AMT
def create_HIT(mturk_conn,letter,imgur_links):
# Given a char and set of links
# create and push HIT
	try:
		canary = mturk_conn.get_account_balance()
	except Exception as e1:
		print "[Error Connecting]",e1
		print "[Exiting]"
		exit(1)
	
	hit = None	
	#-HIT Properties
	title      = 'Select the Best Character'
	description= ('Of the available options below, please select the best representation of the following chracter: '+letter+'\n Your vote will help determine which character gets selected to be used in a collaborative typeface.')
	keywords   = 'image, voting, opinions'	
	
	#-Question Overview
	overview = Overview()
	overview.append_field('Title', 'Choose the best looking letter')
	
	#-Question
	qc1 = QuestionContent()
	qc1.append_field('Title','Select Letter')
	
	# Generate Awnsers 1 per imgur_links[]
	choices = boto_injector(imgur_links)
	
	#-Awnser Choices
	fta1 = SelectionAnswer(min=1, max=1,style='radiobutton',\
		selections=choices,type='binary',other=False)
	
	q1 = Question(identifier='design',content=qc1,\
		answer_spec=AnswerSpecification(fta1),is_required=True)
	
	#-Question Form
	question_form = QuestionForm()
	question_form.append(overview)
	question_form.append(q1)
	
	#Put the HIT up
	try:
		mturk_conn.create_hit(questions=question_form,max_assignments=5,title=title,description=description,keywords=keywords,duration = 60*HIT_TIME,reward=0.01)
		print "Hit issued for item:",letter
	except Exception as e1:
		print "Could not issue hit",e1
コード例 #23
0
    def __generate_qualification_test(self, question_data, num_correct, title):
        '''
		Returns a QuestionForm and AnswerKey for a qualification test from a list of sentence dictionaries
		'''

        # Get question and answer data
        questions = map(
            lambda (i, x): self.__generate_qualification_question(x, i),
            enumerate(question_data))
        answers = map(lambda (i, x): x["answer_key_" + str(i)],
                      enumerate(questions))
        answer_key = self.__generate_answer_key(answers, num_correct,
                                                len(question_data))

        # Create form setup
        qual_overview = Overview()
        qual_overview.append_field("Title", title)

        # Instructions
        qual_overview.append(
            FormattedContent("<h1>You must correctly code " +
                             str(num_correct) + " out of the " +
                             str(len(question_data)) +
                             " test sentences below.</h1>"))
        qual_overview.append(
            FormattedContent(
                "<h2>Coding instructions are listed below. Please read through these carefully before continuing on to the coding task.</h2>"
            ))
        inst_url = "https://s3.amazonaws.com/aws.drewconway.com/mt/experiments/cmp/html/instructions.html"
        qual_overview.append(
            FormattedContent(
                '<iframe src="' + inst_url +
                '" frameborder="0" width="1280" height="300" scrolling="auto">This text is necessary to ensure proper XML validation</iframe>'
            ))

        # Create question form and append contents
        qual_form = QuestionForm()
        qual_form.append(qual_overview)
        for q in questions:
            i = q["question_num"]
            qual_form.append(q["policy_area_" + str(i)])
            qual_form.append(q["econ_scale_" + str(i)])
            qual_form.append(q["soc_scale_" + str(i)])

        return (qual_form, answer_key)
コード例 #24
0
def create_crop_hit(mturk, URLs, num_assignment, qualification=Qualifications()):
    # Constant data for HIT generation
    hit_title = "Photo Quality Assessment"
    hit_description = "This task involves viewing pairs of pictures and judging which picture among the image pair is more beautiful."
    lifetime = 259200
    keywords = ["photo","quality","ranking"]
    duration = 30 * 60
    reward = 0.05
    #approval_delay = 86400

    # Question form for the HIT
    question_form = QuestionForm()

    overview = Overview()
    overview.append_field('Title', 'Photo Quality Assessment')
    overview.append(FormattedContent('For each question, please choose either the left or right image which you think is more beautiful in terms of its <u>composition</u>.'))
    overview.append(FormattedContent('<b>Hints: Please make your decision based on several "rules of thumb" in photography, such as rule of thirds, visual balance and golden ratio.</b>'))
    #overview.append(FormattedContent('<b>You may also make your decision by judging which image contains less unimportant or distracting contents</b>.'))
    overview.append(FormattedContent('For those hard cases, please just select your preferred image based on your sense of aesthetics.'))
    question_form.append(overview)

    ratings = [('Left', '0'), ('Right','1')]
    for i in xrange(len(URLs)):
        qc = QuestionContent()
        qc.append_field('Title', 'Question')
        qc.append_field('Text', 'Please indicate which one of the following images is more beautiful.')
        qc.append(FormattedContent('<img src="'+URLs[i]+'" alt="Image not shown correctly!"></img>'))
        #URLs[i]
        fta = SelectionAnswer(min=1, max=1, style='radiobutton', selections=ratings, type='text', other=False)
        q = Question(identifier='photo_pair_'+str(i),
                    content=qc,
                    answer_spec=AnswerSpecification(fta),
                    is_required=True
        )
        question_form.append(q)

    hit_res = mturk.create_hit(title=hit_title,
                                description=hit_description,
                                reward=Price(amount=reward),
                                duration=duration,
                                keywords=keywords,
                                #approval_delay=approval_delay,
                                question=question_form,
                                #lifetime=lifetime,
                                max_assignments=num_assignment,
                                qualifications=qualification)
    # return HIT ID
    return hit_res[0].HITId
コード例 #25
0
ファイル: textonic.py プロジェクト: atduskgreg/rapidsms
    def SubmitHIT(self, sandbox = 'false'):
        """
        Constructs a HIT from the HITGenerator's attributes, registers it with Amazon, and returns the HITId as a unicode string.

        If the sandbox flag is set to true then the hit will be registered with the Sandbox, otherwise it is registered to AWS
        directly.  All of the necessary data must have been submitted during the HITGenerator's initiation.
        """

        if sandbox is 'true':
            self.host = 'mechanicalturk.sandbox.amazonaws.com'
        conn = MTurkConnection(host = self.host, aws_access_key_id = self.AWS_KEY, aws_secret_access_key = self.AWS_SECRET)
        answer_specification = AnswerSpecification(SelectionAnswer(style = self.answer_style, selections = self.answer_options))
        overview = Overview()
        overview.append('Title', 'Translate these sentences')
        overview.append('FormattedContent', overview_content) 
        qc = QuestionContent()
        the_text = "Some arabic Words."
        qc.append('FormattedContent', u'<table><tr><td></td><td align="right" width="538">%s</td></tr></table>' % the_text)
       # construct an answer field
        fta = FreeTextAnswer()
        ansp = AnswerSpecification(fta)
        ql = []
        for q in self.question_list:
            ql.append(Question(identifier=q[1],
                               content=q[0],
                               answer_spec=ansp))
        #q = Question(identifier=str(uuid.uuid4()),
        #             content=qc,
        #             answer_spec=ansp)
        # build question form with question list
        qf = QuestionForm(ql, overview=overview)
        self.hit_response = conn.create_hit(question = qf,
                                            lifetime = self.lifetime,
                                            max_assignments = self.assignment_count,
                                            title = self.title,
                                            description = self.description,
                                            keywords = self.keywords,
                                            reward = self.reward,
                                            )
        # Returns the HITId as a unicode string
#        self.HITId = self.hit_response.HITId
#        return self.HITId
        return self.hit_response
コード例 #26
0
def post_HIT1(ACCESS_ID,SECRET_KEY,HOST,url_to_task):
    mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                      aws_secret_access_key=SECRET_KEY,
                      host=HOST)
 
    title = 'Dev deploying simulation test Report From SERVER'
    description = ('Report on events in a simulation')
    keywords = 'website, rating, opinions'
    instructions=('<p>You will take part in a web-based experiment where you will watch a simple simulation and provide reports on events</p>'
                 '<p>Instructions:</p>'
                  '<p>1. Click the link below, which will open the webpage in a new window in your browser</p>'
                  '<p>2. Follow the instructions on the website</p>'
                  '<p>3. Once you have completed your work, you will receive a Reward Code</p>'
                  '<p>4. Return to the mechanical turk webpage and enter your code in the Reward Code text box</p>'
                  '<p>5. Your work will then be checked, after which you will receive your payment</p>'
                  '<br/>CLICK "ACCEPT HIT" BEFORE FOLLOWING LINK'
                  '<br/>YOU WILL NOT BE PAID WITHOUT ACCEPTING THE HIT')
                    
                    
    #---------------  BUILD OVERVIEW -------------------
     
    overview = Overview()
    overview.append_field('Title', description)
    overview.append(FormattedContent(instructions))
    overview.append(FormattedContent('<p>Click "Accept HIT" then click this link <a target="_blank"'
                                     ' href="'+url_to_task+'">'
                                     ' Link to task</a></p>'))
 
    #---------------  BUILD QUESTION 1 -------------------
     
    qc1 = QuestionContent()
    qc1.append_field('Title','Enter reward code here:')
     
    fta1 = FreeTextAnswer(num_lines=1)
    
    q1 = Question(identifier='reward_code',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)
     
     
    #--------------- BUILD THE QUESTION FORM -------------------
     
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    
     
    #--------------- CREATE THE HIT -------------------
     
    mtc.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration = 60*5,
                   reward=0.05)
コード例 #27
0
def _gen_overview():
    overview_title = 'Translate these sentences'
    overview_content = """<p>Your task is to translate the Spanish 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 transle.google.com)</b></li>
</ul>
"""

    overview = Overview()
    overview.append('Title', overview_title)
    overview.append('FormattedContent', overview_content)
    
    return overview
コード例 #28
0
ファイル: create_hits.py プロジェクト: bozzkar/mTurk-Auto
def creating_hits(hitters, location='https://c9.io/gibolt/wordcloud565/workspace/aws-python-example/IMG_5109.JPG'): 
    title = 'First thoughts on the photo'
    description = ('Enter the first word that comes to your mind'
                   ' after seeing this photo')
    keywords = 'photo,easy,short,describe,one,word'
    
    string='<p><img src="'+location+'" alt="oops.image missing" height="400" width="500" /></p>'
    
    overview = Overview()
    overview.append_field('Title', 'What is Your First Impression?')
    overview.append(FormattedContent(string))
     
    
    qc1 = QuestionContent()
    qc1.append_field('Title','First word that comes to mind')
    fta1 = FreeTextAnswer()
    q1 = Question(identifier='photo', content=qc1, answer_spec=AnswerSpecification(fta1))
    qc2 = QuestionContent()
    qc2.append_field('Title', 'Second Word')
    q2typ = FreeTextAnswer()
    q2 = Question(identifier="second", content=qc2, answer_spec=AnswerSpecification(q2typ))
    qc3 = QuestionContent()
    qc3.append_field('Title', 'Third Word')
    q3typ = FreeTextAnswer()
    q3 = Question(identifier="third", content=qc3, answer_spec=AnswerSpecification(q3typ))
    
    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
    question_form.append(q3)
     
    for x in range(1,hitters):
        my_hit = conn.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration = 60*5,
                   reward=0.01)
コード例 #29
0
ファイル: mturk.py プロジェクト: pseeth/crowdchoir
def postHIT(link):
	title = 'Sing along to an audio file!'

	description = ('Quick, easy, and fun task. Go to the link below read and record sentences shown on the webpage. Copy the given survey code here.')

	keywords = 'recording, english, tesing'

	overview = Overview()
	overview.append_field('Title', title)
	overview.append(FormattedContent('<a href="' + link + '"> Click this link to go to the task</a>'))

	# qc1 = QuestionContent()
	# qc1.append_field('Title', 'Which city are you from?')
	# fta1 = FreeTextAnswer(default="", num_lines=1)
	# q1 = Question(identifier='pronunciation',
	#                     content = qc1,
	#                     answer_spec=AnswerSpecification(fta1),
	#                     is_required = False)

	qc2 = QuestionContent()
	qc2.append_field('Title', 'Put your survey code here')
	fta2 = FreeTextAnswer(default="", num_lines=1)
	q2 = Question(identifier='pronunciation',
			    content = qc2,
			    answer_spec=AnswerSpecification(fta2),
			    is_required = False)

	question_form = QuestionForm()
	question_form.append(overview)
	# question_form.append(q1)
	question_form.append(q2)

	mtc.create_hit(questions = question_form,
		       max_assignments = 1,
		       title = title,
		       description = description,
		       keywords = keywords,
		       duration = 60*60*6,
		       reward = 0.03)
コード例 #30
0
    def make_question_form_HIT(self,
                               audio_clip_urls,
                               hit_title,
                               question_title,
                               description,
                               keywords,
                               duration=DEFAULT_DURATION,
                               reward=DEFAULT_REWARD):
        overview = Overview()
        overview.append_field("Title", hit_title)
        #overview.append(FormattedContent('<a target = "_blank" href="url">hyperlink</a>'))
        question_form = QuestionForm()
        question_form.append(overview)
        for ac in audio_clip_urls:
            audio_html = self.transcription_question.replace(
                self.audio_url_tag, ac)
            qc = QuestionContent()
            qc.append_field("Title", question_title)
            qc.append(FormattedContent(audio_html))
            fta = FreeTextAnswer()
            q = Question(identifier="transcription",
                         content=qc,
                         answer_spec=AnswerSpecification(fta))
            question_form.append(q)
        try:
            response = self.conn.create_hit(questions=question_form,
                                            max_assignments=1,
                                            title=hit_title,
                                            description=description,
                                            keywords=keywords,
                                            duration=duration,
                                            reward=reward)
        except MTurkRequestError as e:
            if e.reason != "OK":
                raise

        return question_form, response
コード例 #31
0
def validate():
	print '\nValidating results on Mechanical Turk...\n'

	ACCESS_ID = getpass.getpass("Enter your access ID: ")
	SECRET_KEY = getpass.getpass("Enter your secret key: ")

	reward, HOST, numWorkers, votes = getUserInput()

	mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                      aws_secret_access_key=SECRET_KEY,
                      host=HOST)

	overview = Overview()
	overview.append_field('Title', 'Select app features related to a set of words')

	# Get features from file
	questions = readFeatures()

	# Create questions
	mtc_questions = []
	for q in questions:
		mtc_questions.append(createQuestion(q[0], q[1]))

	# Create survey with the questions inside
	q_form = createForm(overview, mtc_questions)

	# Post the survey
	result = createHit(q_form, mtc, reward, numWorkers)
	hitId = result[0].HITId

	# Process the results when they come in
	print '\nFetching results...\n'
	data = fetchResults(mtc, questions, numWorkers, votes, hitId)

	# Write the validated features to file
	outputResults(data, numWorkers)
コード例 #32
0
def createHits(question, answers, params):
    if SANDBOX:
        mturk_url = 'mechanicalturk.sandbox.amazonaws.com'
        preview_url = 'https://workersandbox.mturk.com/mturk/preview?groupId='
    else:
        mturk_url = 'mechanicalturk.amazonaws.com'
        preview_url = 'https://mturk.com/mturk/preview?groupId='

    #Create Hit Form Structure
    overview = Overview()
    overview.append_field('Title', 'We want to know the crowds opinion!')
    overview.append(
        FormattedContent(
            '<a href="http://programthecrowd.com/">Visit us here</a>'))
    questionContent = QuestionContent()
    questionContent.append_field('Title', question)
    answerChoices = SelectionAnswer(min=1,
                                    max=1,
                                    style='checkbox',
                                    selections=answers,
                                    type='text',
                                    other=False)
    q = Question(identifier='Help',
                 content=questionContent,
                 answer_spec=AnswerSpecification(answerChoices),
                 is_required=True)
    questionForm = QuestionForm()
    questionForm.append(overview)
    questionForm.append(q)
    hitIdList = []
    global conn
    # key = params['aws_access_key']
    # secret = params['aws_secret_key']
    conn = MTurkConnection(
        aws_access_key_id='AKIAJBTEJI2RGTJH7OBA',
        aws_secret_access_key='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',
        host=mturk_url)

    #For Loop to create and post hits
    for i in range(0, NUMBER_OF_HITS):
        create_hit_rs = conn.create_hit(questions=questionForm,
                                        lifetime=LIFETIME,
                                        max_assignments=NUMBER_OF_ASSIGNMENTS,
                                        title=TITLE,
                                        keywords=KEYWORDS,
                                        reward=REWARD,
                                        duration=DURATION,
                                        approval_delay=APPROVAL_DELAY,
                                        annotation=DESCRIPTION)
        #print(preview_url + create_hit_rs[0].HITTypeId)
        #print("HIT ID: " + create_hit_rs[0].HITId)
        hitIdList.append(create_hit_rs[0].HITId)

    return hitIdList
コード例 #33
0
    def __generate_qualification_test(self, question_data, num_correct, title):
        '''
            Returns a QuestionForm and AnswerKey for a qualification test from a list of sentence dictionaries.
                question_data : json object containing all the questions.
        '''

        # Get question and answer data
        questions = map(
            lambda (i, x): self.__generate_qualification_question(x, i),
            enumerate(question_data))
        answers = map(lambda (i, x): x["answer_key_" + str(i)],
                      enumerate(questions))

        answer_key = self.__generate_answer_key(answers, num_correct,
                                                len(question_data))

        # Create form setup
        qual_overview = Overview()
        qual_overview.append_field("Title", title)

        # Instructions
        qual_overview.append(
            FormattedContent(
                "<h1>Please answer all the questions below.</h1>"))
        qual_overview.append(
            FormattedContent(
                "<h2>For each question, please choose either the left or right image \
            which you think is more beautiful in terms of its composition. Hints: Please make your decision based on\
            several 'rules of thumb' in photography, such as rule of thirds, visual balance and golden ratio. \
            You may also make your decision by judging which image contains less unimportant or distracting contents.</h2>"
            ))

        # Create question form and append contents
        qual_form = QuestionForm()
        qual_form.append(qual_overview)

        for q in questions:
            i = q["question_num"]
            qual_form.append(q["question_" + str(i)])

        return (qual_form, answer_key)
コード例 #34
0
ファイル: amt.py プロジェクト: zhydhkcws/CDB
def make_free_text_question_form(questions):
    if not questions:
        raise ValueError('Questions cannot be empty!')
    question_form = QuestionForm()

    for q in questions:
        qid = q['id']
        for field in q['columns']:
            if field == q['columns'][0]:
                hint = SimpleField('Title', q['content'])
                question_form.append(Overview([hint]))
            field_id = str(qid) + free_sep + field
            q_text = SimpleField('Text', field)
            q_content = QuestionContent([q_text])
            cons = Constraints([LengthConstraint(min_length=1, max_length=100)])
            answer_spec = AnswerSpecification(FreeTextAnswer(constraints=cons))
            question = Question(field_id, q_content, answer_spec, True)
            question_form.append(question)

    return question_form
コード例 #35
0
def _gen_overview():
    overview_title = 'Translate these sentences'
    overview_content = """<p>Your task is to translate the Spanish 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 transle.google.com)</b></li>
</ul>
"""

    overview = Overview()
    overview.append('Title', overview_title)
    overview.append('FormattedContent', overview_content)

    return overview
コード例 #36
0
def generate_hits(mtc_type, subset, begin_index, args):

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


    mtc = mtk_utils.get_mtc(mtc_type)
 
    title = 'Give your opinion of aesthetics level about images'
    description = ('View images and give us your opinion of aesthetics level about the images')
    keywords = 'image, aesthetic, aesthetics, rating, opinions'

    ratings =[('Very ugly','-2'),
             ('Ugly','-1'),
             ('Neutral','0'),
             ('Beautiful','1'),
             ('Very beautiful, I would like to take such beautiful photo too.','2')]

    #---------------  BUILD OVERVIEW -------------------

    overview = Overview()
    overview.append_field('Title', 'Give your opinion about aesthetics level on those images')
 
    #---------------  BUILD QUESTIONs -------------------

    questions = []

    if (args.m != 'qua'):
        utils.write_file(subset, args.o + '.index_' + str(begin_index) + '.txt')

    if (args.m == 'qua_init' and begin_index > 0):
        return

    for image_url in subset:
     
        qc = QuestionContent()
        qc.append_field('Title','How beautiful the image to you?')
        qc.append(FormattedContent('<img src="' + image_url + '" alt="image" />'))


        fta = SelectionAnswer(min=1, max=1,style='dropdown',
                              selections=ratings,
                              type='text',
                              other=False)

        q = Question(identifier='aesthetics',
                      content=qc,
                      answer_spec=AnswerSpecification(fta),
                      is_required=True)

        questions.append(q)

 
    #--------------- BUILD THE QUESTION FORM -------------------
 
    question_form = QuestionForm()
    question_form.append(overview)

    for question in questions:
        question_form.append(question)

    # BUILD QUALIFICATION

    qualifications = Qualifications()
    req = PercentAssignmentsApprovedRequirement(comparator = "GreaterThan", integer_value = "95")
    qualifications.add(req)

    if (args.m == 'qua'):
        if (args.q != None): 
            qua_req = Requirement(qualification_type_id = args.q, comparator = 'EqualTo', integer_value = '1')
            qualifications.add(qua_req)
        else:
            print("Please give qualification type id in 'qua' mode.")
            sys.exit(0)
 
    #--------------- CREATE THE HIT -------------------
 
    hit = mtc.create_hit(questions = question_form,
                   qualifications = qualifications,
                   max_assignments = 10 * 2,
                   title = title,
                   description = description,
                   keywords = keywords,
                   duration = 60 * 30 * 2,
                   reward = 0.2 * 2)

    if (args.m == 'qua_init'):
        print("Create qualification type for HIT id: " + hit[0].HITId)
        quatype = mtc.create_qualification_type(name = hit[0].HITId, description = "Temporary qualification for HIT " + hit[0].HITId, status = 'Active')
        print("Qualification type id: " + quatype[0].QualificationTypeId)
コード例 #37
0
    def make_html_elicitation_HIT(self,
                                  prompt_list,
                                  hit_title,
                                  prompt_title,
                                  keywords,
                                  hit_description,
                                  duration=DEFAULT_DURATION,
                                  reward_per_clip=DEFAULT_REWARD,
                                  max_assignments=DEFAULT_MAX_ASSIGNMENTS):
        overview = Overview()
        overview.append_field(
            "Title", "Record yourself speaking the words in the prompt.")
        descriptions = [
            "The following prompts are in English.",
            "Click the prompt to record your voice (Redirects to recording Page).",
            "Follow the directions on that page.",
            "Copy and paste the URL in box below the prompt on this page."
        ]
        keywords = "audio, recording, elicitation, English"

        html_head = self.elicitation_head.replace(self.html_tags["title"],
                                                  hit_title)
        for description in descriptions:
            html_head = html_head.replace(
                self.html_tags["description"], "<li>" + description +
                "</li>\n" + self.html_tags["description"])
        questions_html = []
        prompt_ids = []

        for prompt_words, prompt_id in prompt_list:
            #For each prompt, generate the question html given the template
            prompt_id = str(prompt_id)
            prompt = " ".join(prompt_words)
            underscored_prompt = "_".join(prompt_words)
            question = self.elicitation_question.replace(
                self.html_tags["prompt"], prompt)
            question = question.replace(self.html_tags["underscored_prompt"],
                                        underscored_prompt)
            question = question.replace(self.html_tags["prompt_id"],
                                        str(prompt_id))
            questions_html.append(question)
            prompt_ids.append(prompt_id)

        for prompt_id in prompt_ids:
            #Disable the inputs for the prompts, which are just text fields for the
            #audio recording URLs
            script = self.disable_input_script.replace("${input_id}",
                                                       prompt_id)
            html_head = html_head.replace(self.html_tags["disable_script"],script+\
                                          "\n"+self.html_tags["disable_script"])
            if (self.html_tags["prompt_id"]) in html_head:
                html_head = html_head.replace(self.html_tags["prompt_id"],"'"+prompt_id+"'"+\
                                              ","+self.html_tags["prompt_id"])
        #Get rid of html tags
        html_head = html_head.replace(self.html_tags["disable_script"], "")
        html_head = html_head.replace("," + self.html_tags["prompt_id"], "")
        html_head = html_head.replace(self.html_tags["description"], "")
        html = html_head

        for question in questions_html:
            html += question

        html += self.transcription_tail
        html_question = HTMLQuestion(html, 800)
        open("/home/taylor/csaesr/tmp/hithtml.html", "w").write(html)

        #reward calculation

        quals = qualification.Qualifications()
        quals.add(qualification.LocaleRequirement("EqualTo", "US"))
        reward = reward_per_clip * len(prompt_list)
        try:
            return self.conn.create_hit(title=hit_title,
                                        question=html_question,
                                        max_assignments=max_assignments,
                                        description=hit_description,
                                        qualifications=quals,
                                        keywords=keywords,
                                        duration=duration,
                                        reward=reward)
        except MTurkRequestError as e:
            if e.reason != "OK":
                raise
            else:
                print(e)
                return False
        return False
コード例 #38
0
    def make_html_transcription_HIT(self,
                                    audio_clip_urls,
                                    hit_title,
                                    question_title,
                                    description,
                                    keywords,
                                    duration=DEFAULT_DURATION,
                                    reward_per_clip=DEFAULT_REWARD,
                                    max_assignments=DEFAULT_MAX_ASSIGNMENTS):
        overview = Overview()
        overview.append_field(
            "Title", "Type the words in the following audio clip in order.")

        descriptions = [
            "The following audio clips are in English.",
            "Transcribe the audio clip by typing the words that the person \
                        says in order.",
            "Do not use abbreviations: 'street' and NOT 'st.'",
            "Write numbers long-form, as in: 'twenty fifth' NOT '25th'.",
            "Write letters (see example).", "Punctuation does not matter.",
            "Hotkeys: press Tab to play the next clip."
        ]

        keywords = "audio, transcription, English"
        html_head = self.transcription_head.replace(self.html_tags["title"],
                                                    hit_title)
        for description in descriptions:
            html_head = html_head.replace(
                self.html_tags["description"], "<li>" + description +
                "</li>\n" + self.html_tags["description"])
        count = 0
        questions = []
        inputs = []
        for acurl, acid in audio_clip_urls:
            input_id = str(acid)
            question = self.transcription_question.replace(
                self.html_tags["audio_url"], acurl)
            question = question.replace(self.html_tags["audioclip_id"],
                                        str(acid))
            question = question.replace("${count}", input_id)
            count += 1
            questions.append(question)
            inputs.append(input_id)

        for input_id in inputs:
            script = self.disable_input_script.replace("${input_id}", input_id)
            html_head = html_head.replace(self.html_tags["disable_script"],script+\
                                          "\n"+self.html_tags["disable_script"])
            if (self.html_tags["audio_id"]) in html_head:
                html_head = html_head.replace(self.html_tags["audio_id"],"'"+\
                                              input_id+"'"+","+self.html_tags["audio_id"])

        html_head = html_head.replace(self.html_tags["disable_script"], "")
        html_head = html_head.replace("," + self.html_tags["audio_id"], "")
        html_head = html_head.replace(self.html_tags["description"], "")
        html = html_head

        for question in questions:
            html += question
            count += 1

        html += self.transcription_tail
        html_question = HTMLQuestion(html, 800)

        #reward calculation
        reward = reward_per_clip * len(audio_clip_urls)
        try:
            return self.conn.create_hit(title=hit_title,
                                        question=html_question,
                                        max_assignments=max_assignments,
                                        description=description,
                                        keywords=keywords,
                                        duration=duration,
                                        reward=reward)
        except MTurkRequestError as e:
            if e.reason != "OK":
                raise
            else:
                print(e)
                return False
        return False
コード例 #39
0
                      aws_secret_access_key=SECRET_KEY,
                      host=HOST)

print mtc.get_account_balance()

title = 'Give your opinion about categorizing shopping items'
description = ('Visit a website and mark the categories'
               ' that you think are relevant about the product shown to you')
keywords = 'categorization, amazon shopping, rating'

ratings = [('Very Bad', '-2'), ('Bad', '-1'), ('Not bad', '0'), ('Good', '1'),
           ('Very Good', '1')]

#---------------  BUILD OVERVIEW -------------------

overview = Overview()
overview.append_field('Title', 'Give your opinion on this website')
overview.append(
    FormattedContent('<a target="_blank"'
                     ' href="http://www.toforge.com">'
                     ' Mauro Rocco Personal Forge</a>'))

#---------------  BUILD QUESTION 1 -------------------

qc1 = QuestionContent()
qc1.append_field('Title', 'How looks the design ?')

fta1 = SelectionAnswer(min=1,
                       max=1,
                       style='dropdown',
                       selections=ratings,
コード例 #40
0
path_groundtruth = '../../../../ground_truth/groundTruth.csv'
length = len(list(csv.reader(open(path_groundtruth, 'rb'), csv.excel_tab))) - 1
 
with open(path_groundtruth, 'rb') as csvfile:
    reader = csv.reader(csvfile, csv.excel_tab)
    next(reader)
    if ((length == len(titles)) & (length == len(descriptions)) & (length == len(categories))):     
        for row in reader:
            #---------------  BUILD OVERVIEW -------------------
            crowdsourced_content = [str(titles[count-1]), str(descriptions[count-1]), str(categories[count-1])]
            ground_truth = [str(row[0]).replace('&','&amp;'), str(row[1]).replace('&','&amp;'), str(row[2]).replace('&','&amp;')]          
            options = [crowdsourced_content, ground_truth]
            rnd = random.sample(range(0,2),2)
             
            overview = Overview()
            
            html_code = ""
            html_code += '<h3><b>Images</b></h3>'
            html_code += '<table><tr>'
            html_code += '<td><img src="' + str(row[5]) + '" alt="Image 1" width="250" border="2"></img></td>'
            html_code += '<td><img src="' + str(row[6]) + '" alt="Image 2" width="250" border="2"></img></td>'
            html_code += '<td><img src="' + str(row[7]) + '" alt="Image 3" width="250" border="2"></img></td>'
            html_code += '</tr>'
            html_code += '<tr>'
            html_code += '<td><a href="' + str(row[5]) + '" target="_blank">Link to full size image 1 (new window)</a></td>'
            html_code += '<td><a href="' + str(row[6]) + '" target="_blank">Link to full size image 2 (new window)</a></td>'
            html_code += '<td><a href="' + str(row[7]) + '" target="_blank">Link to full size image 3 (new window)</a></td>'        
            html_code += '</tr></table>'
            html_code += '<hr />'
            html_code += '<h3><b>Descriptions</b></h3>'
コード例 #41
0
ファイル: take_out_a_hit.py プロジェクト: JuliaMerz/pincys
def new_rate_hit(PIN_IMAGE_URL, PIN_IMAGE_TITLE, MACYS_IMAGE_URL,
                 MACYS_IMAGE_TITLE):
    mtc = MTurkConnection(aws_access_key_id=AWS_ACCESS_KEY_ID,
                          aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                          host=HOST)

    if debug: print mtc.get_account_balance()

    title = 'Match these Pictures to Macy\'s Products'
    description = 'Look at this photo and match it to Macy\'s products'
    keywords = 'clothing, rating, opinions, easy, quick, macys'

    ratings = [('Very Bad', '1'), ('Bad', '2'), ('OK', '3'), ('Good', '4'),
               ('Very Good', '5')]

    #make overview

    overview = Overview()
    overview.append_field('Title', 'Rank how these two images match.')
    overview.append(
        FormattedContent('<table border="1">><tr><td width="50%"><img src="' +
                         PIN_IMAGE_URL + '" alt="Pintrest Image" /></td>'
                         '<td width="50%"><img src="' + MACYS_IMAGE_URL +
                         '" alt="Macys Image" /></td></tr><tr>'
                         '<td width="50%">' + PIN_IMAGE_TITLE +
                         '</td><td width="50%">' + MACYS_IMAGE_TITLE +
                         '</td></tr></table>'))
    #make q1

    qc1 = QuestionContent()
    qc1.append_field('Title', 'Rank the match between these two')

    fta1 = SelectionAnswer(min=1,
                           max=1,
                           style='dropdown',
                           selections=ratings,
                           type='text',
                           other=False)

    q1 = Question(identifier='rating',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)

    #make q2

    qc2 = QuestionContent()
    qc2.append_field('Title', 'Comments about the HIT (Optional)')

    fta2 = FreeTextAnswer()

    q2 = Question(identifier="comments",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))

    #make question form

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)

    #--------------- CREATE THE HIT -------------------

    mtc.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration=60 * 5,
                   reward=0.05)
コード例 #42
0
ファイル: post_hit.py プロジェクト: jluc19/disambiguator
SECRET_KEY = 'YOUR KEY'
HOST = 'mechanicalturk.sandbox.amazonaws.com'
 
#Set up a connection with MTurk 
conn = MTurkConnection(aws_access_key_id=ACCESS_ID, aws_secret_access_key=SECRET_KEY, host=HOST)

title = "Grade my students' assignments."
description = ('I am a very lazy TA. Please do my work for me.')

#These are the keywords most associated with high volume on MTurk, according to last week's lecture...
keywords = 'data, collection, easy, writing, transcribe'
 

#Overview, to be displayed at the top of the HIT
 
overview = Overview()
overview.append_field('Title', 'Give your opinion on this website')
  
#Create the question

students = ['Shadia', 'Christina', 'Matthew', 'Quanze', 'Casey', 'Manosai', 'Lewis', 'Tiernan', 'Joel', 'Susan', 'Alex', 'Evan', 'Daniel', 'Chenyang', 'Corey', 'Jason', 'Tommy', 'Varshil', 'Crystal', 'Sunny', 'Jiten', 'Taylor', 'Neil']

grades =[('A','A'), ('B','B'), ('C','C'), ('D','D'), ('FAIL!','F')]

questions = []

#add one question for each student
for student in students : 
	qc = QuestionContent()
	qc.append_field('Title','What grade does %s deserve?'%student)
 
コード例 #43
0
def create_crop_hit(mturk,
                    URLs,
                    num_assignment,
                    qualification=Qualifications()):
    # Constant data for HIT generation
    hit_title = "Photo Quality Assessment"
    hit_description = "This task involves viewing pairs of pictures and judging which picture among the image pair is more beautiful."
    lifetime = 259200
    keywords = ["photo", "quality", "ranking"]
    duration = 30 * 60
    reward = 0.05
    #approval_delay = 86400

    # Question form for the HIT
    question_form = QuestionForm()

    overview = Overview()
    overview.append_field('Title', 'Photo Quality Assessment')
    overview.append(
        FormattedContent(
            'For each question, please choose either the left or right image which you think is more beautiful in terms of its <u>composition</u>.'
        ))
    overview.append(
        FormattedContent(
            '<b>Hints: Please make your decision based on several "rules of thumb" in photography, such as rule of thirds, visual balance and golden ratio.</b>'
        ))
    #overview.append(FormattedContent('<b>You may also make your decision by judging which image contains less unimportant or distracting contents</b>.'))
    overview.append(
        FormattedContent(
            'For those hard cases, please just select your preferred image based on your sense of aesthetics.'
        ))
    question_form.append(overview)

    ratings = [('Left', '0'), ('Right', '1')]
    for i in xrange(len(URLs)):
        qc = QuestionContent()
        qc.append_field('Title', 'Question')
        qc.append_field(
            'Text',
            'Please indicate which one of the following images is more beautiful.'
        )
        qc.append(
            FormattedContent('<img src="' + URLs[i] +
                             '" alt="Image not shown correctly!"></img>'))
        #URLs[i]
        fta = SelectionAnswer(min=1,
                              max=1,
                              style='radiobutton',
                              selections=ratings,
                              type='text',
                              other=False)
        q = Question(identifier='photo_pair_' + str(i),
                     content=qc,
                     answer_spec=AnswerSpecification(fta),
                     is_required=True)
        question_form.append(q)

    hit_res = mturk.create_hit(
        title=hit_title,
        description=hit_description,
        reward=Price(amount=reward),
        duration=duration,
        keywords=keywords,
        #approval_delay=approval_delay,
        question=question_form,
        #lifetime=lifetime,
        max_assignments=num_assignment,
        qualifications=qualification)
    # return HIT ID
    return hit_res[0].HITId
コード例 #44
0
def PublishTasks(hitNum, maxAssignments):
    # sandbox in which to simulate: mechanicalturk.sandbox.amazonaws.com
    # real environment: mechanicalturk.amazonaws.com
    mtc = MTurkConnection(host='mechanicalturk.amazonaws.com')

    # print mtc.APIVersion
    # print mtc.get_account_balance()
    # print mtc.get_reviewable_hits()
    # print mtc.get_all_hits()

    #---------------  BUILD OVERVIEW -------------------

    # jbragg: Modified maximum reward description.
    #title = '(Maximum reward possible: $70) Identify the relation between two entities in English sentences'
    title = 'Identify the relation between two entities in English sentences'
    #description = 'You will be given English sentences in which your task is to identify the relation between two designated entities. Your reward will depend on how many questions you have answered. The maximum reward you can earn is $70.'
    description = 'You will be given English sentences in which your task is to identify the relation between two designated entities. Your reward will depend on how many questions you have answered. The maximum reward you can earn is approximately $5.'
    keywords = 'English sentences, relation identification'

    ratings = [('Very Bad', '-2'), ('Bad', '-1'), ('Not bad', '0'),
               ('Good', '1'), ('Very Good', '1')]

    #---------------  BUILD OVERVIEW -------------------

    overview = Overview()
    overview_title = 'Exercise link (please copy the link and paste it in your browser if it cannot be opened directly.)'
    link = '<a target="_blank"' ' href="http://128.208.3.167:3000/mturk">' ' http://128.208.3.167:3000/mturk</a>'
    # jbragg: Commented out long-term bonus.
    instructions = '<p>Instructions:</p><ul><li>You will be presented with sentences that have a person and a location highlighted.</li><li>Your task is to determine which of the 5 designated relations are expressed between the person and location.</li><li>You&#39;ll get paid $0.50 after each successful set of 20 questions<!-- -- plus a bonus of $2.00 after every 10 batches (equal to 200 questions)-->.</li><li>We know the correct answers to some of these sentence questions, and you can stay if you get these questions right.</li><li>You can start by going to the external link above now. After you finish all the questions, you will be provided with a confirm code, used for authentication and determining the appropriate amount of money as the payment.</li><li>In very rare cases where the website crashes, you could click backward and then forward on your browser to reload the question. It won\'t affect the payment because all the questions you have answered are recorded, on which the amount of payment is based. So please don\'t worry about that.</li></ul>'
    overview_content = link + instructions
    overview.append_field('Title', overview_title)
    overview.append(FormattedContent(overview_content))

    #---------------  BUILD QUESTION 1 -------------------

    qc1 = QuestionContent()
    qc1.append_field('Title', 'How looks the design ?')

    fta1 = SelectionAnswer(min=1,
                           max=1,
                           style='dropdown',
                           selections=ratings,
                           type='text',
                           other=False)

    q1 = Question(identifier='design',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)

    #---------------  BUILD QUESTION 2 -------------------

    qc2 = QuestionContent()
    qc2.append_field(
        'Title',
        'Confirm code \n1. The code will be provided to you as you finish from the exercise link. \n2. The code will be verified before paying. \n3. By the end of every 20 questions (as a batch), You can choose to finish and get a confirm code, or continue.'
    )

    fta2 = FreeTextAnswer()

    q2 = Question(identifier="Confirm_code",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))

    #--------------- BUILD THE QUESTION FORM -------------------

    question_form = QuestionForm()
    question_form.append(overview)
    # question_form.append(q1)
    question_form.append(q2)

    #--------------- CREATE HITs -------------------

    HIT_num = hitNum
    for i in range(HIT_num):
        # max_assignments: how many replicas this HIT has
        mtc.create_hit(questions=question_form,
                       max_assignments=maxAssignments,
                       title=title,
                       description=description,
                       keywords=keywords,
                       duration=60 * 60 * 10,
                       reward=0.50)
コード例 #45
0
ファイル: mturk_hits.py プロジェクト: yingning/text-scene
def make_hit(image_url):
    title = 'Label image with its location'
    description = 'Answer questions about an image to label its location.'
    keywords = 'image categorization, locations, scene recognition'

    in_out = [('indoors', '0'), ('outdoors', '1')]
    nat_manmade = [('man-made', '0'), ('natural', '1')]
    functions = [('transportation/urban', '0'), ('restaurant', '1'),
                 ('recreation', '2'), ('domestic', '3'),
                 ('work/education', '4'), ('other/unclear', '5')]
    landscapes = [('body of water/beach', '0'), ('field', '1'),
                  ('mountain', '2'), ('forest/jungle', '3'),
                  ('other/unclear', '4')]

    #---------------  BUILD OVERVIEW -------------------

    overview = Overview()
    overview.append_field('Title', title)
    with open(INSTRUCTIONS_HTML) as html:
        instructions = html.read()
    overview.append(FormattedContent(instructions))

    image = Binary('image', None, image_url, 'image')
    overview.append(image)

    #---------------  BUILD QUESTION 1 -------------------

    qc1 = QuestionContent()
    qc1.append_field(
        'Text', 'Is the location shown in the image indoors or outdoors?')

    fta1 = SelectionAnswer(min=1,
                           max=1,
                           style='checkbox',
                           selections=in_out,
                           type='text',
                           other=False)

    q1 = Question(identifier='Question 1',
                  content=qc1,
                  answer_spec=AnswerSpecification(fta1),
                  is_required=True)

    #---------------  BUILD QUESTION 2 -------------------

    qc2 = QuestionContent()
    qc2.append_field(
        'Text', 'Is the location shown in the image man-made or ' +
        'natural? Examples of man-made locations include ' +
        'buildings and parks while examples of natural ' +
        'locations include mountains and rivers.')

    fta2 = SelectionAnswer(min=1,
                           max=1,
                           style='checkbox',
                           selections=nat_manmade,
                           type='text',
                           other=False)

    q2 = Question(identifier='Question 2',
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2),
                  is_required=True)

    #---------------  BUILD QUESTION 3 -------------------

    qc3 = QuestionContent()
    qc3.append_field(
        'Text', 'If the location in the image is man-made, what is the ' +
        'general function or type of the location? If the ' +
        'location is natural (not man-made), don\'t select ' +
        'anything here.')

    fta3 = SelectionAnswer(min=0,
                           max=1,
                           style='checkbox',
                           selections=functions,
                           type='text',
                           other=False)

    q3 = Question(identifier='Question 3',
                  content=qc3,
                  answer_spec=AnswerSpecification(fta3),
                  is_required=False)

    #---------------  BUILD QUESTION 4 -------------------

    qc4 = QuestionContent()
    qc4.append_field(
        'Text', 'If the location in the picture is natural, what ' +
        'kind of natural location is it? If the location ' +
        'man-made (not natural), don\'t select anything here.')

    fta4 = SelectionAnswer(min=0,
                           max=1,
                           style='checkbox',
                           selections=landscapes,
                           type='text',
                           other=False)

    q4 = Question(identifier='Question 4',
                  content=qc4,
                  answer_spec=AnswerSpecification(fta4),
                  is_required=False)

    #--------------- BUILD THE QUESTION FORM -------------------

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
    question_form.append(q3)
    question_form.append(q4)

    #-------------- QUALIFICATIONS -------------------

    percent = PercentAssignmentsApprovedRequirement('GreaterThanOrEqualTo', 95)
    number = NumberHitsApprovedRequirement('GreaterThanOrEqualTo', 200)
    quals = Qualifications()
    quals.add(percent)
    quals.add(number)

    #--------------- CREATE THE HIT -------------------

    mtc.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   qualifications=quals,
                   annotation=image_url,
                   duration=60 * 10,
                   reward=0.03)
コード例 #46
0
ファイル: take_out_a_hit.py プロジェクト: JuliaMerz/pincys
def new_sugg_hit(PIN_IMAGE_URL, PIN_IMAGE_TITLE):

    mtc = MTurkConnection(aws_access_key_id=AWS_ACCESS_KEY_ID,
                          aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                          host=HOST)

    if debug: print mtc.get_account_balance()

    title = 'Match these Pictures to Macy\'s Products'
    description = 'Look at this photo and match it to Macy\'s products'
    keywords = 'clothing, rating, opinions, easy, quick, macys'

    #make overview

    overview = Overview()
    overview.append_field('Title',
                          'Find three Macys.com Product Web IDs That Match')
    overview.append(
        FormattedContent('<img src="' + PIN_IMAGE_URL +
                         '" alt="Pintrest Image" />'
                         '<br />' + PIN_IMAGE_TITLE))

    #make webid1

    qc1 = QuestionContent()
    qc1.append_field('Title', 'First WebID Code')

    fta1 = FreeTextAnswer(num_lines=1)

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

    #make webid2

    qc2 = QuestionContent()
    qc2.append_field('Title', 'Second WebID Code')

    fta2 = FreeTextAnswer(num_lines=1)

    q2 = Question(identifier="SecondWebCode",
                  content=qc2,
                  answer_spec=AnswerSpecification(fta2))

    #make webid1

    qc3 = QuestionContent()
    qc3.append_field('Title', 'Third WebID Code')

    fta3 = FreeTextAnswer(num_lines=1)

    q3 = Question(identifier="ThirdWebCode",
                  content=qc3,
                  answer_spec=AnswerSpecification(fta3))

    #make question form

    question_form = QuestionForm()
    question_form.append(overview)
    question_form.append(q1)
    question_form.append(q2)
    question_form.append(q3)

    #--------------- CREATE THE HIT -------------------

    mtc.create_hit(questions=question_form,
                   max_assignments=1,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration=60 * 5,
                   reward=0.05)
コード例 #47
0
from django.conf import settings

ACCESS_ID = settings.AWS_KEY
SECRET_KEY = settings.AWS_PRIVATE_KEY
HOST = 'mechanicalturk.sandbox.amazonaws.com'

mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                      aws_secret_access_key=SECRET_KEY,
                      host=HOST)
title = 'Transcription of promotions from image into text'
description = ('Find the promotion information from the image provided.')
keywords = 'image, text, promotion'

#---------------  BUILD OVERVIEW -------------------

overview = Overview()
overview.append_field('Title', title)
overview.append(
    FormattedContent('<a target="_blank"'
                     ' href="http://google.com">'
                     ' Hello</a>'))

#---------------  BUILD QUESTION 1 -------------------

qc1 = QuestionContent()
qc1.append_field('Title', 'How looks the design ?')

fta1 = SelectionAnswer(min=1,
                       max=1,
                       style='dropdown',
                       selections=ratings,
コード例 #48
0
HOST = 'mechanicalturk.sandbox.amazonaws.com'
mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                      aws_secret_access_key=SECRET_KEY,
                      host=HOST)


 
title = 'Profile of record Athlete Information'
description = ('Provide Information about the Athlete')
keywords = 'website, rating, opinions'
 
height =[('4\'11','4\'11'),('5\'1','5\'1'),('5\'2','5\'2'),('5\'3','5\'3'),('5\'4','5\'4'),('5\'5','5\'5'),('5\'6','5\'6'),('5\'7','5\'7')]
 
#---------------  BUILD OVERVIEW -------------------
 
overview = Overview()
overview.append_field('Title', 'What is the Height if this Athlete?')
overview.append(FormattedContent('<a> target="_blank"'
                                 ' href="https://en.wikipedia.org/wiki/Brett_Favre"'
                                 ' Athlete Information URL</a>'))
# 
##---------------  BUILD QUESTION  -------------------
# 
qc = QuestionContent()
qc.append_field('Title','What is the Height of Brett Favre')
 
fta = SelectionAnswer(min=1, max=1,style='dropdown',
                      selections=height,
                      type='text',
                      other=False)
 
コード例 #49
0
def check_notes_mailbox():
    MTURK_HOST = run_mturk('get_extract_keywords_results')
    if not MTURK_HOST:
        return

    try:
        MAILBOX_USER = os.environ['NOTES_MAILBOX_USERNAME']
        MAILBOX_PASSWORD = os.environ['NOTES_MAILBOX_PASSWORD']
        FILEPICKER_API_KEY = os.environ['FILEPICKER_API_KEY']
    except:
        logger.warn(
            'Could not find notes mailbox secrets, not running check_notes_mailbox'
        )
        return

    connection = MTurkConnection(settings.AWS_ACCESS_KEY_ID,
                                 settings.AWS_SECRET_ACCESS_KEY,
                                 host=MTURK_HOST)

    mailbox = poplib.POP3_SSL('pop.gmail.com', 995)
    mailbox.user(MAILBOX_USER)
    mailbox.pass_(MAILBOX_PASSWORD)
    numMessages = len(mailbox.list()[1])
    for i in range(numMessages):
        # construct message object from raw message
        raw_message_string = '\n'.join(mailbox.retr(i + 1)[1])
        message = email.message_from_string(raw_message_string)

        if not message.is_multipart():
            logger.warn('Got an email with no attachments')
            continue

        attachments = []
        message_body = ''

        message_parts = message.get_payload()
        for part in message_parts:
            # Look for the message's plain text body
            if part.get_content_type(
            ) == 'text/plain' and part['Content-Disposition'] is None:
                message_body = part.get_payload()

            # Look for attachments
            elif part['Content-Disposition'] and 'attachment;' in part[
                    'Content-Disposition']:
                attachment_mimetype = part.get_content_type()
                attachment_filename = re.search(
                    CONTENT_DISPOSITION_REGEX,
                    part['Content-Disposition']).group('filename')

                if part['Content-Transfer-Encoding'] == 'base64':
                    attachment_data = base64.decodestring(part.get_payload())
                else:
                    attachment_data = part.get_payload()

                # Upload attachment to filepicker
                resp = requests.post('https://www.filepicker.io/api/store/S3?key={key}&policy={policy}&' \
                                     'signature={signature}&mimetype={mimetype}&filename={filename}'
                                     .format(key=FILEPICKER_API_KEY, policy=FP_POLICY_READ_WRITE,
                                             signature=FP_SIGNATURE_READ_WRITE, mimetype=attachment_mimetype,
                                             filename=attachment_filename),
                                      data=attachment_data)

                if resp.status_code == 200:
                    url = json.loads(resp.text)['url']
                    url = url + '?policy={policy}&amp;signature={signature}'\
                        .format(policy=FP_POLICY_READ, signature=FP_SIGNATURE_READ)
                    attachments.append((url, attachment_filename))
                else:
                    logger.warn('Could not upload an attachment to filepicker')

        message_subject = message['Subject']

        overview = Overview()
        overview.append(
            FormattedContent(
                EMAIL_HIT_OVERVIEW_TEMPLATE.format(subject=message_subject,
                                                   body=message_body,
                                                   attachments='')))

        single_line_answer = FreeTextAnswer()
        single_line_answer.num_lines = 1

        question_form = QuestionForm()
        question_form.append(overview)

        course_spam_content = QuestionContent()
        course_spam_content.append_field(
            'Title',
            'Does the email contain course notes (check attachments below)?')
        answer = SelectionAnswer(style='dropdown',
                                 selections=[('No', 'no'), ('Yes', 'yes')])
        course_spam = Question(identifier=COURSE_SPAM_QID,
                               content=course_spam_content,
                               answer_spec=AnswerSpecification(answer),
                               is_required=True)
        question_form.append(course_spam)

        course_name_content = QuestionContent()
        course_name_content.append_field('Title', 'Course Name')
        course_name = Question(
            identifier=COURSE_NAME_QID,
            content=course_name_content,
            answer_spec=AnswerSpecification(single_line_answer),
            is_required=True)
        question_form.append(course_name)

        instructor_names_content = QuestionContent()
        instructor_names_content.append_field('Title', 'Instructor Name(s)')
        instructor_names = Question(
            identifier=INSTRUCTOR_NAMES_QID,
            content=instructor_names_content,
            answer_spec=AnswerSpecification(single_line_answer),
            is_required=False)
        question_form.append(instructor_names)

        school_name_content = QuestionContent()
        school_name_content.append_field('Title', 'School Name')
        school_name = Question(
            identifier=SCHOOL_NAME_QID,
            content=school_name_content,
            answer_spec=AnswerSpecification(single_line_answer),
            is_required=True)
        question_form.append(school_name)

        department_name_content = QuestionContent()
        department_name_content.append_field('Title', 'Department Name')
        department_name = Question(
            identifier=DEPARTMENT_NAME_QID,
            content=department_name_content,
            answer_spec=AnswerSpecification(single_line_answer),
            is_required=False)
        question_form.append(department_name)

        for i in range(len(attachments)):
            overview = Overview()
            overview.append(
                FormattedContent(
                    EMAIL_HIT_ATTACHMENT_OVERVIEW_TEMPLATE.format(
                        link=attachments[i][0], name=attachments[i][1])))

            question_form.append(overview)

            note_title_content = QuestionContent()
            note_title_content.append_field('Title', 'Note Title')
            note_title = Question(
                identifier=NOTE_TITLE_QID_TEMPLATE + str(i),
                content=note_title_content,
                answer_spec=AnswerSpecification(single_line_answer),
                is_required=True)
            question_form.append(note_title)

            note_category_content = QuestionContent()
            note_category_content.append_field('Title', 'Note Category')
            answer = SelectionAnswer(style='dropdown',
                                     selections=NOTE_CATEGORIES_FOR_MTURK)
            note_category = Question(identifier=NOTE_CATEGORY_QID_TEMPLATE +
                                     str(i),
                                     content=note_category_content,
                                     answer_spec=AnswerSpecification(answer),
                                     is_required=True)
            question_form.append(note_category)

        hit = connection.create_hit(questions=question_form,
                                    max_assignments=1,
                                    title=EMAIL_HIT_TITLE,
                                    description=EMAIL_HIT_DESCRIPTION,
                                    keywords=EMAIL_HIT_KEYWORDS,
                                    duration=EMAIL_HIT_DURATION,
                                    reward=EMAIL_HIT_REWARD,
                                    qualifications=EMAIL_HIT_QUALIFICATION)[0]
コード例 #50
0
    def make_question_form_elicitation_HIT(
            self,
            prompt_list,
            hit_title,
            prompt_title,
            keywords,
            duration=DEFAULT_DURATION,
            reward_per_clip=DEFAULT_REWARD,
            max_assignments=DEFAULT_MAX_ASSIGNMENTS):
        overview = Overview()
        overview.append_field("Title", hit_title)
        #overview.append(FormattedContent('<a target = "_blank" href="url">hyperlink</a>'))
        question_form = QuestionForm()

        descriptions = [
            "The following prompts are in English.",
            "Approve the flash permissions to record audio.",
            "Click the red circle to record yourself.",
            "Read the words after 'prompt:'", "Click 'Click to Stop'",
            "Play the clip back to verify sound quality.",
            "After you are happy with your recording, click 'Click here to save >>'",
            "Copy & paste the URL under 'Sharing options' into the text field for the prompt.",
            "You will NEVER be asked to divulge any personal or identifying information."
        ]
        keywords = "audio, recording, elicitation, English"

        #         for i, description in enumerate(descriptions):
        #             overview.append_field("%dDescription"%i, description)
        #         flash_xml = FlashXml(self.flash_xml.replace(self.html_tags["flash_url"],self.vocaroo_url))
        #         overview.append(flash_xml)
        question_form.append(overview)

        qc = QuestionContent()
        #        qc.append(FormattedContent(flash_xml))

        qc.append_field("Title",
                        "Please select the type of microphone you are using.")
        #         qc.append(Flash(self.vocaroo_url,525,450))
        #
        #answer = FreeTextAnswer()
        answer = SelectionAnswer(max=1,
                                 style="radiobutton",
                                 selections=self.mic_selections)
        q = Question(identifier="MIC",
                     content=qc,
                     answer_spec=AnswerSpecification(answer))
        question_form.append(q)

        qual = qualification.LocaleRequirement("in", "USA")
        reward = reward_per_clip * len(prompt_list)
        xml = question_form.get_as_xml()
        try:
            response = self.conn.create_hit(questions=question_form,
                                            max_assignments=1,
                                            title=hit_title,
                                            qualification=qual,
                                            description=descriptions[0],
                                            keywords=keywords,
                                            duration=duration,
                                            reward=reward)
        except MTurkRequestError as e:
            if e.reason != "OK":
                raise
        return True
コード例 #51
0
HOST = 'mechanicalturk.amazonaws.com'

mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                      aws_secret_access_key=SECRET_KEY,
                      host=HOST)

title = 'Diabetes Tweet Annotation'
description = ('Read a list of tweets and label each tweet'
               'based on the content of the tweet')
keywords = 'diabetes, twitter, tweets, annotation'

ratings = [('Self', '1'), ('Other Person', '2'), ('Neither', '3')]

#---------------  BUILD OVERVIEW -------------------

overview = Overview()
overview.append_field('Title', 'Disease Tweet Annotation')
overview.append_field(
    'Text', 'For each tweet, please specify the following:\n'
    'ONLY if the tweeter HAS diabetes, label Self.\n'
    'If the tweeter is referring to ANOTHER individual who HAS diabetes, label Other Person\n'
    'Otherwise, label Neither.\n'
    'For example: \'I don\'t know if I threw up because of dairy or diabetes. Help. Me.\' should be labeled as Self\n'
    'Another example: \'If Jim has 50 chocolate bars, and eats 45, what does he have? Diabetes. Jim has diabetes..\' should be labeled as Neither'
)

#--------------- BUILD QUESTIONS -----------------------

parsed_tweets_to_annotate_filename = 'diabetes_parsed.txt'
control_tweets_filename = 'control_tweets.txt'
コード例 #52
0
def createQuestionForm(overviewTitle, overviewDescription, numberOfTweets,
                       listOfTweets, listOfTweetIDs):
    """
    Create an overview for an MTurk HIT
    """

    #The Question Form should contain 1 overview and 3 odd questions
    questionForm = QuestionForm()

    #Define the Overview
    overview = Overview()
    Title = FormattedContent(overviewTitle)
    overview.append(Title)
    overviewDescription1 = FormattedContent(overviewDescription[0])
    overviewDescription2 = FormattedContent(overviewDescription[1])
    overviewDescription3 = FormattedContent(overviewDescription[2])
    overview.append(overviewDescription1)
    overview.append(overviewDescription2)
    overview.append(overviewDescription3)
    #Append the Overview to the Question Form
    questionForm.append(overview)

    #Create the Questions, and Add them
    for i in xrange(numberOfTweets):
        overview = Overview()
        questionTitle = FormattedContent(
            '<font face="Helvetica" size="2"><b> Tweet #' + str(i + 1) +
            '</b></font>')
        overview.append(questionTitle)
        questionBody = FormattedContent('<font face="Helvetica" size="2">' +
                                        listOfTweets[i] + '</font>')
        overview.append(questionBody)
        #answerTuple = tuple([('<a href="https://wikipedia.org/en/' + y.replace(" ","_") + '" target="_blank">' + y + "</a>") for y in list(listOfAnswers[i])])
        #links = FormattedContent('<b>Links</b> | ' + answerTuple[0] + ' | ' + answerTuple[1])
        #overview.append(links)
        questionForm.append(overview)
        question = createQuestion(listOfTweetIDs[i], i, listOfTweets[i],
                                  ["Positive", "Negative"])
        questionForm.append(question)

    return questionForm
コード例 #53
0
def generate_hits(subset, begin_index, args, data_ids, images_metainfo):

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

    ACCESS_ID = amazon_config.ACCESS_ID
    SECRET_KEY = amazon_config.SECRET_KEY
    HOST = 'mechanicalturk.amazonaws.com'

    mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                          aws_secret_access_key=SECRET_KEY,
                          host=HOST)

    title = 'Give your opinion of interestingness level about images'
    description = (
        'Watch images and give us your opinion of interestingness level about the images'
    )
    keywords = 'image, interestingness, interesting, rating, opinions'

    ratings = [('Very boring', '-2'), ('Boring', '-1'), ('Neutral', '0'),
               ('Interesting', '1'),
               ('Very interesting, I would like to share it with my friends.',
                '2')]

    #---------------  BUILD OVERVIEW -------------------

    overview = Overview()
    overview.append_field(
        'Title',
        'Give your opinion about interestingness level on those images')

    #---------------  BUILD QUESTIONs -------------------

    questions = []

    utils.write_file(subset, args.o + '.index_' + str(begin_index) + '.txt')

    index = 0
    for image_url in subset:

        image_id = data_ids[index]
        image = images_metainfo[image_id]
        interestingness = 0

        if ('repin_count' in image):
            interestingness = int(image['repin_count']) + int(
                image['like_count'])
        #else:
        # interestingness = int(image['interestingness'])

        index = index + 1

        qc = QuestionContent()

        context = ''
        if (interestingness > 0):
            context = ' (shared by ' + str(interestingness) + ' people)'

        qc.append_field('Title',
                        'How interesting the image' + context + ' to you?')
        qc.append(
            FormattedContent('<img src="' + image_url + '" alt="image" />'))

        fta = SelectionAnswer(min=1,
                              max=1,
                              style='dropdown',
                              selections=ratings,
                              type='text',
                              other=False)

        q = Question(identifier='interestingness',
                     content=qc,
                     answer_spec=AnswerSpecification(fta),
                     is_required=True)

        questions.append(q)

    #--------------- BUILD THE QUESTION FORM -------------------

    question_form = QuestionForm()
    question_form.append(overview)

    for question in questions:
        question_form.append(question)

    # BUILD QUALIFICATION

    qualifications = Qualifications()
    req = PercentAssignmentsApprovedRequirement(comparator="GreaterThan",
                                                integer_value="95")
    qualifications.add(req)

    #--------------- CREATE THE HIT -------------------

    mtc.create_hit(questions=question_form,
                   qualifications=qualifications,
                   max_assignments=10,
                   title=title,
                   description=description,
                   keywords=keywords,
                   duration=60 * 30,
                   reward=0.2)
コード例 #54
0
def submit_extract_keywords_hit(note):
    """Create a Mechanical Turk HIT that asks a worker to
    choose keywords and definitions from the given note."""

    MTURK_HOST = run_mturk('submit_extract_keywords_hit')
    if not MTURK_HOST:
        return

    connection = MTurkConnection(settings.AWS_ACCESS_KEY_ID,
                                 settings.AWS_SECRET_ACCESS_KEY,
                                 host=MTURK_HOST)

    if note.course.school:
        title = KEYWORDS_HIT_TITLE_TEMPLATE.format(
            course=note.course.name, school=note.course.school.name)
    else:
        title = KEYWORDS_HIT_TITLE_TEMPLATE.format(
            course=note.course.name, school=note.course.department.school.name)

    overview = Overview()
    overview.append(
        FormattedContent(
            KEYWORDS_HIT_OVERVIEW_TEMPLATE.format(
                domain=Site.objects.get_current(),
                link=note.get_absolute_url())))

    keyword_fta = FreeTextAnswer()
    keyword_fta.num_lines = 1

    definition_fta = FreeTextAnswer()
    definition_fta.num_lines = 3

    question_form = QuestionForm()
    question_form.append(overview)

    for i in range(
            min(len(KEYWORDS_HIT_KEYWORD_FIELDS),
                len(KEYWORDS_HIT_DEFINITION_FIELDS))):
        keyword_content = QuestionContent()
        keyword_content.append_field('Title',
                                     KEYWORDS_HIT_KEYWORD_FIELDS[i][1])
        keyword_question = Question(
            identifier=KEYWORDS_HIT_KEYWORD_FIELDS[i][0],
            content=keyword_content,
            answer_spec=AnswerSpecification(keyword_fta),
            is_required=True if i <= 10 else False)
        question_form.append(keyword_question)

        definition_content = QuestionContent()
        definition_content.append_field('Title',
                                        KEYWORDS_HIT_DEFINITION_FIELDS[i][1])
        definition_question = Question(
            identifier=KEYWORDS_HIT_DEFINITION_FIELDS[i][0],
            content=definition_content,
            answer_spec=AnswerSpecification(definition_fta),
            is_required=False)
        question_form.append(definition_question)

    hit = connection.create_hit(questions=question_form,
                                max_assignments=1,
                                title=title,
                                description=KEYWORDS_HIT_DESCRIPTION,
                                keywords=KEYWORDS_HIT_KEYWORDS,
                                duration=KEYWORDS_HIT_DURATION,
                                reward=KEYWORDS_HIT_REWARD,
                                qualifications=KEYWORDS_HIT_QUALIFICATION,
                                annotation=str(note.id))[0]

    KeywordExtractionHIT.objects.create(HITId=hit.HITId,
                                        note=note,
                                        processed=False)
コード例 #55
0
ファイル: hit_new_suggest.py プロジェクト: JuliaMerz/pincys
PIN_IMAGE_URL = 'http://media-cache-ak0.pinimg.com/236x/17/8f/99/178f993435fb2718ab6e22ba29d704e0.jpg'
PIN_IMAGE_TITLE = 'Arnhem Clothing \'Song Bird\' Kimono in Mayan Song. Via Soleilblue..'

mtc = MTurkConnection(aws_access_key_id=AWS_ACCESS_KEY_ID,
                      aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                      host=HOST)

if debug: print mtc.get_account_balance()

title = 'Match these Pictures to Macy\'s Products'
description = 'Look at this photo and match it to Macy\'s products'
keywords = 'clothing, rating, opinions, easy, quick, macys'

#make overview

overview = Overview()
overview.append_field('Title',
                      'Find three Macys.com Product Web IDs That Match')
overview.append(
    FormattedContent('<img src="' + PIN_IMAGE_URL + '" alt="Pintrest Image" />'
                     '<br />' + PIN_IMAGE_TITLE))

#make webid1

qc1 = QuestionContent()
qc1.append_field('Title', 'First WebID Code')

fta1 = FreeTextAnswer(num_lines=1)

q1 = Question(identifier="FirstWebCode",
              content=qc1,
コード例 #56
0
                      host=HOST)
 
title = 'Give your opinion about a website'
description = ('Visit a website and give us your opinion about'
               ' the design and also some personal comments')
keywords = 'website, rating, opinions'
 
ratings =[('Very Bad','-2'),
         ('Bad','-1'),
         ('Not bad','0'),
         ('Good','1'),
         ('Very Good','1')]
 
#---------------  BUILD OVERVIEW -------------------
 
overview = Overview()
overview.append_field('Title', 'Give your opinion on this website')
overview.append(FormattedContent('<a target="_blank"'
                                 ' href="http://www.toforge.com">'
                                 ' Mauro Rocco Personal Forge</a>'))
 
#---------------  BUILD QUESTION 1 -------------------
 
qc1 = QuestionContent()
qc1.append_field('Title','How looks the design ?')
 
fta1 = SelectionAnswer(min=1, max=1,style='dropdown',
                      selections=ratings,
                      type='text',
                      other=False)
 
コード例 #57
0
ファイル: snippet.py プロジェクト: someburner/GistsHub
# The overview is used for question oriented text and can be interwoven with
# QuestionContent's inside a QuestionForm.
#
# For this demo, I use only one Overview at the top of the QuestionForm and
# then use five QuestionContents below to host input boxes.

overview_title = 'List your top 5 fav things'
overview_content = """<![CDATA[
<p>Please list your top five favorite things in the box
below. It would help our research if you kept the names general. For example,
instead of saying \"playing shortstop\", please just say, \"baseball\".</p>

<p>Thanks, James and the boto crew</p>
]]>"""

overview = Overview()
overview.append_field('Title', overview_title)
overview.append_field('FormattedContent', overview_content)

# Question design
#
# Questions can each be designed uniquely. For this demo I only build enough
# of a QuestionContent to host an input box by using a FreeTextAnswer. There
# are multiple options for how a QuestionContent is constructed.
#
# I recommend reading: http://docs.amazonwebservices.com/AWSMechanicalTurkRequester/2007-06-21/ApiReference_QuestionFormDataStructureArticle.html
#
# Quickly, the available content types are: Title, Text, List, Binary,
#                                           Application, EmbeddedBinary,
#                                           FormattedContent
コード例 #58
0
ファイル: hit_rate_pair.py プロジェクト: SebastianMerz/pincys
                      
if debug: print mtc.get_account_balance()

title = 'Match these Pictures to Macy\'s Products'
description = 'Look at this photo and match it to Macy\'s products'
keywords = 'clothing, rating, opinions, easy, quick, macys'

ratings =[('Very Bad','1'),
         ('Bad','2'),
         ('OK','3'),
         ('Good','4'),
         ('Very Good','5')]
 
#make overview
 
overview = Overview()
overview.append_field('Title', 'Rank how these two images match.')
overview.append(FormattedContent('<table border="1"><tr><td width="50%"><img src="'+PIN_IMAGE_URL+'" alt="Pintrest Image" /></td>'
                                 '<td width="50%"><img src="'+MACYS_IMAGE_URL+'" alt="Macys Image" /></td></tr><tr>'
                                 '<td width="50%">'+PIN_IMAGE_TITLE+'</td><td width="50%">'+MACYS_IMAGE_TITLE+'</td></tr></table>'))
#make q1
 
qc1 = QuestionContent()
qc1.append_field('Title','Rank the match between these two')
 
fta1 = SelectionAnswer(min=1, max=1,style='dropdown',
                      selections=ratings,
                      type='text',
                      other=False)
 
q1 = Question(identifier='rating',
コード例 #59
0
mtc = MTurkConnection(aws_access_key_id=AWS_ACCESS_KEY_ID,
                      aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                      host=HOST)

if debug: print mtc.get_account_balance()

title = 'Match these Pictures to Macy\'s Products'
description = 'Look at this photo and match it to Macy\'s products'
keywords = 'clothing, rating, opinions, easy, quick, macys'

ratings = [('Very Bad', '1'), ('Bad', '2'), ('OK', '3'), ('Good', '4'),
           ('Very Good', '5')]

#make overview

overview = Overview()
overview.append_field('Title', 'Rank how these two images match.')
overview.append(
    FormattedContent('<table border="1"><tr><td width="50%"><img src="' +
                     PIN_IMAGE_URL + '" alt="Pintrest Image" /></td>'
                     '<td width="50%"><img src="' + MACYS_IMAGE_URL +
                     '" alt="Macys Image" /></td></tr><tr>'
                     '<td width="50%">' + PIN_IMAGE_TITLE +
                     '</td><td width="50%">' + MACYS_IMAGE_TITLE +
                     '</td></tr></table>'))
#make q1

qc1 = QuestionContent()
qc1.append_field('Title', 'Rank the match between these two')

fta1 = SelectionAnswer(min=1,