Block/W2A/EN/FixTags.pm

filter: Statementstmt 45.0% 18 / 40 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 25.2% 24 / 95 CC 17 SCAR 50.6
CC
17
Cov
23%
_get_tag
240.0
process_anode
12.0
BEGIN
1.0
CRAP 158.3
« Tool/EnglishMorpho/Analysis.pm ↑ Summary Block/W2A/EN/FixTagsAfterParse.pm »
1 package Treex::Block::W2A::EN::FixTags;
2 1 $Treex::Block::W2A::EN::FixTags::VERSION = '2.20151102';
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 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 extends 'Treex::Core::Block';
9  
10 0 ▶sub process_anode {
Subroutine process_anode: not called CC=3 SCAR=24.8
Pod documented
11 0 my ( $self, $anode ) = @_;
12  
13 0 my $old_tag = $anode->tag;
14 0 my $new_tag = $self->_get_tag($anode);
15 0 ▶ if ( $new_tag && $new_tag ne $old_tag ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_tag and $new_tag ne $old_tag) 0 0 0
Condition0%0/3
$new_tag and $new_tag ne $old_tag
!ll&&!rl&&r
000
MC/DC0%0/2
$new_tag and $new_tag ne $old_tag
$new_tag $new_tag ne $old_tag
Truth table0%0/3
A and B
A= $new_tagB= $new_tag ne $old_tag
ABresult
0X0
100
111
16 0 $anode->set_tag($new_tag);
17 0 $anode->set_attr( 'gloss', 'tag_origin=Fix_tags' );
18 }
19  
20 0 return 1;
21 }
22  
23 0 ▶sub _get_tag {
Subroutine _get_tag: not called CC=15 SCAR=54.8
24 0 my ( $self, $node ) = @_;
25 0 my ( $form, $tag ) = $node->get_attrs( 'form', 'tag' );
26  
27 #my ( $form, $tag, $id ) = $node->get_attrs( 'form', 'tag', 'id' );
28 # Abbreviations like MPs, CDs or DVDs should be tagged as plural proper noun
29 0 ▶ return 'NNPS' if $tag =~ /^NN/ && $form =~ /^\p{IsUpper}{2,}s$/;
Branch: 1 branch
BranchTrueFalseTotal
if $tag =~ /^NN/ and $form =~ /^\p{IsUpper}{2,}s$/ 0 0 0
Condition0%0/3
$tag =~ /^NN/ and $form =~ /^\p{IsUpper}{2,}s$/
!ll&&!rl&&r
000
MC/DC0%0/2
$tag =~ /^NN/ and $form =~ /^\p{IsUpper}{2,}s$/
$tag =~ /^NN/ $form =~ /^\p{IsUpper}{2,}s$/
Truth table0%0/3
A and B
A= $tag =~ /^NN/B= $form =~ /^\p{IsUpper}{2,}s$/
ABresult
0X0
100
111
30  
31 # All other rules are case insensitive
32 0 $form = lc $form;
33  
34 # "sooner" and "later" should be comparative (RBR or JJR)
35 # This goes against Penn Treebank Tagging Guidelines:
36 # ``Should be tagged as a simple adverb (RB) rather than as a comparative
37 # adverb (RBR), unless its meaning is clearly comparative.
38 # EXAMPLES: I'll get it around sooner/RB or later/RB.
39 # We'll arrive (even) later/RBR than your mother.
40 # ''
41 # However, this particular guideline doesn't match our (MT) purposes.
42 # The distinction can be seen on t-layer: gram/degcmp = comp vs. acomp.
43 0 ▶ return 'RBR' if $form =~ /^(lat|soon|earli)er/ && $tag eq 'RB';
Branch: 1 branch
BranchTrueFalseTotal
if $form =~ /^(lat|soon|earli)er/ and $tag eq "RB" 0 0 0
Condition0%0/3
$form =~ /^(lat|soon|earli)er/ and $tag eq "RB"
!ll&&!rl&&r
000
MC/DC0%0/2
$form =~ /^(lat|soon|earli)er/ and $tag eq "RB"
$form =~ /^(lat|soon|earli)er/ $tag eq "RB"
Truth table0%0/3
A and B
A= $form =~ /^(lat|soon|earli)er/B= $tag eq "RB"
ABresult
0X0
100
111
44  
45 # According to PTB Guidelines "e. g." is FW
46 0 ▶ return 'FW' if $form eq 'e. g.';
Branch: 1 branch
BranchTrueFalseTotal
if $form eq "e. g." 0 0 0
47  
48 # Morce can tag "2008" as VBP, but this rule may help also some dict. base taggers
49 0 ▶ return 'CD' if $form =~ /^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $form =~ /^\d+$/ 0 0 0
50  
51 # 1990s
52 0 ▶ return 'CD' if $form =~ /^\d\d\d0s$/;
Branch: 1 branch
BranchTrueFalseTotal
if $form =~ /^\d\d\d0s$/ 0 0 0
53  
54 # Iraqis = inhabitants of Iraq (The American Heritage Dictionary), Morce puts NNP
55 0 ▶ return 'NNPS' if $form eq 'iraqis';
Branch: 1 branch
BranchTrueFalseTotal
if $form eq "iraqis" 0 0 0
56  
57 # Morce has "burnt = VBD|VBN" in some dictionaries, but doesn't use it
58 0 ▶ return 'VBD' if $form eq 'burnt' && $tag !~ /VB[DN]/;
Branch: 1 branch
BranchTrueFalseTotal
if $form eq "burnt" and not $tag =~ /VB[DN]/ 0 0 0
Condition0%0/3
$form eq "burnt" and not $tag =~ /VB[DN]/
!ll&&!rl&&r
000
MC/DC0%0/2
$form eq "burnt" and not $tag =~ /VB[DN]/
$form eq "burnt" not $tag =~ /VB[DN]/
Truth table0%0/3
A and not(B)
A= $form eq "burnt"B= not $tag =~ /VB[DN]/
ABresult
0X0
100
111
59  
60 # '£' should have the same tag as '$' has
61 0 ▶ return '$' if $form eq '£';
Branch: 1 branch
BranchTrueFalseTotal
if $form eq "\x{a3}" 0 0 0
62  
63 # In "There!" it is not an existential there, but simple adverb.
64 # Otherwise, we would get an empty t-tree for such sentences.
65 return 'RB' if $tag eq 'EX'
66 0 ▶ && join( '', map { $_->form } $node->get_root->get_descendants( { ordered => 1 } ) ) =~ /^There.?$/;
Branch: 1 branch
BranchTrueFalseTotal
if $tag eq "EX" and join("", map({$_->form;} $node->get_root->get_descendants({"ordered", 1}))) =~ /^There.?$/ 0 0 0
Condition0%0/3
$tag eq "EX" and join("", map({$_->form;} $node->get_root->get_descendants({"ordered", 1}))) =~ /^There.?$/
!ll&&!rl&&r
000
MC/DC0%0/2
$tag eq "EX" and join("", map({$_->form;} $node->get_root->get_descendants({"ordered", 1}))) =~ /^There.?$/
$tag eq "EX" join("", map({$_->form;} $node->get_root->get_descendants({"ordered", 1}))) =~ /^There.?$/
Truth table0%0/3
A and B
A= $tag eq "EX"B= join("", map({$_->form;} $node->get_root->get_descendants({"ordered", 1}))) =~ /^There.?$/
ABresult
0X0
100
111
67  
68  
69 # the enities found by a gazeteer list considered being proper nouns
70 0 ▶ return 'NNP' if (defined $node->wild->{gazeteer_entity_id});
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->wild->{"gazeteer_entity_id"} 0 0 0
71  
72 0 return;
73 }
74  
75 1 1;
76  
77 __END__
« Tool/EnglishMorpho/Analysis.pm ↑ Summary Block/W2A/EN/FixTagsAfterParse.pm »