-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary.h
More file actions
35 lines (23 loc) · 900 Bytes
/
dictionary.h
File metadata and controls
35 lines (23 loc) · 900 Bytes
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
#ifndef BINARY_SEARCH_TREE_DICTIONARY_H
#define BINARY_SEARCH_TREE_DICTIONARY_H
#include <utility>
#include <ostream>
#include <string>
#include "search_tree.h"
class dictionary {
private:
search_tree<std::string, std::vector<std::string>> tree;
std::string pathToDict;
void loadDictionary();
static std::vector<std::string> split(const std::string& str, char separator);
public:
explicit dictionary(std::string pathToDict = "../dictionary.properties") :
tree(), pathToDict(std::move(pathToDict)) {
loadDictionary();
}
std::vector<std::string> search(const std::string& toTranslate);
void add(const std::string& word, const std::vector<std::string>& translations);
void remove(const std::string& key);
friend std::ostream &operator<<(std::ostream& os, const dictionary& dictionary);
};
#endif //BINARY_SEARCH_TREE_DICTIONARY_H