[Zope] RE: ZCatalog Indexing
Jason Spisak
444@hiretechs.com
Tue, 28 Mar 2000 12:30:06 -0500
Tobias,
The Catalgo uses a stripper to make the indexes smaller. It doesn't
index =-+*&)(^%$#@. etc... or numbers. Some words too like 'Bill'. From
what I've been told there is a version of the Catalog on it's way which
will allow you to put keywords or charaters in a special place that will
include them. I couldn't wait for that, and I love Zope, so I came up
with a major kludge. catalog_quote() and catalog_unquote(). They are
from an External Method which I wrote catalog_quote.py. Here it is:
from string import strip, split, join, uppercase, lowercase, find
bad_characters=(('.'),
('+'),
('-'),
(';'),
(':'),
('&'),
('*'),
('%'),
('#'),
('@'),
('$'),
('0'),
('1'),
('2'),
('3'),
('4'),
('5'),
('6'),
('7'),
('8'),
('9'))
def catalog_quote(self, ascii):
text = str(ascii)
for re in bad_characters:
if find(text, re) >= 0: text=join(split(text,re),ordinalize(re))
return text
def ordinalize(letter):
number = ord(letter)
number_string = str(number)
myletters = lowercase[-5:] + uppercase[-10:]
converted = ''
for character in number_string:
converted = converted + myletters[int(character)]
return converted + 'g'
def catalog_unquote(self, ascii):
text = str(ascii)
for un in bad_characters:
if find(text, ordinalize(un)) >= 0:
text=join(split(text,ordinalize(un)),un)
return text
I just use it to turn anything that might contain the charaters in
bad_charaters into catalogable stuff.
Then when you search, you must catalog_quote() your search strings, and
you'll get 100% accurate results. Hope this helps.
All my best,
--
Jason Spisak
444@hiretechs.com