| 1 | package PMLTQ::Command::webverify; | ||||||||||||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:MATY'; | |||||||||||||||||||||||||||||
| 3 | 1 | $PMLTQ::Command::webverify::VERSION = '2.0.3'; | |||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Check if treebank is setted in web interface | ||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use PMLTQ::Base 'PMLTQ::Command'; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use File::Path qw( make_path ); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | has usage => sub { shift->extract_usage }; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 12 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 13 | 0 | my $ua = $self->ua; | |||||||||||||||||||||||||||||
| 14 | 0 | $self->login($ua); | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||
| 16 | 0 | my $json = JSON->new; | |||||||||||||||||||||||||||||
| 17 | 0 | my $treebank = $self->get_treebank($ua); | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | if($treebank) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 19 | 0 | print $json->pretty->encode($treebank); | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | if (my $test_query = $self->config->{test_query}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if($test_query->{result_dir} && not(-d $test_query->{result_dir})) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$test_query->{"result_dir"} and not -d $test_query->{"result_dir"}
MC/DC0%0/2
$test_query->{"result_dir"} and not -d $test_query->{"result_dir"}
$test_query->{"result_dir"}
not -d $test_query->{"result_dir"}
Truth table0%0/3
A and not(B)
A= $test_query->{"result_dir"}B= not -d $test_query->{"result_dir"}
| |||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | make_path($test_query->{result_dir}) or die "Unable to create directory ".$test_query->{result_dir}."\n" ; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||
| 24 | 0 | my $i=0; | |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | for my $query (@{$test_query->{queries} // []}) { | ||||||||||||||||||||||||||||
|
Condition0%0/2
$test_query->{"queries"} // []
MC/DC0%0/1
$test_query->{"queries"} // []
$test_query->{"queries"}
Truth table0%0/2
A
A= $test_query->{"queries"}
| |||||||||||||||||||||||||||||||
| 26 | 0 | my $text = $query->{query}; | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $filename = File::Spec->catfile($test_query->{result_dir} // '.', $query->{filename} // $i); | ||||||||||||||||||||||||||||
|
Condition0%0/5
$test_query->{"result_dir"} // "."
$query->{"filename"} // $i
MC/DC0%0/1
$test_query->{"result_dir"} // "."
$test_query->{"result_dir"}
MC/DC0%0/2
$query->{"filename"} // $i
$query->{"filename"}
$i
Truth table0%0/2
A
A= $test_query->{"result_dir"}
Truth table0%0/3
A // B
A= $query->{"filename"}B= $i
| |||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | unless($text) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 29 | 0 | print STDERR "Error in config file: Empty query\n"; | |||||||||||||||||||||||||||||
| 30 | 0 | next; | |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||
| 32 | 0 | my $result = $self->evaluate_query($treebank->{id},$text); | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if($result =~ m!</svg>!) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | print STDERR "There is no text field in SVG result $filename ('$text') => check print server log (wrong styles?)\n" unless $result =~ m!</text>!; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | print STDERR "There is no node field in SVG result $filename ('$text') => check print server log (wrong file path?)\n" unless $result =~ m!<ellipse!; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | open(my $fh, '>', $filename) or die "Could not open file '$filename' $!"; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 39 | 0 | print $fh $result; | |||||||||||||||||||||||||||||
| 40 | 0 | close $fh; | |||||||||||||||||||||||||||||
| 41 | 0 | $i++; | |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||
| 44 | } else { | ||||||||||||||||||||||||||||||
| 45 | 0 | print STDERR "Unknown treebank\n"; | |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||
| 49 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||
| 51 | pmltq webverify <treebank_config> | ||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||
| 53 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||
| 55 | Check if treebank is setted in web interface. | ||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||
| 57 | =head1 OPTIONS | ||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||
| 59 | =head1 PARAMS | ||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||
| 61 | =over 5 | ||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||
| 63 | =item B<treebank_config> | ||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||
| 65 | Path to configuration file. If a treebank_config is --, config is readed from STDIN. | ||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||
| 67 | =back | ||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||
| 71 | 1 | 1; | |||||||||||||||||||||||||||||