當前位置: 首頁>>代碼示例>>Python>>正文


Python qualification.Qualifications類代碼示例

本文整理匯總了Python中boto.mturk.qualification.Qualifications的典型用法代碼示例。如果您正苦於以下問題:Python Qualifications類的具體用法?Python Qualifications怎麽用?Python Qualifications使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Qualifications類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self):
        if SANDBOX:
            host = 'mechanicalturk.sandbox.amazonaws.com'
        else:
            host = 'mechanicalturk.amazonaws.com'
        login_params = {
            'aws_access_key_id': ACCESS_KEY_ID,
            'aws_secret_access_key': SECRET_ACCESS_KEY,
            'host': host
        }
        self.connection = MTurkConnection(**login_params)

        question = ExternalQuestion(EXTERNAL_URL, FRAMEHEIGHT)

        qualifications = Qualifications()
        qualifications.add(PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo", PERCENT_APPROVED_REQUIREMENT))
        self.hit_parameters = {
            'hit_type' : None,
            'question' : question,
            'title' : TITLE,
            'description' : DESCRIPTION,
            'keywords' : KEYWORDS,
            'max_assignments' : MAX_ASSIGNMENTS,
            'lifetime' : datetime.timedelta(hours=HIT_LIFETIME),
            'reward' : REWARD,
            'duration' : datetime.timedelta(DURATION),
            'approval_delay' : None,
            'questions' : None,
            'qualifications' : qualifications
        }
開發者ID:zeyuliu,項目名稱:amt,代碼行數:30,代碼來源:HIT.py

示例2: configure_hit

    def configure_hit(self, hit_config):

        # configure question_url based on the id
        experimentPortalURL = hit_config['ad_location']
        frameheight = 600
        mturkQuestion = ExternalQuestion(experimentPortalURL, frameheight)

        # Qualification:
        quals = Qualifications()
        approve_requirement = hit_config['approve_requirement']
        quals.add(
            PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo",
                                                  approve_requirement))

        if hit_config['us_only']:
            quals.add(LocaleRequirement("EqualTo", "US"))

        # Specify all the HIT parameters
        self.paramdict = dict(
            hit_type = None,
            question = mturkQuestion,
            lifetime = hit_config['lifetime'],
            max_assignments = hit_config['max_assignments'],
            title = hit_config['title'],
            description = hit_config['description'],
            keywords = hit_config['keywords'],
            reward = hit_config['reward'],
            duration = hit_config['duration'],
            approval_delay = None,
            questions = None,
            qualifications = quals
        )
開發者ID:alOlsen,項目名稱:psiTurk,代碼行數:32,代碼來源:amt_services.py

示例3: send_task

	def send_task(self):
		if self.osm_from is not None and self.osm_to is not None and self.reference is not None:
			title = 'Find the corresponding product'
			description = ('Select the most appropriate answer')
			keywords = 'images, selecting, products, matching, match, selection'
			self.save_task()

			question = ExternalQuestion('http://www.dalliz.com/mturk/key/%s'%(self.key), 1106)
			qualifications = Qualifications()
			qualifications.add(PercentAssignmentsApprovedRequirement('GreaterThanOrEqualTo', 95))
			 
			#--------------- CREATE THE HIT -------------------
			 
			a = self.mtc.create_hit(
						question=question,

						title=title,
						description=description,
						keywords=keywords,

						reward=0.01,
						max_assignments=10,

						approval_delay=datetime.timedelta(seconds=3600*24*30), # auto-approve timeout
						duration = datetime.timedelta(seconds=3600*24*30))
開發者ID:Boussadia,項目名稱:osmscraper,代碼行數:25,代碼來源:helper.py

示例4: configure_hit

    def configure_hit(self):

        # Configure portal
        experimentPortalURL = self.config.get('HIT Configuration', 'question_url')
        frameheight = 600
        mturkQuestion = ExternalQuestion(experimentPortalURL, frameheight)

        # Qualification:
        quals = Qualifications()
        approve_requirement = self.config.get('HIT Configuration', 'Approve_Requirement')
        quals.add(
            PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo",
                                                  approve_requirement))
        if self.config.getboolean('HIT Configuration', 'US_only'):
            quals.add(LocaleRequirement("EqualTo", "US"))

        # Specify all the HIT parameters
        self.paramdict = dict(
            hit_type = None,
            question = mturkQuestion,
            lifetime = datetime.timedelta(hours=self.config.getfloat('HIT Configuration', 'HIT_lifetime')),
            max_assignments = self.config.getint('HIT Configuration', 'max_assignments'),
            title = self.config.get('HIT Configuration', 'title'),
            description = self.config.get('HIT Configuration', 'description'),
            keywords = self.config.get('HIT Configuration', 'keywords'),
            reward = self.config.getfloat('HIT Configuration', 'reward'),
            duration = datetime.timedelta(hours=self.config.getfloat('HIT Configuration', 'duration')),
            approval_delay = None,
            questions = None,
            qualifications = quals
        )
開發者ID:AnthonyNystrom,項目名稱:psiTurk,代碼行數:31,代碼來源:amt_services.py

示例5: test_locale_qualification_in_notin

 def test_locale_qualification_in_notin(self):
     self.set_http_response(
         status_code=200,
         body=MOCK_SERVER_RESPONSE)
     q = ExternalQuestion(
         external_url="http://samplesite",
         frame_height=800)
     keywords = ['boto', 'test', 'doctest']
     title = "Boto External Question Test"
     annotation = 'An annotation from boto external question test'
     qualifications = Qualifications()
     test_requirement1 = LocaleRequirement(
                         comparator='In',
                         locale=[('US', 'CA')])
     test_requirement2 = LocaleRequirement(
                         comparator='NotIn',
                         locale=[('US', 'WA'), 'CA'])
     qualifications.add(test_requirement1)
     qualifications.add(test_requirement2)
     create_hit_rs = self.service_connection.create_hit(
                     question=q,
                     lifetime=60*65,
                     max_assignments=2,
                     title=title,
                     keywords=keywords,
                     reward=0.05,
                     duration=60*6,
                     approval_delay=60*60,
                     annotation=annotation,
                     qualifications=qualifications)
     self.assert_request_parameters({
         'QualificationRequirement.1.Comparator': 'In',
         'QualificationRequirement.1.LocaleValue.1.Country': 'US',
         'QualificationRequirement.1.LocaleValue.1.Subdivision': 'CA',
         'QualificationRequirement.1.QualificationTypeId':
             '00000000000000000071',
         'QualificationRequirement.2.Comparator': 'NotIn',
         'QualificationRequirement.2.LocaleValue.1.Country': 'US',
         'QualificationRequirement.2.LocaleValue.1.Subdivision': 'WA',
         'QualificationRequirement.2.LocaleValue.2.Country': 'CA',
         'QualificationRequirement.2.QualificationTypeId':
             '00000000000000000071'},
         ignore_params_values=['AWSAccessKeyId',
                               'SignatureVersion',
                               'Timestamp',
                               'Title',
                               'Question',
                               'AssignmentDurationInSeconds',
                               'RequesterAnnotation',
                               'Version',
                               'LifetimeInSeconds',
                               'AutoApprovalDelayInSeconds',
                               'Reward.1.Amount',
                               'Description',
                               'MaxAssignments',
                               'Reward.1.CurrencyCode',
                               'Keywords',
                               'Operation'])
     self.assertEquals(create_hit_rs.status, True)
開發者ID:10sr,項目名稱:hue,代碼行數:59,代碼來源:test_locale_qualification_notin.py

示例6: test

def test():
    q = ExternalQuestion(external_url="http://websort.net/s/F3481C", frame_height=800)
    conn = MTurkConnection(host='mechanicalturk.sandbox.amazonaws.com')
    keywords=['boto', 'test', 'doctest']
    qualifications = Qualifications()
    qualifications.add(PercentAssignmentsApprovedRequirement(comparator="GreaterThan", integer_value="95"))
    create_hit_rs = conn.create_hit(question=q, lifetime=60*65,max_assignments=2,title="Boto External Question Test", keywords=keywords,reward = 0.05, duration=60*6,approval_delay=60*60, annotation='An annotation from boto external question test', qualifications=qualifications)
    assert(create_hit_rs.status == True)
    print create_hit_rs.HITTypeId
