Skip to content

Commit 924dfc9

Browse files
authored
Merge pull request #7 from WorksApplications/feature/katsuta/readme
Feature/katsuta/readme
2 parents 4d98e6c + e731126 commit 924dfc9

File tree

2 files changed

+63
-16
lines changed

2 files changed

+63
-16
lines changed

README.md

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
[![](https://img.shields.io/github/license/t-yamamura/chikkarpy.svg)](https://github.com/t-yamamura/chikkarpy/blob/master/LICENSE)
66

77
chikkarpyは[chikkar](https://github.com/WorksApplications/chikkar)のPython版です。
8-
chikkarpy is a Python version of chikkar.
9-
10-
chikkarpy は [Sudachi 同義語辞書](https://github.com/WorksApplications/SudachiDict/blob/develop/src/main/text/synonyms.txt)を利用し、[SudachiPy](https://github.com/WorksApplications/SudachiPy)の出力に同義語展開を追加するために開発されたライブラリです。
11-
8+
chikkarpy は [Sudachi 同義語辞書](https://github.com/WorksApplications/SudachiDict/blob/develop/docs/synonyms.md)を利用し、[SudachiPy](https://github.com/WorksApplications/SudachiPy)の出力に同義語展開を追加するために開発されたライブラリです。
129
単体でも同義語辞書の検索ツールとして利用できます。
1310

11+
chikkarpy is a Python version of [chikkar](https://github.com/WorksApplications/chikkar).
12+
chikkarpy is developed to utilize the [Sudachi synonym dictionary](https://github.com/WorksApplications/SudachiDict/blob/develop/docs/synonyms.md) and add synonym expansion to the output of [SudachiPy](https://github.com/WorksApplications/SudachiPy).
13+
This library alone can be used as a search tool for our synonym dictionaries.
14+
1415
## 利用方法 Usage
1516
## TL;DR
1617
```bash
@@ -20,19 +21,30 @@ $ echo "閉店" | chikkarpy
2021
閉店 クローズ,close,店仕舞い
2122
```
2223

23-
## Step 1. chikkarpyのインストール
24+
## Step 1. chikkarpyのインストール Install chikkarpy
2425
```bash
2526
$ pip install chikkarpy
2627
```
27-
## Step 2. 使用方法
28-
### コマンドライン
28+
29+
## Step 2. 使用方法 Usage
30+
### コマンドライン Command Line
2931
```bash
3032
$ echo "閉店" | chikkarpy
3133
閉店 クローズ,close,店仕舞い
3234
```
3335
chikkarpyは入力された単語を見て一致する同義語のリストを返します。
36+
chikkarpy looks at a headword of synonym dictionary by the entered word and returns a list of matching synonyms.
37+
3438
同義語辞書内の曖昧性フラグが`1`の見出し語をトリガーにすることはできません。
39+
You cannot use a headword with an ambiguity flag of `1` in a synonym dictionary as a search trigger.
40+
3541
出力は`クエリ\t同義語リスト`の形式です。
42+
The output is in the form of a `query \t synonym list`.
43+
44+
デフォルトの [Sudachi 同義語辞書](https://github.com/WorksApplications/SudachiDict/blob/develop/docs/synonyms.md) の見出し語は、
45+
SudachiPyの正規化形 (`normalized_form()`) で登録されています。
46+
47+
The headwords in the Sudachi synonym dictionary are registered in SudachiPy's normalized form, `normalized_form()`.
3648

3749
```bash
3850
$ chikkarpy search -h
@@ -55,15 +67,24 @@ optional arguments:
5567
5668
自分で用意したユーザー辞書を使いたい場合は`-d`で読み込むバイナリ辞書を指定できます。
5769
(バイナリ辞書のビルドは[辞書の作成](#辞書の作成-Build-a-dictionary)を参照してください。)
70+
When you use your user dictionary, you should specify the binary dictionary to read with `-d`.
71+
(For building a binary dictionary, see [Building a Dictionary](#辞書の作成-Build-a-dictionary).)
72+
5873
複数辞書を読み込む場合は順番に注意してください。
59-
以下の場合,user2 > user > system の順で同義語を検索して見つかった時点で検索結果を返します。
74+
When reading multiple dictionaries, pay attention to the order.
75+
76+
以下の場合,**user2 > user > system** の順で同義語を検索して見つかった時点で検索結果を返します。
77+
In the following cases, the synonyms are searched in the order of **user2 > user > system**, and the search results are returned which are first found.
6078
6179
```bash
6280
chikkarpy -d system.dic user.dic user2.dic
6381
```
6482
6583
また、出力はデフォルトで**体言**のみです。
84+
Also, the output is **noun** only by default.
85+
6686
**用言**も出力したい場合は`-ev`を有効にしてください。
87+
When you want to output **verb** as well, please enable `-ev`.
6788
6889
```bash
6990
$ echo "開放" | chikkarpy
@@ -72,41 +93,62 @@ $ echo "開放" | chikkarpy -ev
7293
開放 開け放す,開く,オープン,open
7394
```
7495
96+
### Python ライブラリ / Python library
97+
使用例 Example of use
7598
76-
### python ライブラリ
77-
使用例
7899
```python
79100
from chikkarpy import Chikkar
80101
from chikkarpy.dictionarylib import Dictionary
81102
82103
chikkar = Chikkar()
83104
84-
system_dic = Dictionary("system.dic", False)
105+
# デフォルトのシステム同義語辞書を使う場合,Dictionaryの引数は省略可能 You may omit the ``Dictionary`` arguments if you want to use the system synonym dictionary
106+
system_dic = Dictionary()
85107
chikkar.add_dictionary(system_dic)
86108
87109
print(chikkar.find("閉店"))
88110
# => ['クローズ', 'close', '店仕舞い']
89111
90-
print(chikkar.find("閉店", group_ids=[5])) # グループIDによる検索
112+
print(chikkar.find("閉店", group_ids=[5])) # グループIDによる検索 Search by group ID
91113
# => ['クローズ', 'close', '店仕舞い']
92114
93115
print(chikkar.find("開放"))
94116
# => ['オープン', 'open']
95117
96-
chikkar.enable_verb() # 用言の出力制御(デフォルトは体言のみ出力)
118+
chikkar.enable_verb() # 用言の出力制御(デフォルトは体言のみ出力) Output control of verbs (default is to output only nouns)
97119
print(chikkar.find("開放"))
98120
# => ['開け放す', '開く', 'オープン', 'open']
99-
100121
```
101122
102123
`chikkar.add_dictionary()`で複数の辞書を読み込ませる場合は順番に注意してください。
103124
最後に読み込んだ辞書を優先して検索します。
125+
また、`enable_trie``False`に設定した辞書では、同義語を検索するときに見出し語よりもグループIDを優先して検索します。
126+
127+
When you read multiple dictionaries with `chikkar.add_dictionary()`, pay attention to the order.
128+
Priority is given to the last read dictionary.
129+
If ``enable_trie`` is ``False``, a search by synonym group IDs takes precedence over a search by the headword.
130+
131+
```python
132+
chikkar = Chikkar()
133+
134+
system_dic = Dictionary(enable_trie=False)
135+
user_dic = Dictionary(user_dict_path, enable_trie=True)
136+
user2_dic = Dictionary(user_dict_path, enable_trie=True)
137+
138+
chikkar.add_dictionary(system_dic)
139+
chikkar.add_dictionary(user_dic)
140+
chikkar.add_dictionary(user2_dic)
141+
```
142+
104143
105144
## 辞書の作成 Build a dictionary
106145
107146
新しく辞書を追加する場合は、利用前にバイナリ形式辞書の作成が必要です。
108147
Before using new dictionary, you need to create a binary format dictionary.
109148
149+
同義語辞書のフォーマットは[Sudachi 同義語辞書](https://github.com/WorksApplications/SudachiDict/blob/develop/docs/synonyms.md)に従ってください。
150+
Follow the [Sudachi Synonym Dictionary](https://github.com/WorksApplications/SudachiDict/blob/develop/docs/synonyms.md) for the format of the synonym dictionary.
151+
110152
```bash
111153
$ chikkarpy build -i synonym_dict.csv -o system.dic
112154
```
@@ -129,16 +171,21 @@ optional arguments:
129171
### Code Format
130172
131173
`scripts/lint.sh` を実行して、コードが正しいフォーマットかを確認してください。
174+
Run `scripts/lint.sh` to check if your code is formatted correctly.
132175
133176
`flake8` `flake8-import-order` `flake8-builtins` が必要です。
177+
You need packages `flake8` `flake8-import-order` `flake8-builtins`.
134178
135179
### Test
136180
137181
`scripts/test.sh` を実行してテストしてください。
182+
Run `scripts/test.sh` to run the tests.
138183
139184
## Contact
140185
141186
chikkarpyは[WAP Tokushima Laboratory of AI and NLP](http://nlp.worksap.co.jp/)によって開発されています。
187+
chikkarpy is developed by WAP Tokushima Laboratory of AI and NLP.
142188
143189
開発者やユーザーの方々が質問したり議論するためのSlackワークスペースを用意しています。
144-
- https://sudachi-dev.slack.com/ ([こちら](https://join.slack.com/t/sudachi-dev/shared_invite/enQtMzg2NTI2NjYxNTUyLTMyYmNkZWQ0Y2E5NmQxMTI3ZGM3NDU0NzU4NGE1Y2UwYTVmNTViYjJmNDI0MWZiYTg4ODNmMzgxYTQ3ZmI2OWU)から招待を受けてください)
190+
Open an issue, or come to our Slack workspace for questions and discussion.
191+
- https://sudachi-dev.slack.com/ ([招待を受ける/Get invitation](https://join.slack.com/t/sudachi-dev/shared_invite/enQtMzg2NTI2NjYxNTUyLTMyYmNkZWQ0Y2E5NmQxMTI3ZGM3NDU0NzU4NGE1Y2UwYTVmNTViYjJmNDI0MWZiYTg4ODNmMzgxYTQ3ZmI2OWU))

chikkarpy/dictionarylib/dictionary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Dictionary(object):
2525
def __init__(self, filename=None, enable_trie=False):
2626
"""Reads the synonym dictionary from the specified file.
2727
28-
If ``enableTrie`` is ``False``, a search by synonym group IDs takes precedence over a search by the headword.
28+
If ``enable_trie`` is ``False``, a search by synonym group IDs takes precedence over a search by the headword.
2929
3030
Args:
3131
filename (str | None): path of synonym dictionary file

0 commit comments

Comments
 (0)