Skip to content

Instantly share code, notes, and snippets.

@kurain
Created November 21, 2011 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurain/1382199 to your computer and use it in GitHub Desktop.
Save kurain/1382199 to your computer and use it in GitHub Desktop.
To listen the IRC log
use warnings;
use strict;
use Text::MeCab;
use Perl6::Say;
my $mecab = Text::MeCab->new;
while(<>){
chomp;
my (undef,undef, @elms) = split ' ', $_;
my $text = join "", @elms;
my $node = $mecab->parse($text);
my $res = "";
while ($node) {
my @features = split ',', $node->feature;
my $pronaunce = $features[$#features];
$pronaunce = $node->surface if $pronaunce eq '*';
$res .= $pronaunce if $pronaunce;
$node = $node->next
}
say $res;
system "/usr/local/bin/SayKana $res";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment