Use regexp during search computation
This commit is contained in:
parent
12b43ffbed
commit
5010f768d4
18
search.py
18
search.py
|
@ -192,16 +192,16 @@ class Search:
|
|||
if len(word) < Search.MINIMUM_LETTERS:
|
||||
continue
|
||||
word = word.lower()
|
||||
while not word in hashtable and len(word) > Search.MINIMUM_LETTERS:
|
||||
word = word[:-1]
|
||||
if word not in hashtable:
|
||||
continue
|
||||
for post in hashtable[word]:
|
||||
if not post[0] in res:
|
||||
res[post[0]] = post[1]
|
||||
res[post[0]] += post[1]
|
||||
sorted_res = sorted(res.iteritems(), key=operator.itemgetter(1))
|
||||
reg = re.compile('.*' + word + '.*')
|
||||
for key in hashtable.keys():
|
||||
if reg.match(key):
|
||||
for post in hashtable[key]:
|
||||
if not post[0] in res:
|
||||
res[post[0]] = post[1]
|
||||
else:
|
||||
res[post[0]] += post[1]
|
||||
|
||||
sorted_res = sorted(res.iteritems(), key=operator.itemgetter(1))
|
||||
sorted_res.reverse()
|
||||
|
||||
res = []
|
||||
|
|
Loading…
Reference in New Issue
Block a user