| 1 | package Treex::Block::W2A::JA::RehangParticles; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Treex::Block::W2A::JA::RehangParticles::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 | # While recursively depth-first-traversing the tree | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # we sometimes rehang already processed parent node as a child node. | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # But we don't want to process such nodes again. | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my %is_processed; | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub process_atree { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_atree: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my ( $self, $a_root ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | %is_processed = (); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | foreach my $child ( $a_root->get_children() ) { | |||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | fix_subtree($child); | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub fix_subtree { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fix_subtree: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my ($a_node) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ( should_switch_with_parent($a_node) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | switch_with_parent($a_node); | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $is_processed{$a_node} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | foreach my $child ( $a_node->get_children() ) { | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | next if $is_processed{$child}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | fix_subtree($child); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub should_switch_with_parent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
should_switch_with_parent: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my ($a_node) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $tag = $a_node->tag; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | return 0 if $tag !~ /^Joshi/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # conjunctions are handled in other block | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | return 0 if ($tag =~ /^Joshi-SetsuzokuJoshi/ || $tag =~ /^Joshi-Heiritsujoshi/ || $tag =~ /^Setsuzokushi/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$tag =~ /^Joshi-SetsuzokuJoshi/ or $tag =~ /^Joshi-Heiritsujoshi/ or $tag =~ /^Setsuzokushi/
$tag =~ /^Joshi-SetsuzokuJoshi/ or $tag =~ /^Joshi-Heiritsujoshi/
MC/DC0%0/3
$tag =~ /^Joshi-SetsuzokuJoshi/ or $tag =~ /^Joshi-Heiritsujoshi/ or $tag =~ /^Setsuzokushi/
$tag =~ /^Joshi-SetsuzokuJoshi/
$tag =~ /^Joshi-Heiritsujoshi/
$tag =~ /^Setsuzokushi/
Truth table0%0/4
A or B or C
A= $tag =~ /^Joshi-SetsuzokuJoshi/B= $tag =~ /^Joshi-Heiritsujoshi/C= $tag =~ /^Setsuzokushi/
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | # we probably do not want to move adverbial particles | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return 0 if $tag =~ /FukuJoshi/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $parent = $a_node->get_parent(); | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | return 0 if $parent->is_root(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub switch_with_parent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
switch_with_parent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my ($a_node) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $form = $a_node->form; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $parent = $a_node->get_parent(); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $granpa = $parent->get_parent(); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $a_node->set_parent($granpa); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $parent->set_parent($a_node); | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | __END__ | ||||||||||||||||||||||||||||||||||||||||||