-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpellChecker.hpp
More file actions
39 lines (25 loc) · 882 Bytes
/
SpellChecker.hpp
File metadata and controls
39 lines (25 loc) · 882 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
36
37
38
39
//(C) 2020, dan-gubkin@mail.ru
#ifndef SPELL_CHECKER_H_
#define SPELL_CHECKER_H_
#include "Dictionary.hpp"
#include <map>
typedef std::map<size_t, const char*> Result; // value - position into dictionary
class SpellChecker final{
public:
/*
* params:
* word - checked word
* dict - dictionary
* res - result
* returns:
* true if word is correct, overwise - false
* in the case of founded corrections res has len more than 0
*/
bool correct(const char* word, Dictionary& dict, Result& res);
private:
typedef std::map<std::string, size_t> Candidates; // value - modified position
void edits_add(const std::string& word, Candidates& result, ssize_t except);
void edits_del(const std::string& word, Candidates& result, ssize_t except);
void edits_second(const Candidates& add, const Candidates& del, Candidates& result);
};
#endif //SPELL_CHECKER_H_