4 ms·
If you want full-text search in the data store Google gives you App Engine you end up doing about the same thing. One thing though, when indexing text you defin
by hedgehog 18y ago
If you want full-text search in the data store Google gives you App Engine you end up doing about the same thing. One thing though, when indexing text you definitely want to stem the words and remove the duplicates. You can implement a Porter stemmer (probably the right thing to do) or use a quick and dirty one something like this:
tails = 'ally ion ive ing ies ed ly al es e s n y'.split()
def stem(self, s):
slen = len(s)
for t in tails:
if s[-1 * len(t):] == t:
s = s[:-1 * len(t)]
break
if len(s) > 2 and len(s) < slen and s[-1] == s[-2]:
s = s[:-1]
return s