Pixel Pedals of Tomakomai

北海道苫小牧市出身の初老の日常

ChaSen

遊ぶために茶筌をインストールした。手順はほぼドキュメントにある通りだよ。



  1. darts-0.2.tar.gzを頂いてきて、./configure; make; make check; make install;
  2. chasen-2.3.3.tar.gzを頂いてきて、./configure; make; make check; make install
  3. ipadic-2.7.0.tar.gzを頂いてきて、./configure; make; make check; make install;
  4. chasen-2.3.3.tar.gzに入ってるperlディレクトリで、Makefile.PLを編集

    (リンカをC++の物を使うために、'LD' => "c++" を追加)

    後はperl Makefile.PL; make; make install;




で、テスト代わりにセンスのかけらもないスクリプトを作成。
 


#!/usr/local/bin/perl
use Text::ChaSen qw(getopt_argv sparse_tostr);
use LWP::Simple;
use Jcode;
my $html = get('http://hiratara.dyndns.org/movabletype_days/archives/001278.html');
$html = Jcode->new($html, 'utf8')->euc();
$html =~ s/<[^>]+>//gs;

$res = getopt_argv('chasen-perl', '-j', '-F', "%m\n");
$str = sparse_tostr($html);
print $str;

【結果(一部だけ抜粋)】
注文




揃う


バニラ
アイス

浮い

いる
クリーム
ソーダ

さらに
バニラ
アイス

2

投入






おおー、きちんと動いてるみたい。こいつは読みがなやどの品詞のレベルかまでを判定できるので、考えれば色んな使い道がありそう。もちろん辞書に入っている単語だけだけど、その辞書も自分で定義可能っぽい(テストしてないけど)。