| 1 | package PMLTQ::Command::webtreebank; | ||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:MATY'; | |||||||||||||
| 3 | 1 | $PMLTQ::Command::webtreebank::VERSION = '2.0.3'; | |||||||||||||
| 4 | # ABSTRACT: GET actions on treebanks on the web | ||||||||||||||
| 5 | |||||||||||||||
| 6 | 1 | ▶ | use PMLTQ::Base 'PMLTQ::Command'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 1 | ▶ | use JSON; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | ▶ | use YAML::Tiny; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 1 | ▶ | use Hash::Merge 'merge'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | 0 | ▶ | has usage => sub { shift->extract_usage }; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 0 | ▶ | sub run { | ||||||||||||
|
Subroutine
run: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||
| 14 | 0 | my $self = shift; | |||||||||||||
| 15 | 0 | my $subcommand = shift; | |||||||||||||
| 16 | 0 | my $config = $self->config; | |||||||||||||
| 17 | 0 | ▶ | unless($subcommand){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 18 | 0 | say "Subcommand must be set."; | |||||||||||||
| 19 | 0 | return 0; | |||||||||||||
| 20 | } | ||||||||||||||
| 21 | 0 | my $ua = $self->ua; | |||||||||||||
| 22 | 0 | $self->login($ua); | |||||||||||||
| 23 | 0 | my $json = JSON->new; | |||||||||||||
| 24 | |||||||||||||||
| 25 | 0 | ▶ | if($subcommand eq 'list'){ | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 26 | 0 | my $treebanks = $self->get_all_treebanks($ua); | |||||||||||||
| 27 | 0 | my $unknown = 0; | |||||||||||||
| 28 | print join("\n", | ||||||||||||||
| 29 | map { | ||||||||||||||
| 30 | 0 | my $tb = $_; | |||||||||||||
| 31 | join("\t", | ||||||||||||||
| 32 | map { | ||||||||||||||
| 33 | 0 | ▶ | $unknown = 1 unless $tb->{$_}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 34 | 0 | ▶ | my $ret = $tb->{$_} // "<UNKNOWN FIELD $_>"; | ||||||||||||
|
Condition0%0/2
$tb->{$_} // "<UNKNOWN FIELD $_>"
MC/DC0%0/1
$tb->{$_} // "<UNKNOWN FIELD $_>"
$tb->{$_}
Truth table0%0/2
A
A= $tb->{$_}
| |||||||||||||||
| 35 | 0 | ▶ | ref($ret) ? $json->encode($ret) : $ret; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 36 | 0 | } split(/[,; |]/,$config->{info}->{fields}) )} @$treebanks | |||||||||||||
| 37 | ),"\n"; | ||||||||||||||
| 38 | 0 | ▶ | print STDERR "Possible fields: ", join( " ", keys %{$treebanks->[0]}) if $unknown; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | } elsif($subcommand eq 'single') { | ||||||||||||||
| 40 | 0 | my $treebank = $self->get_treebank($ua); | |||||||||||||
| 41 | print YAML::Tiny->new(merge( | ||||||||||||||
| 42 | merge( $config, $self->user2admin_format($treebank)), | ||||||||||||||
| 43 | {test_query => { | ||||||||||||||
| 44 | result_dir => 'query_results/'.$treebank->{name}, | ||||||||||||||
| 45 | 0 | queries => $self->get_test_queries($treebank) | |||||||||||||
| 46 | }} | ||||||||||||||
| 47 | ) | ||||||||||||||
| 48 | )->write_string; | ||||||||||||||
| 49 | } | ||||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | =head1 SYNOPSIS | ||||||||||||||
| 53 | |||||||||||||||
| 54 | pmltq webtreebank <subcommand> | ||||||||||||||
| 55 | |||||||||||||||
| 56 | =head1 DESCRIPTION | ||||||||||||||
| 57 | |||||||||||||||
| 58 | =head1 OPTIONS | ||||||||||||||
| 59 | |||||||||||||||
| 60 | =head2 subcommands | ||||||||||||||
| 61 | |||||||||||||||
| 62 | =over 5 | ||||||||||||||
| 63 | |||||||||||||||
| 64 | =item list | ||||||||||||||
| 65 | |||||||||||||||
| 66 | =over 5 | ||||||||||||||
| 67 | |||||||||||||||
| 68 | Command with this option returns a list of treebank names (ids). | ||||||||||||||
| 69 | |||||||||||||||
| 70 | There in specific option --info-fields with default value "name" that determines which fields should be printed. For example --info-fields="name,title" returns one treebank perl line with tab separated fields name and title. | ||||||||||||||
| 71 | |||||||||||||||
| 72 | =back | ||||||||||||||
| 73 | |||||||||||||||
| 74 | =item single --treebank_id="<tbid>" | ||||||||||||||
| 75 | |||||||||||||||
| 76 | =over 5 | ||||||||||||||
| 77 | |||||||||||||||
| 78 | Command returns yaml formated string for treebank with name or id <tbid>. This config options are merged with default and current configs. So it can be used for generating configuration files from treebank's options saved on web. | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =back | ||||||||||||||
| 81 | |||||||||||||||
| 82 | =back | ||||||||||||||
| 83 | |||||||||||||||
| 84 | =head1 PARAMS | ||||||||||||||
| 85 | |||||||||||||||
| 86 | =over 5 | ||||||||||||||
| 87 | |||||||||||||||
| 88 | =item B<api_url> | ||||||||||||||
| 89 | |||||||||||||||
| 90 | Url to pmltq service | ||||||||||||||
| 91 | |||||||||||||||
| 92 | =back | ||||||||||||||
| 93 | |||||||||||||||
| 94 | =head1 EXAMPLES | ||||||||||||||
| 95 | |||||||||||||||
| 96 | =over 5 | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =item Creates and executes simple queries on all treebanks on web | ||||||||||||||
| 99 | |||||||||||||||
| 100 | for tb in `./script/pmltq webtreebank list`; do echo "$tb"; ./script/pmltq webtreebank single --treebank_id=$tb | ./script/pmltq webverify -c --; sleep 60; done | ||||||||||||||
| 101 | |||||||||||||||
| 102 | =back | ||||||||||||||
| 103 | |||||||||||||||
| 104 | =cut | ||||||||||||||
| 105 | |||||||||||||||
| 106 | 1 | 1; | |||||||||||||