Chromium Code Reviews| Index: appengine/findit/crash/scorers/aggregator.py |
| diff --git a/appengine/findit/crash/scorers/aggregator.py b/appengine/findit/crash/scorers/aggregator.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..085dc581a2439a11f84894f6b1345fdb878654a7 |
| --- /dev/null |
| +++ b/appengine/findit/crash/scorers/aggregator.py |
| @@ -0,0 +1,25 @@ |
| +# Copyright 2016 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. |
| + |
| +"""Aggregator aggregates all the scorers passed in, multiplies scores |
| +together and combines reasons and summaries the result.""" |
| + |
| + |
| +class Aggregator(object): |
| + |
| + def __init__(self, scorers): |
| + self.scorers = scorers |
| + |
| + def ScoreAndReason(self, result): |
| + score = 1.0 |
| + reason = '' |
| + for i, scorer in enumerate(self.scorers): |
| + curr_score, curr_reason = scorer(result) |
|
stgao
2016/04/15 18:35:19
no abbreviation.
Sharu
2016/04/15 22:59:47
Done.
|
| + score *= curr_score |
|
stgao
2016/04/15 18:35:19
So we change from a vector of scores to multiplyin
Sharu
2016/04/15 22:59:47
Add a TODO here to compare these 2 methods later.
|
| + reason += '%d. %s (score: %d)\n' % (i + 1, curr_reason, curr_score) |
| + |
| + reason += '\n%s' % str(result) |
| + |
| + result.confidence = score |
| + result.reason = reason |