22
23

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 5 years have passed since last update.

mecabユーザ辞書を追加

Last updated at Posted at 2016-01-02

環境

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.11.2
BuildVersion:	15C50

mecabインストール

$ brew install mecab
$ brew info mecab
/usr/local/Cellar/mecab/0.996

$ brew install mecab-ipadic
$ brew info mecab-ipadic
/usr/local/Cellar/mecab-ipadic/2.7.0-20070801

動作確認

新語は対応していない

$ mecab
Apple Watch 最高!
Apple	名詞,固有名詞,組織,*,*,*,*
Watch	名詞,一般,*,*,*,*,*
最高	   名詞,一般,*,*,*,*,最高,サイコウ,サイコー
!	     記号,一般,*,*,*,*,!,!,!

ユーザ辞書追加

Wikipediaのタイトル, はてなキーワードのcsvファイル作成

辞書のコンパイル

$ /usr/local/Cellar/mecab/0.996/libexec/mecab/mecab-dict-index \
-d /usr/local/lib/mecab/dic/ipadic \
-u user.dic \
-f utf-8 \
-t utf-8 user.csv
  • オプションの意味
    • -d DIR: システム辞書があるディレクトリ
    • -u FILE: FILE というユーザファイルを作成
    • -f charset: CSVの文字コード
    • -t charset: バイナリ辞書の文字コード

mecabrcにpathを通す

$ vi /usr/local/etc/mecabrc
userdic = /usr/local/lib/mecab/dic/ipadic/user.dic

ユーザ辞書追加の動作確認

$ mecab
Apple Watch 最高!
Apple Watch	名詞,一般,*,*,*,*,Apple Watch,*,*,hatena
最高	       名詞,一般,*,*,*,*,最高,サイコウ,サイコー
!	          記号,一般,*,*,*,*,!,!,!
22
23
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
22
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?