Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # try this!!
- use Template::Reverse;
- use Data::Dumper;
- use utf8;
- binmode(STDOUT,':utf8');
- my $rev = Template::Reverse->new;
- # generating patterns automatically!!
- my $str1 = [split(/(\s)/,"안녕하세 저는 김현승 입니다.")];
- my $str2 = [split(/(\s)/,"반갑습니다 저는 박연건 입니다.")];
- my $parts = $rev->detect($str1, $str2);
- my $str3 = "심심합니다 저는 조건희 입니다.";
- print "$str3\n";
- # extract with TT2
- use Template::Reverse::Converter::TT2;
- my $tt2 = Template::Reverse::Converter::TT2->new;
- my $templates = $tt2->Convert($parts); # equals to ['I am [% value %] and ',' and [% value %]']
- use Template::Extract;
- my $ext = Template::Extract->new;
- foreach my $part (@{$templates}){
- print "$part => ";
- my $value = $ext->extract($part, $str3);
- print $value->{value}."\n"; # output : {'value'=>'king of the world'}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement