Skip to content

Commit

Permalink
Merge pull request #36 from ufal/documentation_commands
Browse files Browse the repository at this point in the history
Documentation commands
  • Loading branch information
matyaskopp committed Jun 27, 2016
2 parents 09f3bc5 + 84d6d58 commit ad3b256
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 27 deletions.
2 changes: 1 addition & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Hash::Merge = 0
IO::Scalar = 2.110
JSON = 2.90
List::MoreUtils = 0
List::Util = 0
List::Util = 1.45
MIME::Types = 2.04
Mojo::Base::XS = 0
Pod::Usage = 1.67
Expand Down
12 changes: 6 additions & 6 deletions lib/PMLTQ/Command.pm
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ sub request {
$data = $JSON->encode($data);
$data =~ s/"false"/false/g;
$data =~ s/"true"/true/g;
$req->content($data);
$req->content($data);
}
my $res = eval { $ua->request( $req ); };
confess($@) if $@;
Expand Down Expand Up @@ -280,9 +280,9 @@ sub create_treebank_param {
languages => \@langs,
serverId => $server[0],
database => $self->config->{db}->{name},
isFree => $self->config->{isFree} // "false",
isPublic => $self->config->{isPublic} // "false",
isFeatured => $self->config->{isFeatured} // "false",
isFree => $self->config->{isFree},
isPublic => $self->config->{isPublic},
isFeatured => $self->config->{isFeatured},
}
}

Expand Down Expand Up @@ -317,11 +317,11 @@ sub evaluate_query {
(undef,$result) = $self->request($self->{ua}, 'POST', $url->abs->as_string, {nodes => $results->[0], tree => 0});
} else { # filter result
$result = join("\n",map {join("\t",@$_)} @$results) . "\n";
}
}
} else {
print STDERR "Empty result for: $query\n";
}
}
return $result;
return $result;
}
1;
74 changes: 59 additions & 15 deletions lib/PMLTQ/Command/init.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ sub run {
push @layers, {
name => $schema->get_root_name,
data => '<change this to point to files relative to the data_dir>',
path => '<change this to point to files relative to the data directory on server>',
COMMENT_path => '<change this to point to files relative to the data directory on server>',
references => {%$refs}
};
}
Expand All @@ -102,24 +102,65 @@ sub run {

my $yaml = YAML::Tiny->new(
{
treebank_id => $treebank_id,
title => $treebank_title,
resources => $resources_dir,
layers => \@layers,
description => '',
isPublic => 'false',
isFree => 'false',
isFeatured => 'false',
web_api =>
treebank_id => $treebank_id,
COMMENT_data_dir => '',
resources => $resources_dir,
COMMENT_output_dir => '',
db =>
{
url => '',
user => '',
password => ''
name => $treebank_id,
COMMENT_host => 'localhost',
COMMENT_port => 5432,
COMMENT_user => '',
COMMENT_password => ''
},
COMMENT_sys_db => 'postgres',
layers => \@layers,
title => $treebank_title,
COMMENT_homepage => '',
COMMENT_description => '',
COMMENT_isFree => 'false',
COMMENT_isPublic => 'false',
COMMENT_isFeatured => 'false',
COMMENT_web_api =>
{
COMMENT_dbserver => '',
COMMENT_url => '',
COMMENT_user => '',
COMMENT_password => ''
},
COMMENT_manuals =>
[
{
COMMENT_title => '',
COMMENT_url => ''
}
],
COMMENT_tags =>
[
'COMMENT_mytag'
],
COMMENT_language => 'lang code',
COMMENT_text_query =>
{
COMMENT_result_dir => 'webverify_query_results',
COMMENT_queries =>
[
{
COMMENT_filename => '01.svg',
COMMENT_query => 'a-node [];'
}
]
}
}
);

say $yaml->write_string;
my $result = $yaml->write_string;

$result =~ s/\n( *[-]? *)COMMENT_/\n#$1/g;
$result =~ s/\n#(.*?)\n( *-)/\n#$1\n#$2/g;

say $result;

my $save = $self->prompt_yn( 'Save?', { default => 0 } );

Expand All @@ -129,7 +170,10 @@ sub run {
default => 'pmltq.yml'
}
);
$yaml->write($filename);
#$yaml->write($filename);
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
print $fh $result;
close $fh;
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/PMLTQ/Command/webverify.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ sub run {
my $self = shift;
my $ua = $self->ua;
$self->login($ua);

my $json = JSON->new;
my $treebank = $self->get_treebank($ua);
if($treebank) {
print $json->pretty->encode($treebank);
if (my $test_query = $self->config->{test_query}) {
if($test_query->{result_dir} && not(-d $test_query->{result_dir})) {
make_path($test_query->{result_dir}) or die "Unable to create directory ".$test_query->{result_dir}."\n" ;
make_path($test_query->{result_dir}) or die "Unable to create directory ".$test_query->{result_dir}."\n" ;
}
my $i=0;
for my $query (@{$test_query->{queries} // []}) {
Expand Down
Loading

0 comments on commit ad3b256

Please sign in to comment.