source: abuse/trunk/data/analyze.py @ 586

Last change on this file since 586 was 586, checked in by Sam Hocevar, 10 years ago

data: create an analyzer script to compare level files.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1#!/usr/bin/env python
2
3from Levenshtein import *
4import sys
5
6if len(sys.argv) < 2:
7    print "Error: requires an argument (0 -- 19)"
8    sys.exit(-1)
9
10n = int(sys.argv[1])
11
12if n < 0 or n > 19:
13    print "Error: argument out of range (0 -- 19)"
14    sys.exit(-1)
15
16class Unbuffered:
17    def __init__(self, stream):
18        self.stream = stream
19    def write(self, data):
20        self.stream.write(data)
21        self.stream.flush()
22    def __getattr__(self, attr):
23        return getattr(self.stream, attr)
24
25sys.stdout = Unbuffered(sys.stdout)
26
27l = [ "data-abuse/levels/level00.spe", "data-abuse/levels/level01.spe",
28"data-abuse/levels/level02.spe", "data-abuse/levels/level03.spe",
29"data-abuse/levels/level04.spe", "data-abuse/levels/level05.spe",
30"data-abuse/levels/level06.spe", "data-abuse/levels/level07.spe",
31"data-abuse/levels/level08.spe", "data-abuse/levels/level09.spe",
32"data-abuse/levels/level10.spe", "data-abuse/levels/level11.spe",
33"data-abuse/levels/level12.spe", "data-abuse/levels/level13.spe",
34"data-abuse/levels/level14.spe", "data-abuse/levels/level15.spe",
35"data-abuse/levels/level16.spe", "data-abuse/levels/level17.spe",
36"data-abuse/levels/level18.spe", "data-abuse/levels/level19.spe",
37"data-abuse/levels/level20.spe", "data-abuse/levels/level21.spe",
38"data-frabs/levels/level00.spe", "data-frabs/levels/level01.spe",
39"data-frabs/levels/level02.spe", "data-frabs/levels/level03.spe",
40"data-frabs/levels/level04.spe", "data-frabs/levels/level05.spe",
41"data-frabs/levels/level06.spe", "data-frabs/levels/level07.spe",
42"data-frabs/levels/level08.spe", "data-frabs/levels/level09.spe",
43"data-frabs/levels/level10.spe", "data-frabs/levels/level11.spe",
44"data-frabs/levels/level12.spe", "data-frabs/levels/level13.spe",
45"data-frabs/levels/level14.spe", "data-frabs/levels/level15.spe",
46"data-frabs/levels/level17.spe", "data-frabs/levels/level18.spe",
47"data-frabs/levels/level19.spe", "data-frabs/levels/level20.spe",
48"data-frabs/levels/level21.spe", "data-frabs/levels/level30.spe",
49"data-frabs/levels/level70.spe", "data-frabs/levels/level71.spe",
50"data-frabs/levels/level72.spe", "data-frabs/levels/level73.spe",
51"data-frabs/levels/level74.spe", "data-mac/levels/demo1.spe",
52"data-mac/levels/demo2.spe", "data-mac/levels/demo4.spe",
53"data-mac/levels/demo5.spe", "data-mac/levels/end.spe",
54"data-mac/levels/flevel12.spe", "data-mac/levels/level00.spe",
55"data-mac/levels/level01.spe", "data-mac/levels/level02.spe",
56"data-mac/levels/level03.spe", "data-mac/levels/level04.spe",
57"data-mac/levels/level05.spe", "data-mac/levels/level06.spe",
58"data-mac/levels/level07.spe", "data-mac/levels/level08.spe",
59"data-mac/levels/level09.spe", "data-mac/levels/level10.spe",
60"data-mac/levels/level11.spe", "data-mac/levels/level12.spe",
61"data-mac/levels/level13.spe", "data-mac/levels/level14.spe",
62"data-mac/levels/level15.spe", "data-mac/levels/level16.spe",
63"data-mac/levels/level17.spe", "data-mac/levels/level18.spe",
64"data-mac/levels/level19.spe", "data-mac/levels/level20.spe",
65"data-mac/levels/level21.spe", "data-mac/levels/levels.spe",
66"data-mac/levels/netreg1.spe", "data-mac/levels/netshar1.spe",
67"data-mac/levels/netshar2.spe" ]
68
69c = []
70for y in range(len(l)):
71    for x in range(y):
72        c.append((x, y))
73
74t = len(c) / 20
75for x, y in c[n * t : (n + 1) * t]:
76    b = open(l[y]).read()
77    a = open(l[x]).read()
78    print ratio(a, b), l[x], l[y]
79
Note: See TracBrowser for help on using the repository browser.