php_mecab 0.5.0 インストール

形態素解析MeCab

事前確認

 状態:-  閲覧数:896  投稿日:2015-03-16  更新日:2016-02-14
MeCabインストール確認
・バージョン表示されれば、MeCabは既にインストールされている
↓コマンド
$ mecab -v


MeCab動作確認
↓コマンド
$ echo 'すもももももももものうち' | mecab


php_mecab動作確認
・インストールされていない時点では「Fatal error」と表示される
↓PHP
<?php
   $meCab = new MeCab_Tagger();
   echo $meCab->parse("すもももももももものうち");
?>


ダウンロード

 閲覧数:233 投稿日:2015-03-16 更新日:2015-03-16 
$ curl -L https://github.com/downloads/rsky/php-mecab/php-mecab-0.5.0.tgz -o php-mecab-0.5.0.tgz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed
100 50180  100 50180    0     0  26510      0  0:00:01  0:00:01 --:--:--  291k



$ tar xzvf php-mecab-0.5.0.tgz
php-mecab-0.5.0/
php-mecab-0.5.0/.gitignore
php-mecab-0.5.0/config.m4
php-mecab-0.5.0/config.w32
php-mecab-0.5.0/CREDITS
php-mecab-0.5.0/examples/
php-mecab-0.5.0/examples/allmorphs-func.php
php-mecab-0.5.0/examples/allmorphs-oo.php
php-mecab-0.5.0/examples/common.inc.php
php-mecab-0.5.0/examples/dicinfo-func.php
php-mecab-0.5.0/examples/dicinfo-oo.php
php-mecab-0.5.0/examples/dumpall-func.php
php-mecab-0.5.0/examples/dumpall-oo.php
php-mecab-0.5.0/examples/dumpall-oo2.php
php-mecab-0.5.0/examples/format-func.php
php-mecab-0.5.0/examples/format-oo.php
php-mecab-0.5.0/examples/format-oo2.php
php-mecab-0.5.0/examples/nbest-func.php
php-mecab-0.5.0/examples/nbest-oo.php
php-mecab-0.5.0/examples/nodelist-func.php
php-mecab-0.5.0/examples/nodelist-oo.php
php-mecab-0.5.0/examples/nodelist-oo2.php
php-mecab-0.5.0/examples/parse-func-p.php
php-mecab-0.5.0/examples/parse-func.php
php-mecab-0.5.0/examples/parse-oo-p.php
php-mecab-0.5.0/examples/parse-oo.php
php-mecab-0.5.0/examples/provides-r.php
php-mecab-0.5.0/examples/provides.php
php-mecab-0.5.0/examples/split-func-p.php
php-mecab-0.5.0/examples/split-func.php
php-mecab-0.5.0/examples/split-oo-p.php
php-mecab-0.5.0/examples/split-oo.php
php-mecab-0.5.0/examples/test-func.php
php-mecab-0.5.0/examples/test-oo.php
php-mecab-0.5.0/examples/wakati-func.php
php-mecab-0.5.0/examples/wakati-oo.php
php-mecab-0.5.0/EXPERIMENTAL
php-mecab-0.5.0/LICENSE
php-mecab-0.5.0/manual/
php-mecab-0.5.0/manual/file-entities.ent
php-mecab-0.5.0/manual/functions.xml
php-mecab-0.5.0/manual/Makefile
php-mecab-0.5.0/manual/manual.xml.in
php-mecab-0.5.0/manual/mecab/
php-mecab-0.5.0/manual/mecab/configure.xml
php-mecab-0.5.0/manual/mecab/functions/
php-mecab-0.5.0/manual/mecab/functions/mecab-destroy.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-dictionary-info.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-format-node.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-get-all-morphs.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-get-lattice-level.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-get-partial.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-get-theta.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-nbest-init.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-nbest-next-tonode.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-nbest-next-tostr.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-nbest-sparse-tostr.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-new.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-alpha.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-begin-node-list.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-beta.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-bnext.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-char-type.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-cost.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-end-node-list.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-enext.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-feature.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-id.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-isbest.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-lcattr.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-length.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-lpath.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-next.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-posid.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-prev.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-prob.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-rcattr.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-rlength.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-rpath.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-sentence-length.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-stat.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-surface.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-toarray.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-tostring.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-node-wcost.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-path-cost.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-path-lnext.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-path-lnode.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-path-prob.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-path-rnext.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-path-rnode.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-set-all-morphs.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-set-lattice-level.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-set-partial.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-set-theta.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-sparse-tonode.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-sparse-tostr.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-split.xml
php-mecab-0.5.0/manual/mecab/functions/mecab-version.xml
php-mecab-0.5.0/manual/mecab/reference.xml
php-mecab-0.5.0/mecab.c
php-mecab-0.5.0/mecab.dsp
php-mecab-0.5.0/package.php
php-mecab-0.5.0/package.xml
php-mecab-0.5.0/php_mecab.h
php-mecab-0.5.0/php_mecab_compat.h
php-mecab-0.5.0/README
php-mecab-0.5.0/tests/
php-mecab-0.5.0/tests/MeCab__getEncoding.phpt
php-mecab-0.5.0/tests/MeCab__setEncoding.phpt
php-mecab-0.5.0/tests/MeCab__split.phpt
php-mecab-0.5.0/tests/MeCab__version.phpt
php-mecab-0.5.0/tests/mecab_destroy.phpt
php-mecab-0.5.0/tests/mecab_dictionary_info.phpt
php-mecab-0.5.0/tests/mecab_format_node.phpt
php-mecab-0.5.0/tests/mecab_nbest_init.phpt
php-mecab-0.5.0/tests/mecab_nbest_next_tonode.phpt
php-mecab-0.5.0/tests/mecab_nbest_next_tostr.phpt
php-mecab-0.5.0/tests/mecab_nbest_sparse_tostr.phpt
php-mecab-0.5.0/tests/mecab_new.phpt
php-mecab-0.5.0/tests/MeCab_Node__getAlpha.phpt
php-mecab-0.5.0/tests/MeCab_Node__getBeginNodeList.phpt
php-mecab-0.5.0/tests/MeCab_Node__getBeta.phpt
php-mecab-0.5.0/tests/MeCab_Node__getBNext.phpt
php-mecab-0.5.0/tests/MeCab_Node__getCharType.phpt
php-mecab-0.5.0/tests/MeCab_Node__getCost.phpt
php-mecab-0.5.0/tests/MeCab_Node__getEndNodeList.phpt
php-mecab-0.5.0/tests/MeCab_Node__getENext.phpt
php-mecab-0.5.0/tests/MeCab_Node__getFeature.phpt
php-mecab-0.5.0/tests/MeCab_Node__getId.phpt
php-mecab-0.5.0/tests/MeCab_Node__getIterator.phpt
php-mecab-0.5.0/tests/MeCab_Node__getLcAttr.phpt
php-mecab-0.5.0/tests/MeCab_Node__getLength.phpt
php-mecab-0.5.0/tests/MeCab_Node__getLPath.phpt
php-mecab-0.5.0/tests/MeCab_Node__getNext.phpt
php-mecab-0.5.0/tests/MeCab_Node__getPosId.phpt
php-mecab-0.5.0/tests/MeCab_Node__getPrev.phpt
php-mecab-0.5.0/tests/MeCab_Node__getProb.phpt
php-mecab-0.5.0/tests/MeCab_Node__getRcAttr.phpt
php-mecab-0.5.0/tests/MeCab_Node__getRLength.phpt
php-mecab-0.5.0/tests/MeCab_Node__getRPath.phpt
php-mecab-0.5.0/tests/MeCab_Node__getSentenceLength.phpt
php-mecab-0.5.0/tests/MeCab_Node__getStat.phpt
php-mecab-0.5.0/tests/MeCab_Node__getSurface.phpt
php-mecab-0.5.0/tests/MeCab_Node__getWCost.phpt
php-mecab-0.5.0/tests/MeCab_Node__isBest.phpt
php-mecab-0.5.0/tests/MeCab_Node__setTraverse.phpt
php-mecab-0.5.0/tests/MeCab_Node__toArray.phpt
php-mecab-0.5.0/tests/MeCab_Node__toString.phpt
php-mecab-0.5.0/tests/mecab_node_alpha.phpt
php-mecab-0.5.0/tests/mecab_node_begin_node_list.phpt
php-mecab-0.5.0/tests/mecab_node_beta.phpt
php-mecab-0.5.0/tests/mecab_node_bnext.phpt
php-mecab-0.5.0/tests/mecab_node_char_type.phpt
php-mecab-0.5.0/tests/mecab_node_cost.phpt
php-mecab-0.5.0/tests/mecab_node_end_node_list.phpt
php-mecab-0.5.0/tests/mecab_node_enext.phpt
php-mecab-0.5.0/tests/mecab_node_feature.phpt
php-mecab-0.5.0/tests/mecab_node_id.phpt
php-mecab-0.5.0/tests/mecab_node_isbest.phpt
php-mecab-0.5.0/tests/mecab_node_lcattr.phpt
php-mecab-0.5.0/tests/mecab_node_length.phpt
php-mecab-0.5.0/tests/mecab_node_lpath.phpt
php-mecab-0.5.0/tests/mecab_node_next.phpt
php-mecab-0.5.0/tests/mecab_node_posid.phpt
php-mecab-0.5.0/tests/mecab_node_prev.phpt
php-mecab-0.5.0/tests/mecab_node_prob.phpt
php-mecab-0.5.0/tests/mecab_node_rcattr.phpt
php-mecab-0.5.0/tests/mecab_node_rlength.phpt
php-mecab-0.5.0/tests/mecab_node_rpath.phpt
php-mecab-0.5.0/tests/mecab_node_sentence_length.phpt
php-mecab-0.5.0/tests/mecab_node_stat.phpt
php-mecab-0.5.0/tests/mecab_node_surface.phpt
php-mecab-0.5.0/tests/mecab_node_toarray.phpt
php-mecab-0.5.0/tests/mecab_node_tostring.phpt
php-mecab-0.5.0/tests/mecab_node_wcost.phpt
php-mecab-0.5.0/tests/MeCab_NodeIterator__current.phpt
php-mecab-0.5.0/tests/MeCab_NodeIterator__key.phpt
php-mecab-0.5.0/tests/MeCab_NodeIterator__next.phpt
php-mecab-0.5.0/tests/MeCab_NodeIterator__rewind.phpt
php-mecab-0.5.0/tests/MeCab_NodeIterator__valid.phpt
php-mecab-0.5.0/tests/MeCab_Path__getCost.phpt
php-mecab-0.5.0/tests/MeCab_Path__getLNext.phpt
php-mecab-0.5.0/tests/MeCab_Path__getLNode.phpt
php-mecab-0.5.0/tests/MeCab_Path__getProb.phpt
php-mecab-0.5.0/tests/MeCab_Path__getRNext.phpt
php-mecab-0.5.0/tests/MeCab_Path__getRNode.phpt
php-mecab-0.5.0/tests/mecab_path_cost.phpt
php-mecab-0.5.0/tests/mecab_path_lnext.phpt
php-mecab-0.5.0/tests/mecab_path_lnode.phpt
php-mecab-0.5.0/tests/mecab_path_prob.phpt
php-mecab-0.5.0/tests/mecab_path_rnext.phpt
php-mecab-0.5.0/tests/mecab_path_rnode.phpt
php-mecab-0.5.0/tests/mecab_sparse_tonode.phpt
php-mecab-0.5.0/tests/mecab_sparse_tostr.phpt
php-mecab-0.5.0/tests/mecab_split.phpt
php-mecab-0.5.0/tests/MeCab_Tagger____construct.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__dictionaryInfo.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__formatNode.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__next.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__nextNode.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__parse.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__parseNBest.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__parseNBestInit.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__parseToNode.phpt
php-mecab-0.5.0/tests/MeCab_Tagger__parseToString.phpt
php-mecab-0.5.0/tests/mecab_version.phpt
php-mecab-0.5.0/tests/test.txt.eucjp


