コード例 #1
0
def xml2comments(xml_files, cheaters=0):
    #cheaters = 0 gets all comments, cheaters = -1 means no cheaters,
    # and cheaters = 1 means only cheaters
    if type(xml_files) is not list:
        xml_files = [xml_files]
    res = []
    ignored = 0
    for xml_file in xml_files:
        a = etree.parse(xml_file)
        b = a.find("answer")
        if not b:
            print "COULD NOT FIND answer"
            return
        for i in b.findall("assignment"):
            wid = i.find("workerID").text

            if (cheaters == -1 and wid in monitor_workers.ignore_list()) or (
                    cheaters == 1
                    and wid not in monitor_workers.ignore_list()):
                ignored += 1
                #print "Ignoring: ",wid
                continue
            li = i.find("comment").text
            if li:
                li = li.strip()
                if li:
                    res.append((wid, li))
    if ignored > 0:
        print "Ignored ", ignored, " assignments."
    return res
コード例 #2
0
ファイル: live.com,YAEL-NEW1.py プロジェクト: omert/simexp
def xml2comments(xml_files,cheaters=0):
    #cheaters = 0 gets all comments, cheaters = -1 means no cheaters,
    # and cheaters = 1 means only cheaters
    if type(xml_files) is not list:
        xml_files = [xml_files]
    res = []
    ignored = 0
    for xml_file in xml_files:
        a = etree.parse(xml_file)
        b = a.find("answer")
        if not b:
            print "COULD NOT FIND answer"
            return   
        for i in b.findall("assignment"):
            wid = i.find("workerID").text

            if (cheaters==-1 and wid in monitor_workers.ignore_list()) or (cheaters==1 and wid not in monitor_workers.ignore_list()):
                ignored+=1
                #print "Ignoring: ",wid
                continue
            li = i.find("comment").text
            if li:
                li = li.strip()
                if li:
                    res.append((wid,li))
    if ignored>0:
        print "Ignored ",ignored," assignments."
    return res
コード例 #3
0
ファイル: live.com,YAEL-NEW1.py プロジェクト: omert/simexp
def xml2trips(xml_files,ignore_list = "default"):
    if ignore_list=="default":
        ignore_list=monitor_workers.ignore_list()
    if type(xml_files) is not list:
        xml_files = [xml_files]
    res = []
    ignored = 0
    for xml_file in xml_files:
        a = etree.parse(xml_file)
        b = a.find("hit_data")
        trips = []
        if not b:
            print "COULD NOT FIND hit_data"
            return
        for i in b.findall("triple"):
            trips.append(eval(i.text))
        b = a.find("answer")
        if not b:
            print "COULD NOT FIND answer"
            return   
        n = len(trips)
        for i in b.findall("assignment"):
            wid = i.find("workerID").text
            if wid in ignore_list:
                ignored+=1
                #print "Ignoring: ",wid
                continue
            li = eval(i.find("annotation").text)
            assert len(li)==n
            for k in range(n):
                (x,y,z) = trips[k]
                if li[k]:
                    res.append((x,y,z,wid))
                else:
                    res.append((x,z,y,wid))
    if ignored>0:
        print "Ignored ",ignored," assignments."
    return res
コード例 #4
0
def xml2trips(xml_files, ignore_list="default"):
    if ignore_list == "default":
        ignore_list = monitor_workers.ignore_list()
    if type(xml_files) is not list:
        xml_files = [xml_files]
    res = []
    ignored = 0
    for xml_file in xml_files:
        a = etree.parse(xml_file)
        b = a.find("hit_data")
        trips = []
        if not b:
            print "COULD NOT FIND hit_data"
            return
        for i in b.findall("triple"):
            trips.append(eval(i.text))
        b = a.find("answer")
        if not b:
            print "COULD NOT FIND answer"
            return
        n = len(trips)
        for i in b.findall("assignment"):
            wid = i.find("workerID").text
            if wid in ignore_list:
                ignored += 1
                #print "Ignoring: ",wid
                continue
            li = eval(i.find("annotation").text)
            assert len(li) == n
            for k in range(n):
                (x, y, z) = trips[k]
                if li[k]:
                    res.append((x, y, z, wid))
                else:
                    res.append((x, z, y, wid))
    if ignored > 0:
        print "Ignored ", ignored, " assignments."
    return res