Chromium Code Reviews| 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 curr_score, curr_reason = scorer(result) | |
|
stgao
2016/04/15 18:35:19
no abbreviation.
Sharu
2016/04/15 22:59:47
Done.
| |
| 19 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.
| |
| 20 reason += '%d. %s (score: %d)\n' % (i + 1, curr_reason, curr_score) | |
| 21 | |
| 22 reason += '\n%s' % str(result) | |
| 23 | |
| 24 result.confidence = score | |
| 25 result.reason = reason | |
| OLD | NEW |