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