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