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