| 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:]))
|
| +
|
|
|