| OLD | NEW |
| (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 | |
| OLD | NEW |