[kupfer] relevance: Update docstrings
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] relevance: Update docstrings
- Date: Sun, 13 Sep 2009 22:53:21 +0000 (UTC)
commit 5246c21b2a61fa6bc63f27be1988f84d17da54c9
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sun Sep 13 16:07:15 2009 +0200
relevance: Update docstrings
Docstrings in relevance use *string* since the functions should be
completely compatible with either str or unicode, as long as `s' and
`query' are passed in of the same type.
kupfer/relevance.py | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/kupfer/relevance.py b/kupfer/relevance.py
index 15a831d..ef48db9 100644
--- a/kupfer/relevance.py
+++ b/kupfer/relevance.py
@@ -82,15 +82,18 @@ def formatCommonSubstrings(s, query, format_clean=None, format_match=None):
def score(s, query):
"""
A relevancy score for the string ranging from 0 to 1
-
- @s: a str to be scored
- @query: a str query to score against
-
+
+ @s: a string to be scored
+ @query: a string query to score against
+
+ `s' is treated case-insensitively while `query' is interpreted literally,
+ including case and whitespace.
+
Returns: a float between 0 and 1
-
+
>>> print score('terminal', 'trml')
0.735098684211
- >>> print score('terminal', 'term')
+ >>> print score(u'terminal', u'term')
0.992302631579
>>> print score('terminal', 'try')
0.0
@@ -157,15 +160,15 @@ def score(s, query):
score = .9 * score
return score
-
+
def _findBestMatch(s, query):
"""
Finds the shortest substring of @s that contains all characters of query
in order.
-
- @s: a str to search
- @query: a str query to search for
-
+
+ @s: a string to search
+ @query: a string query to search for
+
Returns: a two-item tuple containing the start and end indicies of
the match. No match returns (-1,-1).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]