| 1 | package Treex::Core::TredView::Vallex; | ||||||||||||||||||||||
| 2 | 2 | $Treex::Core::TredView::Vallex::VERSION = '2.20210102'; | |||||||||||||||||||||
| 3 | 2 | ▶ | use Moose; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | 2 | ▶ | use Treex::Core::TredView::Common; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 5 | 2 | ▶ | use Treex::Core::Log; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | |||||||||||||||||||||||
| 7 | 2 | has '_treex_doc' => ( | |||||||||||||||||||||
| 8 | is => 'ro', | ||||||||||||||||||||||
| 9 | isa => 'Treex::Core::Document', | ||||||||||||||||||||||
| 10 | weak_ref => 1, | ||||||||||||||||||||||
| 11 | required => 1 | ||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||
| 13 | |||||||||||||||||||||||
| 14 | 0 | ▶ | sub _extension_missing { | ||||||||||||||||||||
|
Subroutine
_extension_missing: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||
| 15 | 0 | my ( $self, $ext ) = @_; | |||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | 0 | my $name = ''; | |||||||||||||||||||||
| 18 | 0 | ▶ | $name = 'Prague English Treebank Annotation' if $ext eq 'pedt'; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 19 | 0 | ▶ | $name = 'PDT-ValLex Editor' if $ext eq 'pdt_vallex'; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 20 | |||||||||||||||||||||||
| 21 | 0 | my $message = "This function requires additional extension that is missing.\n"; | |||||||||||||||||||||
| 22 | 0 | $message .= "Please install extension '$name'."; | |||||||||||||||||||||
| 23 | 0 | TredMacro::ToplevelFrame->messageBox( -type => 'ok', -message => $message ); | |||||||||||||||||||||
| 24 | 0 | return; | |||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||
| 26 | |||||||||||||||||||||||
| 27 | 0 | ▶ | sub _find_vallex { | ||||||||||||||||||||
|
Subroutine
_find_vallex: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 28 | 0 | my ( $self, $node ) = @_; | |||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | 0 | my $ref = $node->attr('val_frame.rf'); | |||||||||||||||||||||
| 31 | 0 | $ref =~ s/#.*//; | |||||||||||||||||||||
| 32 | |||||||||||||||||||||||
| 33 | 0 | my $file = $self->_treex_doc->metaData('references')->{$ref}; | |||||||||||||||||||||
| 34 | 0 | $file = TredMacro::ResolvePath( TredMacro::FileName(), $file, 1 ); | |||||||||||||||||||||
| 35 | 0 | return $file; | |||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||
| 37 | |||||||||||||||||||||||
| 38 | sub OpenValLexicon | ||||||||||||||||||||||
| 39 | 0 | ▶ | { | ||||||||||||||||||||
|
Subroutine
OpenValLexicon: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||||
| 41 | 0 | my $node = Treex::Core::TredView::Common::cur_node(); | |||||||||||||||||||||
| 42 | 0 | ▶ | return unless $node->attr('val_frame.rf'); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 43 | |||||||||||||||||||||||
| 44 | 0 | ▶ | if ( $node->language eq 'cs' ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 45 | 0 | $self->_OpenValLexicon_Cs($node); | |||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||
| 47 | 0 | ▶ | if ( $node->language eq 'en' ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 48 | 0 | $self->_OpenValLexicon_En($node); | |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||
| 50 | 0 | return; | |||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||
| 52 | |||||||||||||||||||||||
| 53 | sub ChooseValFrame | ||||||||||||||||||||||
| 54 | 0 | ▶ | { | ||||||||||||||||||||
|
Subroutine
ChooseValFrame: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||
| 56 | 0 | my $node = Treex::Core::TredView::Common::cur_node(); | |||||||||||||||||||||
| 57 | 0 | ▶ | return unless $node->attr('val_frame.rf'); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | 0 | ▶ | if ( $node->language eq 'cs' ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 60 | 0 | $self->_OpenValFrameList_Cs($node); | |||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||
| 62 | 0 | ▶ | if ( $node->language eq 'en' ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 63 | 0 | $self->_OpenValFrameList_En($node); | |||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||
| 65 | 0 | return; | |||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||
| 67 | |||||||||||||||||||||||
| 68 | 0 | ▶ | sub _assigned_frame_pos_of { | ||||||||||||||||||||
|
Subroutine
_assigned_frame_pos_of: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||
| 69 | 0 | my ( $self, $node ) = @_; | |||||||||||||||||||||
| 70 | 0 | ▶ | return unless $node; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 71 | 0 | ▶ | if ( $node->{'val_frame.rf'} ne q() ) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||
| 73 | 0 | my $vallex_file = FindVallex('cz'); | |||||||||||||||||||||
| 74 | 0 | my $V = ValLex::GUI::Init( { -vallex_file => $vallex_file } ); | |||||||||||||||||||||
| 75 | 0 | ▶ | if ($V) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||
| 77 | 0 | for my $id ( AltV( $node->{'val_frame.rf'} ) ) | |||||||||||||||||||||
| 78 | { | ||||||||||||||||||||||
| 79 | 0 | my $frame = $V->by_id($id); | |||||||||||||||||||||
| 80 | 0 | ▶ | if ($frame) | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||
| 82 | 0 | return lc( $V->getPOS( $V->getWordForFrame($frame) ) ); | |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||
| 87 | 0 | return; | |||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||
| 89 | |||||||||||||||||||||||
| 90 | 0 | ▶ | sub _OpenValLexicon_Cs { | ||||||||||||||||||||
|
Subroutine
_OpenValLexicon_Cs: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||
| 91 | 0 | my ( $self, $node ) = @_; | |||||||||||||||||||||
| 92 | |||||||||||||||||||||||
| 93 | 0 | ▶ | if ( not defined &ValLex::GUI::OpenEditor ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 94 | 0 | $self->_extension_missing('pdt_vallex'); | |||||||||||||||||||||
| 95 | 0 | return; | |||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||
| 97 | |||||||||||||||||||||||
| 98 | 0 | local $ValLex::GUI::frameid_attr = "val_frame.rf"; | |||||||||||||||||||||
| 99 | 0 | local $ValLex::GUI::lemma_attr = "t_lemma"; | |||||||||||||||||||||
| 100 | 0 | local $ValLex::GUI::framere_attr = undef; | |||||||||||||||||||||
| 101 | 0 | local $ValLex::GUI::sempos_attr = "gram/sempos"; | |||||||||||||||||||||
| 102 | 0 | my $vallex_file = $self->_find_vallex($node); | |||||||||||||||||||||
| 103 | 0 | ▶ | return unless $vallex_file; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 104 | |||||||||||||||||||||||
| 105 | 0 | ▶ | ValLex::GUI::OpenEditor( | ||||||||||||||||||||
|
Condition0%0/3
$node->attr('gram/sempos') || $self->_assigned_frame_pos_of($node)
MC/DC0%0/2
$node->attr('gram/sempos') || $self->_assigned_frame_pos_of($node)
$node->attr('gram/sempos')
$self->_assigned_frame_pos_of($node)
Truth table0%0/3
A || B
A= $node->attr('gram/sempos')B= $self->_assigned_frame_pos_of($node)
| |||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||
| 107 | -vallex_file => $vallex_file, | ||||||||||||||||||||||
| 108 | -lemma => $node->attr('t_lemma'), | ||||||||||||||||||||||
| 109 | -sempos => $node->attr('gram/sempos') || $self->_assigned_frame_pos_of($node), | ||||||||||||||||||||||
| 110 | -frameid => $node->attr('val_frame.rf') | ||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||
| 113 | 0 | TredMacro::ChangingFile(0); | |||||||||||||||||||||
| 114 | 0 | return; | |||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||
| 116 | |||||||||||||||||||||||
| 117 | 0 | ▶ | sub _OpenValLexicon_En { | ||||||||||||||||||||
|
Subroutine
_OpenValLexicon_En: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||
| 118 | 0 | my ( $self, $node ) = @_; | |||||||||||||||||||||
| 119 | |||||||||||||||||||||||
| 120 | 0 | ▶ | if ( not defined &TrEd::EngValLex::GUI::OpenEditor ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 121 | 0 | $self->_extension_missing('pedt'); | |||||||||||||||||||||
| 122 | 0 | return; | |||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||
| 124 | |||||||||||||||||||||||
| 125 | 0 | local $TrEd::EngValLex::GUI::frameid_attr = "val_frame.rf"; | |||||||||||||||||||||
| 126 | 0 | local $TrEd::EngValLex::GUI::lemma_attr = "t_lemma"; | |||||||||||||||||||||
| 127 | 0 | local $TrEd::EngValLex::GUI::framere_attr = undef; | |||||||||||||||||||||
| 128 | 0 | local $TrEd::EngValLex::GUI::sempos_attr = "gram/sempos"; | |||||||||||||||||||||
| 129 | 0 | $TrEd::EngValLex::Editor::reviewer_can_modify = 0; | |||||||||||||||||||||
| 130 | 0 | $TrEd::EngValLex::Editor::reviewer_can_delete = 0; | |||||||||||||||||||||
| 131 | |||||||||||||||||||||||
| 132 | # Following subroutines return 1 no matter what. We need to change this behaviour | ||||||||||||||||||||||
| 133 | 0 | require TrEd::EngValLex::Data; | |||||||||||||||||||||
| 134 | 0 | ▶ | *TrEd::EngValLex::Data::user_is_annotator = sub { return 0 }; | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 135 | 0 | ▶ | *TrEd::EngValLex::Data::user_is_reviewer = sub { return 0 }; | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 136 | |||||||||||||||||||||||
| 137 | 0 | my $a_node = $self->_treex_doc->get_node_by_id( $node->attr('a/lex.rf') ); | |||||||||||||||||||||
| 138 | 0 | my $vallex_file = $self->_find_vallex($node); | |||||||||||||||||||||
| 139 | 0 | ▶ | return unless $vallex_file; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 140 | |||||||||||||||||||||||
| 141 | 0 | my $opts = { | |||||||||||||||||||||
| 142 | -vallex_file => $vallex_file, | ||||||||||||||||||||||
| 143 | -lemma => $node->attr('t_lemma'), | ||||||||||||||||||||||
| 144 | -sempos => $node->attr('gram/sempos'), | ||||||||||||||||||||||
| 145 | -frameid => $node->attr('val_frame.rf') | ||||||||||||||||||||||
| 146 | }; | ||||||||||||||||||||||
| 147 | 0 | ▶ | $opts->{-pos} = $a_node->attr('tag') if $a_node->attr('tag'); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 148 | 0 | TrEd::EngValLex::GUI::OpenEditor($opts); | |||||||||||||||||||||
| 149 | 0 | TredMacro::ChangingFile(0); | |||||||||||||||||||||
| 150 | 0 | return; | |||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||
| 152 | |||||||||||||||||||||||
| 153 | 0 | ▶ | sub _OpenValFrameList_Cs { | ||||||||||||||||||||
|
Subroutine
_OpenValFrameList_Cs: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||
| 154 | 0 | my ( $self, $node ) = @_; | |||||||||||||||||||||
| 155 | |||||||||||||||||||||||
| 156 | 0 | ▶ | if ( not defined &ValLex::GUI::ChooseFrame ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 157 | 0 | $self->_extension_missing('pdt_vallex'); | |||||||||||||||||||||
| 158 | 0 | return; | |||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||
| 160 | |||||||||||||||||||||||
| 161 | 0 | local $ValLex::GUI::frameid_attr = "val_frame.rf"; | |||||||||||||||||||||
| 162 | 0 | local $ValLex::GUI::lemma_attr = "t_lemma"; | |||||||||||||||||||||
| 163 | 0 | local $ValLex::GUI::framere_attr = undef; | |||||||||||||||||||||
| 164 | 0 | local $ValLex::GUI::sempos_attr = "gram/sempos"; | |||||||||||||||||||||
| 165 | 0 | my $vallex_file = $self->_find_vallex($node); | |||||||||||||||||||||
| 166 | 0 | ▶ | return unless $vallex_file; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 167 | |||||||||||||||||||||||
| 168 | 0 | ▶ | my $sempos = [ $node->attr('gram/sempos') || $self->_assigned_frame_pos_of($node) ]; | ||||||||||||||||||||
|
Condition0%0/3
$node->attr('gram/sempos') || $self->_assigned_frame_pos_of($node)
MC/DC0%0/2
$node->attr('gram/sempos') || $self->_assigned_frame_pos_of($node)
$node->attr('gram/sempos')
$self->_assigned_frame_pos_of($node)
Truth table0%0/3
A || B
A= $node->attr('gram/sempos')B= $self->_assigned_frame_pos_of($node)
| |||||||||||||||||||||||
| 169 | 0 | ▶ | if ( !$sempos->[0] ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 170 | 0 | $sempos = ['v']; | |||||||||||||||||||||
| 171 | 0 | ▶ | ListQuery( 'Semantical POS', 'browse', [qw(v n)], $sempos ) or return; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||
| 173 | |||||||||||||||||||||||
| 174 | ValLex::GUI::ChooseFrame( | ||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||
| 176 | 0 | ▶ | -withdraw => 1, | ||||||||||||||||||||
|
Condition0%0/2
$node->attr('t_lemma') || undef
MC/DC0%0/1
$node->attr('t_lemma') || undef
$node->attr('t_lemma')
Truth table0%0/2
A
A= $node->attr('t_lemma')
| |||||||||||||||||||||||
| 177 | -vallex_file => $vallex_file, | ||||||||||||||||||||||
| 178 | -lemma => $node->attr('t_lemma') || undef, | ||||||||||||||||||||||
| 179 | -sempos => $sempos->[0], | ||||||||||||||||||||||
| 180 | -lemma_attr => 't_lemma', | ||||||||||||||||||||||
| 181 | -sempos_attr => 'gram/sempos', | ||||||||||||||||||||||
| 182 | -frameid => $node->attr('val_frame.rf'), | ||||||||||||||||||||||
| 183 | -no_assign => 1, | ||||||||||||||||||||||
| 184 | -noadd => 1 | ||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||||
| 187 | 0 | TredMacro::ChangingFile(0); | |||||||||||||||||||||
| 188 | 0 | return; | |||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||
| 190 | |||||||||||||||||||||||
| 191 | 0 | ▶ | sub _OpenValFrameList_En { | ||||||||||||||||||||
|
Subroutine
_OpenValFrameList_En: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||
| 192 | 0 | my ( $self, $node ) = @_; | |||||||||||||||||||||
| 193 | |||||||||||||||||||||||
| 194 | 0 | ▶ | if ( not defined &TrEd::EngValLex::GUI::ChooseFrame ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 195 | 0 | $self->_extension_missing('pedt'); | |||||||||||||||||||||
| 196 | 0 | return; | |||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||
| 198 | |||||||||||||||||||||||
| 199 | 0 | local $EngValLex::GUI::frameid_attr = "val_frame.rf"; | |||||||||||||||||||||
| 200 | 0 | local $EngValLex::GUI::lemma_attr = "t_lemma"; | |||||||||||||||||||||
| 201 | 0 | local $EngValLex::GUI::framere_attr = undef; | |||||||||||||||||||||
| 202 | 0 | local $EngValLex::GUI::sempos_attr = "gram/sempos"; | |||||||||||||||||||||
| 203 | 0 | $TrEd::EngValLex::Editor::reviewer_can_modify = 0; | |||||||||||||||||||||
| 204 | 0 | $TrEd::EngValLex::Editor::reviewer_can_delete = 0; | |||||||||||||||||||||
| 205 | |||||||||||||||||||||||
| 206 | # Following subroutines return 1 no matter what. We need to change this behaviour | ||||||||||||||||||||||
| 207 | 0 | require TrEd::EngValLex::Data; | |||||||||||||||||||||
| 208 | 0 | ▶ | *TrEd::EngValLex::Data::user_is_annotator = sub { return 0 }; | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 209 | 0 | ▶ | *TrEd::EngValLex::Data::user_is_reviewer = sub { return 0 }; | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 210 | |||||||||||||||||||||||
| 211 | 0 | my $a_node = $self->_treex_doc->get_node_by_id( $node->attr('a/lex.rf') ); | |||||||||||||||||||||
| 212 | 0 | my $vallex_file = $self->_find_vallex($node); | |||||||||||||||||||||
| 213 | 0 | ▶ | return unless $vallex_file; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 214 | |||||||||||||||||||||||
| 215 | my $opts = { | ||||||||||||||||||||||
| 216 | -withdraw => 1, | ||||||||||||||||||||||
| 217 | -vallex_file => $vallex_file, | ||||||||||||||||||||||
| 218 | -lemma => $node->{t_lemma} || undef, | ||||||||||||||||||||||
| 219 | -sempos => $node->attr('gram/sempos') || undef, | ||||||||||||||||||||||
| 220 | -lemma_attr => 't_lemma', | ||||||||||||||||||||||
| 221 | -sempos_attr => 'gram/sempos', | ||||||||||||||||||||||
| 222 | -frameid => $node->attr('val_frame.rf'), | ||||||||||||||||||||||
| 223 | 0 | ▶ | -assignfunc => sub { } | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 224 | 0 | ▶ | }; | ||||||||||||||||||||
|
Condition0%0/4
$node->{'t_lemma'} || undef
$node->attr('gram/sempos') || undef
MC/DC0%0/1
$node->{'t_lemma'} || undef
$node->{'t_lemma'}
MC/DC0%0/1
$node->attr('gram/sempos') || undef
$node->attr('gram/sempos')
Truth table0%0/2
A
A= $node->{'t_lemma'}
Truth table0%0/2
A
A= $node->attr('gram/sempos')
| |||||||||||||||||||||||
| 225 | 0 | ▶ | $opts->{-pos} = $a_node->attr('tag') if $a_node->attr('tag'); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 226 | 0 | TrEd::EngValLex::GUI::ChooseFrame($opts); | |||||||||||||||||||||
| 227 | 0 | TredMacro::ChangingFile(0); | |||||||||||||||||||||
| 228 | 0 | return; | |||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||
| 230 | |||||||||||||||||||||||
| 231 | 2 | 1; | |||||||||||||||||||||
| 232 | |||||||||||||||||||||||
| 233 | __END__ | ||||||||||||||||||||||