| 1 | package Treex::Block::Util::FixInvalidIDs; | ||||||||||||||||||||
| 2 | 1 | $Treex::Block::Util::FixInvalidIDs::VERSION = '2.20210102'; | |||||||||||||||||||
| 3 | 1 | ▶ | use Treex::Core::Common; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | extends 'Treex::Core::Block'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | has action => ( | |||||||||||||||||||
| 8 | is=>'ro', | ||||||||||||||||||||
| 9 | default=>'warn', | ||||||||||||||||||||
| 10 | ); | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 0 | ▶ | sub process_zone { | ||||||||||||||||||
|
Subroutine
process_zone: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||
| 13 | 0 | my ( $self, $zone ) = @_; | |||||||||||||||||||
| 14 | 0 | my $doc = $zone->get_document(); | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | foreach my $tnode ($zone->get_ttree()->get_descendants()){ | |||||||||||||||||||
| 17 | 0 | my $lex_rf = $tnode->get_attr('a/lex.rf'); | |||||||||||||||||||
| 18 | 0 | ▶ | if (!defined $lex_rf) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 19 | 0 | ▶ | log_warn "Missing id in a/lex.rf of " . $tnode->get_address if $self->action eq 'warn'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | elsif (!$doc->id_is_indexed($lex_rf)){ | ||||||||||||||||||||
| 22 | 0 | $tnode->set_lex_anode(undef); | |||||||||||||||||||
| 23 | 0 | ▶ | log_warn "Missing node with id $lex_rf in a/lex.rf of " . $tnode->get_address if $self->action eq 'warn'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | 0 | my $aux_rfs = $tnode->get_attr('a/aux.rf'); | |||||||||||||||||||
| 26 | 0 | ▶ | if ($aux_rfs){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | 0 | ▶ | my @filtered = grep {defined $_ && $doc->id_is_indexed($_)} @$aux_rfs; | ||||||||||||||||||
|
Condition0%0/3
defined $_ && $doc->id_is_indexed($_)
MC/DC0%0/2
defined $_ && $doc->id_is_indexed($_)
defined $_
$doc->id_is_indexed($_)
Truth table0%0/3
A && B
A= defined $_B= $doc->id_is_indexed($_)
| |||||||||||||||||||||
| 28 | 0 | ▶ | if (@filtered != @$aux_rfs){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 0 | $tnode->set_attr('a/aux.rf', \@filtered); | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | ▶ | if ($self->action eq 'warn') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 0 | foreach my $aux_rf (@$aux_rfs){ | |||||||||||||||||||
| 33 | 0 | ▶ | if (!defined $aux_rf) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 34 | 0 | log_warn "Missing id in a/aux.rf of " . $tnode->get_address; | |||||||||||||||||||
| 35 | } elsif (!$doc->id_is_indexed($aux_rf)){ | ||||||||||||||||||||
| 36 | 0 | log_warn "Missing node with id $aux_rf in a/aux.rf of " . $tnode->get_address; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | return; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 1 | 1; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | __END__ | ||||||||||||||||||||