-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStats.d
60 lines (55 loc) · 1.57 KB
/
Stats.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module Stats;
import std.stdio;
import std.file;
import std.string;
import ae.sys.file;
import Forum;
void main()
{
bool[string] engineResults;
string postID;
int[string] engineTotal, engineFalsePositive, engineFalseNegative;
foreach (file; fastListDir("logs", "*.log"))
foreach (line; splitLines(cast(string)read(file)))
if (line.startsWith("["))
{
line = line[line.indexOf("] ")+2..$];
if (line.startsWith("Checking post "))
{
postID = line[14..$];
engineResults = null;
}
else
if (line.length > 20 && line[20]==':')
{
auto engine = strip(line[0..20]);
auto result = strip(line[21..$]);
if (result.startsWith("not spam"))
engineResults[engine] = false;
else
if (result.startsWith("SPAM"))
engineResults[engine] = true;
}
else
if (line.startsWith("Verdict: "))
{
bool modVerdict = !postExists(postID);
writefln("Post %s: %s; Mod verdict=%s", postID, engineResults, modVerdict);
foreach (engine, engineResult; engineResults)
{
engineTotal[engine]++;
if (engineResult && !modVerdict)
engineFalsePositive[engine]++;
else
if (!engineResult && modVerdict)
engineFalseNegative[engine]++;
}
}
}
foreach (engine, total; engineTotal)
{
int falsePositives = engine in engineFalsePositive ? engineFalsePositive[engine] : 0;
int falseNegatives = engine in engineFalseNegative ? engineFalseNegative[engine] : 0;
writefln("%-20s: %3d total, %3d false positives, %3d false negatives", engine, total, falsePositives, falseNegatives);
}
}