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