-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (35 loc) · 1.11 KB
/
Copy pathmain.cpp
File metadata and controls
44 lines (35 loc) · 1.11 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
39
40
41
42
43
44
#include "searchserver.h"
int main()
{
std::vector<std::string> searchRequest;
try{ searchRequest = ConverterJSON::GetRequest(); }
catch (nlohmann::json::parse_error &e)
{
std::cerr << "File error in request.json. Details: " << e.what() << std::endl;
return 0;
}
catch(const std::exception &ex){
std::cerr << ex.what() << std::endl;
return 0;
}
InvertedIndex idx;
try{ idx.UpdateDocumentBase(ConverterJSON::GetTextDocuments()); }
catch (nlohmann::json::parse_error &e)
{
std::cerr << "File error in config.json. Details: " << e.what() << std::endl;
return 0;
}
catch(const std::exception &ex){
std::cerr << ex.what() << std::endl;
return 0;
}
std::vector<std::vector<Entry>> results;
for(auto& request : searchRequest) {
std::vector<Entry> word_count = idx.GetWordCount(request);
results.push_back(word_count);
}
SearchServer srv(idx);
std::vector<std::vector<RelativeIndex>> answer = srv.search(searchRequest);
ConverterJSON::putAnswers(answer);
return 0;
}