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

Unified Diff: appengine/findit/crash/occurrence.py

Issue 2649503002: [Predator] Switch from scorer-based classifier to loglinear classifier. (Closed)
Patch Set: Fix nits. Created 3 years, 10 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/findit_for_chromecrash.py ('k') | appengine/findit/crash/predator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/crash/occurrence.py
diff --git a/appengine/findit/crash/occurrence.py b/appengine/findit/crash/occurrence.py
index 4345810e837eb85b8d5c6e43f0821c6096358e8f..59bb14e95e07b78ef5d41fe6aff15e8851adc923 100644
--- a/appengine/findit/crash/occurrence.py
+++ b/appengine/findit/crash/occurrence.py
@@ -40,6 +40,9 @@ def GetOccurrences(names):
"""
occurrences = {}
for index, name in enumerate(names or []):
+ if not name:
+ continue
+
if name not in occurrences:
occurrences[name] = Occurrence(name, [index])
else:
@@ -100,12 +103,7 @@ def RankByOccurrence(names, top_n, rank_function=None):
if not rank_function: # pragma: no cover.
rank_function = DefaultOccurrenceRanking
- # TODO(wrengr): can't we do this sorting/filtering/truncation in one pass?
- occurrences = sorted(GetOccurrences(names).values(), key=rank_function)
-
- # Filter out unnamed classes. Alas, we can't sort these out before
- # constructing the concordance, because then our indices would be off.
# TODO(wrengr): generalize the filter function into another parameter.
- classes = [occurrence.name for occurrence in occurrences if occurrence.name]
+ occurrences = sorted(GetOccurrences(names).values(), key=rank_function)
- return classes[:top_n]
+ return [occurrence.name for occurrence in occurrences[:top_n]]
« no previous file with comments | « appengine/findit/crash/findit_for_chromecrash.py ('k') | appengine/findit/crash/predator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698