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
60
61
62
63
64
65
66
67
68
69
70
71
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "aspell.h"
AspellConfig *spell_config = NULL;
AspellSpeller *spell_checker = 0;
/*int
main(int argc, const char *argv[])*/
int
check_word (char *lang, char *word)
{
int correct = 0;
int word_length = 0;
if (lang == NULL)
{
lang = "ml";
}
word_length = strlen (word);
spell_config = new_aspell_config ();
aspell_config_replace (spell_config, "lang", lang);
aspell_config_replace (spell_config, "encoding", "utf-8");
AspellCanHaveError *possible_err = new_aspell_speller (spell_config);
if (aspell_error_number (possible_err) != 0)
puts (aspell_error_message (possible_err));
else
spell_checker = to_aspell_speller (possible_err);
correct = aspell_speller_check (spell_checker, word, word_length);
if (correct == 0)
{
printf ("word \"%s\" is wrong.\n", word);
}
else
{
printf ("word \"%s\" is correct.\n", word);
exit (0);
}
return correct;
}
void
get_suggestion_list (char *word)
{
const char *sugg_word;
int suggestion_count = 0;
int word_length = 0;
AspellWordList *suggestions = NULL;
suggestions = aspell_speller_suggest (spell_checker, word, word_length);
AspellStringEnumeration *aspell_elements =
aspell_word_list_elements (suggestions);
while ((sugg_word =
aspell_string_enumeration_next (aspell_elements)) != NULL)
{
printf ("%d. %s\n", ++suggestion_count, sugg_word);
}
delete_aspell_string_enumeration (aspell_elements);
}
|