Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SearchServer::Query SearchServer::ParseQuery(const string& text) const {
- Query query;
- for (const string& word : SplitIntoWords(text)) {
- if (word == "-"s) {
- throw invalid_argument("После знака \"-\" отсутствует слово.");
- }
- QueryWord query_word = ParseQueryWord(word);
- if (!query_word.is_stop) {
- if (query_word.is_minus && (find(query.minus_words.begin(), query.minus_words.end(), query_word.data) == query.minus_words.end())) {
- query.minus_words.push_back(query_word.data);
- } else if (find(query.plus_words.begin(), query.plus_words.end(), query_word.data) == query.plus_words.end()) {
- query.plus_words.push_back(query_word.data);
- }
- }
- }
- //cout << "PLUS:" << endl;
- //for (auto w : query.plus_words) {
- // cout << w << endl;
- //}
- //cout << "MINUS:" << endl;
- //for (auto w : query.minus_words) {
- // cout << w << endl;
- //}
- return query;
- }
Advertisement
Add Comment
Please, Sign In to add comment