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 | 41127e3 | 2020-08-07 12:46:19 +0200 | [diff] [blame^] | 15 | use KorAP::XML::Krill qw!get_file_name get_file_name_from_glob!; |
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); |
Akron | 9a062ce | 2017-07-04 19:12:05 +0200 | [diff] [blame] | 27 | use File::Basename; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 28 | use Mojo::Collection 'c'; |
| 29 | use String::Random qw(random_string); |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame] | 30 | use IO::File; |
| 31 | use Archive::Tar::Builder; |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame] | 32 | use Fcntl qw(:flock SEEK_END); |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 33 | |
| 34 | # use KorAP::XML::ForkPool; |
Akron | 75ba57d | 2016-03-07 23:36:27 +0100 | [diff] [blame] | 35 | # TODO: use Parallel::Loops |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 36 | # TODO: make output files |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 37 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 38 | # TODO: Use KorAP::XML::ForkPool! |
| 39 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 40 | # CHANGES: |
| 41 | # ---------------------------------------------------------- |
| 42 | # 2013/11/25 |
| 43 | # - Initial release |
| 44 | # |
| 45 | # 2014/10/29 |
| 46 | # - Merges foundry data to create indexer friendly documents |
| 47 | # |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 48 | # 2016/02/04 |
| 49 | # - renamed to korapxml2krill |
| 50 | # - added Schreibgebrauch support |
Akron | 069bd71 | 2016-02-12 19:09:06 +0100 | [diff] [blame] | 51 | # |
| 52 | # 2016/02/12 |
| 53 | # - fixed foundry skipping |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 54 | # - Support overwrite in archive processing |
Akron | 150b29e | 2016-02-14 23:06:48 +0100 | [diff] [blame] | 55 | # |
| 56 | # 2016/02/14 |
| 57 | # - Added version information |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 58 | # - Added support for archive files |
| 59 | # |
| 60 | # 2016/02/15 |
| 61 | # - Fixed temporary directory bug |
| 62 | # - Improved skipping before unzipping |
| 63 | # - Added EXPERIMENTAL concurrency support |
| 64 | # |
| 65 | # 2016/02/23 |
| 66 | # - Merge korapxml2krill and korapxml2krill_dir |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 67 | # |
| 68 | # 2016/02/27 |
| 69 | # - Added extract function |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 70 | # |
| 71 | # 2016/03/17 |
| 72 | # - Added meta switch |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 73 | # |
| 74 | # 2016/03/18 |
| 75 | # - Added meta data caching |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 76 | # |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 77 | # 2016/06/27 |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 78 | # - Added multi archive support |
| 79 | # - Added prefix negation support |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 80 | # - Added Malt#Dependency support |
Akron | 8b99052 | 2016-07-06 16:45:57 +0200 | [diff] [blame] | 81 | # |
| 82 | # 2016/07/06 |
| 83 | # - Added MDParser#Dependency |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 84 | # |
| 85 | # 2016/10/15 |
Nils Diewald | 0e48977 | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 86 | # - Fixed temporary path issue in script |
| 87 | # |
| 88 | # 2016/10/24 |
| 89 | # - Improved Windows support |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 90 | # |
Akron | b4bbec7 | 2016-10-26 20:21:02 +0200 | [diff] [blame] | 91 | # 2016/10/24 |
| 92 | # - Added support for document extraction |
| 93 | # |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 94 | # 2016/10/27 |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 95 | # - Added wildcard support for document extraction |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 96 | # |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 97 | # 2016/12/21 |
| 98 | # - added support for base-sentences and base-tokenizations |
| 99 | # |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 100 | # 2017/01/20 |
| 101 | # - added support for DRuKoLa annotations |
| 102 | # |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 103 | # 2017/02/08 |
| 104 | # - added support for pagebreak annotations |
| 105 | # |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 106 | # 2017/04/06 |
| 107 | # - added support for wildcards in input |
| 108 | # |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 109 | # 2017/04/07 |
| 110 | # - support configuration option |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 111 | # - support for temporary extraction |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 112 | # |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 113 | # 2017/04/12 |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 114 | # - support serial processing |
| 115 | # - support input root |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 116 | # - introduced --sequential-extraction flag |
Akron | ce125b6 | 2017-06-19 11:54:36 +0200 | [diff] [blame] | 117 | # |
| 118 | # 2017/06/19 |
| 119 | # - added support for DCK |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 120 | # |
| 121 | # 2017/06/29 |
| 122 | # - Fixed exit codes |
Akron | 9a062ce | 2017-07-04 19:12:05 +0200 | [diff] [blame] | 123 | # |
| 124 | # 2017/07/04 |
| 125 | # - Fixed tar building process |
Akron | 4c67919 | 2018-01-16 17:41:49 +0100 | [diff] [blame] | 126 | # |
| 127 | # 2018/01/16 |
| 128 | # - Added LWC support |
Akron | 5fdc7e1 | 2018-07-19 12:37:48 +0200 | [diff] [blame] | 129 | # |
| 130 | # 2018/07/19 |
| 131 | # - Preliminary support for HNC. |
Akron | ed9baf0 | 2019-01-22 17:03:25 +0100 | [diff] [blame] | 132 | # |
| 133 | # 2019/01/22 |
Akron | 57510c1 | 2019-01-04 14:58:53 +0100 | [diff] [blame] | 134 | # - Preliminary support for DGD. |
Akron | ed9baf0 | 2019-01-22 17:03:25 +0100 | [diff] [blame] | 135 | # - Support for non-word tokens. |
Akron | 263274c | 2019-02-07 09:48:30 +0100 | [diff] [blame] | 136 | # |
Akron | 63d03ee | 2019-02-13 18:49:38 +0100 | [diff] [blame] | 137 | # 2019/02/13 |
Akron | 263274c | 2019-02-07 09:48:30 +0100 | [diff] [blame] | 138 | # - Support for 'koral:field' array. |
| 139 | # - Support for Koral versioning. |
Akron | 63d03ee | 2019-02-13 18:49:38 +0100 | [diff] [blame] | 140 | # - Ignore temporary extract parameter on |
| 141 | # directory archiving. |
Akron | 7d5e638 | 2019-08-08 16:36:27 +0200 | [diff] [blame] | 142 | # |
| 143 | # 2019/08/08 |
| 144 | # - Support for Talismane. |
Akron | c29b8e1 | 2019-12-16 14:28:09 +0100 | [diff] [blame] | 145 | # |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 146 | # 2019/12/17 |
Akron | c29b8e1 | 2019-12-16 14:28:09 +0100 | [diff] [blame] | 147 | # - Added support for DGD pseudo-sentences |
| 148 | # based on anchor milestones. |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 149 | # - Support for non-verbal annotations. |
Akron | 07e2477 | 2020-04-23 14:00:54 +0200 | [diff] [blame] | 150 | # |
| 151 | # 2020/04/23 |
| 152 | # - Added support for Redewiedergabe-Korpus structure |
| 153 | # annotations, based on sentence and paragraph milestones |
| 154 | # - Added support for Redewiedergabe-Korpus morphology |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 155 | # ---------------------------------------------------------- |
Akron | 069bd71 | 2016-02-12 19:09:06 +0100 | [diff] [blame] | 156 | |
Akron | 07e2477 | 2020-04-23 14:00:54 +0200 | [diff] [blame] | 157 | our $LAST_CHANGE = '2020/04/23'; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 158 | our $LOCAL = $FindBin::Bin; |
Akron | 263274c | 2019-02-07 09:48:30 +0100 | [diff] [blame] | 159 | our $KORAL_VERSION = 0.03; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 160 | our $VERSION_MSG = <<"VERSION"; |
| 161 | Version $KorAP::XML::Krill::VERSION - diewald\@ids-mannheim.de - $LAST_CHANGE |
| 162 | VERSION |
| 163 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 164 | # Prototypes |
Akron | 41127e3 | 2020-08-07 12:46:19 +0200 | [diff] [blame^] | 165 | sub get_file_name($$); |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 166 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 167 | # Parse comand |
| 168 | my $cmd; |
| 169 | our @ARGV; |
| 170 | if ($ARGV[0] && index($ARGV[0], '-') != 0) { |
| 171 | $cmd = shift @ARGV; |
Akron | 150b29e | 2016-02-14 23:06:48 +0100 | [diff] [blame] | 172 | }; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 173 | my @keep_argv = @ARGV; |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 174 | |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 175 | my (@skip, @sigle, @anno, @input); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 176 | my $text; |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 177 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 178 | # Parse options from the command line |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 179 | GetOptions( |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 180 | 'input|i=s' => \@input, |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 181 | 'input-base|ib=s' => \(my $input_base), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 182 | 'output|o=s' => \(my $output), |
| 183 | 'overwrite|w' => \(my $overwrite), |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 184 | 'meta|m=s' => \(my $meta), |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 185 | 'token|t=s' => \(my $token_base), |
| 186 | 'base-sentences|bs=s' => \(my $base_sentences), |
| 187 | 'base-paragraphs|bp=s' => \(my $base_paragraphs), |
| 188 | 'base-pagebreaks|bpb=s' => \(my $base_pagebreaks), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 189 | 'gzip|z' => \(my $gzip), |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 190 | 'temporary-extract|te=s' => \(my $extract_dir), |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 191 | 'skip|s=s' => \@skip, |
| 192 | 'sigle|sg=s' => \@sigle, |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 193 | 'cache|c=s' => \(my $cache_file), |
| 194 | 'config|cfg=s' => \(my $cfg_file), |
| 195 | 'log|l=s' => \(my $log_level), |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 196 | 'anno|a=s' => \@anno, |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 197 | 'primary|p!' => \(my $primary), |
| 198 | 'pretty|y' => \(my $pretty), |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 199 | 'jobs|j=i' => \(my $jobs), |
Akron | 263274c | 2019-02-07 09:48:30 +0100 | [diff] [blame] | 200 | 'koral|k=f' => \(my $koral), |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 201 | 'to-tar' => \(my $to_tar), |
Akron | ed9baf0 | 2019-01-22 17:03:25 +0100 | [diff] [blame] | 202 | 'non-word-tokens|nwt' => \(my $non_word_tokens), |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 203 | 'non-verbal-tokens|nvt' => \(my $non_verbal_tokens), |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 204 | 'sequential-extraction|se' => \(my $sequential_extraction), |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 205 | 'cache-size|cs=s' => \(my $cache_size), |
| 206 | 'cache-delete|cd!' => \(my $cache_delete), |
| 207 | 'cache-init|ci!' => \(my $cache_init), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 208 | 'help|h' => sub { |
| 209 | pod2usage( |
| 210 | -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS', |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 211 | -verbose => 99, |
| 212 | -msg => $VERSION_MSG, |
| 213 | -output => '-' |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 214 | ); |
| 215 | }, |
| 216 | 'version|v' => sub { |
| 217 | pod2usage( |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 218 | -verbose => 0, |
| 219 | -msg => $VERSION_MSG, |
| 220 | -output => '-' |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 221 | ) |
| 222 | } |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 223 | ); |
| 224 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 225 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 226 | # Load from configuration |
| 227 | if ($cfg_file && -e $cfg_file) { |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 228 | my %config; |
| 229 | |
| 230 | Config::Simple->import_from($cfg_file, \%config); |
| 231 | |
| 232 | # Overwrite |
| 233 | if (!defined($overwrite) && defined $config{overwrite}) { |
| 234 | $overwrite = $config{overwrite}; |
| 235 | }; |
| 236 | |
| 237 | # Gzip |
| 238 | if (!defined($gzip) && defined $config{gzip}) { |
| 239 | $gzip = $config{gzip}; |
| 240 | }; |
| 241 | |
| 242 | # Jobs |
| 243 | if (!defined($jobs) && defined $config{jobs}) { |
| 244 | $jobs = $config{jobs}; |
| 245 | }; |
| 246 | |
Akron | 263274c | 2019-02-07 09:48:30 +0100 | [diff] [blame] | 247 | # Koral version |
| 248 | if (!defined($koral) && defined $config{koral}) { |
| 249 | $koral = $config{koral}; |
| 250 | }; |
| 251 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 252 | # Input root base directory |
| 253 | if (!defined($input_base) && defined $config{'input-base'}) { |
| 254 | $input_base = $config{'input-base'}; |
| 255 | }; |
| 256 | |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 257 | # temporary-extract |
| 258 | if (!defined($extract_dir) && defined $config{'temporary-extract'}) { |
| 259 | $extract_dir = $config{'temporary-extract'}; |
| 260 | }; |
| 261 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 262 | # Token base |
| 263 | if (!defined($token_base) && defined $config{token}) { |
| 264 | $token_base = $config{token}; |
| 265 | }; |
| 266 | |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 267 | # Non-word tokenization |
Akron | ed9baf0 | 2019-01-22 17:03:25 +0100 | [diff] [blame] | 268 | if (!defined($non_word_tokens) && defined $config{'non-word-tokens'}) { |
| 269 | $non_word_tokens = $config{'non-word-tokens'}; |
| 270 | }; |
| 271 | |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 272 | # Non-verbal tokenization |
| 273 | if (!defined($non_verbal_tokens) && defined $config{'non-verbal-tokens'}) { |
| 274 | $non_verbal_tokens = $config{'non-verbal-tokens'}; |
| 275 | }; |
| 276 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 277 | # Cache file |
| 278 | if (!defined($cache_file) && defined $config{cache}) { |
| 279 | $cache_file = $config{cache}; |
| 280 | }; |
| 281 | |
| 282 | # Cache size |
| 283 | if (!defined($cache_size) && defined $config{'cache-size'}) { |
| 284 | $cache_size = $config{'cache-size'}; |
| 285 | }; |
| 286 | |
| 287 | # Cache delete |
| 288 | if (!defined($cache_delete) && defined $config{'cache-delete'}) { |
| 289 | $cache_delete = $config{'cache-delete'} ; |
| 290 | }; |
| 291 | |
| 292 | # Cache init |
| 293 | if (!(defined $cache_init) && defined $config{'cache-init'}) { |
| 294 | $cache_init = $config{'cache-init'} ; |
| 295 | }; |
| 296 | |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 297 | # Jobs for extraction |
| 298 | if (!(defined $sequential_extraction) && defined $config{'sequential-extraction'}) { |
| 299 | $sequential_extraction = $config{'sequential-extraction'} ; |
| 300 | }; |
| 301 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 302 | # Meta |
| 303 | if (!(defined $meta) && defined $config{'meta'}) { |
| 304 | $meta = $config{'meta'} ; |
| 305 | }; |
| 306 | |
| 307 | # Output |
| 308 | if (!(defined $output) && defined $config{'output'}) { |
| 309 | $output = $config{'output'} ; |
| 310 | }; |
| 311 | |
| 312 | # Base-sentences |
| 313 | if (!(defined $base_sentences) && defined $config{'base-sentences'}) { |
| 314 | $base_sentences = $config{'base-sentences'} ; |
| 315 | }; |
| 316 | |
| 317 | # Base-paragraphs |
| 318 | if (!(defined $base_paragraphs) && defined $config{'base-paragraphs'}) { |
| 319 | $base_paragraphs = $config{'base-paragraphs'} ; |
| 320 | }; |
| 321 | |
| 322 | # Base-pagebreaks |
| 323 | if (!(defined $base_pagebreaks) && defined $config{'base-pagebreaks'}) { |
| 324 | $base_pagebreaks = $config{'base-pagebreaks'} ; |
| 325 | }; |
| 326 | |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame] | 327 | # Write to tar |
| 328 | if (!(defined $to_tar) && defined $config{'to-tar'}) { |
| 329 | $to_tar = $config{'to-tar'} ; |
| 330 | }; |
| 331 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 332 | # Log |
| 333 | if (!(defined $log_level) && defined $config{'log'}) { |
| 334 | $log_level = $config{'log'} ; |
| 335 | }; |
| 336 | |
| 337 | # Skip |
| 338 | if (!scalar(@skip) && defined $config{'skip'}) { |
| 339 | @skip = split /\s*;\s*/, $config{'skip'} ; |
| 340 | }; |
| 341 | |
| 342 | # Sigle |
| 343 | if (!scalar(@sigle) && defined $config{'sigle'}) { |
| 344 | @sigle = split /\s*;\s*/, $config{'sigle'} ; |
| 345 | }; |
| 346 | |
| 347 | # Anno |
| 348 | if (!scalar(@anno) && defined $config{'anno'}) { |
| 349 | @anno = split /\s*;\s*/, $config{'anno'} ; |
| 350 | }; |
| 351 | }; |
| 352 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 353 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 354 | # Set default token base |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 355 | $token_base //= 'OpenNLP#tokens'; |
| 356 | $cache_file //= 'korapxml2krill.cache'; |
| 357 | $cache_size //= '50m'; |
| 358 | $jobs //= 0; |
Akron | 263274c | 2019-02-07 09:48:30 +0100 | [diff] [blame] | 359 | $koral //= $KORAL_VERSION; |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 360 | $cache_delete //= 1; |
| 361 | $cache_init //= 1; |
| 362 | $sequential_extraction //= 0; |
| 363 | $log_level //= 'ERROR'; |
| 364 | $base_sentences //= ''; |
| 365 | $base_paragraphs //= ''; |
| 366 | $base_pagebreaks //= ''; |
Akron | ed9baf0 | 2019-01-22 17:03:25 +0100 | [diff] [blame] | 367 | $non_word_tokens //= 0; |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 368 | $non_verbal_tokens //= 0; |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 369 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 370 | $base_sentences = lc $base_sentences; |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 371 | $base_paragraphs = lc $base_paragraphs; |
Akron | 636bd9c | 2017-02-09 17:13:00 +0100 | [diff] [blame] | 372 | $base_pagebreaks = lc $base_pagebreaks; |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 373 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 374 | |
| 375 | # Initialize log4perl object |
| 376 | Log::Log4perl->init({ |
| 377 | 'log4perl.rootLogger' => uc($log_level) . ', STDERR', |
| 378 | 'log4perl.appender.STDERR' => 'Log::Log4perl::Appender::ScreenColoredLevels', |
| 379 | 'log4perl.appender.STDERR.layout' => 'PatternLayout', |
| 380 | 'log4perl.appender.STDERR.layout.ConversionPattern' => '[%r] %F %L %c - %m%n' |
| 381 | }); |
| 382 | |
| 383 | my $log = Log::Log4perl->get_logger('main'); |
| 384 | |
| 385 | |
| 386 | print "Reading config from $cfg_file\n" if $cfg_file; |
| 387 | |
| 388 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 389 | my %ERROR_HASH = ( |
| 390 | -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS', |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 391 | -verbose => 99, |
| 392 | -msg => $VERSION_MSG, |
| 393 | -output => '-', |
| 394 | -exit => 1 |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 395 | ); |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 396 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 397 | # Input has to be defined |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 398 | pod2usage(%ERROR_HASH) unless @input; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 399 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 400 | # Gzip has no effect, if no output is given |
| 401 | pod2usage(%ERROR_HASH) if $gzip && !$output; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 402 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 403 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 404 | if ($jobs eq '-1') { |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 405 | state $cores = Sys::Info->new->device('CPU')->count; |
| 406 | $jobs = ceil(5 * $cores); |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 407 | $log->info("Run using $jobs jobs on $cores cores"); |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 408 | }; |
| 409 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 410 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 411 | # Start serial processing |
Akron | 28c4e54 | 2017-07-04 20:30:33 +0200 | [diff] [blame] | 412 | if ($cmd && $cmd eq 'serial') { |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 413 | |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 414 | if ($output && (!defined($to_tar)) && (!-e $output || !-d $output)) { |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 415 | $log->error("Directory '$output' does not exist."); |
| 416 | exit 1; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 417 | }; |
| 418 | |
| 419 | # Remove all inputs |
| 420 | my $remove_next = 0; |
| 421 | @keep_argv = @{c(@keep_argv)->grep( |
| 422 | sub { |
| 423 | # Input flag |
| 424 | if ($_ eq '-i' || $_ eq '--input' || $_ eq '--output' || $_ eq '-o') { |
| 425 | $remove_next = 1; |
| 426 | return 0; |
| 427 | } |
| 428 | |
| 429 | # input value |
| 430 | elsif ($remove_next) { |
| 431 | $remove_next = 0; |
| 432 | return 0; |
| 433 | }; |
| 434 | |
| 435 | # Pass parameter |
| 436 | return 1; |
| 437 | } |
| 438 | )->to_array}; |
| 439 | |
| 440 | |
| 441 | # Iterate over all inputs |
| 442 | foreach (@input) { |
| 443 | |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame] | 444 | # This will create a directory |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 445 | my $new_out = catdir($output, get_file_name_from_glob($_)); |
| 446 | |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 447 | # Create new path, in case the output is not meant to be tarred |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame] | 448 | unless ($to_tar) { |
| 449 | if (make_path($new_out) == 0 && !-d $new_out) { |
| 450 | $log->error("Can\'t create path $new_out"); |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 451 | exit 1; |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame] | 452 | }; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 453 | }; |
| 454 | |
| 455 | # Create archive command |
| 456 | my @archive_cmd = ($^X, $0, 'archive', @keep_argv, '-i', $_, '-o', $new_out); |
| 457 | print "Start serial processing of $_ to $new_out\n"; |
| 458 | |
| 459 | # Start archiving |
| 460 | system @archive_cmd; |
| 461 | }; |
| 462 | |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 463 | exit; |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 464 | }; |
| 465 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 466 | my %skip; |
| 467 | $skip{lc($_)} = 1 foreach @skip; |
| 468 | |
| 469 | my @layers; |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 470 | push(@layers, ['Base', 'Sentences']) unless $base_sentences; |
| 471 | push(@layers, ['Base', 'Paragraphs']) unless $base_paragraphs; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 472 | |
| 473 | # Connexor |
| 474 | push(@layers, ['Connexor', 'Morpho']); |
| 475 | push(@layers, ['Connexor', 'Syntax']); |
| 476 | push(@layers, ['Connexor', 'Phrase']); |
| 477 | push(@layers, ['Connexor', 'Sentences']); |
| 478 | |
| 479 | # CoreNLP |
| 480 | push(@layers, ['CoreNLP', 'NamedEntities']); |
| 481 | push(@layers, ['CoreNLP', 'Sentences']); |
| 482 | push(@layers, ['CoreNLP', 'Morpho']); |
| 483 | push(@layers, ['CoreNLP', 'Constituency']); |
| 484 | |
Akron | ce125b6 | 2017-06-19 11:54:36 +0200 | [diff] [blame] | 485 | # CMC |
| 486 | push(@layers, ['CMC', 'Morpho']); |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 487 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 488 | # DeReKo |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 489 | my @dereko_attr = (); |
| 490 | if ($base_sentences eq 'dereko#structure') { |
| 491 | push @dereko_attr, 'sentences'; |
| 492 | }; |
| 493 | if ($base_paragraphs eq 'dereko#structure') { |
| 494 | push @dereko_attr, 'paragraphs'; |
| 495 | }; |
Akron | 636bd9c | 2017-02-09 17:13:00 +0100 | [diff] [blame] | 496 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 497 | if ($base_pagebreaks eq 'dereko#structure') { |
| 498 | push @dereko_attr, 'pagebreaks'; |
| 499 | }; |
| 500 | |
| 501 | if ($dereko_attr[0]) { |
| 502 | push(@layers, ['DeReKo', 'Structure', 'base-' . join('-', @dereko_attr)]); |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 503 | } |
| 504 | else { |
| 505 | push(@layers, ['DeReKo', 'Structure']); |
| 506 | }; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 507 | |
Akron | 57510c1 | 2019-01-04 14:58:53 +0100 | [diff] [blame] | 508 | # DGD |
| 509 | push(@layers, ['DGD', 'Morpho']); |
Akron | c29b8e1 | 2019-12-16 14:28:09 +0100 | [diff] [blame] | 510 | if ($base_sentences eq 'dgd#structure') { |
| 511 | push(@layers, ['DGD', 'Structure', 'base-sentence']); |
| 512 | } |
Akron | 57510c1 | 2019-01-04 14:58:53 +0100 | [diff] [blame] | 513 | |
| 514 | # DRuKoLa |
| 515 | push(@layers, ['DRuKoLa', 'Morpho']); |
| 516 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 517 | # Glemm |
| 518 | push(@layers, ['Glemm', 'Morpho']); |
| 519 | |
Akron | ea1aed5 | 2018-07-19 14:43:34 +0200 | [diff] [blame] | 520 | # HNC |
| 521 | push(@layers, ['HNC', 'Morpho']); |
| 522 | |
Akron | 4c67919 | 2018-01-16 17:41:49 +0100 | [diff] [blame] | 523 | # LWC |
| 524 | push(@layers, ['LWC', 'Dependency']); |
| 525 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 526 | # Malt |
| 527 | push(@layers, ['Malt', 'Dependency']); |
| 528 | |
Akron | 57510c1 | 2019-01-04 14:58:53 +0100 | [diff] [blame] | 529 | # Marmot |
| 530 | push(@layers, ['MarMoT', 'Morpho']); |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 531 | |
| 532 | # Mate |
| 533 | push(@layers, ['Mate', 'Morpho']); |
| 534 | push(@layers, ['Mate', 'Dependency']); |
| 535 | |
Akron | 57510c1 | 2019-01-04 14:58:53 +0100 | [diff] [blame] | 536 | # MDParser |
| 537 | push(@layers, ['MDParser', 'Dependency']); |
| 538 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 539 | # OpenNLP |
| 540 | push(@layers, ['OpenNLP', 'Morpho']); |
| 541 | push(@layers, ['OpenNLP', 'Sentences']); |
| 542 | |
Akron | 07e2477 | 2020-04-23 14:00:54 +0200 | [diff] [blame] | 543 | # Redewiedergabe |
| 544 | push(@layers, ['RWK', 'Morpho']); |
| 545 | if ($base_sentences eq 'rwk#structure') { |
| 546 | push(@layers, ['RWK', 'Structure']); |
| 547 | }; |
| 548 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 549 | # Schreibgebrauch |
| 550 | push(@layers, ['Sgbr', 'Lemma']); |
| 551 | push(@layers, ['Sgbr', 'Morpho']); |
| 552 | |
Akron | 7d5e638 | 2019-08-08 16:36:27 +0200 | [diff] [blame] | 553 | # Talismane |
| 554 | push(@layers, ['Talismane', 'Dependency']); |
| 555 | push(@layers, ['Talismane', 'Morpho']); |
| 556 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 557 | # TreeTagger |
| 558 | push(@layers, ['TreeTagger', 'Morpho']); |
| 559 | push(@layers, ['TreeTagger', 'Sentences']); |
| 560 | |
| 561 | # XIP |
| 562 | push(@layers, ['XIP', 'Morpho']); |
| 563 | push(@layers, ['XIP', 'Constituency']); |
| 564 | push(@layers, ['XIP', 'Sentences']); |
| 565 | push(@layers, ['XIP', 'Dependency']); |
| 566 | |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 567 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 568 | # Check filters |
| 569 | my @filtered_anno; |
| 570 | if ($skip{'#all'}) { |
| 571 | foreach (@anno) { |
| 572 | push @filtered_anno, [ split('#', $_) ]; |
| 573 | }; |
| 574 | } |
| 575 | |
| 576 | # Add all annotations that are not skipped |
| 577 | else { |
| 578 | # Add to index file - respect skipping |
| 579 | foreach my $info (@layers) { |
| 580 | # Skip if Foundry or Foundry#Layer should be skipped |
| 581 | unless ($skip{lc($info->[0])} || $skip{lc($info->[0]) . '#' . lc($info->[1])}) { |
| 582 | push @filtered_anno, $info; |
| 583 | }; |
| 584 | }; |
| 585 | }; |
| 586 | |
| 587 | # Get tokenization basis |
Akron | 3c56f50 | 2017-10-24 15:37:27 +0200 | [diff] [blame] | 588 | my ($token_base_foundry, $token_base_layer) = split(/#/, $token_base) if $token_base; |
| 589 | |
| 590 | # Remove file extension |
| 591 | $token_base_layer =~ s/\.xml$//i; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 592 | |
| 593 | # TODO: This should not be initialized for batch |
| 594 | my $cache = Cache::FastMmap->new( |
| 595 | share_file => $cache_file, |
| 596 | cache_size => $cache_size, |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 597 | init_file => $cache_init |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 598 | ); |
| 599 | |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 600 | # Create batch object |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 601 | my $batch_file = KorAP::XML::Batch::File->new( |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 602 | cache => $cache, |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 603 | meta_type => $meta, |
| 604 | overwrite => $overwrite, |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 605 | foundry => $token_base_foundry, |
| 606 | layer => $token_base_layer, |
| 607 | gzip => $gzip, |
| 608 | log => $log, |
Akron | 263274c | 2019-02-07 09:48:30 +0100 | [diff] [blame] | 609 | koral => $koral, |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 610 | primary => $primary, |
| 611 | pretty => $pretty, |
Akron | ed9baf0 | 2019-01-22 17:03:25 +0100 | [diff] [blame] | 612 | anno => \@filtered_anno, |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 613 | non_word_tokens => $non_word_tokens, |
| 614 | non_verbal_tokens => $non_verbal_tokens |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 615 | ); |
| 616 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 617 | # Convert sigle to path construct |
| 618 | s!^\s*([^_]+?)_([^\.]+?)\.(.+?)\s*$!$1/$2/$3! foreach @sigle; |
| 619 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 620 | if ($cmd) { |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 621 | if ($output && (!defined($to_tar)) && (!-e $output || !-d $output)) { |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 622 | $log->error("Directory '$output' does not exist."); |
| 623 | exit 1; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 624 | }; |
| 625 | }; |
| 626 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 627 | |
| 628 | # Glob and prefix files |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 629 | if (@input) { |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 630 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 631 | my @new_input = (); |
| 632 | |
| 633 | # Iterate over all inputs |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 634 | foreach my $wild_card (@input) { |
| 635 | |
| 636 | # Prefix with input root |
| 637 | $wild_card = $input_base ? catfile($input_base, $wild_card) : $wild_card; |
| 638 | |
| 639 | push (@new_input, bsd_glob($wild_card)); |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 640 | }; |
| 641 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 642 | # Sort files by length |
| 643 | @input = sort { length($a) <=> length($b) } @new_input; |
| 644 | |
| 645 | print 'Input is ' . join(', ', @input)."\n"; |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 646 | }; |
| 647 | |
| 648 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 649 | # Process a single file |
| 650 | unless ($cmd) { |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 651 | my $input = $input[0]; |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 652 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 653 | BEGIN { |
| 654 | $main::TIME = Benchmark->new; |
| 655 | $main::LAST_STOP = Benchmark->new; |
| 656 | }; |
| 657 | |
| 658 | sub stop_time { |
| 659 | my $new = Benchmark->new; |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 660 | $log->info( |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 661 | 'The code took: '. |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 662 | timestr(timediff($new, $main::LAST_STOP)) . |
| 663 | ' (overall: ' . timestr(timediff($new, $main::TIME)) . ')' |
| 664 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 665 | $main::LAST_STOP = $new; |
| 666 | }; |
| 667 | |
| 668 | # Create and parse new document |
| 669 | $input =~ s{([^/])$}{$1/}; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 670 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 671 | # Process file |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 672 | $batch_file->process($input, $output); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 673 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 674 | # Delete cache file |
| 675 | unlink($cache_file) if $cache_delete; |
| 676 | |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 677 | stop_time; |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 678 | exit; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 679 | }; |
| 680 | |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 681 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 682 | # Extract XML files |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 683 | if ($cmd eq 'extract') { |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 684 | |
Akron | d5643ad | 2017-07-04 20:27:13 +0200 | [diff] [blame] | 685 | # Output is required |
| 686 | pod2usage(%ERROR_HASH) unless $output; |
| 687 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 688 | # Create new archive object |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 689 | if (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 690 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 691 | # Check zip capabilities |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 692 | unless ($archive->test_unzip) { |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 693 | $log->error("Unzip is not installed or incompatible."); |
| 694 | exit 1; |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 695 | }; |
| 696 | |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 697 | # Add further annotation archived |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 698 | $archive->attach($_) foreach @input[1..$#input]; |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 699 | |
Akron | 31a08cb | 2019-02-20 20:43:26 +0100 | [diff] [blame] | 700 | # Will set @sigle |
| 701 | my $prefix = set_sigle($archive); |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 702 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 703 | # Iterate over all given sigles and extract |
| 704 | foreach (@sigle) { |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 705 | |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 706 | print "$_ ...\n"; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 707 | |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 708 | # TODO: Make this OS independent |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 709 | print '... ' . ( |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 710 | |
Akron | 955b75b | 2019-02-21 14:28:41 +0100 | [diff] [blame] | 711 | # TODO: |
| 712 | # - prefix??? |
| 713 | $archive->extract_sigle([$_], $output, $jobs) |
| 714 | ? '' : 'not ' |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 715 | ); |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 716 | print "extracted.\n"; |
| 717 | }; |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 718 | } |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 719 | |
| 720 | # Can't create archive object |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 721 | else { |
| 722 | $log->error('Unable to extract from primary archive ' . $input[0]); |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 723 | exit 1; |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 724 | }; |
| 725 | } |
| 726 | |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 727 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 728 | # Process an archive |
| 729 | elsif ($cmd eq 'archive') { |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 730 | |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 731 | my $archive_output; |
| 732 | |
| 733 | # First extract, then archive |
Akron | 63d03ee | 2019-02-13 18:49:38 +0100 | [diff] [blame] | 734 | if (defined $extract_dir && !-d $input[0]) { |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 735 | |
| 736 | # Create new archive object |
| 737 | if (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
| 738 | |
| 739 | # Check zip capabilities |
| 740 | unless ($archive->test_unzip) { |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 741 | $log->error("Unzip is not installed or incompatible."); |
| 742 | exit 1; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 743 | }; |
| 744 | |
| 745 | # Add further annotation archived |
| 746 | $archive->attach($_) foreach @input[1..$#input]; |
| 747 | |
| 748 | # Create a temporary directory |
| 749 | if ($extract_dir eq ':temp:') { |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 750 | $extract_dir = tempdir(CLEANUP => 0); |
| 751 | print "Temporarily extract to $extract_dir\n"; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 752 | }; |
| 753 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 754 | # Add some random extra to avoid clashes with multiple archives |
| 755 | $extract_dir = catdir($extract_dir, random_string('cccccc')); |
| 756 | |
Akron | 31a08cb | 2019-02-20 20:43:26 +0100 | [diff] [blame] | 757 | # Extract to temporary directory |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 758 | if ($archive->extract_all($extract_dir, $sequential_extraction ? 1: $jobs)) { |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 759 | @input = ($extract_dir); |
| 760 | } |
| 761 | else { |
| 762 | $log->error('Unable to extract from primary archive ' . $input[0] . |
| 763 | ' to ' . $extract_dir); |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 764 | exit 1; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 765 | }; |
| 766 | } |
| 767 | |
| 768 | # Can't create archive object |
| 769 | else { |
| 770 | $log->error('Unable to extract from primary archive ' . $input[0]); |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 771 | exit 1; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 772 | }; |
| 773 | }; |
| 774 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 775 | # Zero means: everything runs in the parent process |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 776 | my $pool = Parallel::ForkManager->new($jobs); |
| 777 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 778 | my $count = 0; # Texts to process |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 779 | my $iter = 1; # Current text in process |
| 780 | |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame] | 781 | my $tar_archive; |
| 782 | my $output_dir = $output; |
| 783 | my $tar_fh; |
| 784 | |
| 785 | # Initialize tar archive |
| 786 | if ($to_tar) { |
| 787 | $tar_archive = Archive::Tar::Builder->new( |
| 788 | ignore_errors => 1 |
| 789 | ); |
| 790 | |
| 791 | # Set output name |
| 792 | my $tar_file = $output; |
| 793 | unless ($tar_file =~ /\.tar$/) { |
| 794 | $tar_file .= '.tar'; |
| 795 | }; |
| 796 | |
| 797 | # Initiate the tar file |
| 798 | print "Writing to file $tar_file\n"; |
| 799 | $tar_fh = IO::File->new($tar_file, 'w'); |
| 800 | $tar_fh->binmode(1); |
| 801 | |
| 802 | # Set handle |
| 803 | $tar_archive->set_handle($tar_fh); |
| 804 | |
| 805 | # Output to temporary directory |
| 806 | $output_dir = File::Temp->newdir; |
| 807 | }; |
| 808 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 809 | # Report on fork message |
| 810 | $pool->run_on_finish ( |
| 811 | sub { |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 812 | my ($pid, $code) = @_; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 813 | my $data = pop; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 814 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 815 | print 'Convert ['. ($jobs > 0 ? "\$$pid:" : '') . |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 816 | ($iter++) . "/$count]" . |
| 817 | ($code ? " $code" : '') . |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 818 | ' ' . $data->[0] . "\n"; |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame] | 819 | |
| 820 | if (!$code && $to_tar && $data->[2]) { |
| 821 | my $filename = $data->[2]; |
| 822 | |
| 823 | # Lock filehandle |
| 824 | if (flock($tar_fh, LOCK_EX)) { |
| 825 | |
Akron | 9a062ce | 2017-07-04 19:12:05 +0200 | [diff] [blame] | 826 | my $clean_file = fileparse($filename); |
| 827 | |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame] | 828 | # Archive and remove file |
Akron | 9a062ce | 2017-07-04 19:12:05 +0200 | [diff] [blame] | 829 | $tar_archive->archive_as($filename => $clean_file); |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame] | 830 | unlink $filename; |
| 831 | |
| 832 | # Unlock filehandle |
| 833 | flock($tar_fh, LOCK_UN); |
| 834 | } |
| 835 | else { |
| 836 | $log->warn("Unable to add $filename to archive"); |
| 837 | }; |
| 838 | }; |
| 839 | |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 840 | $data->[1] = undef if $data->[1]; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 841 | } |
| 842 | ); |
| 843 | |
| 844 | my $t; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 845 | my $temp; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 846 | print "Reading data ...\n"; |
| 847 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 848 | # unless (Cache::FastMmap->new( |
| 849 | # share_file => $cache_file, |
| 850 | # cache_size => $cache_size, |
| 851 | # init_file => $cache_init |
| 852 | # )) { |
| 853 | # print "Unable to intialize cache '$cache_file'\n\n"; |
| 854 | # exit(1); |
| 855 | # }; |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 856 | |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 857 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 858 | # Input is a directory |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 859 | if (-d $input[0]) { |
| 860 | my $it = Directory::Iterator->new($input[0]); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 861 | my @dirs; |
| 862 | my $dir; |
| 863 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 864 | # Todo: Make a DO WHILE |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 865 | while (1) { |
| 866 | if (!$it->is_directory && ($dir = $it->get) && $dir =~ s{/data\.xml$}{}) { |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 867 | push @dirs, $dir; |
| 868 | $it->prune; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 869 | }; |
| 870 | last unless $it->next; |
| 871 | }; |
| 872 | |
| 873 | print "Start processing ...\n"; |
| 874 | $t = Benchmark->new; |
| 875 | $count = scalar @dirs; |
| 876 | |
| 877 | DIRECTORY_LOOP: |
| 878 | for (my $i = 0; $i < $count; $i++) { |
| 879 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 880 | my $filename = catfile( |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame] | 881 | $output_dir, |
Akron | 41127e3 | 2020-08-07 12:46:19 +0200 | [diff] [blame^] | 882 | get_file_name($input[0], $dirs[$i]) . '.json' . ($gzip ? '.gz' : '') |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 883 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 884 | |
| 885 | # Get the next fork |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 886 | $pool->start and next DIRECTORY_LOOP; |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 887 | |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 888 | if (my $return = $batch_file->process($dirs[$i] => $filename)) { |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 889 | $pool->finish( |
| 890 | 0, |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame] | 891 | [ |
| 892 | "Processed " . $filename . ($return == -1 ? " - already existing" : ''), |
| 893 | undef, |
| 894 | $filename |
| 895 | ] |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 896 | ); |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 897 | } |
| 898 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 899 | $pool->finish(1, ["Unable to process " . $dirs[$i]]); |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 900 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 901 | }; |
| 902 | } |
| 903 | |
| 904 | # Input is a file |
Akron | 29866ac | 2016-06-24 16:40:47 +0200 | [diff] [blame] | 905 | elsif (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 906 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 907 | unless ($archive->test_unzip) { |
Akron | 3abc03e | 2017-06-29 16:23:35 +0200 | [diff] [blame] | 908 | $log->error("Unzip is not installed or incompatible."); |
| 909 | exit 1; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 910 | }; |
| 911 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 912 | # Add further annotation archived |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 913 | $archive->attach($_) foreach @input[1..$#input]; |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 914 | |
Akron | 31a08cb | 2019-02-20 20:43:26 +0100 | [diff] [blame] | 915 | # Get sigles to extract |
| 916 | my $prefix = set_sigle($archive); |
| 917 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 918 | print "Start processing ...\n"; |
| 919 | $t = Benchmark->new; |
| 920 | my @dirs = $archive->list_texts; |
| 921 | $count = scalar @dirs; |
| 922 | |
| 923 | ARCHIVE_LOOP: |
| 924 | for (my $i = 0; $i < $count; $i++) { |
| 925 | |
| 926 | # Split path information |
| 927 | my ($prefix, $corpus, $doc, $text) = $archive->split_path($dirs[$i]); |
| 928 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 929 | my $filename = catfile( |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 930 | $output_dir, |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 931 | get_file_name( |
Akron | 41127e3 | 2020-08-07 12:46:19 +0200 | [diff] [blame^] | 932 | $input[0], |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 933 | catfile($corpus, $doc, $text) |
| 934 | . '.json' . ($gzip ? '.gz' : '') |
| 935 | ) |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 936 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 937 | |
| 938 | # Get the next fork |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 939 | $pool->start and next ARCHIVE_LOOP; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 940 | |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 941 | # Create temporary file |
| 942 | $temp = File::Temp->newdir; |
| 943 | |
Akron | bdf434a | 2016-10-24 17:42:07 +0200 | [diff] [blame] | 944 | # TODO: Check if $filename exist at the beginning, |
| 945 | # because extraction can be horrible slow! |
| 946 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 947 | # Extract from archive |
Akron | 955b75b | 2019-02-21 14:28:41 +0100 | [diff] [blame] | 948 | if ($archive->extract_sigle([join('/', $corpus, $doc, $text)], $temp, $sequential_extraction ? 1 : $jobs)) { |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 949 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 950 | # Create corpus directory |
| 951 | my $input = catdir("$temp", $corpus); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 952 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 953 | # Temporary directory |
| 954 | my $dir = catdir($input, $doc, $text); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 955 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 956 | # Write file |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 957 | if (my $return = $batch_file->process($dir => $filename)) { |
Akron | 486f9ab | 2017-04-22 23:25:19 +0200 | [diff] [blame] | 958 | |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 959 | # Delete temporary file |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 960 | $pool->finish( |
| 961 | 0, |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame] | 962 | [ |
| 963 | "Processed " . $filename . ($return == -1 ? " - already existing" : ''), |
| 964 | $temp, |
| 965 | $filename |
| 966 | ] |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 967 | ); |
| 968 | #$pool->finish(0, ["Processed " . $filename, $temp]); |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 969 | } |
| 970 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 971 | # Delete temporary file |
| 972 | $pool->finish(1, ["Unable to process " . $dir, $temp]); |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 973 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 974 | } |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 975 | |
| 976 | # Unable to extract |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 977 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 978 | $pool->finish(1, ["Unable to extract " . $dirs[$i], $temp]); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 979 | }; |
| 980 | }; |
| 981 | } |
| 982 | |
| 983 | else { |
| 984 | print "Input is neither a directory nor an archive.\n\n"; |
| 985 | }; |
| 986 | |
| 987 | $pool->wait_all_children; |
| 988 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 989 | # Delete cache file |
| 990 | unlink($cache_file) if $cache_delete; |
| 991 | |
Akron | da3097e | 2017-04-23 19:53:57 +0200 | [diff] [blame] | 992 | # Close tar filehandle |
| 993 | if ($to_tar && $tar_fh) { |
| 994 | $tar_archive->finish; |
| 995 | $tar_fh->close; |
| 996 | print "Wrote to tar archive.\n"; |
| 997 | }; |
| 998 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 999 | print timestr(timediff(Benchmark->new, $t))."\n"; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1000 | print "Done.\n"; |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 1001 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1002 | |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 1003 | |
Akron | 31a08cb | 2019-02-20 20:43:26 +0100 | [diff] [blame] | 1004 | # For an archive, this will create the list |
| 1005 | # of all sigles to process |
| 1006 | sub set_sigle { |
| 1007 | my $archive = shift; |
| 1008 | |
| 1009 | my $prefix = 1; |
| 1010 | my @dirs = (); |
| 1011 | |
| 1012 | # No sigles given |
| 1013 | unless (@sigle) { |
| 1014 | |
| 1015 | # Get files |
| 1016 | foreach ($archive->list_texts) { |
| 1017 | |
| 1018 | push @dirs, $_; |
| 1019 | |
| 1020 | # Split path information |
| 1021 | ($prefix, my ($corpus, $doc, $text)) = $archive->split_path($_); |
| 1022 | |
| 1023 | # TODO: Make this OS independent |
| 1024 | push @sigle, join '/', $corpus, $doc, $text; |
| 1025 | }; |
| 1026 | } |
| 1027 | |
| 1028 | # Check sigle for doc sigles |
| 1029 | else { |
| 1030 | my @new_sigle; |
| 1031 | |
| 1032 | my $prefix_check = 0; |
| 1033 | |
| 1034 | # Iterate over all sigle |
| 1035 | foreach (@sigle) { |
| 1036 | |
| 1037 | # Sigle is a doc sigle |
| 1038 | if ($_ =~ m!^(?:\.[/\\])?[^/\\]+?[/\\][^/\\]+?$!) { |
| 1039 | |
| 1040 | print "$_ ..."; |
| 1041 | # Check if a prefix is needed |
| 1042 | unless ($prefix_check) { |
| 1043 | |
| 1044 | if ($prefix = $archive->check_prefix) { |
| 1045 | print " with prefix ..."; |
| 1046 | }; |
| 1047 | $prefix_check = 1; |
| 1048 | }; |
| 1049 | |
| 1050 | print "\n"; |
| 1051 | |
Akron | 31a08cb | 2019-02-20 20:43:26 +0100 | [diff] [blame] | 1052 | print '... ' . ( |
Akron | 955b75b | 2019-02-21 14:28:41 +0100 | [diff] [blame] | 1053 | $archive->extract_sigle([$_], $output, $sequential_extraction ? 1 : $jobs) |
| 1054 | ? '' : 'not ' |
Akron | 31a08cb | 2019-02-20 20:43:26 +0100 | [diff] [blame] | 1055 | ); |
| 1056 | print "extracted.\n"; |
| 1057 | } |
| 1058 | |
| 1059 | # Sigle is a text sigle |
| 1060 | else { |
| 1061 | push @new_sigle, $_; |
| 1062 | |
| 1063 | unless ($prefix_check) { |
| 1064 | |
| 1065 | if ($prefix = $archive->check_prefix) { |
| 1066 | print " with prefix ..."; |
| 1067 | }; |
| 1068 | $prefix_check = 1; |
| 1069 | }; |
| 1070 | }; |
| 1071 | }; |
| 1072 | @sigle = @new_sigle; |
| 1073 | }; |
| 1074 | |
| 1075 | return $prefix; |
| 1076 | }; |
| 1077 | |
| 1078 | |
| 1079 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1080 | # Cleanup temporary extraction directory |
| 1081 | if ($extract_dir) { |
| 1082 | my $objects = remove_tree($extract_dir, { safe => 1 }); |
| 1083 | print "Removed directory $extract_dir with $objects objects.\n"; |
| 1084 | }; |
| 1085 | |
| 1086 | |
| 1087 | print "\n"; |
| 1088 | |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 1089 | __END__ |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1090 | |
| 1091 | =pod |
| 1092 | |
| 1093 | =encoding utf8 |
| 1094 | |
| 1095 | =head1 NAME |
| 1096 | |
Akron | 42f48c1 | 2020-02-14 13:08:13 +0100 | [diff] [blame] | 1097 | korapxml2krill - Merge KorAP-XML data and create Krill documents |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1098 | |
| 1099 | |
| 1100 | =head1 SYNOPSIS |
| 1101 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1102 | korapxml2krill [archive|extract] --input <directory|archive> [options] |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1103 | |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 1104 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1105 | =head1 DESCRIPTION |
| 1106 | |
| 1107 | L<KorAP::XML::Krill> is a library to convert KorAP-XML documents to files |
| 1108 | compatible with the L<Krill|https://github.com/KorAP/Krill> indexer. |
Akron | 8f69d63 | 2020-01-15 16:58:11 +0100 | [diff] [blame] | 1109 | The C<korapxml2krill> command line tool is a simple wrapper of this library. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1110 | |
| 1111 | |
| 1112 | =head1 INSTALLATION |
| 1113 | |
| 1114 | The preferred way to install L<KorAP::XML::Krill> is to use L<cpanm|App::cpanminus>. |
| 1115 | |
Akron | af38698 | 2016-10-12 00:33:25 +0200 | [diff] [blame] | 1116 | $ cpanm https://github.com/KorAP/KorAP-XML-Krill.git |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1117 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1118 | In case everything went well, the C<korapxml2krill> tool will |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1119 | be available on your command line immediately. |
Akron | 6eff23b | 2018-09-24 10:31:20 +0200 | [diff] [blame] | 1120 | Minimum requirement for L<KorAP::XML::Krill> is Perl 5.16. |
Akron | a93d51b | 2016-10-24 20:27:48 +0200 | [diff] [blame] | 1121 | 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] | 1122 | |
| 1123 | =head1 ARGUMENTS |
| 1124 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1125 | $ korapxml2krill -z --input <directory> --output <filename> |
| 1126 | |
| 1127 | Without arguments, C<korapxml2krill> converts a directory of a single KorAP-XML document. |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 1128 | It expects the input to point to the text level folder. |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1129 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1130 | =over 2 |
| 1131 | |
| 1132 | =item B<archive> |
| 1133 | |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame] | 1134 | $ korapxml2krill archive -z --input <directory|archive> --output <directory|tar> |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1135 | |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 1136 | Converts an archive of KorAP-XML documents. It expects a directory |
| 1137 | (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] | 1138 | |
| 1139 | =item B<extract> |
| 1140 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1141 | $ korapxml2krill extract --input <archive> --output <directory> --sigle <SIGLE> |
| 1142 | |
| 1143 | Extracts KorAP-XML documents from a zip file. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1144 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1145 | =item B<serial> |
| 1146 | |
| 1147 | $ korapxml2krill serial -i <archive1> -i <archive2> -o <directory> -cfg <config-file> |
| 1148 | |
| 1149 | Convert archives sequentially. The inputs are not merged but treated |
| 1150 | as they are (so they may be premerged or globs). |
| 1151 | the C<--out> directory is treated as the base directory where subdirectories |
Akron | 081639e | 2017-04-21 19:01:39 +0200 | [diff] [blame] | 1152 | are created based on the archive name. In case the C<--to-tar> flag is given, |
| 1153 | the output will be a tar file. |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1154 | |
| 1155 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1156 | =back |
| 1157 | |
| 1158 | |
| 1159 | =head1 OPTIONS |
| 1160 | |
| 1161 | =over 2 |
| 1162 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1163 | =item B<--input|-i> <directory|zip file> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1164 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1165 | Directory or zip file(s) of documents to convert. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1166 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1167 | Without arguments, C<korapxml2krill> expects a folder of a single KorAP-XML |
Akron | f1a1de9 | 2016-11-02 17:32:12 +0100 | [diff] [blame] | 1168 | document, while C<archive> expects a KorAP-XML corpus folder or a zip |
| 1169 | file to batch process multiple files. |
| 1170 | C<extract> expects zip files only. |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1171 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1172 | C<archive> supports multiple input zip files with the constraint, |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 1173 | that the first archive listed contains all primary data files |
| 1174 | and all meta data files. |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 1175 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1176 | -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] | 1177 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1178 | Input may also be defined using BSD glob wildcards. |
| 1179 | |
| 1180 | -i 'file/news*.zip' |
| 1181 | |
| 1182 | The extended input array will be sorted in length order, so the shortest |
| 1183 | path needs to contain all primary data files and all meta data files. |
| 1184 | |
Akron | 0c3e375 | 2016-06-28 15:55:53 +0200 | [diff] [blame] | 1185 | (The directory structure follows the base directory format, |
| 1186 | that may include a C<.> root folder. |
| 1187 | In this case further archives lacking a C<.> root folder |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1188 | need to be passed with a hash sign in front of the archive's name. |
| 1189 | This may require to quote the parameter.) |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 1190 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1191 | To support zip files, a version of C<unzip> needs to be installed that is |
| 1192 | compatible with the archive file. |
Akron | a93d51b | 2016-10-24 20:27:48 +0200 | [diff] [blame] | 1193 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 1194 | B<The root folder switch using the hash sign is experimental and |
| 1195 | may vanish in future versions.> |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 1196 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1197 | |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1198 | =item B<--input-base|-ib> <directory> |
| 1199 | |
| 1200 | The base directory for inputs. |
| 1201 | |
| 1202 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1203 | =item B<--output|-o> <directory|file> |
| 1204 | |
| 1205 | Output folder for archive processing or |
| 1206 | document name for single output (optional), |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1207 | writes to C<STDOUT> by default |
| 1208 | (in case C<output> is not mandatory due to further options). |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1209 | |
| 1210 | =item B<--overwrite|-w> |
| 1211 | |
| 1212 | Overwrite files that already exist. |
| 1213 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1214 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 1215 | =item B<--token|-t> <foundry>#<file> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1216 | |
| 1217 | Define the default tokenization by specifying |
| 1218 | the name of the foundry and optionally the name |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1219 | of the layer-file. Defaults to C<OpenNLP#tokens>. |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 1220 | This will directly take the file instead of running |
| 1221 | the layer implementation! |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1222 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 1223 | |
| 1224 | =item B<--base-sentences|-bs> <foundry>#<layer> |
| 1225 | |
| 1226 | Define the layer for base sentences. |
| 1227 | If given, this will be used instead of using C<Base#Sentences>. |
Akron | c29b8e1 | 2019-12-16 14:28:09 +0100 | [diff] [blame] | 1228 | Currently C<DeReKo#Structure> and C<DGD#Structure> are the only additional |
| 1229 | layers supported. |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 1230 | |
| 1231 | Defaults to unset. |
| 1232 | |
| 1233 | |
| 1234 | =item B<--base-paragraphs|-bp> <foundry>#<layer> |
| 1235 | |
| 1236 | Define the layer for base paragraphs. |
| 1237 | If given, this will be used instead of using C<Base#Paragraphs>. |
| 1238 | Currently C<DeReKo#Structure> is the only additional layer supported. |
| 1239 | |
| 1240 | Defaults to unset. |
| 1241 | |
| 1242 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 1243 | =item B<--base-pagebreaks|-bpb> <foundry>#<layer> |
| 1244 | |
| 1245 | Define the layer for base pagebreaks. |
| 1246 | Currently C<DeReKo#Structure> is the only layer supported. |
| 1247 | |
| 1248 | Defaults to unset. |
| 1249 | |
| 1250 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1251 | =item B<--skip|-s> <foundry>[#<layer>] |
| 1252 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1253 | Skip specific annotations by specifying the foundry |
| 1254 | (and optionally the layer with a C<#>-prefix), |
| 1255 | 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] | 1256 | Can be set multiple times. |
| 1257 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1258 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1259 | =item B<--anno|-a> <foundry>#<layer> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1260 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1261 | Convert specific annotations by specifying the foundry |
| 1262 | (and optionally the layer with a C<#>-prefix), |
| 1263 | e.g. C<Mate> or C<Mate#Morpho>. |
| 1264 | Can be set multiple times. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1265 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1266 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1267 | =item B<--primary|-p> |
| 1268 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1269 | Output primary data or not. Defaults to C<true>. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1270 | Can be flagged using C<--no-primary> as well. |
| 1271 | This is I<deprecated>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1272 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1273 | |
Akron | ed9baf0 | 2019-01-22 17:03:25 +0100 | [diff] [blame] | 1274 | =item B<--non-word-tokens|-nwt> |
| 1275 | |
| 1276 | Tokenize non-word tokens like word tokens (defined as matching |
| 1277 | C</[\d\w]/>). Useful to treat punctuations as tokens. |
| 1278 | |
| 1279 | Defaults to unset. |
| 1280 | |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 1281 | |
| 1282 | =item B<--non-verbal-tokens|-nvt> |
| 1283 | |
| 1284 | Tokenize non-verbal tokens marked as in the primary data as |
| 1285 | the unicode symbol 'Black Vertical Rectangle' aka \x25ae. |
| 1286 | |
| 1287 | Defaults to unset. |
| 1288 | |
| 1289 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1290 | =item B<--jobs|-j> |
| 1291 | |
| 1292 | Define the number of concurrent jobs in seperated forks |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1293 | for archive processing. |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 1294 | Defaults to C<0> (everything runs in a single process). |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 1295 | |
| 1296 | If C<sequential-extraction> is not set to false, this will |
| 1297 | also apply to extraction. |
| 1298 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 1299 | Pass -1, and the value will be set automatically to 5 |
| 1300 | times the number of available cores. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1301 | This is I<experimental>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1302 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1303 | |
Akron | 263274c | 2019-02-07 09:48:30 +0100 | [diff] [blame] | 1304 | =item B<--koral|-k> |
| 1305 | |
| 1306 | Version of the output format. Supported versions are: |
| 1307 | C<0> for legacy serialization, C<0.03> for serialization |
| 1308 | with metadata fields as key-values on the root object, |
| 1309 | C<0.4> for serialization with metadata fields as a list |
| 1310 | of C<"@type":"koral:field"> objects. |
| 1311 | |
| 1312 | Currently defaults to C<0.03>. |
| 1313 | |
| 1314 | |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 1315 | =item B<--sequential-extraction|-se> |
| 1316 | |
| 1317 | Flag to indicate, if the C<jobs> value also applies to extraction. |
| 1318 | Some systems may have problems with extracting multiple archives |
| 1319 | to the same folder at the same time. |
| 1320 | Can be flagged using C<--no-sequential-extraction> as well. |
| 1321 | Defaults to C<false>. |
| 1322 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1323 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 1324 | =item B<--meta|-m> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1325 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 1326 | Define the metadata parser to use. Defaults to C<I5>. |
| 1327 | Metadata parsers can be defined in the C<KorAP::XML::Meta> namespace. |
| 1328 | This is I<experimental>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1329 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1330 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1331 | =item B<--pretty|-y> |
| 1332 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1333 | Pretty print JSON output. Defaults to C<false>. |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 1334 | This is I<deprecated>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1335 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1336 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1337 | =item B<--gzip|-z> |
| 1338 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1339 | Compress the output. |
| 1340 | Expects a defined C<output> file in single processing. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1341 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1342 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 1343 | =item B<--cache|-c> |
| 1344 | |
| 1345 | File to mmap a cache (using L<Cache::FastMmap>). |
| 1346 | Defaults to C<korapxml2krill.cache> in the calling directory. |
| 1347 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1348 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 1349 | =item B<--cache-size|-cs> |
| 1350 | |
| 1351 | Size of the cache. Defaults to C<50m>. |
| 1352 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1353 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 1354 | =item B<--cache-init|-ci> |
| 1355 | |
| 1356 | Initialize cache file. |
| 1357 | Can be flagged using C<--no-cache-init> as well. |
| 1358 | Defaults to C<true>. |
| 1359 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1360 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 1361 | =item B<--cache-delete|-cd> |
| 1362 | |
| 1363 | Delete cache file after processing. |
| 1364 | Can be flagged using C<--no-cache-delete> as well. |
| 1365 | Defaults to C<true>. |
| 1366 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1367 | |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1368 | =item B<--config|-cfg> |
| 1369 | |
| 1370 | Configure the parameters of your call in a file |
| 1371 | of key-value pairs with whitespace separator |
| 1372 | |
| 1373 | overwrite 1 |
| 1374 | token DeReKo#Structure |
| 1375 | ... |
| 1376 | |
| 1377 | Supported parameters are: |
Akron | 63f20d4 | 2017-04-10 23:40:29 +0200 | [diff] [blame] | 1378 | C<overwrite>, C<gzip>, C<jobs>, C<input-base>, |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1379 | C<token>, C<log>, C<cache>, C<cache-size>, C<cache-delete>, C<meta>, |
Akron | 31a08cb | 2019-02-20 20:43:26 +0100 | [diff] [blame] | 1380 | C<output>, C<koral>, |
| 1381 | C<tempary-extract>, C<sequential-extraction>, |
Akron | 9ec8887 | 2017-04-12 16:29:06 +0200 | [diff] [blame] | 1382 | C<base-sentences>, C<base-paragraphs>, |
| 1383 | C<base-pagebreaks>, |
| 1384 | C<skip> (semicolon separated), C<sigle> |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1385 | (semicolon separated), C<anno> (semicolon separated). |
| 1386 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1387 | Configuration parameters will always be overwritten by |
| 1388 | passed parameters. |
| 1389 | |
| 1390 | |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 1391 | =item B<--temporary-extract|-te> |
| 1392 | |
| 1393 | Only valid for the C<archive> command. |
| 1394 | |
| 1395 | This will first extract all files into a |
| 1396 | directory and then will archive. |
| 1397 | If the directory is given as C<:temp:>, |
| 1398 | a temporary directory is used. |
| 1399 | This is especially useful to avoid |
| 1400 | massive unzipping and potential |
| 1401 | network latency. |
Akron | 636aa11 | 2017-04-07 18:48:56 +0200 | [diff] [blame] | 1402 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1403 | |
Akron | c93a080 | 2019-07-11 15:48:34 +0200 | [diff] [blame] | 1404 | =item B<--to-tar> |
| 1405 | |
| 1406 | Only valid for the C<archive> command. |
| 1407 | |
| 1408 | Writes the output into a tar archive. |
| 1409 | |
| 1410 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 1411 | =item B<--sigle|-sg> |
| 1412 | |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 1413 | Extract the given texts. |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 1414 | Can be set multiple times. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1415 | I<Currently only supported on C<extract>.> |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 1416 | Sigles have the structure C<Corpus>/C<Document>/C<Text>. |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 1417 | 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] | 1418 | On the document level, the postfix wildcard C<*> is supported. |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 1419 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1420 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1421 | =item B<--log|-l> |
| 1422 | |
| 1423 | The L<Log4perl> log level, defaults to C<ERROR>. |
| 1424 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1425 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1426 | =item B<--help|-h> |
| 1427 | |
Akron | 42f48c1 | 2020-02-14 13:08:13 +0100 | [diff] [blame] | 1428 | Print help information. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1429 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1430 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1431 | =item B<--version|-v> |
| 1432 | |
| 1433 | Print version information. |
| 1434 | |
| 1435 | =back |
| 1436 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1437 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1438 | =head1 ANNOTATION SUPPORT |
| 1439 | |
| 1440 | L<KorAP::XML::Krill> has built-in importer for some annotation foundries and layers |
| 1441 | developed in the KorAP project that are part of the KorAP preprocessing pipeline. |
| 1442 | The base foundry with paragraphs, sentences, and the text element are mandatory for |
| 1443 | L<Krill|https://github.com/KorAP/Krill>. |
| 1444 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1445 | Base |
| 1446 | #Paragraphs |
| 1447 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1448 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1449 | Connexor |
| 1450 | #Morpho |
| 1451 | #Phrase |
| 1452 | #Sentences |
| 1453 | #Syntax |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1454 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1455 | CoreNLP |
| 1456 | #Constituency |
| 1457 | #Morpho |
| 1458 | #NamedEntities |
| 1459 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1460 | |
Akron | ce125b6 | 2017-06-19 11:54:36 +0200 | [diff] [blame] | 1461 | CMC |
| 1462 | #Morpho |
| 1463 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1464 | DeReKo |
| 1465 | #Structure |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1466 | |
Akron | 57510c1 | 2019-01-04 14:58:53 +0100 | [diff] [blame] | 1467 | DGD |
| 1468 | #Morpho |
Akron | c29b8e1 | 2019-12-16 14:28:09 +0100 | [diff] [blame] | 1469 | #Structure |
Akron | 57510c1 | 2019-01-04 14:58:53 +0100 | [diff] [blame] | 1470 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1471 | DRuKoLa |
| 1472 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1473 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1474 | Glemm |
| 1475 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1476 | |
Akron | ea1aed5 | 2018-07-19 14:43:34 +0200 | [diff] [blame] | 1477 | HNC |
| 1478 | #Morpho |
| 1479 | |
Akron | 4c67919 | 2018-01-16 17:41:49 +0100 | [diff] [blame] | 1480 | LWC |
| 1481 | #Dependency |
| 1482 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1483 | Malt |
| 1484 | #Dependency |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1485 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1486 | MarMoT |
| 1487 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1488 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1489 | Mate |
| 1490 | #Dependency |
| 1491 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1492 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1493 | MDParser |
| 1494 | #Dependency |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1495 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1496 | OpenNLP |
| 1497 | #Morpho |
| 1498 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1499 | |
Akron | 07e2477 | 2020-04-23 14:00:54 +0200 | [diff] [blame] | 1500 | RWK |
| 1501 | #Morpho |
| 1502 | #Structure |
| 1503 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1504 | Sgbr |
| 1505 | #Lemma |
| 1506 | #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1507 | |
Akron | 7d5e638 | 2019-08-08 16:36:27 +0200 | [diff] [blame] | 1508 | Talismane |
| 1509 | #Dependency |
| 1510 | #Morpho |
| 1511 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1512 | TreeTagger |
| 1513 | #Morpho |
| 1514 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1515 | |
Akron | 821db3d | 2017-04-06 21:19:31 +0200 | [diff] [blame] | 1516 | XIP |
| 1517 | #Constituency |
| 1518 | #Morpho |
| 1519 | #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1520 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 1521 | |
| 1522 | More importers are in preparation. |
| 1523 | New annotation importers can be defined in the C<KorAP::XML::Annotation> namespace. |
| 1524 | See the built-in annotation importers as examples. |
| 1525 | |
Akron | f73ffb6 | 2018-06-27 12:13:59 +0200 | [diff] [blame] | 1526 | |
Akron | 8f69d63 | 2020-01-15 16:58:11 +0100 | [diff] [blame] | 1527 | =head1 About KorAP-XML |
| 1528 | |
| 1529 | KorAP-XML (Bański et al. 2012) is an implementation of the KorAP |
| 1530 | data model (Bański et al. 2013), where text data are stored physically |
| 1531 | separated from their interpretations (i.e. annotations). |
| 1532 | A text document in KorAP-XML therefore consists of several files |
| 1533 | containing primary data, metadata and annotations. |
| 1534 | |
| 1535 | The structure of a single KorAP-XML document can be as follows: |
| 1536 | |
| 1537 | - data.xml |
| 1538 | - header.xml |
| 1539 | + base |
| 1540 | - tokens.xml |
| 1541 | - ... |
| 1542 | + struct |
| 1543 | - structure.xml |
| 1544 | - ... |
| 1545 | + corenlp |
| 1546 | - morpho.xml |
| 1547 | - constituency.xml |
| 1548 | - ... |
| 1549 | + tree_tagger |
| 1550 | - morpho.xml |
| 1551 | - ... |
| 1552 | - ... |
| 1553 | |
| 1554 | The C<data.xml> contains the primary data, the C<header.xml> contains |
| 1555 | the metadata, and the annotation layers are stored in subfolders |
| 1556 | like C<base>, C<struct> or C<corenlp> |
| 1557 | (so-called "foundries"; Bański et al. 2013). |
| 1558 | |
| 1559 | Metadata is available in the TEI-P5 variant I5 |
Akron | d4c5c10 | 2020-02-11 11:47:59 +0100 | [diff] [blame] | 1560 | (Lüngen and Sperberg-McQueen 2012). See the documentation in |
| 1561 | L<KorAP::XML::Meta::I5> for translatable fields. |
| 1562 | |
| 1563 | Annotations correspond to a variant of the TEI-P5 feature structures |
| 1564 | (TEI Consortium; Lee et al. 2004). |
Akron | 72bc522 | 2020-02-06 16:00:13 +0100 | [diff] [blame] | 1565 | Annotation feature structures refer to character sequences of the primary text |
| 1566 | inside the C<text> element of the C<data.xml>. |
| 1567 | A single annotation containing the lemma of a token can have the following structure: |
| 1568 | |
| 1569 | <span from="0" to="3"> |
| 1570 | <fs type="lex" xmlns="http://www.tei-c.org/ns/1.0"> |
| 1571 | <f name="lex"> |
| 1572 | <fs> |
| 1573 | <f name="lemma">zum</f> |
| 1574 | </fs> |
| 1575 | </f> |
| 1576 | </fs> |
| 1577 | </span> |
| 1578 | |
| 1579 | The C<from> and C<to> attributes are refering to the character span |
| 1580 | in the primary text. |
| 1581 | Depending on the kind of annotation (e.g. token-based, span-based, relation-based), |
| 1582 | the structure may vary. See L<KorAP::XML::Annotation::*> for various |
| 1583 | annotation preprocessors. |
Akron | 8f69d63 | 2020-01-15 16:58:11 +0100 | [diff] [blame] | 1584 | |
| 1585 | Multiple KorAP-XML documents are organized on three levels following |
| 1586 | the "IDS Textmodell" (Lüngen and Sperberg-McQueen 2012): |
| 1587 | corpus E<gt> document E<gt> text. On each level metadata information |
| 1588 | can be stored, that C<korapxml2krill> will merge to a single metadata |
| 1589 | object per text. A corpus is therefore structured as follows: |
| 1590 | |
| 1591 | + <corpus> |
| 1592 | - header.xml |
| 1593 | + <document> |
| 1594 | - header.xml |
| 1595 | + <text> |
| 1596 | - data.xml |
| 1597 | - header.xml |
| 1598 | - ... |
| 1599 | - ... |
| 1600 | |
| 1601 | A single text can be identified by the concatenation of |
| 1602 | the corpus identifier, the document identifier and the text identifier. |
| 1603 | This identifier is called the text sigle |
| 1604 | (e.g. a text with the identifier C<18486> in the document C<060> in the |
| 1605 | corpus C<WPD17> has the text sigle C<WPD17/060/18486>, see C<--sigle>). |
| 1606 | |
| 1607 | These corpora are often stored in zip files, with which C<korapxml2krill> |
| 1608 | can deal with. Corpora may also be split in multiple zip archives |
| 1609 | (e.g. one zip file per foundry), which is also supported (see C<--input>). |
| 1610 | |
| 1611 | Examples for KorAP-XML files are included in L<KorAP::XML::Krill> |
| 1612 | in form of a test suite. |
| 1613 | The resulting JSON format merges all annotation layers |
| 1614 | based on a single token stream. |
| 1615 | |
| 1616 | =head2 References |
| 1617 | |
| 1618 | Piotr Bański, Cyril Belica, Helge Krause, Marc Kupietz, Carsten Schnober, Oliver Schonefeld, and Andreas Witt (2011): |
| 1619 | KorAP data model: first approximation, December. |
| 1620 | |
| 1621 | Piotr Bański, Peter M. Fischer, Elena Frick, Erik Ketzan, Marc Kupietz, Carsten Schnober, Oliver Schonefeld and Andreas Witt (2012): |
| 1622 | "The New IDS Corpus Analysis Platform: Challenges and Prospects", |
| 1623 | Proceedings of the Eighth International Conference on Language Resources and Evaluation (LREC 2012). |
| 1624 | L<PDF|http://www.lrec-conf.org/proceedings/lrec2012/pdf/789_Paper.pdf> |
| 1625 | |
| 1626 | Piotr Bański, Elena Frick, Michael Hanl, Marc Kupietz, Carsten Schnober and Andreas Witt (2013): |
| 1627 | "Robust corpus architecture: a new look at virtual collections and data access", |
| 1628 | Corpus Linguistics 2013. Abstract Book. Lancaster: UCREL, pp. 23-25. |
| 1629 | L<PDF|https://ids-pub.bsz-bw.de/frontdoor/deliver/index/docId/4485/file/Ba%c5%84ski_Frick_Hanl_Robust_corpus_architecture_2013.pdf> |
| 1630 | |
| 1631 | Kiyong Lee, Lou Burnard, Laurent Romary, Eric de la Clergerie, Thierry Declerck, |
| 1632 | Syd Bauman, Harry Bunt, Lionel Clément, Tomaz Erjavec, Azim Roussanaly and Claude Roux (2004): |
| 1633 | "Towards an international standard on featurestructure representation", |
| 1634 | Proceedings of the fourth International Conference on Language Resources and Evaluation (LREC 2004), |
| 1635 | pp. 373-376. |
| 1636 | L<PDF|http://www.lrec-conf.org/proceedings/lrec2004/pdf/687.pdf> |
| 1637 | |
| 1638 | Harald Lüngen and C. M. Sperberg-McQueen (2012): |
| 1639 | "A TEI P5 Document Grammar for the IDS Text Model", |
| 1640 | Journal of the Text Encoding Initiative, Issue 3 | November 2012. |
| 1641 | L<PDF|https://journals.openedition.org/jtei/pdf/508> |
| 1642 | |
| 1643 | TEI Consortium, eds: |
| 1644 | "Feature Structures", |
| 1645 | Guidelines for Electronic Text Encoding and Interchange. |
| 1646 | L<html|https://www.tei-c.org/release/doc/tei-p5-doc/en/html/FS.html> |
| 1647 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1648 | =head1 AVAILABILITY |
| 1649 | |
| 1650 | https://github.com/KorAP/KorAP-XML-Krill |
| 1651 | |
| 1652 | |
| 1653 | =head1 COPYRIGHT AND LICENSE |
| 1654 | |
Akron | 8f69d63 | 2020-01-15 16:58:11 +0100 | [diff] [blame] | 1655 | Copyright (C) 2015-2020, L<IDS Mannheim|https://www.ids-mannheim.de/> |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1656 | |
Akron | 8f69d63 | 2020-01-15 16:58:11 +0100 | [diff] [blame] | 1657 | Author: L<Nils Diewald|https://nils-diewald.de/> |
Akron | 8150010 | 2017-04-07 20:45:44 +0200 | [diff] [blame] | 1658 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1659 | Contributor: Eliza Margaretha |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1660 | |
| 1661 | L<KorAP::XML::Krill> is developed as part of the L<KorAP|http://korap.ids-mannheim.de/> |
| 1662 | Corpus Analysis Platform at the |
Akron | 94262ce | 2019-02-28 21:42:43 +0100 | [diff] [blame] | 1663 | L<Leibniz Institute for the German Language (IDS)|http://ids-mannheim.de/>, |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1664 | member of the |
Akron | f1849aa | 2019-12-16 23:35:33 +0100 | [diff] [blame] | 1665 | L<Leibniz-Gemeinschaft|http://www.leibniz-gemeinschaft.de/>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1666 | |
| 1667 | This program is free software published under the |
| 1668 | L<BSD-2 License|https://raw.githubusercontent.com/KorAP/KorAP-XML-Krill/master/LICENSE>. |
| 1669 | |
| 1670 | =cut |