- Notifications
You must be signed in to change notification settings - Fork1
WorksApplications/chikkarpy
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
chikkarpyはchikkarのPython版です。chikkarpy はSudachi 同義語辞書を利用し、SudachiPyの出力に同義語展開を追加するために開発されたライブラリです。単体でも同義語辞書の検索ツールとして利用できます。
chikkarpy is a Python version ofchikkar.chikkarpy is developed to utilize theSudachi synonym dictionary and add synonym expansion to the output ofSudachiPy.This library alone can be used as a search tool for our synonym dictionaries.
$ pip install chikkarpy$echo"閉店"| chikkarpy閉店 クローズ,close,店仕舞い
$ pip install chikkarpy
$echo"閉店"| chikkarpy閉店 クローズ,close,店仕舞い
chikkarpyは入力された単語を見て一致する同義語のリストを返します。chikkarpy looks at a headword of synonym dictionary by the entered word and returns a list of matching synonyms.
同義語辞書内の曖昧性フラグが1
の見出し語をトリガーにすることはできません。You cannot use a headword with an ambiguity flag of1
in a synonym dictionary as a search trigger.
出力はクエリ\t同義語リスト
の形式です。The output is in the form of aquery \t synonym list
.
デフォルトのSudachi 同義語辞書 の見出し語は、SudachiPyの正規化形 (normalized_form()
) で登録されています。
The headwords in the Sudachi synonym dictionary are registered in SudachiPy's normalized form,normalized_form()
.
$ chikkarpy search -husage: chikkarpy search [-h] [-d [file [file ...]]] [-ev] [-o file] [-v] [file [file ...]]Search synonymspositional arguments: file text writtenin utf-8optional arguments:-h, --help show thishelp message andexit-d [file [file ...]] synonym dictionary (default: system synonym dictionary)-ev Enable verb and adjective synonyms.-o file the output file -v, --version print chikkarpy version
自分で用意したユーザー辞書を使いたい場合は-d
で読み込むバイナリ辞書を指定できます。(バイナリ辞書のビルドは辞書の作成を参照してください。)When you use your user dictionary, you should specify the binary dictionary to read with-d
.(For building a binary dictionary, seeBuilding a Dictionary.)
複数辞書を読み込む場合は順番に注意してください。When reading multiple dictionaries, pay attention to the order.
以下の場合,user2 > user > system の順で同義語を検索して見つかった時点で検索結果を返します。In the following cases, the synonyms are searched in the order ofuser2 > user > system, and the search results are returned which are first found.
chikkarpy -d system.dic user.dic user2.dic
また、出力はデフォルトで体言のみです。Also, the output isnoun only by default.
用言も出力したい場合は-ev
を有効にしてください。When you want to outputverb as well, please enable-ev
.
$echo"開放"| chikkarpy開放オープン,open$echo"開放"| chikkarpy -ev開放開け放す,開く,オープン,open
使用例 Example of use
fromchikkarpyimportChikkarfromchikkarpy.dictionarylibimportDictionarychikkar=Chikkar()# デフォルトのシステム同義語辞書を使う場合,Dictionaryの引数は省略可能 You may omit the ``Dictionary`` arguments if you want to use the system synonym dictionarysystem_dic=Dictionary()chikkar.add_dictionary(system_dic)print(chikkar.find("閉店"))# => ['クローズ', 'close', '店仕舞い']print(chikkar.find("閉店",group_ids=[5]))# グループIDによる検索 Search by group ID# => ['クローズ', 'close', '店仕舞い']print(chikkar.find("開放"))# => ['オープン', 'open']chikkar.enable_verb()# 用言の出力制御(デフォルトは体言のみ出力) Output control of verbs (default is to output only nouns)print(chikkar.find("開放"))# => ['開け放す', '開く', 'オープン', 'open']
chikkar.add_dictionary()
で複数の辞書を読み込ませる場合は順番に注意してください。最後に読み込んだ辞書を優先して検索します。また、enable_trie
をFalse
に設定した辞書では、同義語を検索するときに見出し語よりもグループIDを優先して検索します。
When you read multiple dictionaries withchikkar.add_dictionary()
, pay attention to the order.Priority is given to the last read dictionary.Ifenable_trie
isFalse
, a search by synonym group IDs takes precedence over a search by the headword.
chikkar=Chikkar()system_dic=Dictionary(enable_trie=False)user_dic=Dictionary(user_dict_path,enable_trie=True)user2_dic=Dictionary(user_dict_path,enable_trie=True)chikkar.add_dictionary(system_dic)chikkar.add_dictionary(user_dic)chikkar.add_dictionary(user2_dic)
新しく辞書を追加する場合は、利用前にバイナリ形式辞書の作成が必要です。Before using new dictionary, you need to create a binary format dictionary.
同義語辞書のフォーマットはSudachi 同義語辞書に従ってください。Follow theSudachi Synonym Dictionary for the format of the synonym dictionary.
$ chikkarpy build -i synonym_dict.csv -o system.dic
$ chikkarpy build -husage: chikkarpy build [-h] -i file [-o file] [-d string]Build Synonym Dictionaryoptional arguments: -h, --help show thishelp message andexit -i file dictionary file (csv) -o file output file (default: synonym.dic) -d string description comment to be embedded on dictionary
scripts/lint.sh
を実行して、コードが正しいフォーマットかを確認してください。Runscripts/lint.sh
to check if your code is formatted correctly.
flake8
flake8-import-order
flake8-builtins
が必要です。You need packagesflake8
flake8-import-order
flake8-builtins
.
scripts/test.sh
を実行してテストしてください。Runscripts/test.sh
to run the tests.
chikkarpyはWAP Tokushima Laboratory of AI and NLPによって開発されています。chikkarpy is developed by WAP Tokushima Laboratory of AI and NLP.
開発者やユーザーの方々が質問したり議論するためのSlackワークスペースを用意しています。Open an issue, or come to our Slack workspace for questions and discussion.
About
Japanese synonym library
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.