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