Commit 4f132f06 authored by sophia's avatar sophia
Browse files

search

parent 9e6f87ab
Branches
No related merge requests found
Showing with 2 additions and 2 deletions
......@@ -94,7 +94,7 @@ std::vector<std::string_view> Search(std::string_view text, std::string_view que
for (size_t line_num = 0; line_num < all_words_of_all_lines.size(); ++line_num) {
long double tf_idf_for_line = 0;
for (std::string_view que : unique_queries) {
if (all_words_of_all_lines[line_num].empty() || counts_of_texts[que] == 0) {
if (counts_of_texts[que] == 0) {
continue;
}
const long double tf = static_cast<long double>(counts_of_words_of_lines[line_num][que]) /
......@@ -109,7 +109,7 @@ std::vector<std::string_view> Search(std::string_view text, std::string_view que
}
std::sort(tf_idf_for_all_query.begin(), tf_idf_for_all_query.end(),
[](const std::pair<long double, std::string_view>& a, const std::pair<long double, std::string_view>& b) {
return a.first >= b.first;
return a.first > b.first;
});
for (size_t i = 0; i < results_count; ++i) {
if (i >= tf_idf_for_all_query.size()) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment