def assign_qua(mtc_type, args_qua__id, workers): mtc = mtk_utils.get_mtc(mtc_type) for worker in workers: mtc.assign_qualification(qualification_type_id=args_qua__id, worker_id=worker)
def generate_hits(mtc_type, 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, Requirement mtc = mtk_utils.get_mtc(mtc_type) title = 'Tell us if you like those images or not' description = ('View following images and tell us if you like them or not.') keywords = 'image, like, interesting, rating, opinions' ratings =[('Very hate it','-2'), ('Hate it','-1'), ('Neutral','0'), ('Like it','1'), ('Very like it.','2')] #--------------- BUILD OVERVIEW ------------------- overview = Overview() overview.append_field('Title', 'Tell us if you like those images or not.') #--------------- BUILD QUESTIONs ------------------- questions = [] subset_with_pinterest = [] index = 0 for image_url in subset: image_id = data_ids[index] image = images_metainfo[image_id] interestingness = 0 index = index + 1 if ('repin_count' in image): interestingness = int(image['repin_count']) + int(image['like_count']) subset_with_pinterest.append(image_url) else: continue # interestingness = int(image['interestingness']) qc = QuestionContent() context = '' if (interestingness > 0): context = ' (shared by ' + str(interestingness) + ' people)' qc.append_field('Title', str(interestingness) + ' people said they like following image, would you like it too?') 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) if (len(questions) == 0): return if (args.m != 'qua'): utils.write_file(subset_with_pinterest, args.o + '.index_' + str(begin_index) + '.txt') if (args.m == 'qua_init' and begin_index > 0): return #--------------- 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 * 4, 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)
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)
def assign_qua(mtc_type, args_qua__id, workers): mtc = mtk_utils.get_mtc(mtc_type) for worker in workers: mtc.assign_qualification(qualification_type_id = args_qua__id, worker_id = worker)