[open-ils-commits] r1145 - servres/trunk/conifer/syrup (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Dec 29 10:42:57 EST 2010
Author: gfawcett
Date: 2010-12-29 10:42:54 -0500 (Wed, 29 Dec 2010)
New Revision: 1145
Modified:
servres/trunk/conifer/syrup/models.py
Log:
sort item titles case-insensitively.
I also moved the STOPWORDS definition out of the function body, to save a few
CPU cycles.
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2010-12-29 15:42:52 UTC (rev 1144)
+++ servres/trunk/conifer/syrup/models.py 2010-12-29 15:42:54 UTC (rev 1145)
@@ -304,19 +304,12 @@
subtree element, or None if there is no match.
"""
+ # TODO: internationalize the stopwords list.
+ STOPWORDS = set(['a', 'an', 'that', 'there', 'the', 'this'])
+
def sort_title(item):
"""First cut of a stop words routine."""
- # TODO: this needs to either be in its own file or in settings
- stopwords = '''
- a
- an
- that
- there
- the
- this
- '''.split()
-
- normal_text = [t for t in item.split() if t.lower() not in stopwords]
+ normal_text = [t for t in item.lower().split() if t not in STOPWORDS]
return " ".join(normal_text)
items = self.items()
More information about the open-ils-commits
mailing list