3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Sudachiでカスタマイズした辞書を使いたい

Last updated at Posted at 2022-12-21

形態素解析ツールSudachiで、
カスタマイズしたシステム辞書とユーザー辞書のbuild方法について紹介します.

なぜ辞書をbuildしたいのか?

Sudachiにおけるシステム辞書はbuild済みのものが配布されており、それを使うのが一般的です。
しかし、独自に辞書をカスタマイズしたい場合、自分でbuildする必要があります。

辞書のbuild方法(.csv→.dic)

「必要なファイル」

  • build前のシステム辞書(small_lex.csv, notcore_lex.csv, core_lex.csv)
    自由にカスタマイズ可能なCSVファイルとして以下で提供されています.
    こちらからインストール可能
  • javaコマンド実行に必要な各ファイル
    ZIPファイルとして提供されています. zip内に必要なファイルが含まれているため, それらをbuildしたい辞書と同じディレクトリに配置してください.
    こちらからインストール可能
  • matrix.def
    matrix.def.zip内の格納されています.
    こちらからインストール可能

「buildコマンド」

# システム辞書
java -Dfile.encoding=UTF-8 -cp sudachi-0.5.1.jar com.worksap.nlp.sudachi.dictionary.DictionaryBuilder -o [任意の出力ファイル名].dic -m matrix.def small_lex.csv core_lex.csv notcore_lex.csv  
# ユーザー辞書
java -Dfile.encoding=UTF-8 -cp sudachi-0.5.1.jar com.worksap.nlp.sudachi.dictionary.UserDictionaryBuilder -o [任意の出力ファイル名].dic -s [システム辞書].dic [ユーザー辞書].csv

その他 

ユーザー辞書の形式やbuildの詳細に関しては以下のサイトなどに詳しく載っています.
https://github.com/WorksApplications/Sudachi/blob/develop/docs/user_dict.md
https://qiita.com/po3rin/items/d9a0cc9d8202ff16ed3f

システム辞書のbuild方法はWEB上であまり紹介されていません(2022/12/21時点)
もし開発などで行き止まった場合には, slack上のコミュニティなどに助けを求める必要があるかもしれません.

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?