use a better split on words

This commit is contained in:
Frédéric Péters 2013-08-22 10:29:41 +02:00
parent f79fe1838e
commit bf7de54824
1 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import json
import re
from zope.interface import implementer
from zope.interface import implements
@ -127,6 +128,7 @@ class ListKeywordsView(BrowserView):
intermediate = []
other = []
q = query_string.lower()
regex = re.compile(r"[\s'()]")
for normalized, title, id in self.getItems():
for term in query_terms:
if not term in title.lower():
@ -136,7 +138,7 @@ class ListKeywordsView(BrowserView):
if title.lower().startswith(q):
startswith.append((normalized, item))
continue
for word in title.split():
for word in regex.split(title):
if word.lower().startswith(q):
intermediate.append((normalized, item))
break