[kupfer] relevance: Tweak empty query checks
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] relevance: Tweak empty query checks
- Date: Fri, 11 Sep 2009 16:11:09 +0000 (UTC)
commit 874ba20d3345ca964084dca3a0ca51a4b3bbfcec
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Fri Sep 11 15:17:31 2009 +0200
relevance: Tweak empty query checks
if len(query) == 0 -> to pythonic if not query
_findBestMatch returns 0,0 with empty query, not ""; this path of code
is not taken at all here anyway, so removing the if.
kupfer/relevance.py | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/kupfer/relevance.py b/kupfer/relevance.py
index d2f7549..a01ac3b 100644
--- a/kupfer/relevance.py
+++ b/kupfer/relevance.py
@@ -105,8 +105,8 @@ def score(s, query):
>>> print score('terminal', 'tlm')
0.0
"""
- if len(query) == 0:
- return 1
+ if not query:
+ return 1.0
score = float(0)
ls = s.lower()
@@ -185,9 +185,6 @@ def _findBestMatch(s, query):
>>> _findBestMatch('teerminal', 'erml')
(2, 9)
"""
- if len(query) == 0:
- return 0, 0
-
index = -1
bestMatch = -1, -1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]