Block/W2A/JA/RehangAuxVerbs.pm

filter: Statementstmt 40.4% 19 / 47 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 4 totaltotal 31.1% 24 / 77 CC 11 SCAR 27.0
CC
11
Cov
31%
should_switch_with_parent
30.0
fix_subtree
20.0
switch_with_parent
12.0
CRAP 14.9
« Block/W2A/JA/RehangCopulas.pm ↑ Summary Block/W2A/JA/FixCopulas.pm »
1 package Treex::Block::W2A::JA::RehangAuxVerbs;
2 1 $Treex::Block::W2A::JA::RehangAuxVerbs::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  
10 1 extends 'Treex::Core::Block';
11  
12 1 my %is_processed;
13  
14 0 ▶sub process_atree {
Subroutine process_atree: not called CC=2 SCAR=17.9
Pod undocumented
15 0 my ( $self, $a_root ) = @_;
16 0 %is_processed = ();
17 0 foreach my $child ( $a_root->get_children() ) {
18 0 fix_subtree($child);
19 }
20 0 return 1;
21 }
22  
23 0 ▶sub fix_subtree {
Subroutine fix_subtree: not called CC=4 SCAR=30.0
Pod undocumented
24 0 my ($a_node) = @_;
25  
26 0 ▶ if ( should_switch_with_parent($a_node) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (should_switch_with_parent($a_node)) 0 0 0
27 0 switch_with_parent($a_node);
28 }
29 0 $is_processed{$a_node} = 1;
30
31 0 foreach my $child ( $a_node->get_children() ) {
32 0 ▶ next if $is_processed{$child};
Branch: 1 branch
BranchTrueFalseTotal
if $is_processed{$child} 0 0 0
33 0 fix_subtree($child);
34 }
35 0 return;
36 }
37  
38 0 ▶sub should_switch_with_parent {
Subroutine should_switch_with_parent: not called CC=5 SCAR=34.0
Pod undocumented
39 0 my ($a_node) = @_;
40 0 my $tag = $a_node->tag;
41 0 ▶ return 0 if ( $tag !~ /^Dōshi/ );
Branch: 1 branch
BranchTrueFalseTotal
unless $tag =~ /^D\x{14d}shi/ 0 0 0
42  
43 0 my $parent = $a_node->get_parent();
44 0 ▶ return 0 if $parent->is_root();
Branch: 1 branch
BranchTrueFalseTotal
if $parent->is_root 0 0 0
45  
46 # check, if our verb is dependent on a non-independent verb (non-pure auxiliary, e.g. "iru", "aru") or suffix-verb (pure auxiliary, e.g. "rareru", "saseru")
47 # NOTE: pure auxiliaries, which are marked as Jodoshi (e.g. "masu") are parsed correctly in the parser block, so we do not fix them
48 0 ▶ return 0 if ($parent->tag !~ /-HiJiritsu/ && $parent->tag !~ /-Setsubi/);
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->tag =~ /-HiJiritsu/ or $parent->tag =~ /-Setsubi/ 0 0 0
Condition0%0/3
$parent->tag =~ /-HiJiritsu/ or $parent->tag =~ /-Setsubi/
l!l&&r!l&&!r
000
MC/DC0%0/2
$parent->tag =~ /-HiJiritsu/ or $parent->tag =~ /-Setsubi/
$parent->tag =~ /-HiJiritsu/ $parent->tag =~ /-Setsubi/
Truth table0%0/3
A or B
A= $parent->tag =~ /-HiJiritsu/B= $parent->tag =~ /-Setsubi/
ABresult
1X1
011
000
49  
50 0 return 1;
51 }
52  
53 0 ▶sub switch_with_parent {
Subroutine switch_with_parent: not called CC=3 SCAR=24.8
Pod undocumented
54 0 my ($a_node) = @_;
55 0 my $parent = $a_node->get_parent();
56 0 my $granpa = $parent->get_parent();
57 0 $a_node->set_parent($granpa);
58 0 $parent->set_parent($a_node);
59  
60 # we must also rehang other nodes which shouldnt be dependent on the
61 # non-independent verb
62 0 foreach my $child ($parent->get_children()) {
63 # we don't want to rehang aux verbs
64 0 ▶ $child->set_parent($a_node) if ($child->tag !~ /Jodōshi/);
Branch: 1 branch
BranchTrueFalseTotal
unless $child->tag =~ /Jod\x{14d}shi/ 0 0 0
65 }
66 0 return;
67 }
68  
69 1 1;
70  
71 __END__
« Block/W2A/JA/RehangCopulas.pm ↑ Summary Block/W2A/JA/FixCopulas.pm »