| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Aggregator aggregates all the scorers passed in, multiplies scores |
| 6 together and combines reasons and summaries the result.""" |
| 7 |
| 8 |
| 9 class Aggregator(object): |
| 10 |
| 11 def __init__(self, scorers): |
| 12 self.scorers = scorers |
| 13 |
| 14 def ScoreAndReason(self, result): |
| 15 score = 1.0 |
| 16 reason = '' |
| 17 for i, scorer in enumerate(self.scorers): |
| 18 current_score, current_reason = scorer(result) |
| 19 # TODO(katesonia): Compare this mutiply aggregator with a vector of scores |
| 20 # aggregator later. |
| 21 score *= current_score |
| 22 reason += '%d. %s (score: %d)\n' % (i + 1, current_reason, current_score) |
| 23 |
| 24 reason += '\n%s' % str(result) |
| 25 |
| 26 result.confidence = score |
| 27 result.reason = reason |
| OLD | NEW |