インストール

 閲覧数:233 投稿日:2015-03-16 更新日:2015-03-16 
$ ls -la
drwxr-xr-x    5 ★★ ★★    4096  3月  4 04:41 2012 php-mecab-0.5.0
-rw-rw-r--    1 ★★ ★★   50180  3月 16 11:35 2015 php-mecab-0.5.0.tgz


$ cd php-mecab-0.5.0


phpize


共有 PECL 拡張モジュールをコンパイル
・コマンド実行すると、extname.so が作成される
・上記ファイルは、PHP の 拡張モジュールディレクトリ へ配置される
・この拡張モジュールを使用するためには、事前にphp.ini へ 「extension=extname.so」 行を追加する必要がある
$ phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525



$ ./configure --with-php-config=/usr/bin/php-config --with-mecab=/usr/local/bin/mecab-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable MeCab support... yes, shared
checking PHP version... ok
checking for mecab-config... /usr/local/bin/mecab-config
checking for MeCab library version... 0.996 (ok)
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mecab.h usability... yes
checking mecab.h presence... yes
checking for mecab.h... yes
checking for mecab_new2 in -lmecab... yes
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1966080
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands



$ make


sudo make install
・make install だけは特別
※一般ユーザ権限ではなく、スーパーユーザ権限で実施
sudo make install


確認

 閲覧数:212 投稿日:2015-03-16 更新日:2015-03-16 
mecab.so の確認
ls -l /usr/lib64/php/modules/mecab.so


mecab.so を PHP のエクステンションとして登録
sudo vi /etc/php.d/mecab.ini
extension=mecab.so



apache リロード
sudo service httpd reload



MeCab 0.996 インストール

php-mecab 0.6.0 インストール



週間人気ページランキング / 9-18 → 9-24
順位 ページタイトル抜粋 アクセス数
1 Nginx設定。エラーログレベル | Nginx(Webサーバ) 17
2 PHP実行ユーザ設定 / CentOS6 / Apache | PHP(プログラミング言語) 14
3 9回目-13.MySQL5.7.21設定 | CentOS 7 2週間無料のお試し期間 9回目(さくらVPS) 12
4 PHPのmb_send_mail関数でメール送信できない | メール処理システム 10
5 ImageMagick と imagick の違い | ImageMagick(ソフトウェアスイート) 9
6 さくらVPS0 8
6 tar: これは tar アーカイブではないようです 8
7 manページ日本語表示 | CentOS 7 (CentOS) 7
7 Reached target Shutdown メッセージが表示されたあと、シャットダウンまたは再起動プロセスがハングアップする | CentOS 7 (CentOS) 7
8 ABRT により 問題が検出されました | CentOS 7 (CentOS) 6
8 PHPファイルでchmodエラー | PHP(プログラミング言語) 6
8 「設定ファイルに、暗号化 (blowfish_secret) 用の非公開パスフレーズの設定を必要とするようになりました。」対応 6
8 Python 3.5 アンインストール / yum remove | Python(プログラミング言語) 6
9 FFmpeg 2.8.15 を yum インストール | ソフトウェアスイート 5
9 echo と cat の違い 5
10 phpMyAdmin 4.4.3(phpMyAdmin) カテゴリー 4
10 6回目-10.Nginxでバーチャルホスト設定確認 | CentOS 7 2週間無料のお試し期間 6回目(さくらVPS) 4
10 「さくらVPS」で、「CentOS6」を「CentOS7」へ変更するためには? | CentOS 7 2週間無料のお試し期間 Link(さくらVPS) 4
10 cronで定期実行しているphpファイルを、コマンドライン経由で即時実行する | cron(Linuxコマンド) 4
10 MySQL 5.5 から 5.6 へのアップグレード | MySQL(データベース) 4
2021/9/25 1:01 更新