|
* スペルチェック [#t348c7bb] -ページ: [[Request]] -投稿者: [[request.txt]] -優先順位: 低 -状態: 提案 -カテゴリー: -投稿日: 2007-04-05 (木) 00:43:15 -バージョン: ** メッセージ [#u0c49a16] スペルチェックの処理概要 0.初期化 //Aspellの使用を開始する。 AspellConfig* spell_config = new_aspell_config(); aspell_config_replace(spell_config, "lang", "en_US"); //Aspellを配置しているフォルダを指定する。 aspell_config_replace(spell_config, "prefix", "C:/Program Files/Aspell/"); AspellCanHaveError* possible_err = new_aspell_speller(spell_config); AspellSpeller* spell_checker = 0; if (aspell_error_number(possible_err) != 0) puts(aspell_error_message(possible_err)); else spell_checker = to_aspell_speller(possible_err); 0a.ダイアログで、ファイル先頭からチェック、カーソル位置からチェック、キャンセルのいずれかを選択する。&br; なお、マクロから呼ばれることを考慮して、ダイアログをスルーできる機能も持つとよい。&br; 1.次の単語に移動機能を使って単語を取得する。&br; 2.無視リストに登録された単語なら1に戻る。&br; 2a.置換リストに登録された単語なら置換して1に戻る。&br; 3.aspellで単語を検索して候補を取得する。&br; //単語の候補リストを取得する。 AspellWordList* suggestions = aspell_speller_suggest(spell_checker, word, size); AspellStringEnumeration* elements = aspell_word_list_elements(suggestions); const char* word; while ( (word = aspell_string_enumeration_next(aspell_elements)) != NULL ){ //候補リストに追加する。 } delete_aspell_string_enumeration(elements); 4.候補が1個の場合は1に戻る。&br; 5.候補が複数個の場合は選択ダイアログを表示する。&br; Label: 元単語 TextBox: 新単語 ListBox: 単語候補 Button: 無視 Button: すべて無視 Button: 置換 Button: すべて置換 Button: 登録 Button: 中止 6.「無視」を選択した場合、1に戻る。&br; 7.「すべて無視」を選択した場合、単語を無視リストに登録して1に戻る。&br; 8.「置換」を選択した場合、選択された候補と置換して1に戻る。&br; 9.「すべて置換」を選択した場合、置換リストに登録して8に進む。&br; 10.「登録」を選択した場合、単語をパーソナル辞書に登録して1に戻る。&br; //新しい単語を辞書に登録する。 if(personal){ aspell_speller_add_to_personal(spell_checker, word, size); }else{ aspell_speller_add_to_session(spell_checker, word, size); } 11.「終了」を選択した場合、スペルチェックを中止する。&br; 12.終了 //オブジェクトを削除する。 delete_aspell_speller(spell_checker); 削除(possible_err); 削除(spell_config); -無視リスト:スペルチェック中のみ有効な、スペルチェックを無視する単語表 std::map<string> -置換リスト:スペルチェック中のみ有効な、スペルチェックで全置換対象になった単語表 std::map<string,string> -パーソナル辞書:ユーザが新たに登録する単語表(半永久保存)。aspell機能にある。 -選択ダイアログ:beckyのスペルチェック画面を参考にするとよい。 CAspell.cpp/.h CDllHandlerを継承した作成するapsell.dllにアクセスするクラス CDlgAspell.cpp/.h CDialogを継承したスペルチェックの動作を選択するダイアログ 設定画面 apsell.dllのパスを指定する項目 apsellのインストールパス(辞書を探すために必要) (通常はdllの場所がわかれば../を指定すればよいので、1個目のみでもよい) ---- - aspell - http://aspell.net/ を使う方法があります。 -- &new{2008-02-18 (月) 20:14:21}; - Enchant - http://www.abisource.com/projects/enchant/ -- &new{2013-03-23 (土) 10:17:03}; #comment #attach |