| 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 that aggregates results from different scorers.""" |
| 6 |
| 7 from crash.scorers import aggregators |
| 8 |
| 9 |
| 10 class AggregatedScorer(object): |
| 11 |
| 12 def __init__(self, scorers): |
| 13 self.scorers = scorers |
| 14 |
| 15 def Score(self, result, |
| 16 score_aggregator=aggregators.Multiplier(), |
| 17 reasons_aggregator=aggregators.IdentityAggregator(), |
| 18 changed_files_aggregator=aggregators.ChangedFilesAggregator()): |
| 19 """Aggregates score, reasons and changed_files from all the scorers. |
| 20 |
| 21 Note: This method sets confidence, reasons and changed_files of results. |
| 22 """ |
| 23 # Transforms array of [(score1, reason1, changed_files1), (score2, reason2, |
| 24 # changed_files2)] to [(score1, score2), (reason1, reason2), |
| 25 # (changed_files1, changed_files2)] for aggregators to aggregate. |
| 26 scores, reasons, changed_files = zip(*[ |
| 27 scorer(result) for scorer in self.scorers]) |
| 28 |
| 29 result.confidence = score_aggregator(list(scores)) |
| 30 result.reasons = reasons_aggregator(list(reasons)) |
| 31 result.changed_files = changed_files_aggregator(list(changed_files)) |
| 32 |
| 33 return result.confidence, result.reasons, result.changed_files |
| OLD | NEW |