forked from azk0019/CourseProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.py
29 lines (22 loc) · 951 Bytes
/
search.py
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
27
28
29
from apps.backend.utils.facultydb import FacultyDB
from apps.backend.utils.ranker import Ranker
class Search:
def __init__(self):
pass
def get_search_results(self, query, num_of_results, university_filter, dept_filter, location_filter):
try:
# print("Corpus Method")
corpus = FacultyDB().get_biodata_records(university_filter, dept_filter, location_filter)
#print(corpus)
ranked_id_list = Ranker(corpus).score(query, num_of_results)
#print(ranked_id_list)
search_results_list = FacultyDB().get_faculty_records(ranked_id_list)
print(search_results_list )
return search_results_list
except Exception as e:
print(f"Unexpected exception encountered: {e}")
return []
if __name__ == '__main__':
# print("Main")
search = Search()
search.get_search_results("ANOOP BN","Manipal","Sikkim")