Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 4 | use FindBin; |
| 5 | BEGIN { unshift @INC, "$FindBin::Bin/../lib" }; |
| 6 | use File::Spec::Functions qw/catfile catdir/; |
| 7 | use Getopt::Long qw/GetOptions :config no_auto_abbrev/; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 8 | use Benchmark qw/:hireswallclock/; |
| 9 | use IO::Compress::Gzip qw/$GzipError/; |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 10 | use POSIX qw/ceil/; |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 11 | use Log::Log4perl; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 12 | use Pod::Usage; |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 13 | use Cache::FastMmap; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 14 | use Directory::Iterator; |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 15 | use KorAP::XML::Krill; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 16 | use KorAP::XML::Archive; |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 17 | use KorAP::XML::Tokenizer; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 18 | use KorAP::XML::Batch::File; |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 19 | use Config::Simple; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 20 | use Parallel::ForkManager; |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 21 | use v5.10; |
| 22 | use Sys::Info; |
| 23 | use Sys::Info::Constants qw( :device_cpu ); |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 24 | use File::Glob ':bsd_glob'; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 25 | use File::Temp qw/tempdir/; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 26 | use File::Path qw(remove_tree make_path); |
| 27 | use Mojo::Collection 'c'; |
| 28 | use String::Random qw(random_string); |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 29 | use IO::File; |
| 30 | use Archive::Tar::Builder; |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 31 | |
| 32 | # use KorAP::XML::ForkPool; |
Akron | 75ba57d | 2016-03-07 23:36:27 +0100 | [diff] [blame] | 33 | # TODO: use Parallel::Loops |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 34 | # TODO: make output files |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 35 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 36 | # TODO: Use KorAP::XML::ForkPool! |
| 37 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 38 | # CHANGES: |
| 39 | # ---------------------------------------------------------- |
| 40 | # 2013/11/25 |
| 41 | # - Initial release |
| 42 | # |
| 43 | # 2014/10/29 |
| 44 | # - Merges foundry data to create indexer friendly documents |
| 45 | # |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 46 | # 2016/02/04 |
| 47 | # - renamed to korapxml2krill |
| 48 | # - added Schreibgebrauch support |
Akron | 069bd71 | 2016-02-12 19:09:06 +0100 | [diff] [blame] | 49 | # |
| 50 | # 2016/02/12 |
| 51 | # - fixed foundry skipping |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 52 | # - Support overwrite in archive processing |
Akron | 150b29e | 2016-02-14 23:06:48 +0100 | [diff] [blame] | 53 | # |
| 54 | # 2016/02/14 |
| 55 | # - Added version information |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 56 | # - Added support for archive files |
| 57 | # |
| 58 | # 2016/02/15 |
| 59 | # - Fixed temporary directory bug |
| 60 | # - Improved skipping before unzipping |
| 61 | # - Added EXPERIMENTAL concurrency support |
| 62 | # |
| 63 | # 2016/02/23 |
| 64 | # - Merge korapxml2krill and korapxml2krill_dir |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 65 | # |
| 66 | # 2016/02/27 |
| 67 | # - Added extract function |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 68 | # |
| 69 | # 2016/03/17 |
| 70 | # - Added meta switch |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 71 | # |
| 72 | # 2016/03/18 |
| 73 | # - Added meta data caching |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 74 | # |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 75 | # 2016/06/27 |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 76 | # - Added multi archive support |
| 77 | # - Added prefix negation support |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 78 | # - Added Malt#Dependency support |
Akron | 8b99052 | 2016-07-06 16:45:57 +0200 | [diff] [blame] | 79 | # |
| 80 | # 2016/07/06 |
| 81 | # - Added MDParser#Dependency |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 82 | # |
| 83 | # 2016/10/15 |
Nils Diewald | 0e48977 | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 84 | # - Fixed temporary path issue in script |
| 85 | # |
| 86 | # 2016/10/24 |
| 87 | # - Improved Windows support |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 88 | # |
Akron | b4bbec7 | 2016-10-26 20:21:02 +0200 | [diff] [blame] | 89 | # 2016/10/24 |
| 90 | # - Added support for document extraction |
| 91 | # |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 92 | # 2016/10/27 |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 93 | # - Added wildcard support for document extraction |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 94 | # |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 95 | # 2016/12/21 |
| 96 | # - added support for base-sentences and base-tokenizations |
| 97 | # |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 98 | # 2017/01/20 |
| 99 | # - added support for DRuKoLa annotations |
| 100 | # |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 101 | # 2017/02/08 |
| 102 | # - added support for pagebreak annotations |
| 103 | # |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 104 | # 2017/04/06 |
| 105 | # - added support for wildcards in input |
| 106 | # |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 107 | # 2017/04/07 |
| 108 | # - support configuration option |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 109 | # - support for temporary extraction |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 110 | # |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 111 | # 2017/04/12 |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 112 | # - support serial processing |
| 113 | # - support input root |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 114 | # - introduced --sequential-extraction flag |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 115 | # ---------------------------------------------------------- |
Akron | 069bd71 | 2016-02-12 19:09:06 +0100 | [diff] [blame] | 116 | |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 117 | our $LAST_CHANGE = '2017/04/12'; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 118 | our $LOCAL = $FindBin::Bin; |
| 119 | our $VERSION_MSG = <<"VERSION"; |
| 120 | Version $KorAP::XML::Krill::VERSION - diewald\@ids-mannheim.de - $LAST_CHANGE |
| 121 | VERSION |
| 122 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 123 | # Prototypes |
| 124 | sub get_file_name_from_glob($); |
| 125 | sub get_file_name($); |
| 126 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 127 | # Parse comand |
| 128 | my $cmd; |
| 129 | our @ARGV; |
| 130 | if ($ARGV[0] && index($ARGV[0], '-') != 0) { |
| 131 | $cmd = shift @ARGV; |
Akron | 150b29e | 2016-02-14 23:06:48 +0100 | [diff] [blame] | 132 | }; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 133 | my @keep_argv = @ARGV; |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 134 | |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 135 | my (@skip, @sigle, @anno, @input); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 136 | my $text; |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 137 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 138 | # Parse options from the command line |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 139 | GetOptions( |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 140 | 'input|i=s' => \@input, |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 141 | 'input-base|ib=s' => \(my $input_base), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 142 | 'output|o=s' => \(my $output), |
| 143 | 'overwrite|w' => \(my $overwrite), |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 144 | 'meta|m=s' => \(my $meta), |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 145 | 'token|t=s' => \(my $token_base), |
| 146 | 'base-sentences|bs=s' => \(my $base_sentences), |
| 147 | 'base-paragraphs|bp=s' => \(my $base_paragraphs), |
| 148 | 'base-pagebreaks|bpb=s' => \(my $base_pagebreaks), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 149 | 'gzip|z' => \(my $gzip), |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 150 | 'temporary-extract|te=s' => \(my $extract_dir), |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 151 | 'skip|s=s' => \@skip, |
| 152 | 'sigle|sg=s' => \@sigle, |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 153 | 'cache|c=s' => \(my $cache_file), |
| 154 | 'config|cfg=s' => \(my $cfg_file), |
| 155 | 'log|l=s' => \(my $log_level), |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 156 | 'anno|a=s' => \@anno, |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 157 | 'primary|p!' => \(my $primary), |
| 158 | 'pretty|y' => \(my $pretty), |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 159 | 'jobs|j=i' => \(my $jobs), |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 160 | 'to-tar=s' => \(my $to_tar), |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 161 | 'sequential-extraction|se' => \(my $sequential_extraction), |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 162 | 'cache-size|cs=s' => \(my $cache_size), |
| 163 | 'cache-delete|cd!' => \(my $cache_delete), |
| 164 | 'cache-init|ci!' => \(my $cache_init), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 165 | 'help|h' => sub { |
| 166 | pod2usage( |
| 167 | -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS', |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 168 | -verbose => 99, |
| 169 | -msg => $VERSION_MSG, |
| 170 | -output => '-' |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 171 | ); |
| 172 | }, |
| 173 | 'version|v' => sub { |
| 174 | pod2usage( |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 175 | -verbose => 0, |
| 176 | -msg => $VERSION_MSG, |
| 177 | -output => '-' |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 178 | ) |
| 179 | } |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 180 | ); |
| 181 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 182 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 183 | # Load from configuration |
| 184 | if ($cfg_file && -e $cfg_file) { |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 185 | my %config; |
| 186 | |
| 187 | Config::Simple->import_from($cfg_file, \%config); |
| 188 | |
| 189 | # Overwrite |
| 190 | if (!defined($overwrite) && defined $config{overwrite}) { |
| 191 | $overwrite = $config{overwrite}; |
| 192 | }; |
| 193 | |
| 194 | # Gzip |
| 195 | if (!defined($gzip) && defined $config{gzip}) { |
| 196 | $gzip = $config{gzip}; |
| 197 | }; |
| 198 | |
| 199 | # Jobs |
| 200 | if (!defined($jobs) && defined $config{jobs}) { |
| 201 | $jobs = $config{jobs}; |
| 202 | }; |
| 203 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 204 | # Input root base directory |
| 205 | if (!defined($input_base) && defined $config{'input-base'}) { |
| 206 | $input_base = $config{'input-base'}; |
| 207 | }; |
| 208 | |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 209 | # temporary-extract |
| 210 | if (!defined($extract_dir) && defined $config{'temporary-extract'}) { |
| 211 | $extract_dir = $config{'temporary-extract'}; |
| 212 | }; |
| 213 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 214 | # Token base |
| 215 | if (!defined($token_base) && defined $config{token}) { |
| 216 | $token_base = $config{token}; |
| 217 | }; |
| 218 | |
| 219 | # Cache file |
| 220 | if (!defined($cache_file) && defined $config{cache}) { |
| 221 | $cache_file = $config{cache}; |
| 222 | }; |
| 223 | |
| 224 | # Cache size |
| 225 | if (!defined($cache_size) && defined $config{'cache-size'}) { |
| 226 | $cache_size = $config{'cache-size'}; |
| 227 | }; |
| 228 | |
| 229 | # Cache delete |
| 230 | if (!defined($cache_delete) && defined $config{'cache-delete'}) { |
| 231 | $cache_delete = $config{'cache-delete'} ; |
| 232 | }; |
| 233 | |
| 234 | # Cache init |
| 235 | if (!(defined $cache_init) && defined $config{'cache-init'}) { |
| 236 | $cache_init = $config{'cache-init'} ; |
| 237 | }; |
| 238 | |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 239 | # Jobs for extraction |
| 240 | if (!(defined $sequential_extraction) && defined $config{'sequential-extraction'}) { |
| 241 | $sequential_extraction = $config{'sequential-extraction'} ; |
| 242 | }; |
| 243 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 244 | # Meta |
| 245 | if (!(defined $meta) && defined $config{'meta'}) { |
| 246 | $meta = $config{'meta'} ; |
| 247 | }; |
| 248 | |
| 249 | # Output |
| 250 | if (!(defined $output) && defined $config{'output'}) { |
| 251 | $output = $config{'output'} ; |
| 252 | }; |
| 253 | |
| 254 | # Base-sentences |
| 255 | if (!(defined $base_sentences) && defined $config{'base-sentences'}) { |
| 256 | $base_sentences = $config{'base-sentences'} ; |
| 257 | }; |
| 258 | |
| 259 | # Base-paragraphs |
| 260 | if (!(defined $base_paragraphs) && defined $config{'base-paragraphs'}) { |
| 261 | $base_paragraphs = $config{'base-paragraphs'} ; |
| 262 | }; |
| 263 | |
| 264 | # Base-pagebreaks |
| 265 | if (!(defined $base_pagebreaks) && defined $config{'base-pagebreaks'}) { |
| 266 | $base_pagebreaks = $config{'base-pagebreaks'} ; |
| 267 | }; |
| 268 | |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 269 | # Write to tar |
| 270 | if (!(defined $to_tar) && defined $config{'to-tar'}) { |
| 271 | $to_tar = $config{'to-tar'} ; |
| 272 | }; |
| 273 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 274 | # Log |
| 275 | if (!(defined $log_level) && defined $config{'log'}) { |
| 276 | $log_level = $config{'log'} ; |
| 277 | }; |
| 278 | |
| 279 | # Skip |
| 280 | if (!scalar(@skip) && defined $config{'skip'}) { |
| 281 | @skip = split /\s*;\s*/, $config{'skip'} ; |
| 282 | }; |
| 283 | |
| 284 | # Sigle |
| 285 | if (!scalar(@sigle) && defined $config{'sigle'}) { |
| 286 | @sigle = split /\s*;\s*/, $config{'sigle'} ; |
| 287 | }; |
| 288 | |
| 289 | # Anno |
| 290 | if (!scalar(@anno) && defined $config{'anno'}) { |
| 291 | @anno = split /\s*;\s*/, $config{'anno'} ; |
| 292 | }; |
| 293 | }; |
| 294 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 295 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 296 | # Set default token base |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 297 | $token_base //= 'OpenNLP#tokens'; |
| 298 | $cache_file //= 'korapxml2krill.cache'; |
| 299 | $cache_size //= '50m'; |
| 300 | $jobs //= 0; |
| 301 | $cache_delete //= 1; |
| 302 | $cache_init //= 1; |
| 303 | $sequential_extraction //= 0; |
| 304 | $log_level //= 'ERROR'; |
| 305 | $base_sentences //= ''; |
| 306 | $base_paragraphs //= ''; |
| 307 | $base_pagebreaks //= ''; |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 308 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 309 | $base_sentences = lc $base_sentences; |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 310 | $base_paragraphs = lc $base_paragraphs; |
Akron | 636bd9c | 2017-02-09 17:13:00 +0100 | [diff] [blame] | 311 | $base_pagebreaks = lc $base_pagebreaks; |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 312 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 313 | |
| 314 | # Initialize log4perl object |
| 315 | Log::Log4perl->init({ |
| 316 | 'log4perl.rootLogger' => uc($log_level) . ', STDERR', |
| 317 | 'log4perl.appender.STDERR' => 'Log::Log4perl::Appender::ScreenColoredLevels', |
| 318 | 'log4perl.appender.STDERR.layout' => 'PatternLayout', |
| 319 | 'log4perl.appender.STDERR.layout.ConversionPattern' => '[%r] %F %L %c - %m%n' |
| 320 | }); |
| 321 | |
| 322 | my $log = Log::Log4perl->get_logger('main'); |
| 323 | |
| 324 | |
| 325 | print "Reading config from $cfg_file\n" if $cfg_file; |
| 326 | |
| 327 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 328 | my %ERROR_HASH = ( |
| 329 | -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS', |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 330 | -verbose => 99, |
| 331 | -msg => $VERSION_MSG, |
| 332 | -output => '-', |
| 333 | -exit => 1 |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 334 | ); |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 335 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 336 | # Input has to be defined |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 337 | pod2usage(%ERROR_HASH) unless @input; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 338 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 339 | # Gzip has no effect, if no output is given |
| 340 | pod2usage(%ERROR_HASH) if $gzip && !$output; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 341 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 342 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 343 | if ($jobs eq '-1') { |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 344 | state $cores = Sys::Info->new->device('CPU')->count; |
| 345 | $jobs = ceil(5 * $cores); |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 346 | $log->info("Run using $jobs jobs on $cores cores"); |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 347 | }; |
| 348 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 349 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 350 | # Start serial processing |
| 351 | if ($cmd eq 'serial') { |
| 352 | |
| 353 | if ($output && (!-e $output || !-d $output)) { |
| 354 | print "Directory '$output' does not exist.\n\n"; |
| 355 | exit(0); |
| 356 | }; |
| 357 | |
| 358 | # Remove all inputs |
| 359 | my $remove_next = 0; |
| 360 | @keep_argv = @{c(@keep_argv)->grep( |
| 361 | sub { |
| 362 | # Input flag |
| 363 | if ($_ eq '-i' || $_ eq '--input' || $_ eq '--output' || $_ eq '-o') { |
| 364 | $remove_next = 1; |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | # input value |
| 369 | elsif ($remove_next) { |
| 370 | $remove_next = 0; |
| 371 | return 0; |
| 372 | }; |
| 373 | |
| 374 | # Pass parameter |
| 375 | return 1; |
| 376 | } |
| 377 | )->to_array}; |
| 378 | |
| 379 | |
| 380 | # Iterate over all inputs |
| 381 | foreach (@input) { |
| 382 | |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 383 | # This will create a directory |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 384 | my $new_out = catdir($output, get_file_name_from_glob($_)); |
| 385 | |
| 386 | # Create new path |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 387 | unless ($to_tar) { |
| 388 | if (make_path($new_out) == 0 && !-d $new_out) { |
| 389 | $log->error("Can\'t create path $new_out"); |
| 390 | exit(0); |
| 391 | }; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 392 | }; |
| 393 | |
| 394 | # Create archive command |
| 395 | my @archive_cmd = ($^X, $0, 'archive', @keep_argv, '-i', $_, '-o', $new_out); |
| 396 | print "Start serial processing of $_ to $new_out\n"; |
| 397 | |
| 398 | # Start archiving |
| 399 | system @archive_cmd; |
| 400 | }; |
| 401 | |
| 402 | exit(0); |
| 403 | }; |
| 404 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 405 | my %skip; |
| 406 | $skip{lc($_)} = 1 foreach @skip; |
| 407 | |
| 408 | my @layers; |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 409 | push(@layers, ['Base', 'Sentences']) unless $base_sentences; |
| 410 | push(@layers, ['Base', 'Paragraphs']) unless $base_paragraphs; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 411 | |
| 412 | # Connexor |
| 413 | push(@layers, ['Connexor', 'Morpho']); |
| 414 | push(@layers, ['Connexor', 'Syntax']); |
| 415 | push(@layers, ['Connexor', 'Phrase']); |
| 416 | push(@layers, ['Connexor', 'Sentences']); |
| 417 | |
| 418 | # CoreNLP |
| 419 | push(@layers, ['CoreNLP', 'NamedEntities']); |
| 420 | push(@layers, ['CoreNLP', 'Sentences']); |
| 421 | push(@layers, ['CoreNLP', 'Morpho']); |
| 422 | push(@layers, ['CoreNLP', 'Constituency']); |
| 423 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 424 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 425 | # DeReKo |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 426 | my @dereko_attr = (); |
| 427 | if ($base_sentences eq 'dereko#structure') { |
| 428 | push @dereko_attr, 'sentences'; |
| 429 | }; |
| 430 | if ($base_paragraphs eq 'dereko#structure') { |
| 431 | push @dereko_attr, 'paragraphs'; |
| 432 | }; |
Akron | 636bd9c | 2017-02-09 17:13:00 +0100 | [diff] [blame] | 433 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 434 | if ($base_pagebreaks eq 'dereko#structure') { |
| 435 | push @dereko_attr, 'pagebreaks'; |
| 436 | }; |
| 437 | |
| 438 | if ($dereko_attr[0]) { |
| 439 | push(@layers, ['DeReKo', 'Structure', 'base-' . join('-', @dereko_attr)]); |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 440 | } |
| 441 | else { |
| 442 | push(@layers, ['DeReKo', 'Structure']); |
| 443 | }; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 444 | |
| 445 | # Glemm |
| 446 | push(@layers, ['Glemm', 'Morpho']); |
| 447 | |
| 448 | # Malt |
| 449 | push(@layers, ['Malt', 'Dependency']); |
| 450 | |
| 451 | # MDParser |
| 452 | push(@layers, ['MDParser', 'Dependency']); |
| 453 | |
| 454 | # Mate |
| 455 | push(@layers, ['Mate', 'Morpho']); |
| 456 | push(@layers, ['Mate', 'Dependency']); |
| 457 | |
| 458 | # OpenNLP |
| 459 | push(@layers, ['OpenNLP', 'Morpho']); |
| 460 | push(@layers, ['OpenNLP', 'Sentences']); |
| 461 | |
| 462 | # Schreibgebrauch |
| 463 | push(@layers, ['Sgbr', 'Lemma']); |
| 464 | push(@layers, ['Sgbr', 'Morpho']); |
| 465 | |
| 466 | # TreeTagger |
| 467 | push(@layers, ['TreeTagger', 'Morpho']); |
| 468 | push(@layers, ['TreeTagger', 'Sentences']); |
| 469 | |
| 470 | # XIP |
| 471 | push(@layers, ['XIP', 'Morpho']); |
| 472 | push(@layers, ['XIP', 'Constituency']); |
| 473 | push(@layers, ['XIP', 'Sentences']); |
| 474 | push(@layers, ['XIP', 'Dependency']); |
| 475 | |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 476 | # DRuKoLa |
| 477 | push(@layers, ['DRuKoLa', 'Morpho']); |
| 478 | |
Akron | 3bd942f | 2017-02-20 20:09:14 +0100 | [diff] [blame] | 479 | # Marmot |
| 480 | push(@layers, ['MarMoT', 'Morpho']); |
| 481 | |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 482 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 483 | # Check filters |
| 484 | my @filtered_anno; |
| 485 | if ($skip{'#all'}) { |
| 486 | foreach (@anno) { |
| 487 | push @filtered_anno, [ split('#', $_) ]; |
| 488 | }; |
| 489 | } |
| 490 | |
| 491 | # Add all annotations that are not skipped |
| 492 | else { |
| 493 | # Add to index file - respect skipping |
| 494 | foreach my $info (@layers) { |
| 495 | # Skip if Foundry or Foundry#Layer should be skipped |
| 496 | unless ($skip{lc($info->[0])} || $skip{lc($info->[0]) . '#' . lc($info->[1])}) { |
| 497 | push @filtered_anno, $info; |
| 498 | }; |
| 499 | }; |
| 500 | }; |
| 501 | |
| 502 | # Get tokenization basis |
| 503 | my ($token_base_foundry, $token_base_layer) = split(/#/, $token_base) if ($token_base); |
| 504 | |
| 505 | # TODO: This should not be initialized for batch |
| 506 | my $cache = Cache::FastMmap->new( |
| 507 | share_file => $cache_file, |
| 508 | cache_size => $cache_size, |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 509 | init_file => $cache_init |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 510 | ); |
| 511 | |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 512 | # Create batch object |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 513 | my $batch_file = KorAP::XML::Batch::File->new( |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 514 | cache => $cache, |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 515 | meta_type => $meta, |
| 516 | overwrite => $overwrite, |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 517 | foundry => $token_base_foundry, |
| 518 | layer => $token_base_layer, |
| 519 | gzip => $gzip, |
| 520 | log => $log, |
| 521 | primary => $primary, |
| 522 | pretty => $pretty, |
| 523 | anno => \@filtered_anno |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 524 | ); |
| 525 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 526 | # Get file name based on path information |
| 527 | sub get_file_name ($) { |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 528 | my $i = $input[0]; |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 529 | if (-d $i) { |
| 530 | $i =~ s![^\/]+$!!; |
| 531 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 532 | my $file = shift; |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 533 | |
| 534 | # Remove temp dir fragments |
Akron | 6255760 | 2016-06-27 14:10:13 +0200 | [diff] [blame] | 535 | $file =~ s!^/?tmp/[^/]+!!; |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 536 | $file =~ s/^?\/?$i//; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 537 | $file =~ tr/\//-/; |
| 538 | $file =~ s{^-+}{}; |
Akron | b4bbec7 | 2016-10-26 20:21:02 +0200 | [diff] [blame] | 539 | $file =~ s/^.*?-(.+?-.+?-.+?)$/$1/; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 540 | return $file; |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 541 | }; |
| 542 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 543 | |
| 544 | sub get_file_name_from_glob ($) { |
| 545 | my $glob = shift; |
Akron | bd3adda | 2017-04-11 15:00:55 +0200 | [diff] [blame] | 546 | $glob =~ s![\\\/]!-!g; # Transform paths |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 547 | $glob =~ s/[\*\?]//g; # Remove arbitrary fills |
| 548 | $glob =~ s/[\{\}\[\]]/-/g; # Remove class and multiple brackets |
| 549 | $glob =~ s/\-\-+/-/g; # Remove sequences of binding characters |
| 550 | $glob =~ s/^-//; # Clean beginning |
| 551 | $glob =~ s/-$//; # Clean end |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 552 | $glob =~ s/\.zip$//; # Remove file extension |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 553 | return $glob; |
| 554 | }; |
| 555 | |
| 556 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 557 | # Convert sigle to path construct |
| 558 | s!^\s*([^_]+?)_([^\.]+?)\.(.+?)\s*$!$1/$2/$3! foreach @sigle; |
| 559 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 560 | if ($cmd) { |
| 561 | if ($output && (!-e $output || !-d $output)) { |
| 562 | print "Directory '$output' does not exist.\n\n"; |
| 563 | exit(0); |
| 564 | }; |
| 565 | }; |
| 566 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 567 | |
| 568 | # Glob and prefix files |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 569 | if (@input) { |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 570 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 571 | my @new_input = (); |
| 572 | |
| 573 | # Iterate over all inputs |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 574 | foreach my $wild_card (@input) { |
| 575 | |
| 576 | # Prefix with input root |
| 577 | $wild_card = $input_base ? catfile($input_base, $wild_card) : $wild_card; |
| 578 | |
| 579 | push (@new_input, bsd_glob($wild_card)); |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 580 | }; |
| 581 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 582 | # Sort files by length |
| 583 | @input = sort { length($a) <=> length($b) } @new_input; |
| 584 | |
| 585 | print 'Input is ' . join(', ', @input)."\n"; |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 586 | }; |
| 587 | |
| 588 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 589 | # Process a single file |
| 590 | unless ($cmd) { |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 591 | my $input = $input[0]; |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 592 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 593 | BEGIN { |
| 594 | $main::TIME = Benchmark->new; |
| 595 | $main::LAST_STOP = Benchmark->new; |
| 596 | }; |
| 597 | |
| 598 | sub stop_time { |
| 599 | my $new = Benchmark->new; |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 600 | $log->info( |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 601 | 'The code took: '. |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 602 | timestr(timediff($new, $main::LAST_STOP)) . |
| 603 | ' (overall: ' . timestr(timediff($new, $main::TIME)) . ')' |
| 604 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 605 | $main::LAST_STOP = $new; |
| 606 | }; |
| 607 | |
| 608 | # Create and parse new document |
| 609 | $input =~ s{([^/])$}{$1/}; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 610 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 611 | # Process file |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 612 | $batch_file->process($input, $output); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 613 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 614 | # Delete cache file |
| 615 | unlink($cache_file) if $cache_delete; |
| 616 | |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 617 | stop_time; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 618 | exit(1); |
| 619 | }; |
| 620 | |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 621 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 622 | # Extract XML files |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 623 | if ($cmd eq 'extract') { |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 624 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 625 | # Create new archive object |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 626 | if (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 627 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 628 | # Check zip capabilities |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 629 | unless ($archive->test_unzip) { |
| 630 | print "Unzip is not installed or incompatible.\n\n"; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 631 | exit(0); |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 632 | }; |
| 633 | |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 634 | # Add further annotation archived |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 635 | $archive->attach($_) foreach @input[1..$#input]; |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 636 | |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 637 | my $prefix = 1; |
| 638 | |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 639 | # No sigles given |
| 640 | unless (@sigle) { |
| 641 | |
| 642 | # Get files |
| 643 | foreach ($archive->list_texts) { |
| 644 | |
| 645 | # Split path information |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 646 | ($prefix, my ($corpus, $doc, $text)) = $archive->split_path($_); |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 647 | |
| 648 | # TODO: Make this OS independent |
| 649 | push @sigle, join '/', $corpus, $doc, $text; |
| 650 | }; |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | # Check sigle for doc sigles |
| 654 | else { |
| 655 | my @new_sigle; |
| 656 | |
| 657 | my $prefix_check = 0; |
| 658 | |
| 659 | # Iterate over all sigle |
| 660 | foreach (@sigle) { |
| 661 | |
| 662 | # Sigle is a doc sigle |
| 663 | if ($_ =~ m!^(?:\.[/\\])?[^/\\]+?[/\\][^/\\]+?$!) { |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 664 | |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 665 | print "$_ ..."; |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 666 | # Check if a prefix is needed |
| 667 | unless ($prefix_check) { |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 668 | |
| 669 | if ($prefix = $archive->check_prefix) { |
| 670 | print " with prefix ..."; |
| 671 | }; |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 672 | $prefix_check = 1; |
| 673 | }; |
| 674 | |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 675 | print "\n"; |
| 676 | |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 677 | # TODO: Make this OS independent |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 678 | my $path = ($prefix ? './' : '') . $_; |
| 679 | |
| 680 | print '... ' . ( |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 681 | $archive->extract_doc( |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 682 | $path, $output, $sequential_extraction ? 1 : $jobs |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 683 | ) ? '' : 'not ' |
| 684 | ); |
| 685 | print "extracted.\n"; |
| 686 | } |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 687 | |
| 688 | # Sigle is a text sigle |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 689 | else { |
| 690 | push @new_sigle, $_; |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 691 | |
| 692 | unless ($prefix_check) { |
| 693 | |
| 694 | if ($prefix = $archive->check_prefix) { |
| 695 | print " with prefix ..."; |
| 696 | }; |
| 697 | $prefix_check = 1; |
| 698 | }; |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 699 | }; |
| 700 | }; |
| 701 | @sigle = @new_sigle; |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 702 | }; |
| 703 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 704 | # Iterate over all given sigles and extract |
| 705 | foreach (@sigle) { |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 706 | |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 707 | print "$_ ...\n"; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 708 | |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 709 | # TODO: Make this OS independent |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 710 | print '... ' . ( |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 711 | |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 712 | $archive->extract_text( |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 713 | ($prefix ? './' : '') . $_, $output |
| 714 | ) ? '' : 'not ' |
| 715 | ); |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 716 | print "extracted.\n"; |
| 717 | }; |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 718 | } |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 719 | |
| 720 | # Can't create archive object |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 721 | else { |
| 722 | $log->error('Unable to extract from primary archive ' . $input[0]); |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 723 | exit(1); |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 724 | }; |
| 725 | } |
| 726 | |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 727 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 728 | # Process an archive |
| 729 | elsif ($cmd eq 'archive') { |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 730 | |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 731 | my $archive_output; |
| 732 | |
| 733 | # First extract, then archive |
| 734 | if (defined $extract_dir) { |
| 735 | |
| 736 | # Create new archive object |
| 737 | if (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
| 738 | |
| 739 | # Check zip capabilities |
| 740 | unless ($archive->test_unzip) { |
| 741 | print "Unzip is not installed or incompatible.\n\n"; |
| 742 | exit(0); |
| 743 | }; |
| 744 | |
| 745 | # Add further annotation archived |
| 746 | $archive->attach($_) foreach @input[1..$#input]; |
| 747 | |
| 748 | # Create a temporary directory |
| 749 | if ($extract_dir eq ':temp:') { |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 750 | $extract_dir = tempdir(CLEANUP => 0); |
| 751 | print "Temporarily extract to $extract_dir\n"; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 752 | }; |
| 753 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 754 | # Add some random extra to avoid clashes with multiple archives |
| 755 | $extract_dir = catdir($extract_dir, random_string('cccccc')); |
| 756 | |
| 757 | # Extract to temprary directory |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 758 | if ($archive->extract_all($extract_dir, $sequential_extraction ? 1: $jobs)) { |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 759 | @input = ($extract_dir); |
| 760 | } |
| 761 | else { |
| 762 | $log->error('Unable to extract from primary archive ' . $input[0] . |
| 763 | ' to ' . $extract_dir); |
| 764 | exit(1); |
| 765 | }; |
| 766 | } |
| 767 | |
| 768 | # Can't create archive object |
| 769 | else { |
| 770 | $log->error('Unable to extract from primary archive ' . $input[0]); |
| 771 | exit(1); |
| 772 | }; |
| 773 | }; |
| 774 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 775 | # TODO: Support sigles |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 776 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 777 | # Zero means: everything runs in the parent process |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 778 | my $pool = Parallel::ForkManager->new($jobs); |
| 779 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 780 | my $count = 0; # Texts to process |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 781 | my $iter = 1; # Current text in process |
| 782 | |
| 783 | # Report on fork message |
| 784 | $pool->run_on_finish ( |
| 785 | sub { |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 786 | my ($pid, $code) = @_; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 787 | my $data = pop; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 788 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 789 | print 'Convert ['. ($jobs > 0 ? "\$$pid:" : '') . |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 790 | ($iter++) . "/$count]" . |
| 791 | ($code ? " $code" : '') . |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 792 | ' ' . $data->[0] . "\n"; |
| 793 | $data->[1] = undef if $data->[1]; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 794 | } |
| 795 | ); |
| 796 | |
| 797 | my $t; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 798 | my $temp; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 799 | print "Reading data ...\n"; |
| 800 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 801 | # unless (Cache::FastMmap->new( |
| 802 | # share_file => $cache_file, |
| 803 | # cache_size => $cache_size, |
| 804 | # init_file => $cache_init |
| 805 | # )) { |
| 806 | # print "Unable to intialize cache '$cache_file'\n\n"; |
| 807 | # exit(1); |
| 808 | # }; |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 809 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 810 | # Input is a directory |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 811 | if (-d $input[0]) { |
| 812 | my $it = Directory::Iterator->new($input[0]); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 813 | my @dirs; |
| 814 | my $dir; |
| 815 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 816 | # Todo: Make a DO WHILE |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 817 | while (1) { |
| 818 | if (!$it->is_directory && ($dir = $it->get) && $dir =~ s{/data\.xml$}{}) { |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 819 | push @dirs, $dir; |
| 820 | $it->prune; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 821 | }; |
| 822 | last unless $it->next; |
| 823 | }; |
| 824 | |
| 825 | print "Start processing ...\n"; |
| 826 | $t = Benchmark->new; |
| 827 | $count = scalar @dirs; |
| 828 | |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 829 | my $tar_archive; |
| 830 | my $output_dir = $output; |
| 831 | if ($to_tar) { |
| 832 | $tar_archive = Archive::Tar::Builder->new( |
| 833 | ignore_errors => 1 |
| 834 | ); |
| 835 | |
| 836 | # Set output name |
| 837 | my $tar_file = $output; |
| 838 | unless ($tar_file =~ /\.tar$/) { |
| 839 | $tar_file .= '.tar'; |
| 840 | }; |
| 841 | my $fh = IO::File->new($tar_file, 'w'); |
| 842 | $fh->binmode(1); |
| 843 | |
| 844 | # Set handle |
| 845 | $tar_archive->set_handle($fh); |
| 846 | $output_dir = File::Temp->newdir; |
| 847 | }; |
| 848 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 849 | DIRECTORY_LOOP: |
| 850 | for (my $i = 0; $i < $count; $i++) { |
| 851 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 852 | my $filename = catfile( |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 853 | $output_dir, |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 854 | get_file_name($dirs[$i]) . '.json' . ($gzip ? '.gz' : '') |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 855 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 856 | |
| 857 | # Get the next fork |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 858 | $pool->start and next DIRECTORY_LOOP; |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 859 | |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 860 | if (my $return = $batch_file->process($dirs[$i] => $filename)) { |
| 861 | $pool->finish( |
| 862 | 0, |
| 863 | ["Processed " . $filename . ($return == -1 ? " - already existing" : '')] |
| 864 | ); |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 865 | |
| 866 | # Add to tar archive |
| 867 | if ($to_tar) { |
| 868 | $tar_archive->archive($filename); |
| 869 | unlink $filename; |
| 870 | }; |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 871 | } |
| 872 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 873 | $pool->finish(1, ["Unable to process " . $dirs[$i]]); |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 874 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 875 | }; |
| 876 | } |
| 877 | |
| 878 | # Input is a file |
Akron | 29866ac | 2016-06-24 16:40:47 +0200 | [diff] [blame] | 879 | elsif (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 880 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 881 | unless ($archive->test_unzip) { |
| 882 | print "Unzip is not installed or incompatible.\n\n"; |
| 883 | exit(1); |
| 884 | }; |
| 885 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 886 | # Add further annotation archived |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 887 | $archive->attach($_) foreach @input[1..$#input]; |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 888 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 889 | print "Start processing ...\n"; |
| 890 | $t = Benchmark->new; |
| 891 | my @dirs = $archive->list_texts; |
| 892 | $count = scalar @dirs; |
| 893 | |
| 894 | ARCHIVE_LOOP: |
| 895 | for (my $i = 0; $i < $count; $i++) { |
| 896 | |
| 897 | # Split path information |
| 898 | my ($prefix, $corpus, $doc, $text) = $archive->split_path($dirs[$i]); |
| 899 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 900 | my $filename = catfile( |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 901 | $output, |
| 902 | get_file_name( |
| 903 | catfile($corpus, $doc, $text) |
| 904 | . '.json' . ($gzip ? '.gz' : '') |
| 905 | ) |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 906 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 907 | |
| 908 | # Get the next fork |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 909 | $pool->start and next ARCHIVE_LOOP; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 910 | |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 911 | # Create temporary file |
| 912 | $temp = File::Temp->newdir; |
| 913 | |
Akron | bdf434a | 2016-10-24 17:42:07 +0200 | [diff] [blame] | 914 | # TODO: Check if $filename exist at the beginning, |
| 915 | # because extraction can be horrible slow! |
| 916 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 917 | # Extract from archive |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 918 | if ($archive->extract_text($dirs[$i], $temp)) { |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 919 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 920 | # Create corpus directory |
| 921 | my $input = catdir("$temp", $corpus); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 922 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 923 | # Temporary directory |
| 924 | my $dir = catdir($input, $doc, $text); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 925 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 926 | # Write file |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 927 | if (my $return = $batch_file->process($dir => $filename)) { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 928 | # Delete temporary file |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 929 | $pool->finish( |
| 930 | 0, |
| 931 | ["Processed " . $filename . ($return == -1 ? " - already existing" : ''), $temp] |
| 932 | ); |
| 933 | #$pool->finish(0, ["Processed " . $filename, $temp]); |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 934 | } |
| 935 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 936 | # Delete temporary file |
| 937 | $pool->finish(1, ["Unable to process " . $dir, $temp]); |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 938 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 939 | } |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 940 | |
| 941 | # Unable to extract |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 942 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 943 | $pool->finish(1, ["Unable to extract " . $dirs[$i], $temp]); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 944 | }; |
| 945 | }; |
| 946 | } |
| 947 | |
| 948 | else { |
| 949 | print "Input is neither a directory nor an archive.\n\n"; |
| 950 | }; |
| 951 | |
| 952 | $pool->wait_all_children; |
| 953 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 954 | # Delete cache file |
| 955 | unlink($cache_file) if $cache_delete; |
| 956 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 957 | print timestr(timediff(Benchmark->new, $t))."\n"; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 958 | print "Done.\n"; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 959 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 960 | |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 961 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 962 | # Cleanup temporary extraction directory |
| 963 | if ($extract_dir) { |
| 964 | my $objects = remove_tree($extract_dir, { safe => 1 }); |
| 965 | print "Removed directory $extract_dir with $objects objects.\n"; |
| 966 | }; |
| 967 | |
| 968 | |
| 969 | print "\n"; |
| 970 | |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 971 | __END__ |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 972 | |
| 973 | =pod |
| 974 | |
| 975 | =encoding utf8 |
| 976 | |
| 977 | =head1 NAME |
| 978 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 979 | korapxml2krill - Merge KorapXML data and create Krill documents |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 980 | |
| 981 | |
| 982 | =head1 SYNOPSIS |
| 983 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 984 | korapxml2krill [archive|extract] --input <directory|archive> [options] |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 985 | |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 986 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 987 | =head1 DESCRIPTION |
| 988 | |
| 989 | L<KorAP::XML::Krill> is a library to convert KorAP-XML documents to files |
| 990 | compatible with the L<Krill|https://github.com/KorAP/Krill> indexer. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 991 | The C<korapxml2krill> command line tool is a simple wrapper to the library. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 992 | |
| 993 | |
| 994 | =head1 INSTALLATION |
| 995 | |
| 996 | The preferred way to install L<KorAP::XML::Krill> is to use L<cpanm|App::cpanminus>. |
| 997 | |
Akron | af38698 | 2016-10-12 00:33:25 +0200 | [diff] [blame] | 998 | $ cpanm https://github.com/KorAP/KorAP-XML-Krill.git |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 999 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1000 | In case everything went well, the C<korapxml2krill> tool will |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1001 | be available on your command line immediately. |
Akron | 7438151 | 2016-10-14 11:56:22 +0200 | [diff] [blame] | 1002 | Minimum requirement for L<KorAP::XML::Krill> is Perl 5.14. |
Akron | a93d51b | 2016-10-24 20:27:48 +0200 | [diff] [blame] | 1003 | In addition to work with zip archives, the C<unzip> tool needs to be present. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1004 | |
| 1005 | =head1 ARGUMENTS |
| 1006 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1007 | $ korapxml2krill -z --input <directory> --output <filename> |
| 1008 | |
| 1009 | Without arguments, C<korapxml2krill> converts a directory of a single KorAP-XML document. |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 1010 | It expects the input to point to the text level folder. |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1011 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1012 | =over 2 |
| 1013 | |
| 1014 | =item B<archive> |
| 1015 | |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 1016 | $ korapxml2krill archive -z --input <directory|archive> --output <directory|tar> |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1017 | |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 1018 | Converts an archive of KorAP-XML documents. It expects a directory |
| 1019 | (pointing to the corpus level folder) or one or more zip files as input. |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 1020 | |
| 1021 | =item B<extract> |
| 1022 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1023 | $ korapxml2krill extract --input <archive> --output <directory> --sigle <SIGLE> |
| 1024 | |
| 1025 | Extracts KorAP-XML documents from a zip file. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1026 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1027 | =item B<serial> |
| 1028 | |
| 1029 | $ korapxml2krill serial -i <archive1> -i <archive2> -o <directory> -cfg <config-file> |
| 1030 | |
| 1031 | Convert archives sequentially. The inputs are not merged but treated |
| 1032 | as they are (so they may be premerged or globs). |
| 1033 | the C<--out> directory is treated as the base directory where subdirectories |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame^] | 1034 | are created based on the archive name. In case the C<--to-tar> flag is given, |
| 1035 | the output will be a tar file. |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1036 | |
| 1037 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1038 | =back |
| 1039 | |
| 1040 | |
| 1041 | =head1 OPTIONS |
| 1042 | |
| 1043 | =over 2 |
| 1044 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1045 | =item B<--input|-i> <directory|zip file> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1046 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1047 | Directory or zip file(s) of documents to convert. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1048 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1049 | Without arguments, C<korapxml2krill> expects a folder of a single KorAP-XML |
Akron | f1a1de9 | 2016-11-02 17:32:12 +0100 | [diff] [blame] | 1050 | document, while C<archive> expects a KorAP-XML corpus folder or a zip |
| 1051 | file to batch process multiple files. |
| 1052 | C<extract> expects zip files only. |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1053 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1054 | C<archive> supports multiple input zip files with the constraint, |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 1055 | that the first archive listed contains all primary data files |
| 1056 | and all meta data files. |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 1057 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1058 | -i file/news.zip -i file/news.malt.zip -i "#file/news.tt.zip" |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 1059 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1060 | Input may also be defined using BSD glob wildcards. |
| 1061 | |
| 1062 | -i 'file/news*.zip' |
| 1063 | |
| 1064 | The extended input array will be sorted in length order, so the shortest |
| 1065 | path needs to contain all primary data files and all meta data files. |
| 1066 | |
Akron | 0c3e375 | 2016-06-28 15:55:53 +0200 | [diff] [blame] | 1067 | (The directory structure follows the base directory format, |
| 1068 | that may include a C<.> root folder. |
| 1069 | In this case further archives lacking a C<.> root folder |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1070 | need to be passed with a hash sign in front of the archive's name. |
| 1071 | This may require to quote the parameter.) |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 1072 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1073 | To support zip files, a version of C<unzip> needs to be installed that is |
| 1074 | compatible with the archive file. |
Akron | a93d51b | 2016-10-24 20:27:48 +0200 | [diff] [blame] | 1075 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1076 | B<The root folder switch using the hash sign is experimental and |
| 1077 | may vanish in future versions.> |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 1078 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1079 | =item B<--input-base|-ib> <directory> |
| 1080 | |
| 1081 | The base directory for inputs. |
| 1082 | |
| 1083 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1084 | =item B<--output|-o> <directory|file> |
| 1085 | |
| 1086 | Output folder for archive processing or |
| 1087 | document name for single output (optional), |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1088 | writes to C<STDOUT> by default |
| 1089 | (in case C<output> is not mandatory due to further options). |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1090 | |
| 1091 | =item B<--overwrite|-w> |
| 1092 | |
| 1093 | Overwrite files that already exist. |
| 1094 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 1095 | =item B<--token|-t> <foundry>#<file> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1096 | |
| 1097 | Define the default tokenization by specifying |
| 1098 | the name of the foundry and optionally the name |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1099 | of the layer-file. Defaults to C<OpenNLP#tokens>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1100 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 1101 | |
| 1102 | =item B<--base-sentences|-bs> <foundry>#<layer> |
| 1103 | |
| 1104 | Define the layer for base sentences. |
| 1105 | If given, this will be used instead of using C<Base#Sentences>. |
| 1106 | Currently C<DeReKo#Structure> is the only additional layer supported. |
| 1107 | |
| 1108 | Defaults to unset. |
| 1109 | |
| 1110 | |
| 1111 | =item B<--base-paragraphs|-bp> <foundry>#<layer> |
| 1112 | |
| 1113 | Define the layer for base paragraphs. |
| 1114 | If given, this will be used instead of using C<Base#Paragraphs>. |
| 1115 | Currently C<DeReKo#Structure> is the only additional layer supported. |
| 1116 | |
| 1117 | Defaults to unset. |
| 1118 | |
| 1119 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 1120 | =item B<--base-pagebreaks|-bpb> <foundry>#<layer> |
| 1121 | |
| 1122 | Define the layer for base pagebreaks. |
| 1123 | Currently C<DeReKo#Structure> is the only layer supported. |
| 1124 | |
| 1125 | Defaults to unset. |
| 1126 | |
| 1127 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1128 | =item B<--skip|-s> <foundry>[#<layer>] |
| 1129 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1130 | Skip specific annotations by specifying the foundry |
| 1131 | (and optionally the layer with a C<#>-prefix), |
| 1132 | e.g. C<Mate> or C<Mate#Morpho>. Alternatively you can skip C<#ALL>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1133 | Can be set multiple times. |
| 1134 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1135 | =item B<--anno|-a> <foundry>#<layer> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1136 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1137 | Convert specific annotations by specifying the foundry |
| 1138 | (and optionally the layer with a C<#>-prefix), |
| 1139 | e.g. C<Mate> or C<Mate#Morpho>. |
| 1140 | Can be set multiple times. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1141 | |
| 1142 | =item B<--primary|-p> |
| 1143 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1144 | Output primary data or not. Defaults to C<true>. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1145 | Can be flagged using C<--no-primary> as well. |
| 1146 | This is I<deprecated>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1147 | |
| 1148 | =item B<--jobs|-j> |
| 1149 | |
| 1150 | Define the number of concurrent jobs in seperated forks |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1151 | for archive processing. |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 1152 | Defaults to C<0> (everything runs in a single process). |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 1153 | |
| 1154 | If C<sequential-extraction> is not set to false, this will |
| 1155 | also apply to extraction. |
| 1156 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 1157 | Pass -1, and the value will be set automatically to 5 |
| 1158 | times the number of available cores. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1159 | This is I<experimental>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1160 | |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 1161 | =item B<--sequential-extraction|-se> |
| 1162 | |
| 1163 | Flag to indicate, if the C<jobs> value also applies to extraction. |
| 1164 | Some systems may have problems with extracting multiple archives |
| 1165 | to the same folder at the same time. |
| 1166 | Can be flagged using C<--no-sequential-extraction> as well. |
| 1167 | Defaults to C<false>. |
| 1168 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 1169 | =item B<--meta|-m> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1170 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 1171 | Define the metadata parser to use. Defaults to C<I5>. |
| 1172 | Metadata parsers can be defined in the C<KorAP::XML::Meta> namespace. |
| 1173 | This is I<experimental>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1174 | |
| 1175 | =item B<--pretty|-y> |
| 1176 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1177 | Pretty print JSON output. Defaults to C<false>. |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 1178 | This is I<deprecated>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1179 | |
| 1180 | =item B<--gzip|-z> |
| 1181 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1182 | Compress the output. |
| 1183 | Expects a defined C<output> file in single processing. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1184 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 1185 | =item B<--cache|-c> |
| 1186 | |
| 1187 | File to mmap a cache (using L<Cache::FastMmap>). |
| 1188 | Defaults to C<korapxml2krill.cache> in the calling directory. |
| 1189 | |
| 1190 | =item B<--cache-size|-cs> |
| 1191 | |
| 1192 | Size of the cache. Defaults to C<50m>. |
| 1193 | |
| 1194 | =item B<--cache-init|-ci> |
| 1195 | |
| 1196 | Initialize cache file. |
| 1197 | Can be flagged using C<--no-cache-init> as well. |
| 1198 | Defaults to C<true>. |
| 1199 | |
| 1200 | =item B<--cache-delete|-cd> |
| 1201 | |
| 1202 | Delete cache file after processing. |
| 1203 | Can be flagged using C<--no-cache-delete> as well. |
| 1204 | Defaults to C<true>. |
| 1205 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1206 | =item B<--config|-cfg> |
| 1207 | |
| 1208 | Configure the parameters of your call in a file |
| 1209 | of key-value pairs with whitespace separator |
| 1210 | |
| 1211 | overwrite 1 |
| 1212 | token DeReKo#Structure |
| 1213 | ... |
| 1214 | |
| 1215 | Supported parameters are: |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1216 | C<overwrite>, C<gzip>, C<jobs>, C<input-base>, |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1217 | C<token>, C<log>, C<cache>, C<cache-size>, C<cache-delete>, C<meta>, |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 1218 | C<output>, |
| 1219 | C<temp-extract>, C<sequential-extraction>, |
| 1220 | C<base-sentences>, C<base-paragraphs>, |
| 1221 | C<base-pagebreaks>, |
| 1222 | C<skip> (semicolon separated), C<sigle> |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1223 | (semicolon separated), C<anno> (semicolon separated). |
| 1224 | |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 1225 | =item B<--temporary-extract|-te> |
| 1226 | |
| 1227 | Only valid for the C<archive> command. |
| 1228 | |
| 1229 | This will first extract all files into a |
| 1230 | directory and then will archive. |
| 1231 | If the directory is given as C<:temp:>, |
| 1232 | a temporary directory is used. |
| 1233 | This is especially useful to avoid |
| 1234 | massive unzipping and potential |
| 1235 | network latency. |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1236 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 1237 | =item B<--sigle|-sg> |
| 1238 | |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 1239 | Extract the given texts. |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 1240 | Can be set multiple times. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1241 | I<Currently only supported on C<extract>.> |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 1242 | Sigles have the structure C<Corpus>/C<Document>/C<Text>. |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 1243 | In case the C<Text> path is omitted, the whole document will be extracted. |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 1244 | On the document level, the postfix wildcard C<*> is supported. |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 1245 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1246 | =item B<--log|-l> |
| 1247 | |
| 1248 | The L<Log4perl> log level, defaults to C<ERROR>. |
| 1249 | |
| 1250 | =item B<--help|-h> |
| 1251 | |
| 1252 | Print this document. |
| 1253 | |
| 1254 | =item B<--version|-v> |
| 1255 | |
| 1256 | Print version information. |
| 1257 | |
| 1258 | =back |
| 1259 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1260 | =head1 ANNOTATION SUPPORT |
| 1261 | |
| 1262 | L<KorAP::XML::Krill> has built-in importer for some annotation foundries and layers |
| 1263 | developed in the KorAP project that are part of the KorAP preprocessing pipeline. |
| 1264 | The base foundry with paragraphs, sentences, and the text element are mandatory for |
| 1265 | L<Krill|https://github.com/KorAP/Krill>. |
| 1266 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1267 | Base |
| 1268 | #Paragraphs |
| 1269 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1270 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1271 | Connexor |
| 1272 | #Morpho |
| 1273 | #Phrase |
| 1274 | #Sentences |
| 1275 | #Syntax |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1276 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1277 | CoreNLP |
| 1278 | #Constituency |
| 1279 | #Morpho |
| 1280 | #NamedEntities |
| 1281 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1282 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1283 | DeReKo |
| 1284 | #Structure |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1285 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1286 | DRuKoLa |
| 1287 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1288 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1289 | Glemm |
| 1290 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1291 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1292 | Malt |
| 1293 | #Dependency |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1294 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1295 | MarMoT |
| 1296 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1297 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1298 | Mate |
| 1299 | #Dependency |
| 1300 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1301 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1302 | MDParser |
| 1303 | #Dependency |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1304 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1305 | OpenNLP |
| 1306 | #Morpho |
| 1307 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1308 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1309 | Sgbr |
| 1310 | #Lemma |
| 1311 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1312 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1313 | TreeTagger |
| 1314 | #Morpho |
| 1315 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1316 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1317 | XIP |
| 1318 | #Constituency |
| 1319 | #Morpho |
| 1320 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1321 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1322 | |
| 1323 | More importers are in preparation. |
| 1324 | New annotation importers can be defined in the C<KorAP::XML::Annotation> namespace. |
| 1325 | See the built-in annotation importers as examples. |
| 1326 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1327 | =head1 AVAILABILITY |
| 1328 | |
| 1329 | https://github.com/KorAP/KorAP-XML-Krill |
| 1330 | |
| 1331 | |
| 1332 | =head1 COPYRIGHT AND LICENSE |
| 1333 | |
Akron | 3ec0a1c | 2017-01-18 14:41:55 +0100 | [diff] [blame] | 1334 | Copyright (C) 2015-2017, L<IDS Mannheim|http://www.ids-mannheim.de/> |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1335 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1336 | Author: L<Nils Diewald|http://nils-diewald.de/> |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 1337 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1338 | Contributor: Eliza Margaretha |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1339 | |
| 1340 | L<KorAP::XML::Krill> is developed as part of the L<KorAP|http://korap.ids-mannheim.de/> |
| 1341 | Corpus Analysis Platform at the |
| 1342 | L<Institute for the German Language (IDS)|http://ids-mannheim.de/>, |
| 1343 | member of the |
| 1344 | L<Leibniz-Gemeinschaft|http://www.leibniz-gemeinschaft.de/en/about-us/leibniz-competition/projekte-2011/2011-funding-line-2/>. |
| 1345 | |
| 1346 | This program is free software published under the |
| 1347 | L<BSD-2 License|https://raw.githubusercontent.com/KorAP/KorAP-XML-Krill/master/LICENSE>. |
| 1348 | |
| 1349 | =cut |