開發者ID:AlexeyMK,項目名稱:boto,代碼行數:9,代碼來源:create_hit_with_qualifications.py

示例7: build_qualifications

 def build_qualifications():
     """
     Creates a single qualification that workers have a > 95% acceptance rate.
     :return: boto qualification obj.
     """
     qualifications = Qualifications()
     req1 = PercentAssignmentsApprovedRequirement(comparator="GreaterThan", integer_value="95")
     qualifications.add(req1)
     return qualifications
開發者ID:drschwenk,項目名稱:pdfextraction,代碼行數:9,代碼來源:boto_wrap.py

示例8: test_locale_qualification_notin_in

 def test_locale_qualification_notin_in(self):
     self.set_http_response(status_code=200, body=MOCK_SERVER_RESPONSE)
     q = ExternalQuestion(external_url="http://samplesite", frame_height=800)
     keywords = ["boto", "test", "doctest"]
     title = "Boto External Question Test"
     annotation = "An annotation from boto external question test"
     qualifications = Qualifications()
     test_requirement1 = LocaleRequirement(comparator="NotIn", locale=[("US", "WA"), "CA"])
     test_requirement2 = LocaleRequirement(comparator="In", locale=[("US", "CA")])
     qualifications.add(test_requirement1)
     qualifications.add(test_requirement2)
     create_hit_rs = self.service_connection.create_hit(
         question=q,
         lifetime=60 * 65,
         max_assignments=2,
         title=title,
         keywords=keywords,
         reward=0.05,
         duration=60 * 6,
         approval_delay=60 * 60,
         annotation=annotation,
         qualifications=qualifications,
     )
     self.assert_request_parameters(
         {
             "QualificationRequirement.1.Comparator": "NotIn",
             "QualificationRequirement.1.LocaleValue.1.Country": "US",
             "QualificationRequirement.1.LocaleValue.1.Subdivision": "WA",
             "QualificationRequirement.1.LocaleValue.2.Country": "CA",
             "QualificationRequirement.1.QualificationTypeId": "00000000000000000071",
             "QualificationRequirement.2.Comparator": "In",
             "QualificationRequirement.2.LocaleValue.1.Country": "US",
             "QualificationRequirement.2.LocaleValue.1.Subdivision": "CA",
             "QualificationRequirement.2.QualificationTypeId": "00000000000000000071",
         },
         ignore_params_values=[
             "AWSAccessKeyId",
             "SignatureVersion",
             "Timestamp",
             "Title",
             "Question",
             "AssignmentDurationInSeconds",
             "RequesterAnnotation",
             "Version",
             "LifetimeInSeconds",
             "AutoApprovalDelayInSeconds",
             "Reward.1.Amount",
             "Description",
             "MaxAssignments",
             "Reward.1.CurrencyCode",
             "Keywords",
             "Operation",
         ],
     )
     self.assertEquals(create_hit_rs.status, True)
開發者ID:boto,項目名稱:boto,代碼行數:55,代碼來源:test_locale_qualification_in.py

示例9: register_hit

    def register_hit(self, configuration=None):
        """
        Register a hit on Mechanical Turk according to `hit_params`. This will provide you with a HITTypeId.

        Parameters
        ----------
        configuration : dict

        Returns
        -------
        str
            The HITTypeId which is how you refer to your newly registered hit with Amazon
        """
        if configuration is None:
            configuration = app.config

        qualifications = Qualifications()
        if self.debug:
            qualifications.add(NumberHitsApprovedRequirement('GreaterThanOrEqualTo', 0))
            qualifications.add(PercentAssignmentsApprovedRequirement('GreaterThanOrEqualTo', 0))
        else:
            qualifications.add(NumberHitsApprovedRequirement('GreaterThanOrEqualTo',
                                                             configuration['MTURK_NUMBER_HITS_APPROVED_REQUIREMENT']))
            qualifications.add(PercentAssignmentsApprovedRequirement('GreaterThanOrEqualTo',
                                                                     configuration[
                                                                         'MTURK_PERCENT_ASSIGNMENTS_APPROVED_REQUIREMENT']))

        hit_type = self.connection.register_hit_type(configuration['MTURK_TITLE'],
                                                     configuration['MTURK_DESCRIPTION'],
                                                     Price(configuration['MTURK_REWARD']),
                                                     configuration['MTURK_ASSIGNMENT_DURATION_IN_SECONDS'],
                                                     configuration['MTURK_KEYWORDS'],
                                                     configuration['MTURK_AUTO_APPROVAL_DELAY_IN_SECONDS'],
                                                     qualifications)
        return hit_type[0].HITTypeId
開發者ID:interactiveaudiolab,項目名稱:CAQE,代碼行數:35,代碼來源:turk_admin.py

示例10: test_qualification_qualtypewithscore_in

 def test_qualification_qualtypewithscore_in(self):
     self.set_http_response(
         status_code=200,
         body=MOCK_SERVER_RESPONSE)
     q = ExternalQuestion(
         external_url="http://samplesite",
         frame_height=800)
     keywords = ['boto', 'test', 'doctest']
     title = "Boto External Question Test"
     annotation = 'An annotation from boto external question test'
     qualifications = Qualifications()
     test_requirement = Requirement(
                        qualification_type_id=QUAL_WITH_SCORE_ID,
                        comparator='In',
                        integer_value=[100, 90, 80])
     qualifications.add(test_requirement)
     create_hit_rs = self.service_connection.create_hit(
                     question=q,
                     lifetime=60*65,
                     max_assignments=2,
                     title=title,
                     keywords=keywords,
                     reward=0.05,
                     duration=60*6,
                     approval_delay=60*60,
                     annotation=annotation,
                     qualifications=qualifications)
     self.assert_request_parameters({
         'QualificationRequirement.1.Comparator':
             'In',
         'QualificationRequirement.1.QualificationTypeId':
             '333333333333333333333333333333',
         'QualificationRequirement.1.IntegerValue.1':
             100,
         'QualificationRequirement.1.IntegerValue.2':
             90,
         'QualificationRequirement.1.IntegerValue.3':
             80},
         ignore_params_values=['AWSAccessKeyId',
                               'SignatureVersion',
                               'Timestamp',
                               'Title',
                               'Question',
                               'AssignmentDurationInSeconds',
                               'RequesterAnnotation',
                               'Version',
                               'LifetimeInSeconds',
                               'AutoApprovalDelayInSeconds',
                               'Reward.1.Amount',
                               'Description',
                               'MaxAssignments',
                               'Reward.1.CurrencyCode',
                               'Keywords',
                               'Operation'])
     self.assertEquals(create_hit_rs.status, True)
開發者ID:10sr,項目名稱:hue,代碼行數:55,代碼來源:test_qualification_qualtypewithscore_in.py

示例11: create_campaign_hits

