-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspell-checker.c
50 lines (43 loc) · 1 KB
/
spell-checker.c
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
#include <stdlib.h>
#include "spell-checker.h"
#include "spell-checker_runner.h"
typedef struct _SpellCheckerDictionary
{
SpellCheckerRunnerHandle runner;
} _SpellCheckerDictionary;
SpellCheckerDictionaryHandle createSpellCheckerDictionary()
{
SpellCheckerDictionaryHandle dict = malloc(sizeof(_SpellCheckerDictionary));
if (dict)
{
dict->runner = scrInit();
if (!dict->runner)
{
free(dict);
return NULL;
}
}
return dict;
}
int closeSpellCheckerDictionary(SpellCheckerDictionaryHandle dict)
{
if (dict)
{
scrFinalize(dict->runner);
free(dict);
}
return 0;
}
int spellCheckerAddWord(SpellCheckerDictionaryHandle dict, const char *word)
{
if (!dict || !word)
{
return -1;
}
return scrAddWord(dict->runner, word);
}
void spellCheck(SpellCheckerDictionaryHandle dict, const char *text,
SpellCheckerCallback callback)
{
scrRunSpellCheck(dict->runner, text, callback);
}