| 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..e76b4fd0648678e5d6b2eb4a2b616f5848ac2326
|
| --- /dev/null
|
| +++ b/appengine/findit/crash/scorers/aggregator.py
|
| @@ -0,0 +1,31 @@
|
| +# 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):
|
| + """Sets result.confidence and result.reason."""
|
| +
|
| + score = 1.0
|
| + reason = ''
|
| + for i, scorer in enumerate(self.scorers):
|
| + current_score, current_reason = scorer(result)
|
| + # TODO(katesonia): Compare this mutiply aggregator with a vector of scores
|
| + # aggregator later.
|
| + score *= current_score
|
| + reason += '%d. %s (score: %d)\n' % (i + 1, current_reason, current_score)
|
| +
|
| + reason += '\n%s' % str(result)
|
| +
|
| + result.confidence = score
|
| + result.reason = reason
|
|
|