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