CentOS6.5にmecabを入れる

形態素解析エンジンを使ってみたかったのでインストール。
環境はVagrant(ViruatlBOX)上のCentOS6.5。

どうやらyumでそのままでは入らないらしい。
Rails4でnattoを使い、mecabで形態素解析をする方法(CentOS6) - コンユウメモ


全文検索エンジンgroongaのインストールでmecabを入れる。
2.5. CentOS — Groonga v9.0.2ドキュメント

$sudo rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
Retrieving http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
warning: /var/tmp/rpm-tmp.IUh9Nh: Header V4 DSA/SHA1 Signature, key ID 45499429: NOKEY
Preparing... ########################################### [100%]
1:groonga-release ########################################### [100%]
[1]+ Done emacs


多分以下は間違い

$sudo yum install -y groonga-tokenizer-mecab
Loaded plugins: fastestmirror, refresh-packagekit, versionlock
Loading mirror speeds from cached hostfile
epel/metalink | 6.1 kB 00:00
* base: centos.mirror.secureax.com
* epel: epel.mirror.srv.co.ge
* extras: centos.mirror.secureax.com
* updates: centos.mirror.secureax.com
base | 3.7 kB 00:00
epel | 4.4 kB 00:00
epel/primary_db | 6.4 MB 00:01
extras | 3.4 kB 00:00
google-chrome | 951 B 00:00
groonga | 2.5 kB 00:00
groonga/primary_db | 172 kB 00:00
updates | 3.4 kB 00:00
http://centos.mirror.secureax.com/6.6/updates/x86_64/repodata/f3714a9362604ca1df0a0a00df8bb7e5c7bccf7ea8bd43648455caa9b69716e8-primary.sqlite.bz2: [Errno 12] Timeout on http://centos.mirror.secureax.com/6.6/updates/x86_64/repodata/f3714a9362604ca1df0a0a00df8bb7e5c7bccf7ea8bd43648455caa9b69716e8-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
Trying other mirror.
updates/primary_db | 1.5 MB 00:00
zabbix | 951 B 00:00
zabbix-non-supported | 951 B 00:00
Setting up Install Process
Resolving Dependencies

    • > Running transaction check
      • > Package groonga-tokenizer-mecab.x86_64 0:4.1.0-1.el6 will be installed
    • > Processing Dependency: groonga-libs = 4.1.0-1.el6 for package: groonga-tokenizer-mecab-4.1.0-1.el6.x86_64
    • > Processing Dependency: mecab-dic for package: groonga-tokenizer-mecab-4.1.0-1.el6.x86_64
    • > Processing Dependency: libmecab.so.2()(64bit) for package: groonga-tokenizer-mecab-4.1.0-1.el6.x86_64
    • > Processing Dependency: libgroonga.so.0()(64bit) for package: groonga-tokenizer-mecab-4.1.0-1.el6.x86_64
    • > Running transaction check
      • > Package groonga-libs.x86_64 0:4.1.0-1.el6 will be installed
      • > Package mecab.x86_64 0:0.996-1.el6 will be installed
      • > Package mecab-ipadic.x86_64 0:2.7.0.20070801-8.el6.1 will be installed
    • > Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================
Installing:
groonga-tokenizer-mecab x86_64 4.1.0-1.el6 groonga 13 k
Installing for dependencies:
groonga-libs x86_64 4.1.0-1.el6 groonga 1.3 M
mecab x86_64 0.996-1.el6 groonga 353 k
mecab-ipadic x86_64 2.7.0.20070801-8.el6.1 groonga 11 M

Transaction Summary
=====================================================================================================================
Install 4 Package(s)

Total download size: 12 M
Installed size: 57 M
Downloading Packages:
(1/4): groonga-libs-4.1.0-1.el6.x86_64.rpm | 1.3 MB 00:00
(2/4): groonga-tokenizer-mecab-4.1.0-1.el6.x86_64.rpm | 13 kB 00:00
(3/4): mecab-0.996-1.el6.x86_64.rpm | 353 kB 00:00
(4/4): mecab-ipadic-2.7.0.20070801-8.el6.1.x86_64.rpm | 11 MB 00:01

                                                                                                                                                                                                                                        • -

Total 3.5 MB/s | 12 MB 00:03
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 45499429: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-groonga
Importing GPG key 0x45499429:
Userid : groonga Key (groonga Official Signing Key)
Package: groonga-release-1.1.0-1.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-groonga
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : mecab-0.996-1.el6.x86_64 1/4
Installing : mecab-ipadic-2.7.0.20070801-8.el6.1.x86_64 2/4
Installing : groonga-libs-4.1.0-1.el6.x86_64 3/4
Installing : groonga-tokenizer-mecab-4.1.0-1.el6.x86_64 4/4
Verifying : groonga-tokenizer-mecab-4.1.0-1.el6.x86_64 1/4
Verifying : groonga-libs-4.1.0-1.el6.x86_64 2/4
Verifying : mecab-0.996-1.el6.x86_64 3/4
Verifying : mecab-ipadic-2.7.0.20070801-8.el6.1.x86_64 4/4

Installed:
groonga-tokenizer-mecab.x86_64 0:4.1.0-1.el6

Dependency Installed:
groonga-libs.x86_64 0:4.1.0-1.el6 mecab.x86_64 0:0.996-1.el6 mecab-ipadic.x86_64 0:2.7.0.20070801-8.el6.1

Complete!

インストール完了。

多分mecabのインストールはリポジトリを追加した後にこれ↓だけで良かったと思う。

sudo yum install mecab mecab-ipadic

以下、実行結果。

$mecab
すもももももももものうち
すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
も 助詞,係助詞,*,*,*,*,も,モ,モ
もも 名詞,一般,*,*,*,*,もも,モモ,モモ
の 助詞,連体化,*,*,*,*,の,ノ,ノ
うち 名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
EOS

EOS
^C

mecabすごい