Advertisement
dxvmxnd

Untitled

Dec 11th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <set>
  4. #include <cctype>
  5.  
  6. using namespace std;
  7.  
  8. set<string> createPossibleVocabulary(bool& englishLanguage) {
  9.  
  10. string path;
  11. set<string> vocabulary = {};
  12.  
  13. if (englishLanguage) {
  14. path = "..\\..\\englishvocabulary.txt";
  15. }
  16. else {
  17. path = "..\\..\\russianvocabulary.txt";
  18. }
  19.  
  20. string word = "";
  21.  
  22.  
  23. ifstream fin(path);
  24. if (!fin.is_open()) {
  25. printf("Какая-то ошибка с файлом.");
  26. }
  27. else {
  28. while (fin >> word) {
  29. vocabulary.insert({ word });
  30. }
  31. }
  32. fin.close();
  33.  
  34. return vocabulary;
  35.  
  36. }
  37.  
  38. void addNewWord(string line, set<string>& vocabulary, bool& englishLanguage) {
  39.  
  40. string path;
  41. string word = "";
  42.  
  43. if (englishLanguage) {
  44. path = "..\\..\\englishvocabulary.txt";
  45. }
  46. else {
  47. path = "..\\..\\russianvocabulary.txt";
  48. }
  49.  
  50. ofstream fout(path, fstream::app);
  51. fout << "\n" << line;
  52. fout.close();
  53.  
  54. vocabulary.insert({ line });
  55.  
  56. }
  57.  
  58. void lowcase(string& word) {
  59. for (char& c : word) {
  60. c = tolower(c);
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement