Re: Re: chenxiajian_enchant_dict_hyphenation?

From: chenxiajian1985 <chenxiajian1985_at_gmail.com>
Date: Mon Jun 20 2011 - 17:35:10 CEST

Hi, Urmas
Thanks for your last mail. Recently I learned more about enchant.

> No, you'll need a separate object for doing hyphenation, something like:
> EnchantHyph* enchant_broker_request_hyph(EnchantBroker*, const char *const lang);
> to create an provider-dependant hyphenation object, and
> char *enchant_hyph_hyphenate(EnchantHyph *hyphenator, const char *const word);
> which would call a virtual method of "hyphenator" to obtain results;
  
I think we can combine the hyphenation with spell-checking together. so that we can make the code more flexsible.
In my opinion, we can make code like this:
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);

===================== 1
In order to achieve this, we need to add hyphenation function in EnchantDict. something like:
char **(*hyphenate) (struct str_enchant_dict * me,
                           const char *const word, size_t len,
                           size_t * out_n_suggs);

======================== 2
and the function is implement by the backend.
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);
}
 ====================3
 finally, we set the connetion

 dict->hyphenate = ispell_dict_hyphenate;
 dict->suggest = hspell_dict_hyphenate;
dict->suggest = zemberek_dict_hyphenate;


some good idea?


chen xiajian



发件人: Urmas
发送时间: 2011-06-14 22:02:23
收件人: abiword-dev
抄送:
主题: Re: chenxiajian_enchant_dict_hyphenationSuggest ?
 
From: "chenxiajian1985" <chenxiajian1985@gmail.com>
Subject: chenxiajian_enchant_dict_hyphenationSuggest ?
> I try to implement hyphenation using enchant. so I add one method in enchant.
> ENCHANT_MODULE_EXPORT (char **)
> enchant_dict_hyphenationSuggest (EnchantDict * dict, const char *const word,
> ssize_t len, size_t * out_n_suggs);
>
No, you'll need a separate object for doing hyphenation, something like:
EnchantHyph* enchant_broker_request_hyph(EnchantBroker*, const char *const lang);
to create an provider-dependant hyphenation object, and
char *enchant_hyph_hyphenate(EnchantHyph *hyphenator, const char *const word);
which would call a virtual method of "hyphenator" to obtain results;
>
> 2. what is the best way to encode hyphenation results from enchant
> now I used (char **) to save the hyphenation results:
> such as : the word "hyphenation" can be save as:
> "hy-phen-ation" "hyphen-ation"....
That's looks like terribly inefficient way, better just to return a string with embedded meta-characters (like '~' or control ones) in most desired and less desired breakpoints.
Received on Mon Jun 20 17:35:09 2011

This archive was generated by hypermail 2.1.8 : Mon Jun 20 2011 - 17:35:09 CEST