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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « get_screenshots.py ('k') | write_features_csv.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import argparse
7 import csv
8 import json
9 import os
10 import shutil
11 import sys
12
13 def main(argv):
14 parser = argparse.ArgumentParser()
15 parser.add_argument('--features', required=True)
16 options = parser.parse_args(argv)
17
18 features = list(csv.DictReader(open(options.features)))
19
20 t = 0
21 s = 0
22 for f in features:
23 w = 2 if (int(f['good']) == 1) else 1
24 p = 0
25 if int(f['opengraph']) == 1 and not int(f['pathlength']) == 0:
26 p = 1
27 t += w
28 if p == int(f['good']):
29 s += w
30
31 print t, s, float(s)/t
32
33 t = 0
34 c = 0
35 w = 0
36 for f in features:
37 g = int(f['good'])
38 fb = int(f['opengraph'])
39 home = int(f['pathlength']) < 2
40 t += g
41 if fb == 1 and not home:
42 if g == 1:
43 c += 1
44 else:
45 w += 1
46
47 print float(c) / (c + w)
48 print float(c) / t
49
50 return 0
51
52 if __name__ == '__main__':
53 sys.exit(main(sys.argv[1:]))
54
OLDNEW
« 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