| 1 | package Treex::Block::W2A::EN::FixTags; | ||||||||||||||||||||||||||||
| 2 | BEGIN { | ||||||||||||||||||||||||||||
| 3 | 1 | ▶ | $Treex::Block::W2A::EN::FixTags::VERSION = '0.06903_1'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 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 | sub process_anode { | ||||||||||||||||||||||||||||
| 11 | 0 | ▶ | my ( $self, $anode ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
process_anode: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$new_tag and $new_tag ne $old_tag
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
| |||||||||||||||||||||||||||||
| 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 | sub _get_tag { | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my ($self, $node) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_tag: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||
| 25 | 0 | my ( $form, $tag ) = $node->get_attrs( 'form', 'tag' ); | |||||||||||||||||||||||||||
| 26 | #my ( $form, $tag, $id ) = $node->get_attrs( 'form', 'tag', 'id' ); | ||||||||||||||||||||||||||||
| 27 | # Abbreviations like MPs, CDs or DVDs should be tagged as plural proper noun | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | return 'NNPS' if $tag =~ /^NN/ && $form =~ /^\p{IsUpper}{2,}s$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tag =~ /^NN/ and $form =~ /^\p{IsUpper}{2,}s$/
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$/
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # All other rules are case insensitive | ||||||||||||||||||||||||||||
| 31 | 0 | $form = lc $form; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # "sooner" and "later" should be comparative (RBR or JJR) | ||||||||||||||||||||||||||||
| 34 | # This goes against Penn Treebank Tagging Guidelines: | ||||||||||||||||||||||||||||
| 35 | # ``Should be tagged as a simple adverb (RB) rather than as a comparative | ||||||||||||||||||||||||||||
| 36 | # adverb (RBR), unless its meaning is clearly comparative. | ||||||||||||||||||||||||||||
| 37 | # EXAMPLES: I'll get it around sooner/RB or later/RB. | ||||||||||||||||||||||||||||
| 38 | # We'll arrive (even) later/RBR than your mother. | ||||||||||||||||||||||||||||
| 39 | # '' | ||||||||||||||||||||||||||||
| 40 | # However, this particular guideline doesn't match our (MT) purposes. | ||||||||||||||||||||||||||||
| 41 | # The distinction can be seen on t-layer: gram/degcmp = comp vs. acomp. | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | return 'RBR' if $form =~ /^(lat|soon|earli)er/ && $tag eq 'RB'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$form =~ /^(lat|soon|earli)er/ and $tag eq "RB"
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"
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # According to PTB Guidelines "e. g." is FW | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | return 'FW' if $form eq 'e. g.'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # Morce can tag "2008" as VBP, but this rule may help also some dict. base taggers | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return 'CD' if $form =~ /^\d+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # 1990s | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | return 'CD' if $form =~ /^\d\d\d0s$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # Iraqis = inhabitants of Iraq (The American Heritage Dictionary), Morce puts NNP | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | return 'NNPS' if $form eq 'iraqis'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # Morce has "burnt = VBD|VBN" in some dictionaries, but doesn't use it | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | return 'VBD' if $form eq 'burnt' && $tag !~ /VB[DN]/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$form eq "burnt" and not $tag =~ /VB[DN]/
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]/
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # '£' should have the same tag as '$' has | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return '$' if $form eq '£'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | return; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 1 | 1; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 NAME | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Treex::Block::W2A::EN::FixTags - Fixes tags for TectoMT purposes. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head1 VERSION | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | version 0.06903_1 | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =over 4 | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =item sooner | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | "sooner" and "later" are always tagged as C<RBR> (comparative adverb) | ||||||||||||||||||||||||||||
| 86 | Beware that this goes against Penn Treebank Tagging Guidelines. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =item "e. g." -> FW (according to PTB Guidelines) | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =item numbers | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | All numbers (C</^\d+$/>) get tag CD. | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =item plural abbreviations | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Abbreviations like I<MPs, CDs or DVDs> are tagged as plural proper noun (C<NNPS>). | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =back | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 OVERRIDEN METHODS | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head2 from C<Treex::Core::Block> | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =over 4 | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =item process_anode | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =back | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head1 AUTHORS | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Zdeněk Žabokrtský <zabokrtsky@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | Martin Popel <popel@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | Copyright © 2008 - 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||