chen xiajian_Share some learing about Enchant

From: chenxiajian1985 <chenxiajian1985_at_gmail.com>
Date: Thu Apr 21 2011 - 05:27:28 CEST

Hi, all
I have read more about Enchant. in my opinion,Enchant is just an abstraction, appears to be a generic engine. we can do lots of thing using enchant, request a dictionary , spell checking. But Enchant is not really do that. the backend do the most thing. but we can use enchant to easy change from one dictionary to another and get the result which dictionary has a best performance. read some of the code, you can see that the implementation use some "virtual function calls" to do that:

the attachment image is the call process
call process: FL_DocLayout spellcheck->fl_BlockLayout checkSpelling->SpeellManager requestDictionary->EnchantspellChecker requestDictionary-> enchant.h (!!!!)

in the defination of SpeellManager, we can see that
requestDictionary calls the SpellCheck requestDictionary
!!!! is an virtual function--> and the concreate implementation is in the EnchantCheck (also is not implement by itself, but in the enchant.h.) so the concreate implementation is the library set in the enchant.h

====================================spell_manager=======================
the expose class spell_manager in Abiword:(FL_DocLayout spellcheck and fl_BlockLayout checkSpelling)
requestDictionary->load the dic to checkWord(m_BarbarismChecker)
checkWord
suggestWord
addToCustomDict
correctWord

====================================EnchantspellChecker inherit from spellChecker=======================
the implementation of some virtual function in SpellChecker
virtual bool addToCustomDict (const UT_UCSChar *word, size_t len);
virtual void correctWord (const UT_UCSChar *toCorrect, size_t toCorrectLen,
virtual void ignoreWord (const UT_UCSChar *toCorrect, size_t toCorrectLen);
virtual bool isIgnored (const UT_UCSChar * pWord, size_t len) const;

but it call the function from enchant.h
====================================spellChecker=======================
define some function in high level and some virtual function
so that we can use it in the FL_DocLayout

==============================enchant.h=====
In "enchant.h" we can see that some important function:
EnchantBrokerDescribeFn: Callback used to enumerate and describe Enchant's various providers
enchant_dict_add
enchant_dict_remove
EnchantDictDescribeFn: Callback used to describe an individual dictionary
typedef struct str_enchant_broker EnchantBroker;
typedef struct str_enchant_dict EnchantDict;

Anyone interested in Enchant can disscus with me, Thanks

Chen Xiajian

Received on Thu Apr 21 05:27:42 2011

This archive was generated by hypermail 2.1.8 : Thu Apr 21 2011 - 05:27:42 CEST