Esempio n. 1
0
def load_notes(ids):
    from jv3.study.content_analysis import _notes_to_values    
    print ids
    ns = [x for x in _notes_to_values(Note.objects.filter(pk__in=ids))]
    def cmp(x,y):
        #print "(%d,%d)"%(x["id"],y["id"])
        return ids.index(x["id"])-ids.index(y["id"])
    ns.sort(cmp=cmp)
    return ns
Esempio n. 2
0
def load_notes(ids):
    from jv3.study.content_analysis import _notes_to_values
    print ids
    ns = [x for x in _notes_to_values(Note.objects.filter(pk__in=ids))]

    def cmp(x, y):
        #print "(%d,%d)"%(x["id"],y["id"])
        return ids.index(x["id"]) - ids.index(y["id"])

    ns.sort(cmp=cmp)
    return ns
Esempio n. 3
0
def export_features(fkeys, features, notes=None, filename='/tmp/features.csv'):
    from jv3.study.content_analysis import _notes_to_values
    F = open(filename, 'wb')
    writer = csv.writer(F,
                        dialect="excel",
                        delimiter=',',
                        quoting=csv.QUOTE_MINIMAL)
    # write headers
    writer.writerow(["nid", "jid", "email", "contents"] + fkeys)
    #
    for nid, nf in features.items():
        n = _notes_to_values(Note.objects.filter(pk=nid))[0]
        u = User.objects.filter(id=n["owner"])
        print n
        row = [
            n["id"], n["jid"], u[0].email,
            n["contents"].encode('utf-8', 'ignore')[:32767]
        ]
        for f in fkeys:
            row.append(nf.get(f))
        writer.writerow(row)
    F.close()

    ## write pickles
    import pickle
    from jv3.study.ca_sigscroll import ca_caches
    FP = open("%s.pickle" % filename, "w")
    FP.write(
        pickle.dumps({
            "features": features,
            "fkeys": fkeys,
            "sigscroll_caches": ca_caches(),
            "notes": notes
        }))
    FP.close()
    pass
Esempio n. 4
0
def export_features(fkeys,features,notes=None,filename='/tmp/features.csv'):
    from jv3.study.content_analysis import _notes_to_values
    F = open(filename, 'wb')
    writer = csv.writer(F, dialect="excel", delimiter=',', quoting=csv.QUOTE_MINIMAL)
    # write headers
    writer.writerow( ["nid","jid","email","contents"] + fkeys )
    #
    for nid,nf in features.items():
        n = _notes_to_values(Note.objects.filter(pk=nid))[0]
        u = User.objects.filter(id=n["owner"])
        print n
        row = [n["id"],n["jid"],u[0].email,n["contents"].encode('utf-8','ignore')[:32767]]
        for f in fkeys:
            row.append( nf.get(f) )
        writer.writerow(row)
    F.close()

    ## write pickles
    import pickle
    from jv3.study.ca_sigscroll import ca_caches
    FP = open("%s.pickle"%filename,"w")
    FP.write(pickle.dumps({"features":features,"fkeys":fkeys,"sigscroll_caches":ca_caches(),"notes":notes}))
    FP.close()
    pass