※インストール後、コンピューターの再起動が必要になります。
#===================================================
#!-*- coding:utf-8 -*-
import codecs
#辞書ファイルのパスを指定
dbpath = 'C:\Program Files\Justsystem\ATOK\ATOKDIRECT\PLUGIN\<辞書ファイル>.txt'
def atok_plugin_run_process( a_request_data ):
result_data = {}
candidate_array = []
str = a_request_data[ 'composition_string' ]
if str:
candidate_array = retList(str)
result_data[ 'candidate' ] = candidate_array
return result_data
def retList(keyword):
list = []
f = codecs.open(dbpath, "r","utf-8")
l = f.readline()
strLen =len(keyword)
while l:
h = l.split("\t")
#if h[0]==keyword:
if h[0][0:strLen]==keyword[0:strLen]:
# コメントとして返すXHTMLを定義
# (unicode文字列で作成するが、記述はUTF-8のXHTMLとして指定する必要がある)
comment_xhtml1 = u'''<?xml version="1.0" encoding="UTF-8"
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja"
lang="ja">
<head><title>漢字とかなの使い分け</title></head>
<h2>漢字とかなの使い分け</h2>
<body>''' + h[2] + '''</body>
</html>'''
list.append({ 'hyoki' : h[1] ,
'comment_xhtml' : comment_xhtml1} )
l = f.readline()
f.close
return list
#===================================================
辞書ファイルの詳細は、「辞書ファイルの作り方」を参照のこと。
(WindowsVista/7 の場合はSetup.exeを右クリックして「管理者として実行」する必要があるかもしれない)
Python.exeへのバスが通っていないと次のようなメッセージが表示される
適切なフォルダーに展開される。
【アンインストール】
アンインストールは「プログラムの追加と削除」→「ATOK ダイレクトプラグインの削除」から簡単に行えます。