Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3045)

Unified Diff: appengine/findit/crash/scorers/min_distance.py

Issue 1861373003: [Findit] Initial code of findit for crash. Add scorers to apply heuristic rules. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nits and rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/crash/scorers/aggregator.py ('k') | appengine/findit/crash/scorers/scorer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/scorers/min_distance.py
diff --git a/appengine/findit/crash/scorers/min_distance.py b/appengine/findit/crash/scorers/min_distance.py
new file mode 100644
index 0000000000000000000000000000000000000000..06f52ae571b3d937a39fff479eaa067ceb62e97c
--- /dev/null
+++ b/appengine/findit/crash/scorers/min_distance.py
@@ -0,0 +1,46 @@
+# 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.
+
+"""MinDistance scorer applies to MatchResult objects.
+
+It represents a heuristic rule:
+ 1. Highest score if the result changed the crashed lines.
+ 2. 0 score if changed lines are too far away from crashed lines.
+"""
+
+import logging
+
+from crash.scorers.scorer import Scorer
+
+_MAX_DISTANCE = 50
+
+
+class MinDistance(Scorer):
+
+ def __init__(self, max_distance=_MAX_DISTANCE):
+ self.max_distance = max_distance
+
+ def GetMetric(self, result):
+ if not hasattr(result, 'min_distance'):
+ logging.warning('Scorer %s only applies to MatchResult', self.name)
+ return None
+
+ return result.min_distance
+
+ def Score(self, min_distance):
+ if min_distance > self.max_distance:
+ return 0
+
+ if min_distance == 0:
+ return 1
+
+ # TODO(katesonia): This number is randomly picked from a reasonable range,
+ # best value to use still needs be experimented out.
+ return 0.8
+
+ def Reason(self, min_distance, score):
+ if score == 0:
+ return ''
+
+ return 'Minimum distance to crashed line is %d' % min_distance
« no previous file with comments | « appengine/findit/crash/scorers/aggregator.py ('k') | appengine/findit/crash/scorers/scorer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698