| 1 | package PMLTQ::Command::load; | ||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:MATY'; | |||||||||
| 3 | 1 | $PMLTQ::Command::load::VERSION = '2.0.3'; | |||||||||
| 4 | # ABSTRACT: Load treebank to database | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use PMLTQ::Base 'PMLTQ::Command'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 0 | ▶ | has usage => sub { shift->extract_usage }; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 9 | |||||||||||
| 10 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||
| 11 | 0 | my $self = shift; | |||||||||
| 12 | |||||||||||
| 13 | 0 | my $config = $self->config; | |||||||||
| 14 | 0 | my $output_dir = $self->config->{output_dir}; | |||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | unless ( -d $output_dir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | die <<"MSG"; | |||||||||
| 18 | Output directory $output_dir does not exist. | ||||||||||
| 19 | |||||||||||
| 20 | Maybe you need to run 'pmltq convert' first. | ||||||||||
| 21 | |||||||||||
| 22 | MSG | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | my $dbh; | |||||||||
| 26 | 0 | eval { $dbh = $self->db }; | |||||||||
| 27 | 0 | ▶ | if ( $@ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | die <<"MSG"; | |||||||||
| 29 | $@ | ||||||||||
| 30 | Maybe you need to run 'pmltq initdb' first. | ||||||||||
| 31 | |||||||||||
| 32 | MSG | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | for my $layer ( @{ $config->{layers} } ) { | |||||||||
| 36 | 0 | my $listfile = File::Spec->catfile( $output_dir, "$layer->{name}__init.list" ); | |||||||||
| 37 | 0 | ▶ | open my $fh, '<', $listfile or die "Can't open $listfile: $!"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | for my $file (<$fh>) { | |||||||||
| 39 | 0 | $file =~ s/\n$//; | |||||||||
| 40 | 0 | ▶ | next unless $file; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | $self->run_sql_from_file( $file, $output_dir, $dbh ); | |||||||||
| 42 | } | ||||||||||
| 43 | ###$dbh->do($sql); | ||||||||||
| 44 | } | ||||||||||
| 45 | 0 | $dbh->disconnect; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | =encoding utf8 | ||||||||||
| 49 | |||||||||||
| 50 | =head1 SYNOPSIS | ||||||||||
| 51 | |||||||||||
| 52 | pmltq load <treebank_config> <sql_dir> | ||||||||||
| 53 | |||||||||||
| 54 | =head1 DESCRIPTION | ||||||||||
| 55 | |||||||||||
| 56 | Load treebank to database | ||||||||||
| 57 | |||||||||||
| 58 | =head1 OPTIONS | ||||||||||
| 59 | |||||||||||
| 60 | =head1 PARAMS | ||||||||||
| 61 | |||||||||||
| 62 | =over 5 | ||||||||||
| 63 | |||||||||||
| 64 | =item B<treebank_config> | ||||||||||
| 65 | |||||||||||
| 66 | Path to configuration file. If a treebank_config is --, config is readed from STDIN. | ||||||||||
| 67 | |||||||||||
| 68 | Path to input directory. | ||||||||||
| 69 | |||||||||||
| 70 | =back | ||||||||||
| 71 | |||||||||||
| 72 | =cut | ||||||||||
| 73 | |||||||||||
| 74 | 1 | 1; | |||||||||