Seredenko-V

ParseQuery

Aug 2nd, 2022
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. SearchServer::Query SearchServer::ParseQuery(const string& text) const {
  2.     Query query;
  3.     for (const string& word : SplitIntoWords(text)) {
  4.         if (word == "-"s) {
  5.             throw invalid_argument("После знака \"-\" отсутствует слово.");
  6.         }
  7.         QueryWord query_word = ParseQueryWord(word);
  8.         if (!query_word.is_stop) {
  9.             if (query_word.is_minus && (find(query.minus_words.begin(), query.minus_words.end(), query_word.data) == query.minus_words.end())) {
  10.                 query.minus_words.push_back(query_word.data);
  11.             } else if (find(query.plus_words.begin(), query.plus_words.end(), query_word.data) == query.plus_words.end()) {
  12.                 query.plus_words.push_back(query_word.data);
  13.             }
  14.         }
  15.     }
  16.     //cout << "PLUS:" << endl;
  17.     //for (auto w : query.plus_words) {
  18.     //    cout << w << endl;
  19.     //}
  20.     //cout << "MINUS:" << endl;
  21.     //for (auto w : query.minus_words) {
  22.     //    cout << w << endl;
  23.     //}
  24.     return query;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment