示例#1
0
def submit_forms():
    """
    Creates all of the surveys for processing as HITs on Mechanical Turk. Article sources are pulled from
    articles.py
    """
    fact = MTurkSurveyFactory()
    mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                         aws_secret_access_key=SECRET_KEY,
                         host=HOST, is_secure=True,
                         https_connection_factory=(https_connection_factory, ()))
    #loop over every article
    tuple_list = []
    tuple_list.extend(build_survey_list(mississippi))
    tuple_list.extend(build_survey_list(boston_miranda))
    tuple_list.extend(build_survey_list(bangladesh))
    tuple_list.extend(build_survey_list(sunil_tripathi))
    tuple_list.extend(build_survey_list(syria))
    tuple_list.extend(build_survey_list(spain))
    tuple_list.extend(build_survey_list(virgin_galactic))
    tuple_list.extend(build_survey_list(michigan))
    tuple_list.extend(build_survey_list(jason_collins))
    tuple_list.extend(build_survey_list(american_held_nk))
    tuple_list.extend(build_survey_list(sherpa_fight))
    tuple_list.extend(build_survey_list(faa_furloughs))
    tuple_list.extend(build_survey_list(bagram))
    tuple_list.extend(build_survey_list(jackson))
    tuple_list.extend(build_survey_list(pills))
    tuple_list.extend(build_survey_list(poison))
    print 'Retrieved', len(tuple_list)
    print 'Missing: ', len(missing)
    print missing
    print 'Sending it to mechanicalturk'
    fact = MTurkSurveyFactory()
    questionForms = fact.buildSurvey(tuple_list)
    print len(questionForms)
    missing_forms = []
    for questionForm in questionForms:
        try:
            fact.submitHITs(mtc=mtc, questionForms=[questionForm])
        except:
            missing_forms.extend(questionForm)

    print len(missing_forms), ' forms could not be submitted'
    print missing_forms
示例#2
0
            print url, title, text
            tuple_list.append([url, title, ' '.join(text)])
        
    print len(tuple_list)
    print 'Retrieved', len(tuple_list)
    print 'Missing: ', len(missing)
    print missing
    print 'Sending it to mechanicalturk'
    mtc = MTurkConnection(aws_access_key_id=ACCESS_ID,
                         aws_secret_access_key=SECRET_KEY,
                         host=HOST, is_secure=True,
                         https_connection_factory=(https_connection_factory, ()))
    
    print mtc.get_all_hits()

    fact = MTurkSurveyFactory()
    questionForms = fact.buildSurvey(tuple_list)
    print len(questionForms)
    missing_forms = []
    for questionForm in questionForms:
        try:
            fact.submitHITs(mtc=mtc, questionForms=[questionForm])
        except:
            missing_forms.extend(questionForm)
            print "Unexpected error:", sys.exc_info()[0]

    print len(missing_forms), ' forms could not be submitted'
    print missing_forms