3
2

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のユーザー辞書をphp-mecabから認識させる

Posted at

mecabのユーザー辞書をインストールして、mecabrcも書き換えて、コマンドラインでユーザー辞書が使われているのを確認して、さあphpから処理をスタートするぞって時に「あれっ、エラーになる?」そんな時は、php.inimecab.default_userdicを作成したユーザー辞書ファイルに指定しましょう。

(※ini_setでやる場合)

ini_set('mecab.default_userdic', '/usr/lib64/mecab/dic/ipadic/user.dic');

尚、ユーザー辞書ファイルにたどり着けなかった場合は変わらずエラーとなるのでご注意を。

// 失敗したコード
ini_set('mecab.default_userdic', '/home/ec2-user/mecab/user.dic');

/*
 PHP Warning:  MeCab_Tagger::__construct(): '/home/ec2-user/mecab/user.dic' does not exist or is not readable in /var/www/html/text/text_convert.php on line 43
*/
3
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?