1.1 --- a/tests/Dict.py Wed Sep 28 16:15:15 2005 +0000
1.2 +++ b/tests/Dict.py Wed Sep 28 16:15:49 2005 +0000
1.3 @@ -27,10 +27,26 @@
1.4
1.5 words = []
1.6 for token in tokens:
1.7 + token = self._strip(token)
1.8 if token not in words:
1.9 channel.send((token, self.dict_location))
1.10 words.append(token)
1.11
1.12 + def _strip(self, token):
1.13 +
1.14 + "Return the token stripped of non-alphanumeric symbols at each end."
1.15 +
1.16 + characters = []
1.17 + in_alphanum = 0
1.18 + for c in token:
1.19 + if not c.isalpha() and not c.isdigit():
1.20 + if in_alphanum:
1.21 + break
1.22 + else:
1.23 + in_alphanum = 1
1.24 + characters.append(c)
1.25 + return "".join(characters)
1.26 +
1.27 class Indexer:
1.28 def __init__(self):
1.29 self.index = {}