File Coverage

lib/PMLTQ/Command/suggest.pm
Criterion Covered Total %
statement 35 35 100.0
branch 2 4 50.0
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 45 48 93.7


line stmt bran cond sub pod time code
1             package PMLTQ::Command::suggest;
2             our $AUTHORITY = 'cpan:MATY';
3             $PMLTQ::Command::suggest::VERSION = '1.0.4';
4             # ABSTRACT: Return query for given nodes
5              
6 1     1   251838 use PMLTQ::Base 'PMLTQ::Command';
  1         2813  
  1         5  
7 1     1   145650 use PMLTQ;
  1         26293  
  1         44  
8 1     1   519 use PMLTQ::Suggest::Utils;
  1         7  
  1         13  
9 1     1   533 use PMLTQ::Suggest;
  1         4  
  1         18  
10 1     1   51 use File::Path qw( make_path );
  1         1  
  1         70  
11 1     1   796 use Getopt::Long qw(GetOptionsFromArray);
  1         10931  
  1         53  
12 1     1   176 use Treex::PML;
  1         2  
  1         408  
13              
14             has usage => sub { shift->extract_usage };
15              
16             my %opts;
17              
18             sub run {
19 8     8 0 57746 my $self = shift;
20 8         31 my @args = @_;
21 8 50       55 GetOptionsFromArray(\@args, \%opts,
22             'nodes|N=s'
23             ) || die "invalid options";
24             Treex::PML::AddResourcePath(
25             PMLTQ->resources_dir,
26             File::Spec->catfile(${FindBin::RealBin},'config'),
27             $ENV{HOME}.'/.tred.d',
28             $self->config->{resources}
29 8         3321 );
30 8 50       889 my @paths = $opts{nodes} ? split(/\|/, $opts{nodes}) : ();
31 8         24 my @positions;
32 8         32 foreach my $p (@paths) {
33 15         73 my ($path, $goto)=PMLTQ::Suggest::Utils::parse_file_suffix($p);
34 15         143 $path = URI->new($path)->canonical->as_string;
35 15         1382 push @positions, [$path,$goto];
36             }
37 8         64 my $pmltq = PMLTQ::Suggest::make_pmltq(
38             \@positions
39             );
40 8         29144 Encode::_utf8_off($pmltq);
41 8         422406 print "$pmltq\n";
42 8         211 return 1;
43             }
44              
45             =head1 SYNOPSIS
46              
47             pmltq suggest [--resources="path to resources directory"] --nodes "FILE2#NODE_ID1|FILE2#NODE_ID2|..."
48              
49             =head1 DESCRIPTION
50              
51             Return query for given nodes. It works on local PML files.
52              
53             =head1 OPTIONS
54              
55             =head1 PARAMS
56              
57             =over 5
58              
59             =item B
60              
61             Path to configuration file. If a treebank_config is --, config is readed from STDIN.
62              
63             =back
64              
65             =cut
66              
67             1;