def create_campaign_hits(campaignid):
    """ 
    Create HITs for a campaign. 
    """
    campaign = Campaign.query.filter_by(id=campaignid).first()
    options = campaign.options
    terms = campaign.terms
    
    # Determine the number of quizzes that need to be generated
    numquizzes = int(math.ceil(float(len(terms)) / campaign.terms_per_quiz))

    # A set of questions will be built for each "page"
    for pagenum in range(numquizzes):
        conn = create_connection()
        question_form = create_question_form(campaign.title, campaign.title,"categorization")

        # Add the term questions to the page / quiz
        for i in range(campaign.terms_per_quiz):
            termnum = i + (pagenum * campaign.terms_per_quiz)
            if termnum < len(terms):
                term = terms[termnum]
                # Build up an answer dictionary for use with the question form 
                answers = [(cgi.escape(option.option_text), 
                            ("%s|%s" % (option.id, cgi.escape(option.option_text)))) 
                           for option in options]
                # A question should be appended for each term under consideration
                questiontext = campaign.question.replace("[term]", cgi.escape(term.term))
                identifier = "%s|%s|%s" % (campaign.id, term.id, cgi.escape(term.term))
                question_form.append(create_question(identifier,
                                                     questiontext,
                                                     answers))
  
        # Create a locale requirement that answerers must be in the US
        qualifications = Qualifications()
        lr = LocaleRequirement("EqualTo","US")
        qualifications.add(lr)
        print lr.get_as_params()

        # Now that the questions have been added, create the HIT
        conn.create_hit(questions=question_form,
                        max_assignments=campaign.times_per_term,
                        title=campaign.title,
                        description=campaign.title,
                        duration=60*30, # allot 30 minutes per quiz 
                        qualifications=qualifications, # require the answerers be in the US
                        reward=campaign.reward_per_quiz)

    # Update the campaign to prevent multiple generation attempts
    campaign.job_generated = True
    db.session.add(campaign)
    db.session.commit()
開發者ID:pmn,項目名稱:docsift-old,代碼行數:51,代碼來源:mturk.py

示例12: update_hit

def update_hit(settings):
  global hit
  hit_quals = Qualifications()
  old_hit_type_id = hit["type_id"]
  settings_quals = settings["qualifications"]
  ## TODO: master worker, custom quals, utility for creating qualifications?
  if (settings_quals):
    if settings_quals["location"]:
      hit_quals.add(LocaleRequirement("EqualTo", settings_quals["location"]))

    if settings_quals["approval_percentage"]:
      hit_quals.add(PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo",
                                                          settings_quals["approval_percentage"]))

  request_settings = dict(
    title           = settings["title"],
    description     = settings["description"],
    keywords        = settings["keywords"],
    reward          = settings["reward"],
    approval_delay  = timedelta(seconds = settings["auto_approval_delay"]),
    duration        = timedelta(seconds = settings["assignment_duration"]),
    qual_req        = hit_quals
  )

  try:
    new_hit_type_id = mtc.register_hit_type(**request_settings)[0].HITTypeId

    if new_hit_type_id == old_hit_type_id:
      prints("Settings haven't changed; not updating")
      sys.exit(1)

    change_existing_hit_type_result = mtc.change_hit_type_of_hit(hit["id"], new_hit_type_id)
  except MTurkRequestError as e:
    print("Error\n")
    pp(e.__dict__)

  hit_modes[mode]["type_id"] = new_hit_type_id

  ## write new_hit_type_id to hit_modes.json
  with open("hit_modes.json", 'w') as f:
    json.dump(hit_modes, f, indent=4, separators=(',', ': '))

  prints("Updated from type:",
    old_hit_type_id,
    "to type:",
    new_hit_type_id)
開發者ID:erindb,項目名稱:cosub,代碼行數:46,代碼來源:runner.py

示例13: __init__

    def __init__(self, sandbox):
        if sandbox == '0':
            mturk_host = settings.MTURK_REST_ENDPOINT
        else:
            mturk_host = settings.MTURK_REST_SANDBOX_ENDPOINT
        self.mturk_connection = MTurkConnection(
            aws_access_key_id=settings.AWS_ACCESS_KEY,
            aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
            host=mturk_host)

        quals = Qualifications()
        if settings.MTURK_APPROVED_PERCENT_REQUIREMENT > 0:            
            quals.add(
                PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo",
                    settings.MTURK_APPROVED_PERCENT_REQUIREMENT))
        if settings.MTURK_USONLY_REQUIREMENT:
            quals.add( LocaleRequirement("EqualTo", "US"))
        if settings.MTURK_MASTERS_REQUIREMENT:
            quals.add(Requirement('2ARFPLSP75KLA8M8DH1HTEQVJT3SY6' if sandbox!='0' \
                else '2F1QJWKUDD8XADTFD2Q0G6UTO95ALH', "Exists"))
        self.paramdict = dict(
            hit_type=None,
            lifetime=datetime.timedelta(hours=settings.MTURK_HIT_LIFETIME_HOURS),
            max_assignments=settings.MTURK_MAX_ASSIGNMENTS,
            title = settings.MTURK_GAME_TITLE,
            description = settings.MTURK_GAME_DESCRIPTION,
            keywords = 'search',
            reward = settings.MTURK_HIT_REWARD,
            duration = datetime.timedelta(hours=settings.MTURK_HIT_DURATION),
            approval_delay = datetime.timedelta(hours=settings.MTURK_APPROVAL_DELAY),
            questions = None,
            qualifications = quals
        )
