1 | /* Copyright (C) 2003-2012 Nadav Har'El and Dan Kenigsberg */ |
2 | |
3 | /* This header file defines the Hspell Hebrew spellchecking API in C, as |
4 | implemented by the libhspell.a library. |
5 | Please check out the hspell(3) manual for more information on how to use |
6 | the Hspell C interface. |
7 | */ |
8 | #ifndef INCLUDED_HSPELL_H |
9 | #define INCLUDED_HSPELL_H |
10 | |
11 | /* The following macros can be used to verify which version of the Hspell |
12 | API this header file supports. Note that this API might change. |
13 | */ |
14 | #define HSPELL_VERSION_MAJOR 1 |
15 | #define HSPELL_VERSION_MINOR 2 |
16 | #define HSPELL_VERSION_EXTRA "" |
17 | |
18 | |
19 | struct dict_radix; |
20 | struct corlist; |
21 | |
22 | /* flags for hspell_init: */ |
23 | #define HSPELL_OPT_DEFAULT 0 |
24 | #define HSPELL_OPT_HE_SHEELA 1 /* flag to accept He Ha-she'ela */ |
25 | #define HSPELL_OPT_LINGUISTICS 2 /* initialize morphological analyzer, |
26 | not just spell-checker */ |
27 | |
28 | int hspell_init(struct dict_radix **dictp, int flags); |
29 | |
30 | int hspell_check_word(struct dict_radix *dict, |
31 | const char *word, int *preflen); |
32 | void hspell_trycorrect(struct dict_radix *dict, |
33 | const char *w, struct corlist *cl); |
34 | unsigned int hspell_is_canonic_gimatria(const char *w); |
35 | |
36 | void hspell_uninit(struct dict_radix *dict); |
37 | |
38 | const char *hspell_get_dictionary_path(void); |
39 | void hspell_set_dictionary_path(const char *path); |
40 | |
41 | extern int hspell_debug; |
42 | |
43 | /* Corlist is our simple data structure for holding a list of corrections |
44 | * returned by hspell_trycorrect. This silly implementation has fixed sizes! |
45 | * A no-no in good programming, but enough for what we need it for... (the |
46 | * implementation makes sure that the arrays aren't overflowed, don't worry). |
47 | */ |
48 | #define N_CORLIST_WORDS 50 |
49 | #define N_CORLIST_LEN 30 /* max len per word */ |
50 | struct corlist { |
51 | char correction[N_CORLIST_WORDS][N_CORLIST_LEN]; |
52 | int n; |
53 | }; |
54 | int corlist_add(struct corlist *cl, const char *s); |
55 | int corlist_init(struct corlist *cl); |
56 | int corlist_free(struct corlist *cl); |
57 | |
58 | |
59 | #define corlist_n(cl) ((cl)->n) |
60 | #define corlist_str(cl,i) ((cl)->correction[(i)]) |
61 | |
62 | /* type definition for the function to be called by hspell_enum_splits on |
63 | every legal split between prefix and base word that is found. word is the |
64 | original word that is split. baseword is the base word found, preflen is |
65 | the length of the prefix, and prefspec is the prefix specifier of the base |
66 | word. |
67 | */ |
68 | typedef int hspell_word_split_callback_func(const char *word, |
69 | const char *baseword, int preflen, int prefspec); |
70 | |
71 | /* find all legal splittings of word into a baseword and a prefix. call enumf |
72 | * for every such split. */ |
73 | int hspell_enum_splits(struct dict_radix *dict, const char *word, |
74 | hspell_word_split_callback_func *enumf); |
75 | |
76 | #endif /* INCLUDED_HSPELL_H */ |
77 | |