Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: quick_score.py

Issue 1289123002: Merge branch 'master' into heuristics Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « get_screenshots.py ('k') | write_features_csv.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: quick_score.py
diff --git a/quick_score.py b/quick_score.py
new file mode 100755
index 0000000000000000000000000000000000000000..c12c84f8c83e68e76a03dcc2311596206cc30739
--- /dev/null
+++ b/quick_score.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import csv
+import json
+import os
+import shutil
+import sys
+
+def main(argv):
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--features', required=True)
+ options = parser.parse_args(argv)
+
+ features = list(csv.DictReader(open(options.features)))
+
+ t = 0
+ s = 0
+ for f in features:
+ w = 2 if (int(f['good']) == 1) else 1
+ p = 0
+ if int(f['opengraph']) == 1 and not int(f['pathlength']) == 0:
+ p = 1
+ t += w
+ if p == int(f['good']):
+ s += w
+
+ print t, s, float(s)/t
+
+ t = 0
+ c = 0
+ w = 0
+ for f in features:
+ g = int(f['good'])
+ fb = int(f['opengraph'])
+ home = int(f['pathlength']) < 2
+ t += g
+ if fb == 1 and not home:
+ if g == 1:
+ c += 1
+ else:
+ w += 1
+
+ print float(c) / (c + w)
+ print float(c) / t
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
+
« no previous file with comments | « get_screenshots.py ('k') | write_features_csv.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698