-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (34 loc) · 1.24 KB
/
main.cpp
File metadata and controls
38 lines (34 loc) · 1.24 KB
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
30
31
32
33
34
35
36
37
38
/*
* Command-line interface to take search query, compare it to data processed by Search class,
* and present the results to the user.
* Coded by Samy Katibi.
*/
#include <iostream>
#include "search.cpp"
int main(){
std::cout << "Welcome to Gem search. Since this is the first time running the program, please wait a few seconds for the functions to initialize." << std::endl;
std::string query;
Search s = Search();
s.loadData();
std::vector<string> results;
std::vector<double> percentages;
while(true){
std::cout << "Please enter your search query (Enter Exit to exit the program): ";
getline(cin, query);
if(query == "Exit"){
break;
}
std::cout << "Please wait..." << std::endl;
// Convert query into lowercase
for(int i = 0; i < query.length(); i++){
query[i] = tolower(query[i]);
}
results = s.getTopSites_Block(query);
percentages = s.getTopScores_Block(query);
std::cout << "Results: Name: Percentage Match with query:" << std::endl;
for(int j = 0; j < 10; j++){
std::cout << results[j] << " ----------- " << percentages[j] << "%" << std::endl;
}
}
return 0;
}