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