開發者ID:DenXX,項目名稱:ufindit,代碼行數:33,代碼來源:mturk.py

示例14: __init__

 def __init__(self, host, n=10):
     mturkparams = dict(
         aws_access_key_id = config.get( 'AWS Access', 'aws_access_key_id' ),
         aws_secret_access_key = config.get( 'AWS Access', 'aws_secret_access_key' ),
         host=host)
     self.mtc = MTurkConnection( **mturkparams )
     
     # Configure portal
     experimentPortalURL = config.get( 'HIT Configuration', 'question_url' )
     frameheight = 600
     mturkQuestion = ExternalQuestion( experimentPortalURL, frameheight )
     
     # Qualification:
     quals = Qualifications();
     approve_requirement = config.getint('HIT Configuration',
                                         'Approve_Requirement')
     quals.add(
         PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo",
                                               approve_requirement))
     if config.getboolean('HIT Configuration', 'US_only'):
         quals.add( LocaleRequirement("EqualTo", "US") )
     
     # Specify all the HIT parameters
     self.paramdict = dict(
         hit_type = None,
         question = mturkQuestion,
         lifetime = datetime.timedelta(hours=config.getfloat('HIT Configuration', 'HIT_lifetime')),
         max_assignments = config.getint('HIT Configuration', 'max_assignments'),
         title = config.get('HIT Configuration', 'title'),
         description = config.get('HIT Configuration', 'description'),
         keywords = config.get('HIT Configuration', 'keywords'),
         reward = config.getfloat('HIT Configuration', 'reward'),
         duration = datetime.timedelta(
             hours=config.getfloat('HIT Configuration', 'duration')),
         approval_delay = None,
         questions = None,
         qualifications = quals
     )
開發者ID:dmarkant,項目名稱:psiTurk,代碼行數:38,代碼來源:createHIT.py

示例15: create_hit

def create_hit(task_type, URL, num_of_assignments):
    title = title_set[task_type]
    description = description_set[task_type]
    keywords = keywords_set[task_type]
    reward = price_set[task_type]
    
    print mturk.get_account_balance()

    # Qualification
    qualifications = Qualifications()
    qualifications.add(PercentAssignmentsApprovedRequirement("GreaterThanOrEqualTo", approve_requirement))
    #qualifications.add(LocaleRequirement("EqualTo", "US"))
    #qualifications.add(LocaleRequirement("In", ['US', 'GB', 'IN'], required_to_preview=True))
    questionform = ExternalQuestion(URL, frame_height)

    # create HIT
    create_hit_result = mturk.create_hit(
        title=title,
        description=description,
        keywords=keywords,
        question=questionform,
        reward=reward,
        qualifications=qualifications,

        duration=duration,
        max_assignments=num_of_assignments,
        lifetime=lifetime,
        approval_delay=approval_delay
        #response_groups = ( 'Minimal', 'HITDetail' ), # I don't know what response groups are
    )

    HIT = create_hit_result[0]
    assert create_hit_result.status

    print '[create_hit( %s, $%s ): %s]' % (URL, reward, HIT.HITId)
    print HIT.HITId
    return HIT.HITId
開發者ID:janetyc,項目名稱:writingfeedback,代碼行數:37,代碼來源:create_hit.py


注:本文中的boto.mturk.qualification.Qualifications類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。