From be8a067f89e5a99c6a898d13a4edf14eaf5db9fd Mon Sep 17 00:00:00 2001 From: gfawcett Date: Wed, 29 Dec 2010 15:42:54 +0000 Subject: [PATCH] sort item titles case-insensitively. I also moved the STOPWORDS definition out of the function body, to save a few CPU cycles. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@1145 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/models.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index 43eeb17..182541b 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -304,19 +304,12 @@ class Site(BaseModel): 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() -- 2.11.0