示例#1
0
def reject_work(wids, label=None):
    label = label or turk.get_last_label()
    file = open(turk.log_root + "/" + label + ".results", "r")
    blah = csv.DictReader(file, delimiter="\t")
    aids = []
    for r in blah:
        wid = r["workerid"]
        if wid in wids:
            aids.append(r["assignmentid"])
    file.close()
    ttext = ""
    for aid in aids:
        st = "rejectWork -assignment " + aid + " -force"
        text = tools.my_run(st, turk.turk_root).strip()
        my_log("[REJECT WORK]" + st + text + "\n")
        ttext += st + "\n" + text + "\n"
    return ttext
示例#2
0
def reject_work(wids,label=None):
    label = label or turk.get_last_label()
    file = open(turk.log_root+"/"+label+".results","r")
    blah = csv.DictReader(file,delimiter='\t')
    aids = []
    for r in blah:
        wid = r['workerid']
        if wid in wids:
            aids.append(r['assignmentid'])       
    file.close()
    ttext = ""
    for aid in aids:
        st = "rejectWork -assignment "+aid+' -force'
        text = tools.my_run(st,turk.turk_root).strip()    
        my_log("[REJECT WORK]"+st+text+"\n")
        ttext+=st+"\n"+text+"\n"
    return ttext
示例#3
0
def results2trips(label=None, ignore_list=[]):
    label = label or turk.get_last_label()
    file = open(turk.log_root + "/" + label + ".results", "r")
    blah = csv.DictReader(file, delimiter="\t")
    trips = []
    for r in blah:
        wid = r["workerid"]
        if wid in ignore_list:
            continue
        challenge = r["annotation"].split("_")
        li = r["Answer.res"].split("_")
        assert challenge[0] == li[0]
        if match(challenge[1:], li[1:]):
            n = (len(li) - 1) / 5
            li2 = [tuple(li[5 * i + 1 : 5 * i + 6]) for i in range(n)]
            li3 = [((a, b, c) if d == "0" else (a, c, b)) for (a, b, c, d, e) in li2]
            trips += [(int(a), int(b), int(c), wid) for (a, b, c) in li3]
    file.close()
    return trips
示例#4
0
def results2trips(label = None,ignore_list=[]):
    label = label or turk.get_last_label()
    file = open(turk.log_root+"/"+label+".results","r")
    blah = csv.DictReader(file,delimiter='\t')
    trips = []
    for r in blah:
        wid = r['workerid']
        if wid in ignore_list:
            continue
        challenge = r['annotation'].split("_")
        li = r['Answer.res'].split("_")
        assert challenge[0]==li[0]    
        if match(challenge[1:],li[1:]):
            n = (len(li)-1)/5
            li2 = [tuple(li[5*i+1:5*i+6]) for i in range(n)]
            li3 = [((a,b,c) if d=='0' else (a,c,b)) for (a,b,c,d,e) in li2]
            trips += [(int(a),int(b),int(c),wid) for (a,b,c) in li3]
    file.close()
    return trips
def results2sess(label = None,ignore_list=[]):
    label = label or turk.get_last_label()
    file = open(turk.log_root+"/"+label+".results","r")
    blah = csv.DictReader(file,delimiter='\t')
    sess = []
    for r in blah:
        wid = r['workerid']
        if wid in ignore_list:
            continue
        challenge = r['annotation'].split("_")
        li = r['Answer.res'].split("_")
        assert challenge[0]==li[0]    
        if match(challenge[1:],li[1:]):
            n = (len(li)-1)/5
            li2 = [tuple(li[5*i+1:5*i+6]) for i in range(n)]
            li3 = [((a,b,c,e,d) if d=='0' else (a,c,b,e,d)) for (a,b,c,d,e) in li2]
            sess.append([wid]+[(int(a),int(b),int(c),int(e)*0.001,d) for (a,b,c,e,d) in li3])
    file.close()
    return sess
示例#6
0
import turk, time
import sys, glob
import tools, random, string

#sys.argv = ["","c:/sim/font_sample.config","c:/sim/sample.trips","c:/sim/sample.out"]

#print "Usage: checktrips.py"
#print "or"
#print "checktrips.py batch_id, where batch_id is the integer id of the batch"
#print "or"
#print "checktrips.py outfileloc"

if len(sys.argv) == 2:
    label = sys.argv[1].strip()
else:
    label = str(turk.get_last_label())

if "\\" in label or "." in label or "/" in label:
    label = label.replace("/", "\\")
    count = 0
    fname = ""
    for filename in glob.glob(turk.log_root + "/*.out_file_loc"):
        if tools.my_read(filename).strip().replace("/", "\\") == label:
            fname = filename
            count += 1
    if count > 1:
        print "Found more than one .out_file_loc file pointing to", label
        print "Exiting..."
        exit(0)
    if count == 0:
        print "Couldn't find any .out_file_loc file pointing to", label
示例#7
0
"""

import turk, time
import sys, glob
import tools, random, string

#sys.argv = ["","c:/sim/font_sample.config","c:/sim/sample.trips","c:/sim/sample.out"]

#print "Usage: checktrips.py"
#print "or"
#print "checktrips.py batch_id, where batch_id is the integer id of the batch"

if len(sys.argv)==2:
    label = sys.argv[1].strip()
else:
    label = str(turk.get_last_label())



if "\\" in label or "." in label or "/" in label:
    label=label.replace("/","\\")
    count = 0
    fname = ""
    for filename in glob.glob(turk.log_root+"/*.out_file_loc"):
        if tools.my_read(filename).strip().replace("/","\\")==label:
            fname = filename
            count += 1
    if count>1:
        print "Found more than one .out_file_loc file pointing to",label
        print "Exiting..."
        exit(0)