[Zope] Ignore stopwords/characters in alphabetical results
Ken Ara
feedreader at yahoo.com
Tue Feb 7 05:26:26 EST 2006
Thanks Dieter and others for helping me understand
this problem.
In the end I added the following code to my product:
def norm_title(self):
"""Returns a normalized copy of the title for
sorting purposes"""
nt = ''
if hasattr(self, 'title'):
nt = re.sub('^A |^An |^The |\W', ' ',
self.title)
nt = join(split(nt))
return nt
I then added a norm_title index to my ZCatalog for
sorting. I'm a regex newbie so any improvements are
welcome!
Thanks,
Ken
--- Dieter Maurer <dieter at handshake.de> wrote:
> Ken Ara wrote at 2006-2-2 00:41 -0800:
> >I have been asked to improve the order of search
> >results, so that stop words and certain characters
> at
> >the beginning of a title are ignored. "Final
> Report",
> >"The Final Report" and "[Final] Report" all need to
> >appear under the letter 'F'.
>
> Thus, you only want the change the result order.
>
> Unless you want relevancy ranking (which is not the
> case,
> depending on your description), ordering has nothing
> to
> do with the indexes (at least not the text indexes).
>
> Ordering can be done with "sequence.sort"
> (documented in
> the Zope Online help system) or with Python's "sort"
> method.
> In both cases, you can provide your own comparison
> function.
> The comparison faction to use the vocabulary to
> check for
> stopwords (words not known by the vocabulary are
> stopwords).
>
> --
> Dieter
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Zope
mailing list