Exemplo n.º 1
0
def average_edit_distance(n):
    import nltk.metrics.distance as d
    edits = [ e["noteText"] for e in activity_logs_for_note(n) if e["action"] == "note-save"]  ##//ActivityLog.objects.filter(noteid=n["id"],action="note-edit").order_by("when").values_list("noteText")
    distances = []
    if len(edits) > 1:
        #print "edits: %s " % repr(edits)
        for i in range(0,len(edits)-1):
            if edits[i] is None or edits[i+1] is None:
                continue
            distances.append( d.edit_distance( edits[i], edits[i+1] ) )
        if len(distances) > 0:
            return make_feature("edit_distance",median(distances))
    return make_feature('edit_distance',MISSING)
Exemplo n.º 2
0
def average_edit_distance(n):
    import nltk.metrics.distance as d
    edits = [
        e["noteText"] for e in activity_logs_for_note(n)
        if e["action"] == "note-save"
    ]  ##//ActivityLog.objects.filter(noteid=n["id"],action="note-edit").order_by("when").values_list("noteText")
    distances = []
    if len(edits) > 1:
        #print "edits: %s " % repr(edits)
        for i in range(0, len(edits) - 1):
            if edits[i] is None or edits[i + 1] is None:
                continue
            distances.append(d.edit_distance(edits[i], edits[i + 1]))
        if len(distances) > 0:
            return make_feature("edit_distance", median(distances))
    return make_feature('edit_distance', MISSING)
Exemplo n.º 3
0
def s(counts):
    print "min:%g max:%g mode:%g mean:%g median:%g var:%g" % (min(counts),max(counts),mode(counts),mean(counts),median(counts),var(counts))
    return (min(counts),max(counts),mode(counts),mean(counts),median(counts),var(counts))
Exemplo n.º 4
0
def s(counts):
    print "min:%g max:%g mode:%g mean:%g median:%g var:%g" % (
        min(counts), max(counts), mode(counts), mean(counts), median(counts),
        var(counts))
    return (min(counts), max(counts), mode(counts), mean(counts),
            median(counts), var(counts))