-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (47 loc) · 1.29 KB
/
main.cpp
File metadata and controls
59 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <string>
#include <cctype>
#include <vector>
#include <iostream>
#include "lib/Dictionary.h"
using namespace std;
int main() {
Dictionary dict;
dict.loadFromFile("./res/words_unix.txt");
dict.loadFromFile("./res/words_alpha.txt");
cout << "Loaded " << dict.getWordCount() << " words." << endl;
const char* searchWords[] = {
"gess",
"manga",
"mango",
"nerdy",
"dictionary",
"zwitterionic",
"ngaudifnkjlvdkvl"
};
for (const char* word : searchWords) {
cout << word << ' ' << dict.searchWord(word) << endl;
}
cout << endl << "Welcome to the world's \"fastest\" notepad. Type away! (press esc+enter to escape)" << endl << endl;
string word = "";
vector<string> words;
while (true) {
const char ch = cin.get();
if (ch == 27) {
break;
}
if (isalnum(ch)) word += ch;
else {
if (!word.empty()) {
words.push_back(word);
word.clear();
}
}
}
cout << endl << "Your english:" << endl;
for (const auto& w : words) {
cout << w << ' ';
if (dict.searchWord(w.c_str())) cout << "...ok" << endl;
else cout << "...lol" << endl;
}
return 0;
}