mecabでUTF-8

apt-get install mecab-ipadic
cd cd /usr/share/mecab/dic/ipadic/

dicrc の charset = utf8 に変更し、このディレクトリのファイルを全てutf8へ変換。

for i in * ; do mv $i $i.euc; nkf -w $i.euc > $i; done

辞書をmecabに取り込む

dpkg-reconfigure mecab-ipadic
phpから使ってみる
$descriptorspec = array(
        0=>array("pipe", "r"),
        1=>array("pipe", "w"),
        2=>array("pipe", "r"),
);
$mecab = '/usr/bin/mecab';
$string = '太郎はこの本を二郎を見た女性に渡した。';
$ph = proc_open($mecab,$descriptorspec, $pipes, $cwd, $env);
if( is_resource($ph) )
{
  fwrite($pipes[0],$string);
  fclose($pipes[0]);
  $sp = stream_get_contents($pipes[1]);
}