| 1 | package App::cdif::Command::Mecab; | ||||||||||
| 2 | |||||||||||
| 3 | 15 | ▶ | use parent "App::cdif::Command"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 15 | ▶ | use v5.14; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 15 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 15 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 15 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 15 | our $debug; | |||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | sub wordlist { | ||||||||
|
Subroutine
wordlist: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 14 | 0 | my $obj = shift; | |||||||||
| 15 | 0 | my $text = shift; | |||||||||
| 16 | |||||||||||
| 17 | ## | ||||||||||
| 18 | ## mecab ignores trailing spaces. | ||||||||||
| 19 | ## | ||||||||||
| 20 | 0 | ▶ | my $removeme = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 21 | 0 | local *_ = shift; | |||||||||
| 22 | 0 | ▶ | return sub { 0 } unless /[ \t]+$/m; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 23 | 0 | my $magic = "15570"."67583"; | |||||||||
| 24 | 0 | ▶ | $magic++ while /$magic/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | s/[ \t]+\K$/$magic/mg; | |||||||||
| 26 | 0 | ▶ | sub { $_ eq $magic }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 27 | 0 | }->(\$text); | |||||||||
| 28 | |||||||||||
| 29 | 0 | my $eos = "EOS" . "000"; | |||||||||
| 30 | 0 | ▶ | $eos++ while $text =~ /$eos/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | ▶ | my $is_newline = sub { $_ eq $eos }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 32 | |||||||||||
| 33 | 0 | my @mecab = ('mecab', '--node-format', '%M\\n', '--eos-format', "$eos\\n"); | |||||||||
| 34 | 0 | my $result = $obj->command(@mecab)->setstdin($text)->update->data; | |||||||||
| 35 | 0 | ▶ | warn $result =~ s/^/MECAB: /mgr if $debug; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | do { | |||||||||
| 37 | 0 | ▶ | map { $is_newline->() ? "\n" : $_ } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | grep { not $removeme->() } | |||||||||
| 39 | 0 | ▶ | map { /\A\w/ ? $_ : uniqchar($_) } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | grep { length } | |||||||||
| 41 | $result =~ /^([^\w\n]*+)(.*)\n/mg; | ||||||||||
| 42 | }; | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub uniqchar { | ||||||||
|
Subroutine
uniqchar: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 46 | 0 | my @s; | |||||||||
| 47 | 0 | for (@_) { | |||||||||
| 48 | 0 | ▶ | while (/(\X)\g{-1}*/pg) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | push @s, ${^MATCH}; | |||||||||
| 50 | } | ||||||||||
| 51 | } | ||||||||||
| 52 | 0 | @s; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 15 | 1; | |||||||||