Commit a500dea7 authored by chris's avatar chris

fixed bug in Index.__getitem__() which caused a TypeError

when searching for a stopword
parent 285ecf40
...@@ -30,7 +30,7 @@ Example usage: ...@@ -30,7 +30,7 @@ Example usage:
print i['blah'] print i['blah']
$Id: InvertedIndex.py,v 1.42 1997/04/24 14:20:32 chris Exp $''' $Id: InvertedIndex.py,v 1.43 1997/04/25 15:42:07 chris Exp $'''
# Copyright # Copyright
# #
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne # Copyright 1996 Digital Creations, L.C., 910 Princess Anne
...@@ -82,6 +82,10 @@ $Id: InvertedIndex.py,v 1.42 1997/04/24 14:20:32 chris Exp $''' ...@@ -82,6 +82,10 @@ $Id: InvertedIndex.py,v 1.42 1997/04/24 14:20:32 chris Exp $'''
# (540) 371-6909 # (540) 371-6909
# #
# $Log: InvertedIndex.py,v $ # $Log: InvertedIndex.py,v $
# Revision 1.43 1997/04/25 15:42:07 chris
# fixed bug in Index.__getitem__() which caused a TypeError
# when searching for a stopword
#
# Revision 1.42 1997/04/24 14:20:32 chris # Revision 1.42 1997/04/24 14:20:32 chris
# Fixed small bug in Index.__init__() # Fixed small bug in Index.__init__()
# #
...@@ -223,7 +227,7 @@ $Id: InvertedIndex.py,v 1.42 1997/04/24 14:20:32 chris Exp $''' ...@@ -223,7 +227,7 @@ $Id: InvertedIndex.py,v 1.42 1997/04/24 14:20:32 chris Exp $'''
# #
# #
# #
__version__='$Revision: 1.42 $'[11:-2] __version__='$Revision: 1.43 $'[11:-2]
import regex, string, copy import regex, string, copy
...@@ -610,7 +614,7 @@ class Index: ...@@ -610,7 +614,7 @@ class Index:
addentry = self.addentry addentry = self.addentry
for word, positions in d.items(): for word, positions in d.items():
freq = int(100 * (len(positions) / nwords)) freq = int(100 * (len(positions) / nwords))
addentry(word,srckey,(freq, positions)) addentry(word,srckey,(freq, tuple(positions)))
def addentry(self,word,key,data): def addentry(self,word,key,data):
...@@ -674,7 +678,7 @@ class Index: ...@@ -674,7 +678,7 @@ class Index:
except KeyError: except KeyError:
break break
else: else:
if (key[0] == '"'): if ((key is not None) and (key[0] == '"')):
ws = WordSequence(key, self.synstop) ws = WordSequence(key, self.synstop)
ws = map(lambda x, self = self: self[x], ws) ws = map(lambda x, self = self: self[x], ws)
return reduce(lambda x, y: x.near(y), ws) return reduce(lambda x, y: x.near(y), ws)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment