|
|
@@ -37,22 +37,57 @@ with open ("data/obfs4-email-bridges", 'r') as f:
|
|
|
if line != "":
|
|
|
email_bridges.add(line.strip())
|
|
|
|
|
|
-loesing_table = """
|
|
|
+## Set up all the LaTeX
|
|
|
+
|
|
|
+table_start = """
|
|
|
+\\documentclass[sigconf]{acmart}
|
|
|
+\\begin{document}
|
|
|
+\\begin{table*}[t]
|
|
|
+ \\caption{Results from running Algorithm~1 (using an absolute threshold of 32 and an absolute connection count minimum of 100), Algorithm~2 (using an absolute threshold $t$ and an absolute connection count minimum $m$), and Algorithm~3 (using a relative connection count difference $d$).}
|
|
|
+ \\begin{tabular}{c c | c c c c c c c}
|
|
|
+
|
|
|
\\hline
|
|
|
-\\textbf{TP} & \\textbf{TN} & \\textbf{FP} & \\textbf{FN} & \\textbf{Precision} & \\textbf{Recall} \\\\
|
|
|
+
|
|
|
+"""
|
|
|
+
|
|
|
+loesing_table = """
|
|
|
+\\multicolumn{8}{c}{\\textbf{Algorithm~1}} \\\\
|
|
|
+\\multicolumn{2}{c@{}}{} & \\textbf{TP} & \\textbf{TN} & \\textbf{FP} & \\textbf{FN} & \\textbf{Precision} & \\textbf{Recall} \\\\
|
|
|
\\hline
|
|
|
"""
|
|
|
abs_table = """
|
|
|
+\\\\
|
|
|
+\\hline
|
|
|
+\\multicolumn{8}{c}{\\textbf{Algorithm~2}} \\\\
|
|
|
+$t$ & $m$ & \\textbf{TP} & \\textbf{TN} & \\textbf{FP} & \\textbf{FN} & \\textbf{Precision} & \\textbf{Recall} \\\\
|
|
|
+\\hline
|
|
|
+"""
|
|
|
+
|
|
|
+abs_table_start_2 = """
|
|
|
+ \\end{tabular}
|
|
|
+ \\hspace{3em}
|
|
|
+ \\begin{tabular}{c c | c c c c c c}
|
|
|
\\hline
|
|
|
+\\multicolumn{8}{c}{\\textbf{Algorithm~2 (continued)}} \\\\
|
|
|
$t$ & $m$ & \\textbf{TP} & \\textbf{TN} & \\textbf{FP} & \\textbf{FN} & \\textbf{Precision} & \\textbf{Recall} \\\\
|
|
|
\\hline
|
|
|
"""
|
|
|
+
|
|
|
rel_table = """
|
|
|
+\\\\
|
|
|
\\hline
|
|
|
-$d$ & \\textbf{TP} & \\textbf{TN} & \\textbf{FP} & \\textbf{FN} & \\textbf{Precision} & \\textbf{Recall} \\\\
|
|
|
+\\multicolumn{8}{c}{\\textbf{Algorithm~3}} \\\\
|
|
|
+& $d$ & \\textbf{TP} & \\textbf{TN} & \\textbf{FP} & \\textbf{FN} & \\textbf{Precision} & \\textbf{Recall} \\\\
|
|
|
\\hline
|
|
|
"""
|
|
|
|
|
|
+table_end = """
|
|
|
+
|
|
|
+ \\end{tabular}
|
|
|
+\\end{table*}
|
|
|
+\\end{document}
|
|
|
+"""
|
|
|
+
|
|
|
def accuracy (filename):
|
|
|
with open (filename, 'r') as f:
|
|
|
# obfs4 email bridges correctly identified as blocked
|
|
|
@@ -89,27 +124,28 @@ def accuracy (filename):
|
|
|
|
|
|
return f"{tp} & {tn} & {fp} & {fn} & {precision} & {recall} \\\\\n"
|
|
|
|
|
|
+
|
|
|
+## Add the data to the table
|
|
|
+
|
|
|
# Loesing
|
|
|
-loesing_table += accuracy ("data/blocked_loesing")
|
|
|
+loesing_table += "\\multicolumn{2}{c@{}}{} & " + accuracy ("data/blocked_loesing")
|
|
|
|
|
|
# Absolute threshold
|
|
|
for t in range (8, 40, 8):
|
|
|
for m in range (t+8, 112, 8):
|
|
|
abs_table += f"{t} & {m} & " + accuracy (f"data/blocked_abs_{t}_{m}")
|
|
|
+ if t == 24 and m == 56:
|
|
|
+ # push to second column
|
|
|
+ abs_table += abs_table_start_2
|
|
|
|
|
|
# Relative threshold
|
|
|
for d in range (8, 112, 8):
|
|
|
- rel_table += f"{d} & " + accuracy (f"data/blocked_rel_{d}")
|
|
|
-
|
|
|
-print ("Loesing's algorithm:")
|
|
|
-print (loesing_table)
|
|
|
-
|
|
|
-print ("Absolute threshold:")
|
|
|
-print (abs_table)
|
|
|
-
|
|
|
-print ("Relative threshold:")
|
|
|
-print (rel_table)
|
|
|
+ rel_table += f"& {d} & " + accuracy (f"data/blocked_rel_{d}")
|
|
|
|
|
|
+## Output the LaTeX file
|
|
|
+table = table_start + loesing_table + abs_table + rel_table + table_end
|
|
|
+with open("appendix-a-results.tex", 'w') as f:
|
|
|
+ f.write(table)
|
|
|
|
|
|
# Now let's look at stddevs
|
|
|
|
|
|
@@ -194,9 +230,6 @@ for i in range(len(email_bridge_data)):
|
|
|
# Get smallest key, i.e., the first date BOTH bridges have data for
|
|
|
start_date = max(min(bridge_i), min(bridge_j))
|
|
|
|
|
|
- # Get counts before censorship started
|
|
|
- #for d in range(start_date, FIRST_DAY):
|
|
|
-
|
|
|
# Get set of keys between start_date and FIRST_DAY
|
|
|
keys = set()
|
|
|
for d in bridge_i:
|