-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_mode.py
More file actions
26 lines (22 loc) · 790 Bytes
/
Copy pathsearch_mode.py
File metadata and controls
26 lines (22 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from search_engine import search_phrase, search_words
from paragraph import print_result
from rank import rank
def words_search(trie, words, hashmap, graph):
print("Search results:\n")
result = search_words(trie, words, graph, hashmap)
if len(result) > 0:
if isinstance(result[0], tuple):
sorted_pages = result
else:
sorted_pages = rank(result, graph)
print_result(sorted_pages, hashmap, words, 1)
else:
print("No results found")
def phrase_search(phrase, hashmap, graph):
print("Search results:\n")
result = search_phrase(phrase, hashmap)
if len(result) > 0:
sorted_pages = rank(result, graph)
print_result(sorted_pages, hashmap, phrase, 0)
else:
print("No results found")