Block/W2A/JA/FixInterpunction.pm

filter: Statementstmt 42.8% 18 / 42 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 30.2% 23 / 76 CC 12 SCAR 47.0
CC
12
Cov
29%
process_atree
156.0
BEGIN
1.0
BEGIN
1.0
CRAP 110.4
« Tool/Parser/JDEPP.pm ↑ Summary Block/W2A/JA/TagMeCab.pm »
1 package Treex::Block::W2A::JA::FixInterpunction;
2 1 $Treex::Block::W2A::JA::FixInterpunction::VERSION = '0.13095';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Treex::Core::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 extends 'Treex::Core::Block';
10  
11 # we change "。", "?" and "!" to ".", "?" and "!"
12 # we also rehang them to the root
13  
14 0 ▶sub process_atree {
Subroutine process_atree: not called CC=12 SCAR=50.5
Pod undocumented
15 0 my ( $self, $a_root ) = @_;
16 0 foreach my $a_node ( $a_root->get_descendants() ) {
17
18 0 ▶ next if ( $a_node->form !~ /[。?!]/ );
Branch: 1 branch
BranchTrueFalseTotal
unless $a_node->form =~ /[\x{3002}\x{ff1f}\x{ff01}]/ 0 0 0
19  
20 # we do not want Interpunction nodes to have children, so we rehang
21 # them to the previous parent
22 0 my $parent = $a_node->get_parent();
23 0 my @children = $a_node->get_children();
24
25 # set new parent for the children (since japanese is head final,
26 # it should be the last child)
27 0 my $new_parent;
28 0 ▶ if (@children) {
Branch: 1 branch
BranchTrueFalseTotal
if (@children) 0 0 0
29 0 $new_parent = pop @children;
30 0 ▶ $new_parent->set_parent($parent) if ($new_parent);
Branch: 1 branch
BranchTrueFalseTotal
if $new_parent 0 0 0
31 }
32  
33 # rehang the rest of the children
34 0 foreach my $child (@children) {
35 0 $child->set_parent($new_parent);
36 }
37  
38  
39 0 ▶ if ( $a_node->form eq "。" and $a_node->tag =~ /^Kigō/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a_node->form eq "\x{3002}" and $a_node->tag =~ /^Kig\x{14d}/) 0 0 0
Condition0%0/3
$a_node->form eq "\x{3002}" and $a_node->tag =~ /^Kig\x{14d}/
!ll&&!rl&&r
000
MC/DC0%0/2
$a_node->form eq "\x{3002}" and $a_node->tag =~ /^Kig\x{14d}/
$a_node->form eq "\x{3002}" $a_node->tag =~ /^Kig\x{14d}/
Truth table0%0/3
A and B
A= $a_node->form eq "\x{3002}"B= $a_node->tag =~ /^Kig\x{14d}/
ABresult
0X0
100
111
40 0 $a_node->set_form(".");
41 0 $a_node->set_lemma(".");
42 0 $a_node->set_parent($a_root);
43 }
44 0 ▶ if ( $a_node->form eq "?" and $a_node->tag =~ /^Kigō/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a_node->form eq "\x{ff1f}" and $a_node->tag =~ /^Kig\x{14d}/) 0 0 0
Condition0%0/3
$a_node->form eq "\x{ff1f}" and $a_node->tag =~ /^Kig\x{14d}/
!ll&&!rl&&r
000
MC/DC0%0/2
$a_node->form eq "\x{ff1f}" and $a_node->tag =~ /^Kig\x{14d}/
$a_node->form eq "\x{ff1f}" $a_node->tag =~ /^Kig\x{14d}/
Truth table0%0/3
A and B
A= $a_node->form eq "\x{ff1f}"B= $a_node->tag =~ /^Kig\x{14d}/
ABresult
0X0
100
111
45 0 $a_node->set_form("?");
46 0 $a_node->set_lemma("?");
47 0 $a_node->set_parent($a_root);
48 }
49 0 ▶ if ( $a_node->form eq "!" and $a_node->tag =~ /^Kigō/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a_node->form eq "\x{ff01}" and $a_node->tag =~ /^Kig\x{14d}/) 0 0 0
Condition0%0/3
$a_node->form eq "\x{ff01}" and $a_node->tag =~ /^Kig\x{14d}/
!ll&&!rl&&r
000
MC/DC0%0/2
$a_node->form eq "\x{ff01}" and $a_node->tag =~ /^Kig\x{14d}/
$a_node->form eq "\x{ff01}" $a_node->tag =~ /^Kig\x{14d}/
Truth table0%0/3
A and B
A= $a_node->form eq "\x{ff01}"B= $a_node->tag =~ /^Kig\x{14d}/
ABresult
0X0
100
111
50 0 $a_node->set_form("!");
51 0 $a_node->set_lemma("!");
52 0 $a_node->set_parent($a_root);
53 }
54  
55 }
56 0 return 1;
57 }
58  
59 1 1;
60  
61 __END__
« Tool/Parser/JDEPP.pm ↑ Summary Block/W2A/JA/TagMeCab.pm »