[kupfer] search: Rank aliases only if main value is not perfect
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] search: Rank aliases only if main value is not perfect
- Date: Fri, 11 Sep 2009 16:10:54 +0000 (UTC)
commit 95ddb00416e870c18c57fa6aba83f52968b29aac
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Fri Sep 11 14:47:26 2009 +0200
search: Rank aliases only if main value is not perfect
I want some aliases to show up even if the original name has a match,
if rank < 90, it is not a perfect match, so we try aliases.
kupfer/search.py | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/kupfer/search.py b/kupfer/search.py
index cf92df4..065a229 100644
--- a/kupfer/search.py
+++ b/kupfer/search.py
@@ -62,14 +62,14 @@ def score_objects(rankables, key):
for rb in rankables:
# Rank object
rank = score(rb.value, key)*100
- maxval = None
- for alias in rb.aliases:
- # consider aliases and change rb.value if alias is better
- # aliases rank lower so that value is chosen when close
- arank = score(alias, key)*95
- if arank > rank:
- rank = arank
- rb.value = alias
+ if rank < 90:
+ for alias in rb.aliases:
+ # consider aliases and change rb.value if alias is better
+ # aliases rank lower so that value is chosen when close
+ arank = score(alias, key)*95
+ if arank > rank:
+ rank = arank
+ rb.value = alias
if rank:
rb.rank = rank
yield rb
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]