Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 4 | use FindBin; |
| 5 | BEGIN { unshift @INC, "$FindBin::Bin/../lib" }; |
| 6 | use File::Spec::Functions qw/catfile catdir/; |
| 7 | use Getopt::Long qw/GetOptions :config no_auto_abbrev/; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 8 | use Benchmark qw/:hireswallclock/; |
| 9 | use IO::Compress::Gzip qw/$GzipError/; |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 10 | use POSIX qw/ceil/; |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 11 | use Log::Log4perl; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 12 | use Pod::Usage; |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 13 | use Cache::FastMmap; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 14 | use Directory::Iterator; |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 15 | use KorAP::XML::Krill; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 16 | use KorAP::XML::Archive; |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 17 | use KorAP::XML::Tokenizer; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 18 | use KorAP::XML::Batch::File; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 19 | use Parallel::ForkManager; |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 20 | use v5.10; |
| 21 | use Sys::Info; |
| 22 | use Sys::Info::Constants qw( :device_cpu ); |
| 23 | |
| 24 | # use KorAP::XML::ForkPool; |
Akron | 75ba57d | 2016-03-07 23:36:27 +0100 | [diff] [blame] | 25 | # TODO: use Parallel::Loops |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 26 | # TODO: make output files |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 27 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 28 | # TODO: Use KorAP::XML::ForkPool! |
| 29 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 30 | # CHANGES: |
| 31 | # ---------------------------------------------------------- |
| 32 | # 2013/11/25 |
| 33 | # - Initial release |
| 34 | # |
| 35 | # 2014/10/29 |
| 36 | # - Merges foundry data to create indexer friendly documents |
| 37 | # |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 38 | # 2016/02/04 |
| 39 | # - renamed to korapxml2krill |
| 40 | # - added Schreibgebrauch support |
Akron | 069bd71 | 2016-02-12 19:09:06 +0100 | [diff] [blame] | 41 | # |
| 42 | # 2016/02/12 |
| 43 | # - fixed foundry skipping |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 44 | # - Support overwrite in archive processing |
Akron | 150b29e | 2016-02-14 23:06:48 +0100 | [diff] [blame] | 45 | # |
| 46 | # 2016/02/14 |
| 47 | # - Added version information |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 48 | # - Added support for archive files |
| 49 | # |
| 50 | # 2016/02/15 |
| 51 | # - Fixed temporary directory bug |
| 52 | # - Improved skipping before unzipping |
| 53 | # - Added EXPERIMENTAL concurrency support |
| 54 | # |
| 55 | # 2016/02/23 |
| 56 | # - Merge korapxml2krill and korapxml2krill_dir |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 57 | # |
| 58 | # 2016/02/27 |
| 59 | # - Added extract function |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 60 | # |
| 61 | # 2016/03/17 |
| 62 | # - Added meta switch |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 63 | # |
| 64 | # 2016/03/18 |
| 65 | # - Added meta data caching |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 66 | # |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 67 | # 2016/06/27 |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 68 | # - Added multi archive support |
| 69 | # - Added prefix negation support |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 70 | # - Added Malt#Dependency support |
Akron | 8b99052 | 2016-07-06 16:45:57 +0200 | [diff] [blame] | 71 | # |
| 72 | # 2016/07/06 |
| 73 | # - Added MDParser#Dependency |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 74 | # |
| 75 | # 2016/10/15 |
Nils Diewald | 0e48977 | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 76 | # - Fixed temporary path issue in script |
| 77 | # |
| 78 | # 2016/10/24 |
| 79 | # - Improved Windows support |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 80 | # |
Akron | b4bbec7 | 2016-10-26 20:21:02 +0200 | [diff] [blame] | 81 | # 2016/10/24 |
| 82 | # - Added support for document extraction |
| 83 | # |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 84 | # 2016/10/27 |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 85 | # - Added wildcard support for document extraction |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 86 | # |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 87 | # 2016/12/21 |
| 88 | # - added support for base-sentences and base-tokenizations |
| 89 | # |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 90 | # 2017/01/20 |
| 91 | # - added support for DRuKoLa annotations |
| 92 | # |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 93 | # 2017/02/08 |
| 94 | # - added support for pagebreak annotations |
| 95 | # |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 96 | # ---------------------------------------------------------- |
Akron | 069bd71 | 2016-02-12 19:09:06 +0100 | [diff] [blame] | 97 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 98 | our $LAST_CHANGE = '2017/02/08'; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 99 | our $LOCAL = $FindBin::Bin; |
| 100 | our $VERSION_MSG = <<"VERSION"; |
| 101 | Version $KorAP::XML::Krill::VERSION - diewald\@ids-mannheim.de - $LAST_CHANGE |
| 102 | VERSION |
| 103 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 104 | # Parse comand |
| 105 | my $cmd; |
| 106 | our @ARGV; |
| 107 | if ($ARGV[0] && index($ARGV[0], '-') != 0) { |
| 108 | $cmd = shift @ARGV; |
Akron | 150b29e | 2016-02-14 23:06:48 +0100 | [diff] [blame] | 109 | }; |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 110 | |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 111 | my (@skip, @sigle, @anno, @input); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 112 | my $text; |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 113 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 114 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 115 | # Parse options from the command line |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 116 | GetOptions( |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 117 | 'input|i=s' => \@input, |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 118 | 'output|o=s' => \(my $output), |
| 119 | 'overwrite|w' => \(my $overwrite), |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 120 | 'meta|m=s' => \(my $meta), |
Akron | af38698 | 2016-10-12 00:33:25 +0200 | [diff] [blame] | 121 | 'token|t=s' => \(my $token_base = 'OpenNLP#tokens'), |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 122 | 'base-sentences|bs=s' => \(my $base_sentences = ''), |
| 123 | 'base-paragraphs|bp=s' => \(my $base_paragraphs = ''), |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 124 | 'base-pagebreaks|bpb=s' => \(my $base_pagebreaks = ''), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 125 | 'gzip|z' => \(my $gzip), |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 126 | 'skip|s=s' => \@skip, |
| 127 | 'sigle|sg=s' => \@sigle, |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 128 | 'cache|c=s' => \(my $cache_file = 'korapxml2krill.cache'), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 129 | 'log|l=s' => \(my $log_level = 'ERROR'), |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 130 | 'anno|a=s' => \@anno, |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 131 | 'primary|p!' => \(my $primary), |
| 132 | 'pretty|y' => \(my $pretty), |
| 133 | 'jobs|j=i' => \(my $jobs = 0), |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 134 | 'cache-size|cs=s' => \(my $cache_size = '50m'), |
| 135 | 'cache-delete|cd!' => \(my $cache_delete = 1), |
| 136 | 'cache-init|ci!' => \(my $cache_init = 1), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 137 | 'help|h' => sub { |
| 138 | pod2usage( |
| 139 | -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS', |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 140 | -verbose => 99, |
| 141 | -msg => $VERSION_MSG, |
| 142 | -output => '-' |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 143 | ); |
| 144 | }, |
| 145 | 'version|v' => sub { |
| 146 | pod2usage( |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 147 | -verbose => 0, |
| 148 | -msg => $VERSION_MSG, |
| 149 | -output => '-' |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 150 | ) |
| 151 | } |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 152 | ); |
| 153 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 154 | $base_sentences = lc $base_sentences; |
| 155 | $base_paragraphs = lc $base_paragraphs; |
Akron | 636bd9c | 2017-02-09 17:13:00 +0100 | [diff] [blame] | 156 | $base_pagebreaks = lc $base_pagebreaks; |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 157 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 158 | my %ERROR_HASH = ( |
| 159 | -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS', |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 160 | -verbose => 99, |
| 161 | -msg => $VERSION_MSG, |
| 162 | -output => '-', |
| 163 | -exit => 1 |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 164 | ); |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 165 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 166 | # Input has to be defined |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 167 | pod2usage(%ERROR_HASH) unless @input; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 168 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 169 | # Gzip has no effect, if no output is given |
| 170 | pod2usage(%ERROR_HASH) if $gzip && !$output; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 171 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 172 | # Initialize log4perl object |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 173 | Log::Log4perl->init({ |
| 174 | 'log4perl.rootLogger' => uc($log_level) . ', STDERR', |
| 175 | 'log4perl.appender.STDERR' => 'Log::Log4perl::Appender::ScreenColoredLevels', |
| 176 | 'log4perl.appender.STDERR.layout' => 'PatternLayout', |
| 177 | 'log4perl.appender.STDERR.layout.ConversionPattern' => '[%r] %F %L %c - %m%n' |
| 178 | }); |
| 179 | |
| 180 | my $log = Log::Log4perl->get_logger('main'); |
| 181 | |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 182 | |
| 183 | if ($jobs == -1) { |
| 184 | state $cores = Sys::Info->new->device('CPU')->count; |
| 185 | $jobs = ceil(5 * $cores); |
| 186 | $log->info("Run using $jobs jobs"); |
| 187 | }; |
| 188 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 189 | my %skip; |
| 190 | $skip{lc($_)} = 1 foreach @skip; |
| 191 | |
| 192 | my @layers; |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 193 | push(@layers, ['Base', 'Sentences']) unless $base_sentences; |
| 194 | push(@layers, ['Base', 'Paragraphs']) unless $base_paragraphs; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 195 | |
| 196 | # Connexor |
| 197 | push(@layers, ['Connexor', 'Morpho']); |
| 198 | push(@layers, ['Connexor', 'Syntax']); |
| 199 | push(@layers, ['Connexor', 'Phrase']); |
| 200 | push(@layers, ['Connexor', 'Sentences']); |
| 201 | |
| 202 | # CoreNLP |
| 203 | push(@layers, ['CoreNLP', 'NamedEntities']); |
| 204 | push(@layers, ['CoreNLP', 'Sentences']); |
| 205 | push(@layers, ['CoreNLP', 'Morpho']); |
| 206 | push(@layers, ['CoreNLP', 'Constituency']); |
| 207 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 208 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 209 | # DeReKo |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 210 | my @dereko_attr = (); |
| 211 | if ($base_sentences eq 'dereko#structure') { |
| 212 | push @dereko_attr, 'sentences'; |
| 213 | }; |
| 214 | if ($base_paragraphs eq 'dereko#structure') { |
| 215 | push @dereko_attr, 'paragraphs'; |
| 216 | }; |
Akron | 636bd9c | 2017-02-09 17:13:00 +0100 | [diff] [blame] | 217 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 218 | if ($base_pagebreaks eq 'dereko#structure') { |
| 219 | push @dereko_attr, 'pagebreaks'; |
| 220 | }; |
| 221 | |
| 222 | if ($dereko_attr[0]) { |
| 223 | push(@layers, ['DeReKo', 'Structure', 'base-' . join('-', @dereko_attr)]); |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 224 | } |
| 225 | else { |
| 226 | push(@layers, ['DeReKo', 'Structure']); |
| 227 | }; |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 228 | |
| 229 | # Glemm |
| 230 | push(@layers, ['Glemm', 'Morpho']); |
| 231 | |
| 232 | # Malt |
| 233 | push(@layers, ['Malt', 'Dependency']); |
| 234 | |
| 235 | # MDParser |
| 236 | push(@layers, ['MDParser', 'Dependency']); |
| 237 | |
| 238 | # Mate |
| 239 | push(@layers, ['Mate', 'Morpho']); |
| 240 | push(@layers, ['Mate', 'Dependency']); |
| 241 | |
| 242 | # OpenNLP |
| 243 | push(@layers, ['OpenNLP', 'Morpho']); |
| 244 | push(@layers, ['OpenNLP', 'Sentences']); |
| 245 | |
| 246 | # Schreibgebrauch |
| 247 | push(@layers, ['Sgbr', 'Lemma']); |
| 248 | push(@layers, ['Sgbr', 'Morpho']); |
| 249 | |
| 250 | # TreeTagger |
| 251 | push(@layers, ['TreeTagger', 'Morpho']); |
| 252 | push(@layers, ['TreeTagger', 'Sentences']); |
| 253 | |
| 254 | # XIP |
| 255 | push(@layers, ['XIP', 'Morpho']); |
| 256 | push(@layers, ['XIP', 'Constituency']); |
| 257 | push(@layers, ['XIP', 'Sentences']); |
| 258 | push(@layers, ['XIP', 'Dependency']); |
| 259 | |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 260 | # DRuKoLa |
| 261 | push(@layers, ['DRuKoLa', 'Morpho']); |
| 262 | |
Akron | 3bd942f | 2017-02-20 20:09:14 +0100 | [diff] [blame] | 263 | # Marmot |
| 264 | push(@layers, ['MarMoT', 'Morpho']); |
| 265 | |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 266 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 267 | # Check filters |
| 268 | my @filtered_anno; |
| 269 | if ($skip{'#all'}) { |
| 270 | foreach (@anno) { |
| 271 | push @filtered_anno, [ split('#', $_) ]; |
| 272 | }; |
| 273 | } |
| 274 | |
| 275 | # Add all annotations that are not skipped |
| 276 | else { |
| 277 | # Add to index file - respect skipping |
| 278 | foreach my $info (@layers) { |
| 279 | # Skip if Foundry or Foundry#Layer should be skipped |
| 280 | unless ($skip{lc($info->[0])} || $skip{lc($info->[0]) . '#' . lc($info->[1])}) { |
| 281 | push @filtered_anno, $info; |
| 282 | }; |
| 283 | }; |
| 284 | }; |
| 285 | |
| 286 | # Get tokenization basis |
| 287 | my ($token_base_foundry, $token_base_layer) = split(/#/, $token_base) if ($token_base); |
| 288 | |
| 289 | # TODO: This should not be initialized for batch |
| 290 | my $cache = Cache::FastMmap->new( |
| 291 | share_file => $cache_file, |
| 292 | cache_size => $cache_size, |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 293 | init_file => $cache_init |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 294 | ); |
| 295 | |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 296 | # Create batch object |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 297 | my $batch_file = KorAP::XML::Batch::File->new( |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 298 | cache => $cache, |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 299 | meta_type => $meta, |
| 300 | overwrite => $overwrite, |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 301 | foundry => $token_base_foundry, |
| 302 | layer => $token_base_layer, |
| 303 | gzip => $gzip, |
| 304 | log => $log, |
| 305 | primary => $primary, |
| 306 | pretty => $pretty, |
| 307 | anno => \@filtered_anno |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 308 | ); |
| 309 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 310 | |
| 311 | # Get file name based on path information |
| 312 | sub get_file_name ($) { |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 313 | my $i = $input[0]; |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 314 | if (-d $i) { |
| 315 | $i =~ s![^\/]+$!!; |
| 316 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 317 | my $file = shift; |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 318 | |
| 319 | # Remove temp dir fragments |
Akron | 6255760 | 2016-06-27 14:10:13 +0200 | [diff] [blame] | 320 | $file =~ s!^/?tmp/[^/]+!!; |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 321 | $file =~ s/^?\/?$i//; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 322 | $file =~ tr/\//-/; |
| 323 | $file =~ s{^-+}{}; |
Akron | b4bbec7 | 2016-10-26 20:21:02 +0200 | [diff] [blame] | 324 | $file =~ s/^.*?-(.+?-.+?-.+?)$/$1/; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 325 | return $file; |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 326 | }; |
| 327 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 328 | # Convert sigle to path construct |
| 329 | s!^\s*([^_]+?)_([^\.]+?)\.(.+?)\s*$!$1/$2/$3! foreach @sigle; |
| 330 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 331 | if ($cmd) { |
| 332 | if ($output && (!-e $output || !-d $output)) { |
| 333 | print "Directory '$output' does not exist.\n\n"; |
| 334 | exit(0); |
| 335 | }; |
| 336 | }; |
| 337 | |
| 338 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 339 | # Process a single file |
| 340 | unless ($cmd) { |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 341 | my $input = $input[0]; |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 342 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 343 | BEGIN { |
| 344 | $main::TIME = Benchmark->new; |
| 345 | $main::LAST_STOP = Benchmark->new; |
| 346 | }; |
| 347 | |
| 348 | sub stop_time { |
| 349 | my $new = Benchmark->new; |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 350 | $log->info( |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 351 | 'The code took: '. |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 352 | timestr(timediff($new, $main::LAST_STOP)) . |
| 353 | ' (overall: ' . timestr(timediff($new, $main::TIME)) . ')' |
| 354 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 355 | $main::LAST_STOP = $new; |
| 356 | }; |
| 357 | |
| 358 | # Create and parse new document |
| 359 | $input =~ s{([^/])$}{$1/}; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 360 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 361 | # Process file |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 362 | $batch_file->process($input, $output); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 363 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 364 | # Delete cache file |
| 365 | unlink($cache_file) if $cache_delete; |
| 366 | |
Akron | 5f51d42 | 2016-08-16 16:26:43 +0200 | [diff] [blame] | 367 | stop_time; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 368 | } |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 369 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 370 | # Extract XML files |
| 371 | elsif ($cmd eq 'extract') { |
| 372 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 373 | # Create new archive object |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 374 | if (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 375 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 376 | # Check zip capabilities |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 377 | unless ($archive->test_unzip) { |
| 378 | print "Unzip is not installed or incompatible.\n\n"; |
| 379 | exit(1); |
| 380 | }; |
| 381 | |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 382 | # Add further annotation archived |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 383 | $archive->attach($_) foreach @input[1..$#input]; |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 384 | |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 385 | my $prefix = 1; |
| 386 | |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 387 | # No sigles given |
| 388 | unless (@sigle) { |
| 389 | |
| 390 | # Get files |
| 391 | foreach ($archive->list_texts) { |
| 392 | |
| 393 | # Split path information |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 394 | ($prefix, my ($corpus, $doc, $text)) = $archive->split_path($_); |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 395 | |
| 396 | # TODO: Make this OS independent |
| 397 | push @sigle, join '/', $corpus, $doc, $text; |
| 398 | }; |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | # Check sigle for doc sigles |
| 402 | else { |
| 403 | my @new_sigle; |
| 404 | |
| 405 | my $prefix_check = 0; |
| 406 | |
| 407 | # Iterate over all sigle |
| 408 | foreach (@sigle) { |
| 409 | |
| 410 | # Sigle is a doc sigle |
| 411 | if ($_ =~ m!^(?:\.[/\\])?[^/\\]+?[/\\][^/\\]+?$!) { |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 412 | |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 413 | print "$_ ..."; |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 414 | # Check if a prefix is needed |
| 415 | unless ($prefix_check) { |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 416 | |
| 417 | if ($prefix = $archive->check_prefix) { |
| 418 | print " with prefix ..."; |
| 419 | }; |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 420 | $prefix_check = 1; |
| 421 | }; |
| 422 | |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 423 | print "\n"; |
| 424 | |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 425 | # TODO: Make this OS independent |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 426 | my $path = ($prefix ? './' : '') . $_; |
| 427 | |
| 428 | print '... ' . ( |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 429 | $archive->extract_doc( |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 430 | $path, $output, $jobs |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 431 | ) ? '' : 'not ' |
| 432 | ); |
| 433 | print "extracted.\n"; |
| 434 | } |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 435 | |
| 436 | # Sigle is a text sigle |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 437 | else { |
| 438 | push @new_sigle, $_; |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 439 | |
| 440 | unless ($prefix_check) { |
| 441 | |
| 442 | if ($prefix = $archive->check_prefix) { |
| 443 | print " with prefix ..."; |
| 444 | }; |
| 445 | $prefix_check = 1; |
| 446 | }; |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 447 | }; |
| 448 | }; |
| 449 | @sigle = @new_sigle; |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 450 | }; |
| 451 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 452 | # Iterate over all given sigles and extract |
| 453 | foreach (@sigle) { |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 454 | |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 455 | print "$_ ...\n"; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 456 | |
Akron | 03b24db | 2016-08-16 20:54:32 +0200 | [diff] [blame] | 457 | # TODO: Make this OS independent |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 458 | print '... ' . ( |
Akron | 60a8caa | 2017-02-17 21:51:27 +0100 | [diff] [blame] | 459 | |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 460 | $archive->extract_text( |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 461 | ($prefix ? './' : '') . $_, $output |
| 462 | ) ? '' : 'not ' |
| 463 | ); |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 464 | print "extracted.\n"; |
| 465 | }; |
| 466 | |
| 467 | print "\n"; |
| 468 | exit(1); |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 469 | } |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 470 | |
| 471 | # Can't create archive object |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 472 | else { |
| 473 | $log->error('Unable to extract from primary archive ' . $input[0]); |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 474 | }; |
| 475 | } |
| 476 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 477 | # Process an archive |
| 478 | elsif ($cmd eq 'archive') { |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 479 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 480 | # TODO: Support sigles |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 481 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 482 | # Zero means: everything runs in the parent process |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 483 | my $pool = Parallel::ForkManager->new($jobs); |
| 484 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 485 | my $count = 0; # Texts to process |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 486 | my $iter = 1; # Current text in process |
| 487 | |
| 488 | # Report on fork message |
| 489 | $pool->run_on_finish ( |
| 490 | sub { |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 491 | my ($pid, $code) = @_; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 492 | my $data = pop; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 493 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 494 | print 'Convert ['. ($jobs > 0 ? "\$$pid:" : '') . |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 495 | ($iter++) . "/$count]" . |
| 496 | ($code ? " $code" : '') . |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 497 | ' ' . $data->[0] . "\n"; |
| 498 | $data->[1] = undef if $data->[1]; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 499 | } |
| 500 | ); |
| 501 | |
| 502 | my $t; |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 503 | my $temp; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 504 | print "Reading data ...\n"; |
| 505 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 506 | # unless (Cache::FastMmap->new( |
| 507 | # share_file => $cache_file, |
| 508 | # cache_size => $cache_size, |
| 509 | # init_file => $cache_init |
| 510 | # )) { |
| 511 | # print "Unable to intialize cache '$cache_file'\n\n"; |
| 512 | # exit(1); |
| 513 | # }; |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 514 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 515 | # Input is a directory |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 516 | if (-d $input[0]) { |
| 517 | my $it = Directory::Iterator->new($input[0]); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 518 | my @dirs; |
| 519 | my $dir; |
| 520 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 521 | # Todo: Make a DO WHILE |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 522 | while (1) { |
| 523 | if (!$it->is_directory && ($dir = $it->get) && $dir =~ s{/data\.xml$}{}) { |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 524 | push @dirs, $dir; |
| 525 | $it->prune; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 526 | }; |
| 527 | last unless $it->next; |
| 528 | }; |
| 529 | |
| 530 | print "Start processing ...\n"; |
| 531 | $t = Benchmark->new; |
| 532 | $count = scalar @dirs; |
| 533 | |
| 534 | DIRECTORY_LOOP: |
| 535 | for (my $i = 0; $i < $count; $i++) { |
| 536 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 537 | my $filename = catfile( |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 538 | $output, |
| 539 | get_file_name($dirs[$i]) . '.json' . ($gzip ? '.gz' : '') |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 540 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 541 | |
| 542 | # Get the next fork |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 543 | $pool->start and next DIRECTORY_LOOP; |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 544 | |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 545 | if (my $return = $batch_file->process($dirs[$i] => $filename)) { |
| 546 | $pool->finish( |
| 547 | 0, |
| 548 | ["Processed " . $filename . ($return == -1 ? " - already existing" : '')] |
| 549 | ); |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 550 | } |
| 551 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 552 | $pool->finish(1, ["Unable to process " . $dirs[$i]]); |
Akron | 3ec4897 | 2016-08-17 23:24:52 +0200 | [diff] [blame] | 553 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 554 | }; |
| 555 | } |
| 556 | |
| 557 | # Input is a file |
Akron | 29866ac | 2016-06-24 16:40:47 +0200 | [diff] [blame] | 558 | elsif (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 559 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 560 | unless ($archive->test_unzip) { |
| 561 | print "Unzip is not installed or incompatible.\n\n"; |
| 562 | exit(1); |
| 563 | }; |
| 564 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 565 | # Add further annotation archived |
Akron | 2812ba2 | 2016-10-28 21:55:59 +0200 | [diff] [blame] | 566 | $archive->attach($_) foreach @input[1..$#input]; |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 567 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 568 | print "Start processing ...\n"; |
| 569 | $t = Benchmark->new; |
| 570 | my @dirs = $archive->list_texts; |
| 571 | $count = scalar @dirs; |
| 572 | |
| 573 | ARCHIVE_LOOP: |
| 574 | for (my $i = 0; $i < $count; $i++) { |
| 575 | |
| 576 | # Split path information |
| 577 | my ($prefix, $corpus, $doc, $text) = $archive->split_path($dirs[$i]); |
| 578 | |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 579 | my $filename = catfile( |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 580 | $output, |
| 581 | get_file_name( |
| 582 | catfile($corpus, $doc, $text) |
| 583 | . '.json' . ($gzip ? '.gz' : '') |
| 584 | ) |
Akron | e1dbc38 | 2016-07-08 22:24:52 +0200 | [diff] [blame] | 585 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 586 | |
| 587 | # Get the next fork |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 588 | $pool->start and next ARCHIVE_LOOP; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 589 | |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 590 | # Create temporary file |
| 591 | $temp = File::Temp->newdir; |
| 592 | |
Akron | bdf434a | 2016-10-24 17:42:07 +0200 | [diff] [blame] | 593 | # TODO: Check if $filename exist at the beginning, |
| 594 | # because extraction can be horrible slow! |
| 595 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 596 | # Extract from archive |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 597 | if ($archive->extract_text($dirs[$i], $temp)) { |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 598 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 599 | # Create corpus directory |
| 600 | my $input = catdir("$temp", $corpus); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 601 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 602 | # Temporary directory |
| 603 | my $dir = catdir($input, $doc, $text); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 604 | |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 605 | # Write file |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 606 | if (my $return = $batch_file->process($dir => $filename)) { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 607 | # Delete temporary file |
Akron | 13d5662 | 2016-10-31 14:54:49 +0100 | [diff] [blame] | 608 | $pool->finish( |
| 609 | 0, |
| 610 | ["Processed " . $filename . ($return == -1 ? " - already existing" : ''), $temp] |
| 611 | ); |
| 612 | #$pool->finish(0, ["Processed " . $filename, $temp]); |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 613 | } |
| 614 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 615 | # Delete temporary file |
| 616 | $pool->finish(1, ["Unable to process " . $dir, $temp]); |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 617 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 618 | } |
Akron | 7d4cdd8 | 2016-08-17 21:39:45 +0200 | [diff] [blame] | 619 | |
| 620 | # Unable to extract |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 621 | else { |
Akron | 4c0cf31 | 2016-10-15 16:42:09 +0200 | [diff] [blame] | 622 | $pool->finish(1, ["Unable to extract " . $dirs[$i], $temp]); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 623 | }; |
| 624 | }; |
| 625 | } |
| 626 | |
| 627 | else { |
| 628 | print "Input is neither a directory nor an archive.\n\n"; |
| 629 | }; |
| 630 | |
| 631 | $pool->wait_all_children; |
| 632 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 633 | # Delete cache file |
| 634 | unlink($cache_file) if $cache_delete; |
| 635 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 636 | print "Done.\n"; |
| 637 | print timestr(timediff(Benchmark->new, $t))."\n\n"; |
| 638 | } |
| 639 | |
| 640 | # Unknown command |
| 641 | else { |
| 642 | warn "Unknown command '$cmd'.\n\n"; |
| 643 | pod2usage(%ERROR_HASH); |
| 644 | } |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 645 | |
| 646 | __END__ |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 647 | |
| 648 | =pod |
| 649 | |
| 650 | =encoding utf8 |
| 651 | |
| 652 | =head1 NAME |
| 653 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 654 | korapxml2krill - Merge KorapXML data and create Krill documents |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 655 | |
| 656 | |
| 657 | =head1 SYNOPSIS |
| 658 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 659 | korapxml2krill [archive|extract] --input <directory|archive> [options] |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 660 | |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 661 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 662 | =head1 DESCRIPTION |
| 663 | |
| 664 | L<KorAP::XML::Krill> is a library to convert KorAP-XML documents to files |
| 665 | compatible with the L<Krill|https://github.com/KorAP/Krill> indexer. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 666 | The C<korapxml2krill> command line tool is a simple wrapper to the library. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 667 | |
| 668 | |
| 669 | =head1 INSTALLATION |
| 670 | |
| 671 | The preferred way to install L<KorAP::XML::Krill> is to use L<cpanm|App::cpanminus>. |
| 672 | |
Akron | af38698 | 2016-10-12 00:33:25 +0200 | [diff] [blame] | 673 | $ cpanm https://github.com/KorAP/KorAP-XML-Krill.git |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 674 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 675 | In case everything went well, the C<korapxml2krill> tool will |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 676 | be available on your command line immediately. |
Akron | 7438151 | 2016-10-14 11:56:22 +0200 | [diff] [blame] | 677 | Minimum requirement for L<KorAP::XML::Krill> is Perl 5.14. |
Akron | a93d51b | 2016-10-24 20:27:48 +0200 | [diff] [blame] | 678 | 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] | 679 | |
| 680 | =head1 ARGUMENTS |
| 681 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 682 | $ korapxml2krill -z --input <directory> --output <filename> |
| 683 | |
| 684 | Without arguments, C<korapxml2krill> converts a directory of a single KorAP-XML document. |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 685 | It expects the input to point to the text level folder. |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 686 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 687 | =over 2 |
| 688 | |
| 689 | =item B<archive> |
| 690 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 691 | $ korapxml2krill archive -z --input <directory|archive> --output <directory> |
| 692 | |
Akron | 2fd402b | 2016-10-27 21:26:48 +0200 | [diff] [blame] | 693 | Converts an archive of KorAP-XML documents. It expects a directory |
| 694 | (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] | 695 | |
| 696 | =item B<extract> |
| 697 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 698 | $ korapxml2krill extract --input <archive> --output <directory> --sigle <SIGLE> |
| 699 | |
| 700 | Extracts KorAP-XML documents from a zip file. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 701 | |
| 702 | =back |
| 703 | |
| 704 | |
| 705 | =head1 OPTIONS |
| 706 | |
| 707 | =over 2 |
| 708 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 709 | =item B<--input|-i> <directory|zip file> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 710 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 711 | Directory or zip file(s) of documents to convert. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 712 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 713 | Without arguments, C<korapxml2krill> expects a folder of a single KorAP-XML |
Akron | f1a1de9 | 2016-11-02 17:32:12 +0100 | [diff] [blame] | 714 | document, while C<archive> expects a KorAP-XML corpus folder or a zip |
| 715 | file to batch process multiple files. |
| 716 | C<extract> expects zip files only. |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 717 | |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 718 | C<archive> supports multiple input zip files with the constraint, |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 719 | that the first archive listed contains all primary data files |
| 720 | and all meta data files. |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 721 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 722 | -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] | 723 | |
Akron | 0c3e375 | 2016-06-28 15:55:53 +0200 | [diff] [blame] | 724 | (The directory structure follows the base directory format, |
| 725 | that may include a C<.> root folder. |
| 726 | In this case further archives lacking a C<.> root folder |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 727 | need to be passed with a hash sign in front of the archive's name. |
| 728 | This may require to quote the parameter.) |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 729 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 730 | To support zip files, a version of C<unzip> needs to be installed that is |
| 731 | compatible with the archive file. |
Akron | a93d51b | 2016-10-24 20:27:48 +0200 | [diff] [blame] | 732 | |
Akron | 7606afa | 2016-10-25 16:23:49 +0200 | [diff] [blame] | 733 | B<The root folder switch using the hash sign is experimental and |
| 734 | may vanish in future versions.> |
Akron | 651cb8d | 2016-08-16 21:44:49 +0200 | [diff] [blame] | 735 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 736 | =item B<--output|-o> <directory|file> |
| 737 | |
| 738 | Output folder for archive processing or |
| 739 | document name for single output (optional), |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 740 | writes to C<STDOUT> by default |
| 741 | (in case C<output> is not mandatory due to further options). |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 742 | |
| 743 | =item B<--overwrite|-w> |
| 744 | |
| 745 | Overwrite files that already exist. |
| 746 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 747 | =item B<--token|-t> <foundry>#<file> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 748 | |
| 749 | Define the default tokenization by specifying |
| 750 | the name of the foundry and optionally the name |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 751 | of the layer-file. Defaults to C<OpenNLP#tokens>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 752 | |
Akron | 3741f8b | 2016-12-21 19:55:21 +0100 | [diff] [blame] | 753 | |
| 754 | =item B<--base-sentences|-bs> <foundry>#<layer> |
| 755 | |
| 756 | Define the layer for base sentences. |
| 757 | If given, this will be used instead of using C<Base#Sentences>. |
| 758 | Currently C<DeReKo#Structure> is the only additional layer supported. |
| 759 | |
| 760 | Defaults to unset. |
| 761 | |
| 762 | |
| 763 | =item B<--base-paragraphs|-bp> <foundry>#<layer> |
| 764 | |
| 765 | Define the layer for base paragraphs. |
| 766 | If given, this will be used instead of using C<Base#Paragraphs>. |
| 767 | Currently C<DeReKo#Structure> is the only additional layer supported. |
| 768 | |
| 769 | Defaults to unset. |
| 770 | |
| 771 | |
Akron | 41ac10b | 2017-02-08 22:47:25 +0100 | [diff] [blame] | 772 | =item B<--base-pagebreaks|-bpb> <foundry>#<layer> |
| 773 | |
| 774 | Define the layer for base pagebreaks. |
| 775 | Currently C<DeReKo#Structure> is the only layer supported. |
| 776 | |
| 777 | Defaults to unset. |
| 778 | |
| 779 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 780 | =item B<--skip|-s> <foundry>[#<layer>] |
| 781 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 782 | Skip specific annotations by specifying the foundry |
| 783 | (and optionally the layer with a C<#>-prefix), |
| 784 | 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] | 785 | Can be set multiple times. |
| 786 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 787 | =item B<--anno|-a> <foundry>#<layer> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 788 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 789 | Convert specific annotations by specifying the foundry |
| 790 | (and optionally the layer with a C<#>-prefix), |
| 791 | e.g. C<Mate> or C<Mate#Morpho>. |
| 792 | Can be set multiple times. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 793 | |
| 794 | =item B<--primary|-p> |
| 795 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 796 | Output primary data or not. Defaults to C<true>. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 797 | Can be flagged using C<--no-primary> as well. |
| 798 | This is I<deprecated>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 799 | |
| 800 | =item B<--jobs|-j> |
| 801 | |
| 802 | Define the number of concurrent jobs in seperated forks |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 803 | for archive processing. |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 804 | Defaults to C<0> (everything runs in a single process). |
Akron | c11f798 | 2017-02-21 21:20:14 +0100 | [diff] [blame] | 805 | Pass -1, and the value will be set automatically to 5 |
| 806 | times the number of available cores. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 807 | This is I<experimental>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 808 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 809 | =item B<--meta|-m> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 810 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 811 | Define the metadata parser to use. Defaults to C<I5>. |
| 812 | Metadata parsers can be defined in the C<KorAP::XML::Meta> namespace. |
| 813 | This is I<experimental>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 814 | |
| 815 | =item B<--pretty|-y> |
| 816 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 817 | Pretty print JSON output. Defaults to C<false>. |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 818 | This is I<deprecated>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 819 | |
| 820 | =item B<--gzip|-z> |
| 821 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 822 | Compress the output. |
| 823 | Expects a defined C<output> file in single processing. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 824 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 825 | =item B<--cache|-c> |
| 826 | |
| 827 | File to mmap a cache (using L<Cache::FastMmap>). |
| 828 | Defaults to C<korapxml2krill.cache> in the calling directory. |
| 829 | |
| 830 | =item B<--cache-size|-cs> |
| 831 | |
| 832 | Size of the cache. Defaults to C<50m>. |
| 833 | |
| 834 | =item B<--cache-init|-ci> |
| 835 | |
| 836 | Initialize cache file. |
| 837 | Can be flagged using C<--no-cache-init> as well. |
| 838 | Defaults to C<true>. |
| 839 | |
| 840 | =item B<--cache-delete|-cd> |
| 841 | |
| 842 | Delete cache file after processing. |
| 843 | Can be flagged using C<--no-cache-delete> as well. |
| 844 | Defaults to C<true>. |
| 845 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 846 | =item B<--sigle|-sg> |
| 847 | |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 848 | Extract the given texts. |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 849 | Can be set multiple times. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 850 | I<Currently only supported on C<extract>.> |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 851 | Sigles have the structure C<Corpus>/C<Document>/C<Text>. |
Akron | 2080758 | 2016-10-26 17:11:34 +0200 | [diff] [blame] | 852 | 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] | 853 | On the document level, the postfix wildcard C<*> is supported. |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 854 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 855 | =item B<--log|-l> |
| 856 | |
| 857 | The L<Log4perl> log level, defaults to C<ERROR>. |
| 858 | |
| 859 | =item B<--help|-h> |
| 860 | |
| 861 | Print this document. |
| 862 | |
| 863 | =item B<--version|-v> |
| 864 | |
| 865 | Print version information. |
| 866 | |
| 867 | =back |
| 868 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 869 | =head1 ANNOTATION SUPPORT |
| 870 | |
| 871 | L<KorAP::XML::Krill> has built-in importer for some annotation foundries and layers |
| 872 | developed in the KorAP project that are part of the KorAP preprocessing pipeline. |
| 873 | The base foundry with paragraphs, sentences, and the text element are mandatory for |
| 874 | L<Krill|https://github.com/KorAP/Krill>. |
| 875 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 876 | =over 2 |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 877 | |
| 878 | =item B<Base> |
| 879 | |
| 880 | =over 4 |
| 881 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 882 | =item #Paragraphs |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 883 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 884 | =item #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 885 | |
| 886 | =back |
| 887 | |
| 888 | =item B<Connexor> |
| 889 | |
| 890 | =over 4 |
| 891 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 892 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 893 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 894 | =item #Phrase |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 895 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 896 | =item #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 897 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 898 | =item #Syntax |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 899 | |
| 900 | =back |
| 901 | |
| 902 | =item B<CoreNLP> |
| 903 | |
| 904 | =over 4 |
| 905 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 906 | =item #Constituency |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 907 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 908 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 909 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 910 | =item #NamedEntities |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 911 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 912 | =item #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 913 | |
| 914 | =back |
| 915 | |
| 916 | =item B<DeReKo> |
| 917 | |
| 918 | =over 4 |
| 919 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 920 | =item #Structure |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 921 | |
| 922 | =back |
| 923 | |
| 924 | =item B<Glemm> |
| 925 | |
| 926 | =over 4 |
| 927 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 928 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 929 | |
| 930 | =back |
| 931 | |
| 932 | =item B<Mate> |
| 933 | |
| 934 | =over 4 |
| 935 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 936 | =item #Dependency |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 937 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 938 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 939 | |
| 940 | =back |
| 941 | |
| 942 | =item B<OpenNLP> |
| 943 | |
| 944 | =over 4 |
| 945 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 946 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 947 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 948 | =item #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 949 | |
| 950 | =back |
| 951 | |
| 952 | =item B<Sgbr> |
| 953 | |
| 954 | =over 4 |
| 955 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 956 | =item #Lemma |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 957 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 958 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 959 | |
| 960 | =back |
| 961 | |
Akron | 4fa37c3 | 2017-01-20 14:43:10 +0100 | [diff] [blame] | 962 | =item B<DRuKoLa> |
| 963 | |
| 964 | =over 4 |
| 965 | |
| 966 | =item #Morpho |
| 967 | |
| 968 | =back |
| 969 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 970 | =item B<TreeTagger> |
| 971 | |
| 972 | =over 4 |
| 973 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 974 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 975 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 976 | =item #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 977 | |
| 978 | =back |
| 979 | |
| 980 | =item B<XIP> |
| 981 | |
| 982 | =over 4 |
| 983 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 984 | =item #Constituency |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 985 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 986 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 987 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 988 | =item #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 989 | |
| 990 | =back |
| 991 | |
| 992 | =back |
| 993 | |
| 994 | More importers are in preparation. |
| 995 | New annotation importers can be defined in the C<KorAP::XML::Annotation> namespace. |
| 996 | See the built-in annotation importers as examples. |
| 997 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 998 | =head1 AVAILABILITY |
| 999 | |
| 1000 | https://github.com/KorAP/KorAP-XML-Krill |
| 1001 | |
| 1002 | |
| 1003 | =head1 COPYRIGHT AND LICENSE |
| 1004 | |
Akron | 3ec0a1c | 2017-01-18 14:41:55 +0100 | [diff] [blame] | 1005 | Copyright (C) 2015-2017, L<IDS Mannheim|http://www.ids-mannheim.de/> |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 1006 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1007 | Author: L<Nils Diewald|http://nils-diewald.de/> |
Akron | a76d835 | 2016-10-27 16:27:32 +0200 | [diff] [blame] | 1008 | Contributor: Eliza Margaretha |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 1009 | |
| 1010 | L<KorAP::XML::Krill> is developed as part of the L<KorAP|http://korap.ids-mannheim.de/> |
| 1011 | Corpus Analysis Platform at the |
| 1012 | L<Institute for the German Language (IDS)|http://ids-mannheim.de/>, |
| 1013 | member of the |
| 1014 | L<Leibniz-Gemeinschaft|http://www.leibniz-gemeinschaft.de/en/about-us/leibniz-competition/projekte-2011/2011-funding-line-2/>. |
| 1015 | |
| 1016 | This program is free software published under the |
| 1017 | L<BSD-2 License|https://raw.githubusercontent.com/KorAP/KorAP-XML-Krill/master/LICENSE>. |
| 1018 | |
| 1019 | =cut |