Advertisement
Mosaic

practicum.yandex.ru Основы C++ | Тема 3. Структуры и классы | Урок 6: Методы классов | Задача 2/5

Jan 23rd, 2022 (edited)
1,182
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class SearchServer {
  2.     public:
  3.     void AddDocument(int document_id, const string& document) {
  4.         const vector<string> words = SplitIntoWordsNoStop(document);
  5.         documents_.push_back({document_id, words});
  6.     }
  7.  
  8. private:
  9.     struct DocumentContent {
  10.         int id = 0;
  11.         vector<string> words;
  12.     };
  13.  
  14.     vector<DocumentContent> documents_;
  15.     set<string> stop_words_;
  16.    
  17.     vector<string> SplitIntoWordsNoStop(const string& text) {
  18.     vector<string> words;
  19.     for (const string& word : SplitIntoWords(text)) {
  20.         if (stop_words_.count(word) == 0) {
  21.             words.push_back(word);
  22.         }
  23.     }
  24.     return words;
  25.     }  
  26. };
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement