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