Filter::YomiHiraGana 人çã«å¿ è¦ãªç¥æµã¯ãã¹ã¦Pla(ry
ãã¿ããª(平仮å)ãä»ããFilter::YomiHiraGanaãid:lestrratããã®Text::MeCabã使ã£ã¦ãã¾ãã
ã¾ã æ¼¢åãèªããªããåæ§ãããã§å¤§ä¸å¤«ãã¤ã³ã¿ã¼ãããã§æ¼¢åã楽ããåå¼·ã§ãã¾ããå¹¼ç¨åãå°å¦æ ¡ã«Plaggerããã²å°å ¥ãã¾ãããã
人çã«å¿ è¦ãªç¥æµã¯ãã¹ã¦å¹¼ç¨åã®ç å ´ã§å¦ãã (æ²³åºæ庫)
- ä½è : ããã¼ããã«ã¬ã ,Robert Fulghum,æ± å¤®è¿
- åºç社/ã¡ã¼ã«ã¼: æ²³åºæ¸æ¿æ°ç¤¾
- çºå£²æ¥: 1996/03
- ã¡ãã£ã¢: æ庫
- è³¼å ¥: 6人 ã¯ãªãã¯: 89å
- ãã®ååãå«ãããã° (30件) ãè¦ã
package Plagger::Plugin::Filter::YomiHiraGana; use strict; use base qw( Plagger::Plugin ); use Text::MeCab; use Unicode::Japanese; sub register { my($self, $context) = @_; $context->register_hook( $self, 'update.entry.fixup' => \&update, ); } sub update { my($self, $context, $args) = @_; my $title = $args->{entry}->title; my $body = $args->{entry}->body; $title = $self->add_hiragana($title); $body = $self->add_hiragana($body); $args->{entry}->title($title); $args->{entry}->body($body); } sub add_hiragana{ my ($self,$string) = @_; my $mecab = Text::MeCab->new(); my $hiragana_string; for (my $node = $mecab->parse($string); $node; $node = $node->next) { my $kana = (split(',',$node->feature))[7]; my $s = Unicode::Japanese->new(); my $code = $s->getcode($node->surface); my $hiragana = $s->set($kana)->kata2hira->get; if($hiragana && $hiragana ne "*" && $hiragana ne $node->surface && $kana ne $node->surface && $code ne "ascii"){ $hiragana_string .= $node->surface."($hiragana)"; }elsif($code ne "unknown"){ $hiragana_string .= $node->surface; } } $hiragana_string; } 1; __END__