2011年8月21日星期日

1. Hyphenation module in Enchant


1.1 Add hyphenation function in Enchant

Firstly, I add hyphenation method in Enchant:
================the code===========
I think we can combine the hyphenation with spell-checking together, So that we can make the code more flexible. In my opinion, the hyphenation function defines as following:
EnchantDict* enchant_broker_request_dict (EnchantBroker* broker, const
char *const lang); //same as spell-checking
char *enchant_dict_hyphenate(EnchantDict *dict, const char *const word,size_t len);

In order to achieve the function and implement in abstract layer, we need to add hyphenation function in EnchantDict. something like, just as a function pointer:
char* (*hyphenate) (struct str_enchant_dict * me,
                          const char *const word, size_t len,
                          size_t * out_n_suggs);

and the function is implement by the backend. Take “ispell” as example:
static char * ispell_dict_hyphenate (EnchantDict * me, const char *const word,
                    size_t len, size_t * out_n_suggs)
{
       ISpellChecker * checker;
       checker = (ISpellChecker *) me->user_data;
       return checker->hyphenate (word, len, out_n_suggs);
}

Finally, we set the connetion
 dict->hyphenate = ispell_dict_hyphenate;
 dict->suggest = hspell_dict_hyphenate;
dict->suggest = zemberek_dict_hyphenate;

没有评论:

发表评论