#!/usr/local/bin/perl
BEGIN { push(@INC, '$B$3$3$K!"(BChasen.pm $B$,$"$k%G%#%l%/%H%j$r5-=R$9$k(B'); }
use Chasen;

$chasen = Chasen->new('$B$3$3$K(B chasend $B$N%[%9%HL>$r;XDj$9$k(B', 31000)
    || die "Can't connect to chasen server.\n";

$text = join('', <>);
for($chasen->run($text, '%m %h'))
{
    ($word, $n) = /([^ ]*) (.*)/;
    $noun_table{$word}++ if $n eq '6';
}

while(($word, $cnt) = each %noun_table)
{
    print "$cnt $word\n";
}

$chasen->quit;
