PML/Backend/CSTS/Csts2fs.pm

filter: Statementstmt 10.5% 44 / 419 Branchbran 0.4% 1 / 230 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 13.7% 7 / 51 Podpod 0.0% 0 / 19 totaltotal 6.7% 52 / 772 CC 141 SCAR 67.4
CC
141
Cov
7%
assign_TRt
2862.0
build_tree
342.0
read
210.0
CRAP 849.0
« PML/Instance/Reader.pm ↑ Summary PML/Instance.pm »
1 package Treex::PML::Backend::CSTS::Csts2fs;
2  
3 2 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 $VERSION='2.29'; # version template
6 }
7 2 ▶use Treex::PML;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #
10 # TR vs AR (vs M)
11 #
12 # $ord = ord (also in TR case)
13 # $gov = ordorig vs govTR (vs govMD)
14 #
15 # "ordorig" :=<g> on TR
16 # "govTR" := <TRg> on AR
17 #
18 # "TR" is @H on TR
19 # @N: ord on AR, dord on TR
20 # sentord is @W on TR
21 # govTR is stored on AR
22 # ordorig is stored on TR
23 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 2 our $gov="ordorig";
27 2 our $ord="ord";
28 2 our $sentord="sentord";
29  
30 2 our $normal_gap='gappost';
31 2 our $no_node_gap='gappre';
32  
33 2 our $fill_empty_ord=0;
34  
35 2 our $fs_tail='(2,3)';
36 2 our @fs_patterns=('${form}', '${afun}');
37 2 our $fs_hint="tag:\t".'${tag}';
38  
39 2 our $next_sentord=0;
40  
41 2 our %composed_attrs=();
42  
43 0 ▶sub assign_TRt {
Subroutine assign_TRt: not called CC=53 SCAR=79.6
Pod undocumented
44 0 my ($s,$data,$machine)=@_;
45 0 ▶ $machine = $machine ? "M" : "";
Branch: 1 branch
BranchTrueFalseTotal
$machine ? : 0 0 0
46 # hajic 2002/04/02
47 # - moved - to front of [] expressions
48 # - added X to last [] ($9)
49 # - swapped $2 and $3
50 # (based on observations of data only!)
51  
52 0 ▶ if ($data=~/([-MIFNX])([-123X])([-SPX])([-SPAX])([-PCRX])([-10X])([-IMCX])([-DBHVSPFX])([.!DM?X])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /([-MIFNX])([-123X])([-SPX])([-SPAX])([-PCRX])([-10X])([-IMCX])([-DBHVSPFX])([.!DM?X])/) 0 0 0
53 0 my $result;
54 0 ▶ if ($1 eq 'M') { $result = 'ANIM' }
Branch: 6 branches
BranchTrueFalseTotal
if ($1 eq 'M') { } 0 0 0
elsif ($1 eq 'I') { } 0 0 0
elsif ($1 eq 'F') { } 0 0 0
elsif ($1 eq 'N') { } 0 0 0
elsif ($1 eq '-') { } 0 0 0
elsif ($1 eq 'X') { } 0 0 0
55 0 elsif ($1 eq 'I') { $result = 'INAN' }
56 0 elsif ($1 eq 'F') { $result = 'FEM' }
57 0 elsif ($1 eq 'N') { $result = 'NEUT' }
58 0 elsif ($1 eq '-') { $result = 'NA' }
59 0 elsif ($1 eq 'X') { $result = '???' }
60 0 to_node_attr($s,$result,'|','gender'.$machine);
61  
62 # hajic 2002/04/02
63 # - swapped $2 <-> $3 in teh following two switch sections:
64 0 ▶ if ($3 eq 'S') { $result = 'SG' }
Branch: 4 branches
BranchTrueFalseTotal
if ($3 eq 'S') { } 0 0 0
elsif ($3 eq 'P') { } 0 0 0
elsif ($3 eq '-') { } 0 0 0
elsif ($3 eq 'X') { } 0 0 0
65 0 elsif ($3 eq 'P') { $result = 'PL' }
66 0 elsif ($3 eq '-') { $result = 'NA' }
67 0 elsif ($3 eq 'X') { $result = '???' }
68 0 to_node_attr($s,$result,'|','number'.$machine);
69  
70 0 ▶ if ($2 eq '1') { $result = 'POS' }
Branch: 5 branches
BranchTrueFalseTotal
if ($2 eq '1') { } 0 0 0
elsif ($2 eq '2') { } 0 0 0
elsif ($2 eq '3') { } 0 0 0
elsif ($2 eq '-') { } 0 0 0
elsif ($2 eq 'X') { } 0 0 0
71 0 elsif ($2 eq '2') { $result = 'COMP' }
72 0 elsif ($2 eq '3') { $result = 'SUP' }
73 0 elsif ($2 eq '-') { $result = 'NA' }
74 0 elsif ($2 eq 'X') { $result = '???' }
75 0 to_node_attr($s,$result,'|','degcmp'.$machine);
76  
77 0 ▶ if ($4 eq 'S') { $result = 'SIM' }
Branch: 5 branches
BranchTrueFalseTotal
if ($4 eq 'S') { } 0 0 0
elsif ($4 eq 'P') { } 0 0 0
elsif ($4 eq 'A') { } 0 0 0
elsif ($4 eq '-') { } 0 0 0
elsif ($4 eq 'X') { } 0 0 0
78 0 elsif ($4 eq 'P') { $result = 'POST' }
79 0 elsif ($4 eq 'A') { $result = 'ANT' }
80 0 elsif ($4 eq '-') { $result = 'NA' }
81 0 elsif ($4 eq 'X') { $result = '???' }
82 0 to_node_attr($s,$result,'|','tense'.$machine);
83  
84 0 ▶ if ($5 eq 'P') { $result = 'PROC' }
Branch: 5 branches
BranchTrueFalseTotal
if ($5 eq 'P') { } 0 0 0
elsif ($5 eq 'C') { } 0 0 0
elsif ($5 eq 'R') { } 0 0 0
elsif ($5 eq '-') { } 0 0 0
elsif ($5 eq 'X') { } 0 0 0
85 0 elsif ($5 eq 'C') { $result = 'CPL' }
86 0 elsif ($5 eq 'R') { $result = 'RES' }
87 0 elsif ($5 eq '-') { $result = 'NA' }
88 0 elsif ($5 eq 'X') { $result = '???' }
89 0 to_node_attr($s,$result,'|','aspect'.$machine);
90  
91 0 ▶ if ($6 eq '1') { $result = 'IT1' }
Branch: 4 branches
BranchTrueFalseTotal
if ($6 eq '1') { } 0 0 0
elsif ($6 eq '0') { } 0 0 0
elsif ($6 eq '-') { } 0 0 0
elsif ($6 eq 'X') { } 0 0 0
92 0 elsif ($6 eq '0') { $result = 'IT0' }
93 0 elsif ($6 eq '-') { $result = 'NA' }
94 0 elsif ($6 eq 'X') { $result = '???' }
95 0 to_node_attr($s,$result,'|','iterativeness'.$machine);
96  
97 0 ▶ if ($7 eq 'I') { $result = 'IND' }
Branch: 5 branches
BranchTrueFalseTotal
if ($7 eq 'I') { } 0 0 0
elsif ($7 eq 'M') { } 0 0 0
elsif ($7 eq 'C') { } 0 0 0
elsif ($7 eq '-') { } 0 0 0
elsif ($7 eq 'X') { } 0 0 0
98 0 elsif ($7 eq 'M') { $result = 'IMP' }
99 0 elsif ($7 eq 'C') { $result = 'CDN' }
100 0 elsif ($7 eq '-') { $result = 'NA' }
101 0 elsif ($7 eq 'X') { $result = '???' }
102 0 to_node_attr($s,$result,'|','verbmod'.$machine);
103  
104 0 ▶ if ($8 eq 'D') { $result = 'DECL' }
Branch: 9 branches
BranchTrueFalseTotal
if ($8 eq 'D') { } 0 0 0
elsif ($8 eq 'B') { } 0 0 0
elsif ($8 eq 'H') { } 0 0 0
elsif ($8 eq 'V') { } 0 0 0
elsif ($8 eq 'S') { } 0 0 0
elsif ($8 eq 'P') { } 0 0 0
elsif ($8 eq 'F') { } 0 0 0
elsif ($8 eq '-') { } 0 0 0
elsif ($8 eq 'X') { } 0 0 0
105 0 elsif ($8 eq 'B') { $result = 'DEB' }
106 0 elsif ($8 eq 'H') { $result = 'HRT' }
107 0 elsif ($8 eq 'V') { $result = 'VOL' }
108 0 elsif ($8 eq 'S') { $result = 'POSS' }
109 0 elsif ($8 eq 'P') { $result = 'PERM' }
110 0 elsif ($8 eq 'F') { $result = 'FAC' }
111 0 elsif ($8 eq '-') { $result = 'NA' }
112 0 elsif ($8 eq 'X') { $result = '???' }
113 0 to_node_attr($s,$result,'|','deontmod'.$machine);
114  
115 0 ▶ if ($9 eq '.') { $result = 'ENUNC' }
Branch: 7 branches
BranchTrueFalseTotal
if ($9 eq '.') { } 0 0 0
elsif ($9 eq '!') { } 0 0 0
elsif ($9 eq 'D') { } 0 0 0
elsif ($9 eq 'M') { } 0 0 0
elsif ($9 eq '?') { } 0 0 0
elsif ($9 eq '-') { } 0 0 0
elsif ($9 eq 'X') { } 0 0 0
116 0 elsif ($9 eq '!') { $result = 'EXCL' }
117 0 elsif ($9 eq 'D') { $result = 'DESID' }
118 0 elsif ($9 eq 'M') { $result = 'IMPER' }
119 0 elsif ($9 eq '?') { $result = 'INTER' }
120 0 elsif ($9 eq '-') { $result = 'NA' }
121 0 elsif ($9 eq 'X') { $result = '???' }
122 0 to_node_attr($s,$result,'|','sentmod'.$machine);
123 }
124 }
125  
126 0 ▶sub assign_quot_dsp {
Subroutine assign_quot_dsp: not called CC=3 SCAR=24.8
Pod undocumented
127 0 my ($s,$data)=@_;
128 0 ▶ if ($data=~/quot/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /quot/) { } 0 0 0
129 0 to_node_attr($s,'QUOT','|','quoted');
130 } else {
131 0 to_node_attr($s,'NIL','|','quoted');
132 }
133 0 ▶ if ($data=~/(dspp|dspi|dsp)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /(dspp|dspi|dsp)/) 0 0 0
134 0 to_node_attr($s,uc($1),'|','dsp');
135 }
136 }
137  
138 my %start_tag = (
139 0 ▶ 's' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
140 0 my ($s)=@_;
141 0 &make_new_tree(@_);
142 0 $s->{treeNo}++;
143 0 $s->{ID2}=$s->{file};
144 0 $s->{root}->{form}="#$s->{treeNo}";
145 0 $s->{root}->{origf}=$s->{root}->{form};
146 0 $s->{root}->{afun}="AuxS";
147 0 $s->{root}->{ord}=0;
148 0 $s->{root}->{sentord}=0;
149 0 $s->{root}->{dord}=0;
150 0 $s->{root}->{tag}="Z#-------------";
151 0 $s->{root}->{lemma}="#";
152 0 $s->{root}->{trlemma}=$s->{root}->{form};
153 0 $s->{root}->{TR}="";
154 0 $s->{root}->{ARhide}='';
155 0 $s->{root}->{X_hide}='';
156 0 $s->{root}->{func}="SENT";
157 }],
158 0 ▶ 'salt' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
159 0 my ($s)=@_;
160 0 &make_new_tree(@_);
161 0 $s->{root}->{form}="#$s->{treeNo}.alt";
162 0 $s->{root}->{origf}=$s->{root}->{form};
163 0 $s->{root}->{ord}=0;
164 0 $s->{root}->{dord}=0;
165 0 $s->{root}->{sentord}=0;
166 0 $s->{root}->{afun}="AuxS";
167 0 $s->{root}->{tag}="Z#-------------";
168 0 $s->{root}->{lemma}="#";
169 0 $s->{root}->{trlemma}=$s->{root}->{form};
170 0 $s->{root}->{TR}="";
171 0 $s->{root}->{ARhide}='';
172 0 $s->{root}->{X_hide}='';
173 0 $s->{root}->{func}="SENT";
174 }],
175 'f' => [\&make_new_node,0],
176 'd' => [\&make_new_node,0],
177 'fadd' => [\&make_new_node,1],
178 0 ▶ 'TRl' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
179 0 my ($s)=@_;
180 # inicialization may be altered to fill
181 # 'hide' here otherwise
182 0 $s->{node}->{TR}="";
183 }],
184 0 ▶ 'MTRl' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
185 0 my ($s)=@_;
186 # inicialization may be altered to fill
187 # 'hide' here otherwise (maybe not easy as
188 # these attributes are generated)
189 0 to_composed_node_attr($s,"","_","","src","MTR");
190 }],
191 # 'D' => [\&copy_tag_to,'','<','!GAP'],
192 0 ▶ 'D' => [sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
193 0 my ($s)=@_;
194 0 ▶ if ($s->{node}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->{'node'}) { } 0 0 0
195 0 $s->{node}->{nospace}=1;
196 } else {
197 0 copy_tag_to(@_,'','<','!GAP');
198 # $s->{following}->{$no_node_gap}.="<D>";
199 }
200 }],
201  
202 0 ▶ 'mauth' => [sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
203 0 my ($s)=@_;
204 0 ▶ if (($s->{elements}->[-3]||'') eq 'h') {
Branch: 1 branch
BranchTrueFalseTotal
if (($s->{'elements'}[-3] || '') eq 'h') { } 0 0 0
Condition0%0/2
$s->{'elements'}[-3] || ''
l!l
00
MC/DC0%0/1
$s->{'elements'}[-3] || ''
$s->{'elements'}[-3]
Truth table0%0/2
A
A= $s->{'elements'}[-3]
Aresult
11
00
205 0 copy_tag_to_following_root(@_,'','<','cstsmarkup');
206 } else {
207 0 copy_tag_to_following_root(@_,'','<','docmarkup');
208 }
209 }],
210 0 ▶ 'mdate' => [sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
211 0 my ($s)=@_;
212 0 ▶ if (($s->{elements}->[-3]||'') eq 'h') {
Branch: 1 branch
BranchTrueFalseTotal
if (($s->{'elements'}[-3] || '') eq 'h') { } 0 0 0
Condition0%0/2
$s->{'elements'}[-3] || ''
l!l
00
MC/DC0%0/1
$s->{'elements'}[-3] || ''
$s->{'elements'}[-3]
Truth table0%0/2
A
A= $s->{'elements'}[-3]
Aresult
11
00
213 0 copy_tag_to_following_root(@_,'','<','cstsmarkup');
214 } else {
215 0 copy_tag_to_following_root(@_,'','<','docmarkup');
216 }
217 }],
218 0 ▶ 'mdesc' => [sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
219 0 my ($s)=@_;
220 0 ▶ if (($s->{elements}->[-3]||'') eq 'h') {
Branch: 1 branch
BranchTrueFalseTotal
if (($s->{'elements'}[-3] || '') eq 'h') { } 0 0 0
Condition0%0/2
$s->{'elements'}[-3] || ''
l!l
00
MC/DC0%0/1
$s->{'elements'}[-3] || ''
$s->{'elements'}[-3]
Truth table0%0/2
A
A= $s->{'elements'}[-3]
Aresult
11
00
221 0 copy_tag_to_following_root(@_,'','<','cstsmarkup');
222 } else {
223 0 copy_tag_to_following_root(@_,'','<','docmarkup');
224 }
225 }],
226 0 ▶ 'doc' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
227 0 my ($s)=@_;
228 0 my %attributes = map @$_, @{$s->{attributes}[-1]};
229 0 $s->{following_root}->{doc}=$attributes{'file'};
230 0 $s->{following_root}->{docid}=$attributes{'id'};
231 }],
232 'mod' => [\&copy_tag_to_following_root,'','<','docprolog'],
233 'txtype' => [\&copy_tag_to_following_root,'','<','docprolog'],
234 'genre' => [\&copy_tag_to_following_root,'','<','docprolog'],
235 0 ▶ 'c' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
236 0 shift->{following_root}->{chap}='1';
237 2 }],
238 'verse' => [\&copy_tag_to_following_root,'','<','docprolog'],
239 'med' => [\&copy_tag_to_following_root,'','<','docprolog'],
240 'authsex' => [\&copy_tag_to_following_root,'','<','docprolog'],
241 'lang' => [\&copy_tag_to_following_root,'','<','docprolog'],
242 'transsex' => [\&copy_tag_to_following_root,'','<','docprolog'],
243 'srclang' => [\&copy_tag_to_following_root,'','<','docprolog'],
244 'temp' => [\&copy_tag_to_following_root,'','<','docprolog'],
245 'firsted' => [\&copy_tag_to_following_root,'','<','docprolog'],
246 'authname' => [\&copy_tag_to_following_root,'','<','docprolog'],
247 'transname' => [\&copy_tag_to_following_root,'','<','docprolog'],
248 'opus' => [\&copy_tag_to_following_root,'','<','docprolog'],
249 'id' => [\&copy_tag_to_following_root,'','<','docprolog'],
250 'i' => [\&copy_tag_to,'','<','!GAP'],
251 'idioms' => [\&copy_tag_to,'','<','!GAP'],
252 'idiom' => [\&copy_tag_to,'','<','!GAP'],
253 'iref' => [\&copy_tag_to,'','<','!GAP'],
254 );
255  
256 2 my %end_tag = (
257 'csts' => [ \&make_last_tree ],
258 );
259  
260 my %att = (
261 0 ▶ 'p n' => [sub { my($s,$data)=@_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
262 0 $s->{following_root}->{para}=$data;
263 }],
264 'A parallel' => [\&to_node_attr,'|','parallel'],
265 'A paren' => [\&to_node_attr,'|','paren'],
266 'A arabfa' => [\&to_node_attr,'|','arabfa'],
267 'A arabspec' => [\&to_node_attr,'|','arabspec'],
268 'A arabclause' => [\&to_node_attr,'|','arabclause'],
269 'MDt w' => [\&to_composed_node_attr,'_','|','src','wMDt'],
270 'MDl w' => [\&to_composed_node_attr,'_','|','src','wMDl'],
271 'MDA w' => [\&to_composed_node_attr,'_','|','src','wMDA'],
272 'MDA parallel' => [\&to_composed_node_attr,'_','|','src','parallelMD'],
273 'MDA paren' => [\&to_composed_node_attr,'_','|','src','parenMD'],
274 'MDA arabfa' => [\&to_composed_node_attr,'_','|','src','arabfaMD'],
275 'MDA arabspec' => [\&to_composed_node_attr,'_','|','src','arabspecMD'],
276 'MDA arabclause' => [\&to_composed_node_attr,'_','|','src','arabclauseMD'],
277 'MDg w' => [\&to_composed_node_attr,'_','|','src','wMDg'],
278 'wsd s' => [\&to_node_attr,'|','wsds'],
279 'wsd ewn' => [\&to_node_attr,'|','wsdewn'],
280 'wsd ili' => [\&to_node_attr,'|','wsdili'],
281 'wsd iliOffset' => [\&to_node_attr,'|','wsdiliOffset'],
282 's id' => [\&to_attr,'root','|','ID1'],
283 'salt id' => [\&to_attr,'root','|','ID1'],
284 'csts lang' => [\&to_node_attr,'|','cstslang'],
285 'f case' => [\&to_node_attr,'|','formtype'],
286 'f id' => [\&to_node_attr,'','AID'],
287 'd type' => [\&to_node_attr,'|','formtype'],
288 'd id' => [\&to_node_attr,'|','AID'],
289 'w kind' => [\&to_next_node_attr,'|','origfkind'],
290 't w'=> [\&to_node_attr,'|','wt'],
291 'fadd id' => [\&to_node_attr,'','TID'],
292 0 ▶ 'fadd del' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
293 0 my ($s,$data)=@_;
294 0 &to_node_attr($s,uc($data),'|','del');
295 0 &to_node_attr($s,'hide','','ARhide');
296 }],
297 'MTRl quot' => [\&to_composed_node_attr,'_','|','src','quotMTRl'],
298 'TRl quot' => [\&assign_quot_dsp],
299 'coref ref' => [\&to_node_attr,'|','coref'],
300 'coref type' => [\&to_node_attr,'|','cortype'],
301 0 ▶ 'TRl status' => [sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
302 0 my ($s,$data)=@_;
303 0 ▶ &to_node_attr($s,'hide','','TR')
Branch: 1 branch
BranchTrueFalseTotal
if $data eq "hidden" 0 0 0
304 if ($data eq 'hidden');
305 }],
306 0 ▶ 'MTRl status' => [sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
307 0 my ($s,$data)=@_;
308 0 ▶ &to_composed_node_attr($s,'hide','_','|','src','MTR')
Branch: 1 branch
BranchTrueFalseTotal
if $data eq "hidden" 0 0 0
309 if ($data eq 'hidden');
310 }],
311 0 ▶ 'TRl origin' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
312 0 my ($s,$data)=@_;
313 0 $data=~s/\s+/|/g;
314 0 &to_node_attr($s,$data,'','AIDREFS');
315 }],
316 0 ▶ 'MTRl origin' => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
317 0 my ($s,$data)=@_;
318 0 $data=~s/\s+/|/g;
319 0 &to_composed_node_attr($s,$data,'_','','src','MAIDREFS');
320 }],
321 0 ▶ 'x name' => [sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
322 0 my ($s,$data)=@_;
323 0 ▶ $s->{node}->{X_hide}='' if ($data eq 'TNT');
Branch: 1 branch
BranchTrueFalseTotal
if $data eq "TNT" 0 0 0
324 2 }]
325 );
326  
327 my %pcdata = (
328 'source' => [\&to_node_attr,'','cstssource'],
329 0 ▶ 'mauth' => [sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
330 0 my ($s)=@_;
331 0 ▶ if (($s->{elements}->[-3]||'') eq 'h') {
Branch: 1 branch
BranchTrueFalseTotal
if (($s->{'elements'}[-3] || '') eq 'h') { } 0 0 0
Condition0%0/2
$s->{'elements'}[-3] || ''
l!l
00
MC/DC0%0/1
$s->{'elements'}[-3] || ''
$s->{'elements'}[-3]
Truth table0%0/2
A
A= $s->{'elements'}[-3]
Aresult
11
00
332 0 to_attr(@_,'following_root','','cstsmarkup');
333 } else {
334 0 to_attr(@_,'following_root','','docmarkup');
335 }
336 }],
337 0 ▶ 'mdate' => [sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
338 0 my ($s)=@_;
339 0 ▶ if (($s->{elements}->[-3]||'') eq 'h') {
Branch: 1 branch
BranchTrueFalseTotal
if (($s->{'elements'}[-3] || '') eq 'h') { } 0 0 0
Condition0%0/2
$s->{'elements'}[-3] || ''
l!l
00
MC/DC0%0/1
$s->{'elements'}[-3] || ''
$s->{'elements'}[-3]
Truth table0%0/2
A
A= $s->{'elements'}[-3]
Aresult
11
00
340 0 to_attr(@_,'following_root','','cstsmarkup');
341 } else {
342 0 to_attr(@_,'following_root','','docmarkup');
343 }
344 }],
345 0 ▶ 'mdesc' => [sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
346 0 my ($s)=@_;
347 0 ▶ if (($s->{elements}->[-3]||'') eq 'h') {
Branch: 1 branch
BranchTrueFalseTotal
if (($s->{'elements'}[-3] || '') eq 'h') { } 0 0 0
Condition0%0/2
$s->{'elements'}[-3] || ''
l!l
00
MC/DC0%0/1
$s->{'elements'}[-3] || ''
$s->{'elements'}[-3]
Truth table0%0/2
A
A= $s->{'elements'}[-3]
Aresult
11
00
348 0 to_attr(@_,'following_root','','cstsmarkup');
349 } else {
350 0 to_attr(@_,'following_root','','docmarkup');
351 }
352 }],
353 'mod' => [\&to_attr,'following_root','','docprolog'],
354 'txtype' => [\&to_attr,'following_root','','docprolog'],
355 'genre' => [\&to_attr,'following_root','','docprolog'],
356 'verse' => [\&to_attr,'following_root','','docprolog'],
357 'med' => [\&to_attr,'following_root','','docprolog'],
358 'authsex' => [\&to_attr,'following_root','','docprolog'],
359 'lang' => [\&to_attr,'following_root','','docprolog'],
360 'transsex' => [\&to_attr,'following_root','','docprolog'],
361 'srclang' => [\&to_attr,'following_root','','docprolog'],
362 'temp' => [\&to_attr,'following_root','','docprolog'],
363 'firsted' => [\&to_attr,'following_root','','docprolog'],
364 'authname' => [\&to_attr,'following_root','','docprolog'],
365 'transname' => [\&to_attr,'following_root','','docprolog'],
366 'opus' => [\&to_attr,'following_root','','docprolog'],
367 'id' => [\&to_attr,'following_root','','docprolog'],
368 'i' => [\&to_node_attr,'','!GAP'],
369 'iref' => [\&to_node_attr,'','!GAP'],
370 MDt => [\&to_composed_node_attr,'_','|','src','tagMD'],
371 MDl => [\&to_composed_node_attr,'_','|','src','lemmaMD'],
372 0 ▶ MMt => [sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
373 0 my ($s,$data) = @_;
374 # dirty hack to have the same number of MMl and MMt values
375 0 to_composed_node_attr(@_,'_','|','src','tagMM');
376 0 my $name;
377 0 for my $a (@{$s->{attributes}[-1]}) {
378 0 ▶ if ($a->[0] eq 'src') {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->[0] eq "src") 0 0 0
379 0 $name='MM_'.$a->[1];
380 0 last;
381 }
382 }
383 0 my @l = split /\|/,$s->{node}->{'lemma'.$name};
384 0 my @t = split /\|/,$s->{node}->{'tag'.$name};
385 0 ▶ $s->{node}->{'lemma'.$name}.='|'.$l[$#l] if (@l == scalar(@t)-1);
Branch: 1 branch
BranchTrueFalseTotal
if @l == scalar(@t) - 1 0 0 0
386 }],
387 MMl => [\&to_composed_node_attr,'_','|','src','lemmaMM'],
388 MTRl => [\&to_composed_node_attr,'_','|','src','trlemmaM'],
389 MDg => [\&to_composed_node_attr,'_','|','src','govMD'],
390 MDA => [\&to_composed_node_attr,'_','|','src','afunMD'],
391 coref => [\&to_node_attr,'|','corlemma'],
392 0 ▶ f => [sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
393 0 my ($s,$data)=@_;
394 0 &to_node_attr(@_,'|','form');
395 0 ▶ unless (exists($s->{node}->{origf})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $s->{"node"}{"origf"} or $s->{"node"}{"formtype"} =~ /gen$/) 0 0 0
Condition0%0/3
exists $s->{"node"}{"origf"} or $s->{"node"}{"formtype"} =~ /gen$/
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $s->{"node"}{"origf"} or $s->{"node"}{"formtype"} =~ /gen$/
exists $s->{"node"}{"origf"} $s->{"node"}{"formtype"} =~ /gen$/
Truth table0%0/3
A or B
A= exists $s->{"node"}{"origf"}B= $s->{"node"}{"formtype"} =~ /gen$/
ABresult
1X1
011
000
396 or
397 $s->{node}->{formtype} =~ /gen$/
398 ) {
399 0 $s->{node}->{origf}=$data;
400 }
401 }],
402 w => [\&to_next_node_attr,'|','origf'],
403 0 ▶ d => [sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
404 0 my ($s,$data)=@_;
405 0 &to_node_attr(@_,'|','form');
406 0 ▶ unless (exists($s->{node}->{origf})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $s->{"node"}{"origf"} or $s->{"node"}{"formtype"} =~ /gen$/) 0 0 0
Condition0%0/3
exists $s->{"node"}{"origf"} or $s->{"node"}{"formtype"} =~ /gen$/
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $s->{"node"}{"origf"} or $s->{"node"}{"formtype"} =~ /gen$/
exists $s->{"node"}{"origf"} $s->{"node"}{"formtype"} =~ /gen$/
Truth table0%0/3
A or B
A= exists $s->{"node"}{"origf"}B= $s->{"node"}{"formtype"} =~ /gen$/
ABresult
1X1
011
000
407 or
408 $s->{node}->{formtype} =~ /gen$/
409 ) {
410 0 $s->{node}->{origf}=$data;
411 }
412 }],
413 P => [\&to_node_attr,'|','pronunciation'],
414 Ct => [\&to_node_attr,'|','alltags'],
415 l => [\&to_node_attr,'|','lemma'],
416 R => [\&to_node_attr,'|','root'], # should be src-ed by n parent
417 E => [\&to_node_attr,'|','ending'], # should be src-ed by n parent
418 t => [\&to_node_attr,'|','tag'],
419 A => [\&to_node_attr,'|','afun'],
420 TRl => [\&to_node_attr,'|','trlemma'],
421 TRg => [\&to_node_attr,'|','govTR'],
422 T => [\&to_node_attr,'|','func'],
423 Tmo => [\&to_node_attr,'|','memberof'],
424 Tpa => [\&to_node_attr,'|','parenthesis'],
425 Top => [\&to_node_attr,'|','operand'],
426 grm => [\&to_node_attr,'|','gram'],
427 TRt => [\&assign_TRt,0],
428 tfa => [\&to_node_attr,'|','tfa'],
429 tfr => [\&to_node_attr,'|','dord'],
430 fw => [\&to_node_attr,'|','fw'],
431 phr => [\&to_node_attr,'|','phraseme'],
432 Tframeid => [\&to_node_attr,'|','frameid'],
433 Tframere => [\&to_node_attr,'|','framere'],
434 0 ▶ g => [sub{
Subroutine __ANON__: not called CC=2 SCAR=17.9
435 0 my ($s,$data)=@_;
436 0 to_node_attr(@_);
437 0 ▶ $s->{node}->{govTR}=$data if $s->{node}->{govTR} eq "";
Branch: 1 branch
BranchTrueFalseTotal
if $s->{"node"}{"govTR"} eq "" 0 0 0
438 },'|','ordorig'],
439 r => [\&to_node_attr,'|','ord'],
440 0 ▶ x => [sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
441 0 my ($s,$data)=@_;
442 0 to_composed_node_attr($s,$data,"x_","","name","");
443 2 }],
444 );
445  
446 2 our (@csts,@misc,@minARheader,@minTRheader,@ARspecial,@ARheader,@PADTattributes,@PADTARheader,@TRheader);
447  
448 2 my $headers = <<'EOF';
449  
450 @csts = (
451 '@P nospace',
452 '@P root',
453 '@P ending',
454 '@P pronunciation',
455 '@P alltags',
456 '@P wt',
457 '@P origfkind',
458 '@P formtype',
459 "\@P $normal_gap",
460 "\@P $no_node_gap",
461 '@P para',
462 '@P cstslang',
463 '@P cstssource',
464 '@P cstsmarkup',
465 '@P chap',
466 '@P doc',
467 '@P docid',
468 '@P docmarkup',
469 '@P docprolog'
470 );
471  
472 @misc = (
473 '@P1 warning',
474 '@P3 err1',
475 '@P3 err2',
476 '@P reserve1',
477 '@P reserve2',
478 '@P reserve3',
479 '@P reserve4',
480 '@P reserve5'
481 );
482  
483  
484 @minARheader = (
485 '@P lemma',
486 '@O lemma',
487 '@P tag',
488 '@O tag',
489 '@P form',
490 '@O form',
491 '@P afun',
492 '@O afun',
493 '@L1 afun|---|Pred|Pnom|AuxV|Sb|Obj|Atr|Adv|AtrAdv|AdvAtr|Coord|AtrObj|ObjAtr|AtrAtr|AuxT|AuxR|AuxP|Apos|ExD|AuxC|Atv|AtvV|AuxO|AuxZ|AuxY|AuxG|AuxK|AuxX|AuxS|Pred_Co|Pnom_Co|AuxV_Co|Sb_Co|Obj_Co|Atr_Co|Adv_Co|AtrAdv_Co|AdvAtr_Co|Coord_Co|AtrObj_Co|ObjAtr_Co|AtrAtr_Co|AuxT_Co|AuxR_Co|AuxP_Co|Apos_Co|ExD_Co|AuxC_Co|Atv_Co|AtvV_Co|AuxO_Co|AuxZ_Co|AuxY_Co|AuxG_Co|AuxK_Co|AuxX_Co|Pred_Ap|Pnom_Ap|AuxV_Ap|Sb_Ap|Obj_Ap|Atr_Ap|Adv_Ap|AtrAdv_Ap|AdvAtr_Ap|Coord_Ap|AtrObj_Ap|ObjAtr_Ap|AtrAtr_Ap|AuxT_Ap|AuxR_Ap|AuxP_Ap|Apos_Ap|ExD_Ap|AuxC_Ap|Atv_Ap|AtvV_Ap|AuxO_Ap|AuxZ_Ap|AuxY_Ap|AuxG_Ap|AuxK_Ap|AuxX_Ap|Pred_Pa|Pnom_Pa|AuxV_Pa|Sb_Pa|Obj_Pa|Atr_Pa|Adv_Pa|AtrAdv_Pa|AdvAtr_Pa|Coord_Pa|AtrObj_Pa|ObjAtr_Pa|AtrAtr_Pa|AuxT_Pa|AuxR_Pa|AuxP_Pa|Apos_Pa|ExD_Pa|AuxC_Pa|Atv_Pa|AtvV_Pa|AuxO_Pa|AuxZ_Pa|AuxY_Pa|AuxG_Pa|AuxK_Pa|AuxX_Pa|Generated|NA|???',
494 '@P ID1',
495 '@P ID2',
496 '@VA origf',
497 '@P origf',
498 '@P afunprev',
499 '@P semPOS',
500 '@P tagauto',
501 '@P lemauto',
502 '@P AID',
503 '@P AIDREFS',
504 );
505  
506 @minTRheader = (
507 '@P ordtf',
508 '@P trlemma',
509 '@P gender',
510 '@L gender|---|ANIM|INAN|FEM|NEUT|NA|???',
511 '@P number',
512 '@L number|---|SG|PL|NA|???',
513 '@P degcmp',
514 '@L degcmp|---|POS|COMP|SUP|NA|???',
515 '@P tense',
516 '@L tense|---|SIM|ANT|POST|NA|???',
517 '@P aspect',
518 '@L aspect|---|PROC|CPL|RES|NA|???',
519 '@P iterativeness',
520 '@L iterativeness|---|IT1|IT0|NA|???',
521 '@P verbmod',
522 '@L verbmod|---|IND|IMP|CDN|NA|???',
523 '@P deontmod',
524 '@L deontmod|---|DECL|DEB|HRT|VOL|POSS|PERM|FAC|NA|???',
525 '@P sentmod',
526 '@L sentmod|---|ENUNC|EXCL|DESID|IMPER|INTER|NA|???',
527 '@P tfa',
528 '@L tfa|---|T|F|C|NA|???',
529 '@P func',
530 '@L2 func|---|ACT|AUTH|PAT|ADDR|EFF|ORIG|ACMP|ADVS|AIM|APP|APPS|ATT|BEN|CAUS|CNCS|COMPL|CONJ|COND|CONFR|CONTRA|CONTRD|CM|CPHR|CPR|CRIT|CSQ|CTERF|DENOM|DES|DIFF|DIR1|DIR2|DIR3|DISJ|DPHR|ETHD|EXT|FPHR|GRAD|HER|ID|INTF|INTT|LOC|MANN|MAT|MEANS|MOD|NA|NORM|OPER|PAR|PARTL|PREC|PRED|REAS|REG|RESL|RESTR|RHEM|RSTR|SUBS|TFHL|TFRWH|THL|THO|TOWH|TPAR|TSIN|TTILL|TWHEN|VOC|VOCAT|SENT|???',
531 '@P gram',
532 '@L gram|---|0|GNEG|DISTR|APPX|GPART|GMULT|VCT|PNREL|DFR|BEF|AFT|JBEF|INTV|WOUT|AGST|MORE|LESS|MULT|RATIO|ADD|SUBTR|ORDER|NIL|blízko|kolem|mezi.1|mezi.2|mimo|na|nad|naproti|pod|pøed|u|uprostøed|v|vedle|za|pøes|uvnitø|NA|???',
533 '@P memberof',
534 '@L memberof|---|CO|AP|NIL|???',
535 '@P fw',
536 '@P phraseme',
537 '@P del',
538 '@L del|---|ELID|ELEX|EXPN|NIL|???',
539 '@P quoted',
540 '@L quoted|---|QUOT|NIL|???',
541 '@P dsp',
542 '@L dsp|---|DSP|DSPP|DSPI|NIL|???',
543 '@P dispmod',
544 '@L dispmod|---|DISP|NIL|NA|???',
545 '@P coref',
546 '@P cortype',
547 '@L cortype|textual|grammatical|---',
548 '@P corlemma',
549 '@P corinfo',
550 '@P commentA',
551 '@P parenthesis',
552 '@L parenthesis|---|PA|NIL|???',
553 '@P operand',
554 '@L operand|---|OP|NIL|???',
555 '@P funcauto',
556 '@P funcprec',
557 '@P funcaux',
558 '@P TID',
559 '@P frameid',
560 '@P framere',
561 '@P state',
562 '@L state|---|NA|NIL|ST|???',
563 '@P argnum'
564 );
565  
566 @ARspecial = (
567 '@N ord',
568 '@P dord',
569 '@W sentord',
570 '@P TR',
571 '@P govTR',
572 '@H ARhide',
573 );
574  
575 our @ARheader = (
576 @minARheader,
577 @ARspecial,
578 @minTRheader,
579 @csts,
580 @misc
581 );
582  
583 @PADTattributes = (
584 '@P parallel',
585 '@L parallel|Co|Ap|no-parallel',
586 '@P paren',
587 '@L paren|Pa|no-paren',
588 '@P arabfa',
589 '@L arabfa|Ca|Exp|Fi|no-fa',
590 '@P arabspec',
591 '@L arabspec|Ref|Msd|no-spec',
592 '@P arabclause',
593 '@L arabclause|Pred|PredC|PredE|PredP|Pnom|no-claus'
594 );
595  
596 @PADTARheader= (
597 (map { my $x=$_; $x=~s/^(\@L[0-9]?\s*afun\|)(.*)$/$1---|Pred|Pnom|Sb|Obj|Atr|Adv|AtrAdv|AdvAtr|Coord|Ref|AtrObj|ObjAtr|AtrAtr|AuxP|Apos|ExD|Atv|Ante|AuxC|AuxO|AuxE|AuxY|AuxM|AuxG|AuxK|AuxX|AuxS|Generated|NA|???/; $x } @minARheader),
598 @ARspecial,
599 @PADTattributes,
600 @minTRheader,
601 @csts,
602 @misc
603 );
604  
605 @TRheader = (
606 @minARheader,
607 '@P ord',
608 '@N dord',
609 '@W sentord',
610 '@H TR',
611 '@P ordorig',
612 '@P ARhide',
613 @minTRheader,
614 @csts,
615 @misc,
616 );
617  
618 EOF
619  
620 2 ▶if ($]>=5.008) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.008) { } 2 0 2
621 2 require Encode;
622 2 $headers=Encode::decode('iso-8859-2',$headers);
623 2 ▶ eval('use utf8;'.$headers);
Subroutine BEGIN: called CC=1 SCAR=0.0
624 } else {
625 0 eval($headers);
626 }
627  
628 2 our %initial_root_values = ();
629  
630 2 our %initial_node_values = (
631 # 'afun' => '???',
632 # 'gender' => '???',
633 # 'number' => '???',
634 # 'degcmp' => '???',
635 # 'tense' => '???',
636 # 'aspect' => '???',
637 # 'iterativeness' => '???',
638 # 'verbmod' => '???',
639 # 'deontmod' => '???',
640 # 'sentmod' => '???',
641 # 'tfa' => '???',
642 # 'func' => '???',
643 # 'gram' => '???',
644 # 'memberof' => '???',
645 # 'del' => 'NIL',
646 # 'quoted' => '???',
647 # 'dsp' => '???',
648 # 'corsnt' => '???',
649 # 'antec' => '???',
650 # 'parenthesis' => '???'
651 );
652  
653 2 our $header=\@ARheader;
654  
655  
656 0 ▶sub build_tree {
Subroutine build_tree: not called CC=18 SCAR=58.3
Pod undocumented
657 0 my $root = shift;
658  
659 0 my %ordered=();
660 0 my @unordered=();
661 # fill uninitialized node values
662 0 foreach my $t (keys %initial_root_values) {
663 0 ▶ $root->{$t} = $initial_root_values{$t} unless exists($root->{$t});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $root->{$t} 0 0 0
664 }
665 0 foreach (@_) {
666 0 ▶ if ($_->{$ord} ne "" and !exists($ordered{$_->{$ord}})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{$Treex::PML::Backend::CSTS::Csts2fs::ord} ne "" and not exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::ord}}) 0 0 0
Condition0%0/3
$_->{$Treex::PML::Backend::CSTS::Csts2fs::ord} ne "" and not exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::ord}}
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{$Treex::PML::Backend::CSTS::Csts2fs::ord} ne "" and not exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::ord}}
$_->{$Treex::PML::Backend::CSTS::Csts2fs::ord} ne "" not exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::ord}}
Truth table0%0/3
A and not(B)
A= $_->{$Treex::PML::Backend::CSTS::Csts2fs::ord} ne ""B= not exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::ord}}
ABresult
0X0
100
111
667 0 $ordered{$_->{$ord}}=$_;
668 }
669 }
670 0 foreach (@_) {
671 0 ▶ next unless $_;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 0 0 0
672 0 ▶ if ($_->{$gov} ne "" and exists($ordered{$_->{$gov}})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{$Treex::PML::Backend::CSTS::Csts2fs::gov} ne "" and exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::gov}}) 0 0 0
Condition0%0/3
$_->{$Treex::PML::Backend::CSTS::Csts2fs::gov} ne "" and exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::gov}}
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{$Treex::PML::Backend::CSTS::Csts2fs::gov} ne "" and exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::gov}}
$_->{$Treex::PML::Backend::CSTS::Csts2fs::gov} ne "" exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::gov}}
Truth table0%0/3
A and B
A= $_->{$Treex::PML::Backend::CSTS::Csts2fs::gov} ne ""B= exists $ordered{$_->{$Treex::PML::Backend::CSTS::Csts2fs::gov}}
ABresult
0X0
100
111
673 0 my $parent=$ordered{$_->{$gov}};
674 0 $_->paste_on($parent, $ord); # paste using $ord as the numbering attribute
675 }
676 }
677 0 foreach (reverse @_) {
678 0 ▶ if (ref($_) and ! $_->parent) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ and not $_->parent) 0 0 0
Condition0%0/3
ref $_ and not $_->parent
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ and not $_->parent
ref $_ not $_->parent
Truth table0%0/3
A and not(B)
A= ref $_B= not $_->parent
ABresult
0X0
100
111
679 0 $_->paste_on($root, $ord); # paste using $ord as the numbering attribute
680 }
681 }
682 0 ▶ if ($fill_empty_ord) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Treex::PML::Backend::CSTS::Csts2fs::fill_empty_ord) 0 0 0
683 0 foreach (@_) {
684 0 ▶ if ($_->{$ord} eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{$Treex::PML::Backend::CSTS::Csts2fs::ord} eq "") 0 0 0
685 0 $_->{$ord}=$_->{$sentord};
686 }
687 }
688 }
689 0 ▶ unless (ref($root)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $root) 0 0 0
690 0 print STDERR "No root node\n";
691 }
692 0 ▶ return defined($root) ? $root : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $root ? : 0 0 0
693 }
694  
695 0 ▶sub convert_element_to_string {
Subroutine convert_element_to_string: not called CC=3 SCAR=24.8
Pod undocumented
696 0 my ($element_name,$attributes)=@_;
697 0 my $string="<".$element_name;
698 0 foreach my $attr (@$attributes) {
699 0 ▶ next unless defined $attr->[1];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $attr->[1] 0 0 0
700 0 $string.=' '.$attr->[0].'="'.$attr->[1].'"';
701 }
702 0 return $string.">";
703 }
704  
705 0 ▶sub to_attr {
Subroutine to_attr: not called CC=5 SCAR=34.0
Pod undocumented
706 0 my ($s,$data,$node,$concat,$attr)=@_;
707 0 ▶ if ($attr eq '!GAP') {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr eq "!GAP") 0 0 0
708 0 ▶ $attr = $s->{node} ? $normal_gap : $no_node_gap;
Branch: 1 branch
BranchTrueFalseTotal
$s->{'node'} ? : 0 0 0
709 }
710 $s->{$node}->{$attr} =
711 exists($s->{$node}->{$attr}) && $s->{$node}->{$attr} ne "" ?
712 0 ▶ $s->{$node}->{$attr}.$concat.$data : $data;
Branch: 1 branch
BranchTrueFalseTotal
exists $s->{$node}{$attr} && $s->{$node}{$attr} ne '' ? : 0 0 0
Condition0%0/3
exists $s->{$node}{$attr} and $s->{$node}{$attr} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{$node}{$attr} and $s->{$node}{$attr} ne ""
exists $s->{$node}{$attr} $s->{$node}{$attr} ne ""
Truth table0%0/3
A and B
A= exists $s->{$node}{$attr}B= $s->{$node}{$attr} ne ""
ABresult
0X0
100
111
713 }
714  
715 0 ▶sub to_node_attr {
Subroutine to_node_attr: not called CC=2 SCAR=17.9
Pod undocumented
716 0 my ($s,$data,$concat,$attr)=@_;
717 0 ▶ my $node = ref($s->{node}) ? 'node' : 'following';
Branch: 1 branch
BranchTrueFalseTotal
ref $s->{'node'} ? : 0 0 0
718 0 to_attr($s,$data,$node,$concat,$attr);
719 }
720  
721 0 ▶sub to_next_node_attr {
Subroutine to_next_node_attr: not called CC=3 SCAR=24.8
Pod undocumented
722 0 my ($s,$data,$concat,$attr)=@_;
723 $s->{following}->{$attr} =
724 exists($s->{following}->{$attr}) && $s->{following}->{$attr} ne "" ?
725 0 ▶ $s->{following}->{$attr}.$concat.$data : $data;
Branch: 1 branch
BranchTrueFalseTotal
exists $s->{'following'}{$attr} && $s->{'following'}{$attr} ne '' ? : 0 0 0
Condition0%0/3
exists $s->{"following"}{$attr} and $s->{"following"}{$attr} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{"following"}{$attr} and $s->{"following"}{$attr} ne ""
exists $s->{"following"}{$attr} $s->{"following"}{$attr} ne ""
Truth table0%0/3
A and B
A= exists $s->{"following"}{$attr}B= $s->{"following"}{$attr} ne ""
ABresult
0X0
100
111
726 }
727  
728 0 ▶sub to_composed_node_attr {
Subroutine to_composed_node_attr: not called CC=3 SCAR=24.8
Pod undocumented
729 0 my ($s,$data,$prefix,$concat,$compose,$attr)=@_;
730 0 my $value;
731 0 for (@{$s->{attributes}[-1]}) {
732 0 ▶ if ($_->[0] eq $compose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->[0] eq $compose) 0 0 0
733 0 $value = $_->[1]; last;
734 }
735 }
736 0 $attr.=$prefix.$value;
737 0 to_node_attr($s,$data,$concat,$attr);
738 0 $composed_attrs{$attr}=1;
739 }
740  
741 0 ▶sub make_new_node {
Subroutine make_new_node: not called CC=5 SCAR=34.0
Pod undocumented
742 0 my ($s,$data,$added)=@_;
743 # starting a new node
744 0 ▶ push @{$s->{nodes}},$s->{node} if ref($s->{node});
Branch: 1 branch
BranchTrueFalseTotal
if ref $s->{"node"} 0 0 0
745 #my $sentord=ref($s->{node}) ? $s->{node}->{sentord}+1 : 0;
746 0 $s->{node} = Treex::PML::Factory->createNode();
747 0 foreach (keys %initial_node_values) {
748 0 $s->{node}->{$_} = $initial_node_values{$_};
749 }
750 0 ▶ if ($added) {
Branch: 1 branch
BranchTrueFalseTotal
if ($added) { } 0 0 0
751 0 $s->{node}->{sentord}=999;
752 } else {
753 0 $s->{node}->{sentord}=$next_sentord;
754 0 $next_sentord++;
755 }
756 0 foreach (keys %{$s->{following}}) {
757 0 $s->{node}->{$_} = $s->{following}->{$_};
758 }
759 0 $s->{following}={};
760 }
761  
762 0 ▶sub make_new_tree {
Subroutine make_new_tree: not called CC=3 SCAR=24.8
Pod undocumented
763 0 my ($s)=@_;
764 # starting a new tree
765 0 $next_sentord=0;
766 0 make_new_node(@_);
767 0 ▶ push @{$s->{trees}}, build_tree(@{$s->{nodes}}) if (@{$s->{nodes}});
Branch: 1 branch
BranchTrueFalseTotal
if @{$s->{"nodes"};} 0 0 0
768 0 $s->{root}=$s->{node};
769 0 foreach (keys %{$s->{following_root}}) {
770 0 $s->{root}->{$_} = $s->{following_root}->{$_};
771 }
772 0 $s->{following_root}={};
773 0 @{$s->{nodes}}=();
774 }
775  
776 0 ▶sub make_last_tree {
Subroutine make_last_tree: not called CC=5 SCAR=34.0
Pod undocumented
777 0 my ($s)=@_;
778 0 ▶ push @{$s->{nodes}},$s->{node} if ref($s->{node});
Branch: 1 branch
BranchTrueFalseTotal
if ref $s->{"node"} 0 0 0
779 0 ▶ push @{$s->{trees}}, build_tree(@{$s->{nodes}}) if (@{$s->{nodes}});
Branch: 1 branch
BranchTrueFalseTotal
if @{$s->{"nodes"};} 0 0 0
780 0 ▶ print STDERR "Unstored data for following node\n" if (keys(%{$s->{following}}));
Branch: 1 branch
BranchTrueFalseTotal
if keys %{$$s{"following"};} 0 0 0
781 0 ▶ print STDERR "Unstored data for following root\n" if (keys(%{$s->{following_root}}));
Branch: 1 branch
BranchTrueFalseTotal
if keys %{$$s{"following_root"};} 0 0 0
782 0 @{$s->{nodes}}=();
783 }
784  
785 0 ▶sub copy_tag_to_following_root {
Subroutine copy_tag_to_following_root: not called CC=3 SCAR=24.8
Pod undocumented
786 0 my ($s,$data,$concat,$tag,$attr)=@_;
787 0 ▶ if ($tag =~/\</) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /\</) 0 0 0
788 0 to_attr($s,convert_element_to_string($s->{elements}->[-1],$s->{attributes}->[1]),"following_root",$concat,$attr);
789 }
790 0 ▶ if ($tag =~/\>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /\>/) 0 0 0
791 0 to_attr($s,"</$data>","following_root",$concat,$attr);
792 }
793 }
794  
795 0 ▶sub copy_tag_to {
Subroutine copy_tag_to: not called CC=3 SCAR=24.8
Pod undocumented
796 0 my ($s,$data,$concat,$tag,$attr)=@_;
797 0 ▶ if ($tag =~/\</) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /\</) 0 0 0
798 0 to_node_attr($s,convert_element_to_string($s->{elements}->[-1],$s->{attributes}->[-1]),$concat,$attr);
799 }
800 0 ▶ if ($tag =~/\>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /\>/) 0 0 0
801 0 to_node_attr($s,"</$data>",$concat,$attr);
802 }
803 }
804  
805 0 ▶sub unescape_data {
Subroutine unescape_data: not called CC=4 SCAR=25.8
Pod undocumented
806 0 my ($data)=@_;
807 2 ▶ use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
808 0 $data =~ s{\\ ( \| | \\ | n | [0-9]{0-3})}{
809 0 my $case = $1;
810 0 ▶ if ($case eq '\\') { # escaped backslash
Branch: 3 branches
BranchTrueFalseTotal
if ($case eq '\\') { } 0 0 0
elsif ($case eq 'n') { } 0 0 0
elsif ($case eq '|') { } 0 0 0
811 0 '\\'
812 } elsif ($case eq 'n') { # escaped newline (record end)
813 0 "\n"
814 } elsif ($case eq '|') { # SDATA bracket (ignoring)
815 0 ''
816 } else {
817 0 chr(oct($1))
818 }
819 }gex;
820 0 return $data;
821 }
822  
823 0 ▶sub read {
Subroutine read: not called CC=14 SCAR=53.5
Pod undocumented
824 0 my ($fh,$fsfile) = @_;
825 0 ▶ return unless ref($fsfile);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $fsfile 0 0 0
826  
827 0 my (%defs,@attlist,$event,@trees,@header);
828 0 my (@elements, $next_attributes, @attributes);
829 0 $next_attributes=[];
830 0 my $state = {
831 elements => \@elements, # element name stack
832 attributes => \@attributes, # element attribute-list stack
833 file => undef, # fixme
834 event => undef,
835 root => undef,
836 following_root => {},
837 node => undef,
838 following => {},
839 trees => [],
840 nodes => []
841 };
842  
843 0 my $document_is_conforming=0;
844 # we parse the the output of nsgmls
845 # and dispatch as needed
846 0 ▶ while (!eof($fh)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eof $fh) 0 0 0
847 0 my $type = getc($fh);
848 0 my $data = <$fh>;
849 0 chop($data);
850 0 ▶ if ($type eq '(') { # start element
Branch: 5 branches
BranchTrueFalseTotal
if ($type eq '(') { } 0 0 0
elsif ($type eq ')') { } 0 0 0
elsif ($type eq '-') { } 0 0 0
elsif ($type eq 'A') { } 0 0 0
elsif ($type eq 'C') { } 0 0 0
851 0 push @elements, $data;
852 0 push @attributes, $next_attributes;
853 0 ▶ if (exists($start_tag{$data})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $start_tag{$data}) 0 0 0
854 0 my ($cb,@args)=@{ $start_tag{$data} };
855 0 &$cb($state,$data,@args);
856 }
857 0 for my $attribute (@$next_attributes) {
858 0 ▶ if (exists $att{"$data $attribute->[0]"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $att{"$data $attribute->[0]"}) 0 0 0
859 0 my ($cb,@args)=@{ $att{"$data $attribute->[0]"} };
860 0 &$cb($state,$attribute->[1],@args);
861 }
862 }
863 0 $next_attributes=[];
864 } elsif ($type eq ')') { # end element
865 0 ▶ if (exists($end_tag{$data})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $end_tag{$data}) 0 0 0
866 0 my ($cb,@args)=@{ $end_tag{$data} };
867 0 &$cb($state,$data,@args);
868 }
869 0 pop @elements;
870 0 pop @attributes;
871 } elsif ($type eq '-') { # character data
872 0 my $element = $elements[-1];
873 0 ▶ if (exists($pcdata{$element})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $pcdata{$element}) 0 0 0
874 0 my ($cb,@args)=@{ $pcdata{$element} };
875 0 &$cb($state,unescape_data($data),@args);
876 }
877 } elsif ($type eq 'A') { # attribute of the next element
878 0 my ($name,$value)= $data=~m{^(\S+) (?:IMPLIED$|(?:CDATA|NOTATION|ENTITY|TOKEN|ID) (.*))};
879 0 push @$next_attributes,[$name,unescape_data($value)];
880 } elsif ($type eq 'C') { # document is conforming
881 0 $document_is_conforming=1;
882 }
883 }
884  
885 0 @header=@{$header};
886 0 foreach (keys %composed_attrs) {
887 0 push @header,"\@P $_";
888 }
889 0 $fsfile->changeFS(Treex::PML::Factory->createFSFormat(\@header));
890 0 $fsfile->changeTail("$fs_tail\n");
891 0 $fsfile->changeTrees(@{$state->{trees}});
892 0 $fsfile->changePatterns(@fs_patterns);
893 0 $fsfile->changeHint($fs_hint);
894  
895 0 return $document_is_conforming;
896 }
897  
898 0 ▶sub setupTR {
Subroutine setupTR: not called CC=1 SCAR=6.9
Pod undocumented
899 0 $gov = "govTR";
900 0 $header = \@TRheader;
901 0 $initial_node_values{TR}='hide';
902 0 $initial_root_values{reserve1}='TR_TREE';
903 0 $fs_tail='(2,3)';
904 0 @fs_patterns=(); # proper patterns added by TrEd's hook
905 0 $fs_hint=undef;
906  
907 }
908  
909 0 ▶sub setupAR {
Subroutine setupAR: not called CC=1 SCAR=6.9
Pod undocumented
910 0 $gov="ordorig";
911 0 $header = \@ARheader;
912 0 delete $initial_node_values{TR};
913 0 delete $initial_root_values{reserve1};
914 0 $fs_tail='(2,3)';
915 0 @fs_patterns=('${form}', '${afun}');
916 0 $fs_hint="tag:\t\${tag}\nlemma:\t\${lemma}";
917 }
918  
919 0 ▶sub setupPADTAR {
Subroutine setupPADTAR: not called CC=1 SCAR=6.9
Pod undocumented
920 0 setupAR();
921 0 $header = \@PADTARheader;
922 0 @fs_patterns=('${form}',
923 '#{custom1}<? join "_", map { "\${$_}" }'.
924 ' grep { $this->{$_}=~/./ && $this->{$_}!~/^no-/ }'.
925 ' qw(afun parallel paren arabfa arabspec arabclause) ?>');
926 0 $fs_hint="tag:\t\${tag}\nlemma:\t\${lemma}\ngloss:\t\${x_gloss}\ncommentA:\t\${commentA}";
927 }
928  
929 # hackish stuff follows...
930 # people should stop using CSTS |-/
931 0 ▶sub setupSpec {
Subroutine setupSpec: not called CC=5 SCAR=34.0
Pod undocumented
932 0 $gov = $_[0];
933 0 ▶ if (@_>1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
934 0 $header = [ @TRheader ];
935 0 ▶ if ($_[1] ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1] ne "") 0 0 0
936 0 @$header = ((grep !/\@N/,@$header), '@N '.$_[1]);
937 }
938 0 ▶ if (@_>2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 2) 0 0 0
939 0 ▶ if ($_[2] ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[2] ne '') { } 0 0 0
940 0 @$header = ((grep !/\@[H]/,@$header) , '@H '.$_[2]);
941 } else {
942 # backward in-compatibility: empty => use X_hide
943 # old behavior: always use X_hide
944 0 @$header = ((grep !/\@[H]/,@$header) , '@H X_hide');
945 0 $initial_node_values{X_hide}='hide';
946 }
947 }
948 }
949 }
950  
951 2 1;
« PML/Instance/Reader.pm ↑ Summary PML/Instance.pm »