Sudachi is Japanese morphological analyzer. Morphological analysis consists mainly of the following tasks.
For a tutorial on installation, please refer to the tutorial page.
For a tutorial on the plugin, please refer to the plugin tutorial page.
For information on building Sudachi from source or development see Development page.
Sudachi has the following features.
Sudachi has three types of dictionaries.
Click here for pre-built dictionaries. For more details, see SudachiDict.
Run the command line tool with the configuration string
$ java -jar sudachi-XX.jar -s '{"systemDict":"system_small.dic"}'
$ java -jar sudachi-XX.jar [-r conf] [-s json] [-m mode] [-a] [-d] [-f] [-o output] [file...]
-r conf
specifies the setting file (overrides -s)-s json
additional settings (overrides -r)-p directory
root directory of resources-m {A|B|C}
specifies the mode of splitting-a
outputs the dictionary form and the reading form-d
dump the debug outputs-o file
specifies output file (default: the standard output)-t
separate words with spaces-ts
separate words with spaces, and break line for each sentence-f
ignore errors--systemDict file
specify path to the system dictionary. Will override other settings.--userDict file
add a user dictionary. Will not override other settings, but add another user dictionary.--format class
use the provided class for formatting output instead of default configuration$ echo 東京都へ行く | java -jar target/sudachi.jar
東京都 名詞,固有名詞,地名,一般,*,* 東京都
へ 助詞,格助詞,*,*,*,* へ
行く 動詞,非自立可能,*,*,五段-カ行,終止形-一般 行く
EOS
$ echo 東京都へ行く | java -jar target/sudachi.jar -a
東京都 名詞,固有名詞,地名,一般,*,* 東京都 東京都 トウキョウト
へ 助詞,格助詞,*,*,*,* へ へ エ
行く 動詞,非自立可能,*,*,五段-カ行,終止形-一般 行く 行く イク
EOS
$ echo 東京都へ行く | java -jar target/sudachi.jar -m A
東京 名詞,固有名詞,地名,一般,*,* 東京
都 名詞,普通名詞,一般,*,*,* 都
へ 助詞,格助詞,*,*,*,* へ
行く 動詞,非自立可能,*,*,五段-カ行,終止形-一般 行く
EOS
$ echo 東京都へ行く | java -jar target/sudachi.jar -t
東京都 へ 行く
You can find details in the Javadoc.
To compile an application with Sudachi API, declare a dependency on Sudachi in maven project.
<dependency>
<groupId>com.worksap.nlp</groupId>
<artifactId>sudachi</artifactId>
<version>0.5.3</version>
</dependency>
Sudachi provides three modes of splitting. In A mode, texts are divided into the shortest units equivalent to the UniDic short unit. In C mode, it extracts named entities. In B mode, into the middle units.
The followings are examples in the core dictionary.
A:選挙/管理/委員/会
B:選挙/管理/委員会
C:選挙管理委員会
A:客室/乗務/員
B:客室/乗務員
C:客室乗務員
A:労働/者/協同/組合
B:労働者/協同/組合
C:労働者協同組合
A:機能/性/食品
B:機能性/食品
C:機能性食品
The followings are examples in the full dictionary.
A:医薬/品/安全/管理/責任/者
B:医薬品/安全/管理/責任者
C:医薬品安全管理責任者
A:消費/者/安全/調査/委員/会
B:消費者/安全/調査/委員会
C:消費者安全調査委員会
A:さっぽろ/テレビ/塔
B:さっぽろ/テレビ塔
C:さっぽろテレビ塔
A:カンヌ/国際/映画/祭
B:カンヌ/国際/映画祭
C:カンヌ国際映画祭
In full-text searching, to use A and B can improve precision and recall.
You can use or make plugins which modify the behavior of Sudachi.
Type of Plugins | Example |
---|---|
Modify the Inputs | Character normalization |
Make OOVs | Considering script styles |
Connect Words | Inhibition, Overwrite costs |
Modify the Path | Fix Person names, Equalization of splitting |
We prepared following plugins.
Type of Plugins | Plugin | |
---|---|---|
Modify the Inputs | character normalization | Full/half-width, Cases, Variants |
normalization of prolong symbols | Normalize "~", "ー"s | |
Remove yomigana | Remove yomigana in parentheses | |
Make OOVs | Make one character OOVs | Use as the fallback |
MeCab compatible OOVs | ||
Connect Words | Inhibition | Specified by part-of-speech |
Modify the Path | Join Katakata OOVs | |
Join numerics | ||
Equalization of splitting* | Smooth of OOVs and not OOVs | |
Normalize numerics | Normalize Kanji numerics and scales | |
Estimate person names* |
* will be released at a later date.
Sudachi normalize the following variations.
DefaultInputTextPlugin
normalizes an input text in the following order.
Character.toLowerCase()
When rewrite.def
has the following descriptions, DefaultInputTextPlugin
stops the above processing and aplies the followings.
# single code point: this character is skipped in character normalization
髙
# rewrite rule: <target> <replacement>
A' Ā
If the number of characters increases as a result of character normalization, Sudachi may output morphemes whose length is 0 in the original input text.
To create and use your own dictionaries, please refer to docs/user_dict.md.
Sudachi | MeCab | kuromoji | |
---|---|---|---|
Multiple Segmentation | Yes | No | Limited ^a |
Normalization | Yes | No | Limited ^b |
Joining, Correction | Yes | No | Limited ^b |
Use multiple user dictionary | Yes | Yes | No |
Saving Memory | Good ^c | Poor | Good |
Accuracy | Good | Good | Good |
Speed | Good | Excellent | Good |
Sudachi by Works Applications Co., Ltd. is licensed under the Apache License, Version2.0
Copyright (c) 2017 Works Applications Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This logo or a modified version may be used by anyone to refer to the morphological analyzer Sudachi, but does not indicate endorsement by Works Applications Co., Ltd.
Copyright (c) 2017 Works Applications Co., Ltd.
We release a plug-in for Elasticsearch.
An implementation of Sudachi in Python
We have a Slack workspace for developers and users to ask questions and discuss a variety of topics.
We have published a paper about Sudachi and its language resources; "Sudachi: a Japanese Tokenizer for Business" (Takaoka et al., LREC2018).
When citing Sudachi in papers, books, or services, please use the follow BibTex entry;
@InProceedings{TAKAOKA18.8884,
author = {Kazuma Takaoka and Sorami Hisamoto and Noriko Kawahara and Miho Sakamoto and Yoshitaka Uchida and Yuji Matsumoto},
title = {Sudachi: a Japanese Tokenizer for Business},
booktitle = {Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC 2018)},
year = {2018},
month = {may},
date = {7-12},
location = {Miyazaki, Japan},
editor = {Nicoletta Calzolari (Conference chair) and Khalid Choukri and Christopher Cieri and Thierry Declerck and Sara Goggi and Koiti Hasida and Hitoshi Isahara and Bente Maegaard and Joseph Mariani and Hélène Mazo and Asuncion Moreno and Jan Odijk and Stelios Piperidis and Takenobu Tokunaga},
publisher = {European Language Resources Association (ELRA)},
address = {Paris, France},
isbn = {979-10-95546-00-9},
language = {english}
}
Sudachi は日本語形態素解析器です。形態素解析はおもに以下の3つの処理を おこないます。
インストールのチュートリアルは、インストールのチュートリアルを参照ください。
プラグインのチュートリアルは、プラグインのチュートリアルを参照ください。
プラグイン機構を用いて、分かち書きを実現しています。
Sudachi は従来の形態素解析器とくらべ、以下のような特長があります。
Sudachi には3種類の辞書があります。
ビルド済みの辞書はこちらで配布しています。 くわしくは SudachiDict をごらんください。
コマンドラインツールで設定文字列を指定します
$ java -jar sudachi-XX.jar -s '{"systemDict":"system_small.dic"}'
$ java -jar sudachi-XX.jar [-r conf] [-s json] [-m mode] [-a] [-d] [-f] [-o output] [file...]
$ echo 東京都へ行く | java -jar target/sudachi.jar
東京都 名詞,固有名詞,地名,一般,*,* 東京都
へ 助詞,格助詞,*,*,*,* へ
行く 動詞,非自立可能,*,*,五段-カ行,終止形-一般 行く
EOS
$ echo 東京都へ行く | java -jar target/sudachi.jar -a
東京都 名詞,固有名詞,地名,一般,*,* 東京都 東京都 トウキョウト
へ 助詞,格助詞,*,*,*,* へ へ エ
行く 動詞,非自立可能,*,*,五段-カ行,終止形-一般 行く 行く イク
EOS
$ echo 東京都へ行く | java -jar target/sudachi.jar -m A
東京 名詞,固有名詞,地名,一般,*,* 東京
都 名詞,普通名詞,一般,*,*,* 都
へ 助詞,格助詞,*,*,*,* へ
行く 動詞,非自立可能,*,*,五段-カ行,終止形-一般 行く
EOS
$ echo 東京都へ行く | java -jar target/sudachi.jar -t
東京都 へ 行く
ライブラリとしての利用は Javadoc を参照してください。
Maven プロジェクトで利用する場合は以下の dependency を追加してください。
<dependency>
<groupId>com.worksap.nlp</groupId>
<artifactId>sudachi</artifactId>
<version>0.5.3</version>
</dependency>
Sudachi では短い方から A, B, C の3つの分割モードを提供します。 A は UniDic 短単位相当、C は固有表現相当、B は A, C の中間的な単位です。
以下に例を示します。
(コア辞書利用時)
A:選挙/管理/委員/会
B:選挙/管理/委員会
C:選挙管理委員会
A:客室/乗務/員
B:客室/乗務員
C:客室乗務員
A:労働/者/協同/組合
B:労働者/協同/組合
C:労働者協同組合
A:機能/性/食品
B:機能性/食品
C:機能性食品
(フル辞書利用時)
A:医薬/品/安全/管理/責任/者
B:医薬品/安全/管理/責任者
C:医薬品安全管理責任者
A:消費/者/安全/調査/委員/会
B:消費者/安全/調査/委員会
C:消費者安全調査委員会
A:さっぽろ/テレビ/塔
B:さっぽろ/テレビ塔
C:さっぽろテレビ塔
A:カンヌ/国際/映画/祭
B:カンヌ/国際/映画祭
C:カンヌ国際映画祭
検索用途であれば A と C を併用することで、再現率と適合率を向上させる ことができます。
Sudachi では形態素解析の各ステップをフックして処理を差し込むプラグイン機構を 提供しています。
プラグイン | 処理例 |
---|---|
入力テキスト修正 | 異体字統制、表記補正 |
未知語処理 | 文字種による調整 |
単語接続処理 | 品詞接続禁制、コスト値上書き |
出力解修正 | 人名処理、分割粒度調整 |
プラグインを作成することでユーザーが独自の処理をおこなうことができます。
システム提供のプラグインとして以下のものを利用できます。
処理部分 | プラグイン | |
---|---|---|
入力テキスト修正 | 文字列正規化 | 全半角、大文字/小文字、異体字 |
カスタマイズ可能 | ||
長音正規化 | 「~」や長音記号連続の正規化 | |
読みがな削除 | 括弧内の読み仮名を削除 | |
未知語処理 | 1文字未知語 | フォールバックとして利用 |
MeCab互換 | ||
単語接続処理 | 品詞接続禁制 | カスタマイズ可能 |
出力解修正 | カタカナ未知語まとめ上げ | |
数詞まとめ上げ | ||
分割粒度調整* | 未知語/既知語の分割粒度の平滑化 | |
数詞正規化 | 漢数詞や位取りの正規化 | |
人名補正* | 敬称や前後関係から人名部を推定 |
* は後日公開予定
Sudachi のシステム辞書では以下のような表記正規化を提供します。
デフォルトで適用されるプラグイン DefaultInputTextPlugin
で入力文に対して以下の順で正規化をおこないます。
Character.toLowerCase()
をつかった小文字化ただし、rewrite.def
に以下の記述があった場合は上記の処理は適用されず、こちらの処理が優先されます。
# コードポイントが1つのみ記述されている場合は、文字正規化を抑制します
髙
# 置換対象文字列 置換先文字列
A' Ā
文字正規化の結果、文字数が増えた場合、原文上では長さが0になる形態素が出力されることがあります。
ユーザー辞書の作成と利用方法については、docs/user_dict.mdをご覧ください。
Sudachi | MeCab | kuromoji | |
---|---|---|---|
分割単位の併用 | ○ | × | △ ^1 |
文字正規化、表記正規化 | ○ | × | △ ^2 |
まとめ上げ、補正処理 | ○ | × | △ ^2 |
複数ユーザ辞書の利用 | ○ | ○ | × |
省メモリ | ◎ ^3 | △ | ○ |
解析精度 | ○ | ○ | ○ |
解析速度 | △ | ○ | △ |
Elasticsearch で Sudachi をつかうためのプラグインも公開しています。
Python 版も公開しています。
開発者やユーザーの方々が質問したり議論するためのSlackワークスペースを用意しています。
Sudachiとその言語資源について、論文を発表しています; "Sudachi: a Japanese Tokenizer for Business" (Takaoka et al., LREC2018).
Sudachiを論文や書籍、サービスなどで引用される際には、以下のBibTexをご利用ください。
@InProceedings{TAKAOKA18.8884,
author = {Kazuma Takaoka and Sorami Hisamoto and Noriko Kawahara and Miho Sakamoto and Yoshitaka Uchida and Yuji Matsumoto},
title = {Sudachi: a Japanese Tokenizer for Business},
booktitle = {Proceedings of the Eleventh International Conference on Language Resources and Evaluation (LREC 2018)},
year = {2018},
month = {may},
date = {7-12},
location = {Miyazaki, Japan},
editor = {Nicoletta Calzolari (Conference chair) and Khalid Choukri and Christopher Cieri and Thierry Declerck and Sara Goggi and Koiti Hasida and Hitoshi Isahara and Bente Maegaard and Joseph Mariani and Hélène Mazo and Asuncion Moreno and Jan Odijk and Stelios Piperidis and Takenobu Tokunaga},
publisher = {European Language Resources Association (ELRA)},
address = {Paris, France},
isbn = {979-10-95546-00-9},
language = {english}
}