Example #1
0
def print_workers(rows):
	workers = {}
	for row in rows:
		workerid = row["WorkerId"]
		if row["AssignmentStatus"] == "Rejected": continue
		workers[workerid] = workers.get(workerid,0) + 1
	sorted = nt.sorted_freqs(workers)
	for k,v in sorted:
		print k,v
Example #2
0
def gold_score_workers(rows,skipdone = False):
	right = {}
	wrong = {}
	for row in rows:
		workerid = row["WorkerId"]
		if skipdone and row["AssignmentStatus"] == "Rejected": continue
		if skipdone and row["AssignmentStatus"] == "Accepted": continue
		if not workerid in right: right[workerid] = 0
		if not workerid in wrong: wrong[workerid] = 0
		for i in range(1,11):
			snip = row["Input.snip"+str(i)]
			answer = row["Answer.Q"+str(i)]
			if snip in td.good_gold or snip in td.bad_gold:
				if (snip in td.good_gold and answer == "good") or (snip in td.bad_gold and answer != "good"):
					right[workerid] = right[workerid] + 1
				else:
					wrong[workerid] = wrong[workerid] + 1
	sorted_wrong = nt.sorted_freqs(wrong)
	for k,v in sorted_wrong:
		yield {"worker":k,"wrong":wrong[k],"right":right[k]}