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 | 405f0c5 | 2016-07-07 17:56:16 +0200 | [diff] [blame^] | 17 | use KorAP::XML::ProcessFile; |
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 | 8b99052 | 2016-07-06 16:45:57 +0200 | [diff] [blame] | 68 | our $LAST_CHANGE = '2016/07/06'; |
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 | |
| 74 | |
| 75 | # Parse comand |
| 76 | my $cmd; |
| 77 | our @ARGV; |
| 78 | if ($ARGV[0] && index($ARGV[0], '-') != 0) { |
| 79 | $cmd = shift @ARGV; |
Akron | 150b29e | 2016-02-14 23:06:48 +0100 | [diff] [blame] | 80 | }; |
Akron | 93d620e | 2016-02-05 19:40:05 +0100 | [diff] [blame] | 81 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 82 | my (@skip, @sigle, @input); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 83 | my $text; |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 84 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 85 | # Parse options from the command line |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 86 | GetOptions( |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 87 | 'input|i=s' => \@input, |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 88 | 'output|o=s' => \(my $output), |
| 89 | 'overwrite|w' => \(my $overwrite), |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 90 | 'meta|m=s' => \(my $meta), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 91 | 'token|t=s' => \(my $token_base), |
| 92 | 'gzip|z' => \(my $gzip), |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 93 | 'skip|s=s' => \@skip, |
| 94 | 'sigle|sg=s' => \@sigle, |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 95 | 'cache|c=s' => \(my $cache_file = 'korapxml2krill.cache'), |
| 96 | 'cache-size|cs=s' => \(my $cache_size = '50m'), |
| 97 | 'cache-delete|cd!' => \(my $cache_delete = 1), |
| 98 | 'cache-init|ci!' => \(my $cache_init = 1), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 99 | 'log|l=s' => \(my $log_level = 'ERROR'), |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 100 | 'anno|a=s' => \(my @anno), |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 101 | 'primary|p!' => \(my $primary), |
| 102 | 'pretty|y' => \(my $pretty), |
| 103 | 'jobs|j=i' => \(my $jobs = 0), |
| 104 | 'help|h' => sub { |
| 105 | pod2usage( |
| 106 | -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS', |
| 107 | -verbose => 99, |
| 108 | -msg => $VERSION_MSG, |
| 109 | ); |
| 110 | }, |
| 111 | 'version|v' => sub { |
| 112 | pod2usage( |
| 113 | -verbose => 0, |
| 114 | -msg => $VERSION_MSG |
| 115 | ) |
| 116 | } |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 117 | ); |
| 118 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 119 | my %ERROR_HASH = ( |
| 120 | -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS', |
| 121 | -verbose => 99, |
| 122 | -msg => $VERSION_MSG, |
| 123 | -exit => 1 |
| 124 | ); |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 125 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 126 | # Input has to be defined |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 127 | pod2usage(%ERROR_HASH) unless @input; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 128 | |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 129 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 130 | # Initialize log4perl object |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 131 | Log::Log4perl->init({ |
| 132 | 'log4perl.rootLogger' => uc($log_level) . ', STDERR', |
| 133 | 'log4perl.appender.STDERR' => 'Log::Log4perl::Appender::ScreenColoredLevels', |
| 134 | 'log4perl.appender.STDERR.layout' => 'PatternLayout', |
| 135 | 'log4perl.appender.STDERR.layout.ConversionPattern' => '[%r] %F %L %c - %m%n' |
| 136 | }); |
| 137 | |
| 138 | my $log = Log::Log4perl->get_logger('main'); |
| 139 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 140 | |
| 141 | # Get file name based on path information |
| 142 | sub get_file_name ($) { |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 143 | my $i = $input[0]; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 144 | my $file = shift; |
Akron | 6255760 | 2016-06-27 14:10:13 +0200 | [diff] [blame] | 145 | $file =~ s!^/?tmp/[^/]+!!; |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 146 | $file =~ s/^?\/?$i//; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 147 | $file =~ tr/\//-/; |
| 148 | $file =~ s{^-+}{}; |
| 149 | return $file; |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 150 | }; |
| 151 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 152 | |
| 153 | # Write file |
| 154 | sub write_file { |
| 155 | my $anno = shift; |
| 156 | my $file = get_file_name $anno; |
| 157 | |
| 158 | # TODO: This should be done directly with a data structure! KorAP::XML::Wrap |
| 159 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 160 | my $call = 'perl ' . $LOCAL . '/korapxml2krill'; |
| 161 | $call .= ' -i ' . $anno; |
| 162 | $call .= ' -o ' . $output . '/' . $file . '.json'; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 163 | $call .= '.gz -z' if $gzip; |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 164 | $call .= ' -m ' . $meta if $meta; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 165 | $call .= ' -w' if $overwrite; |
| 166 | $call .= ' -t ' . $token_base if $token_base; |
| 167 | $call .= ' -l ' . $log_level if $log_level; |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 168 | $call .= ' -c ' . $cache_file; |
| 169 | $call .= ' -cs ' . $cache_size; |
| 170 | $call .= ' --no-cache-delete'; # Don't delete the cache |
| 171 | $call .= ' --no-cache-init'; # Don't initialize the cache |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 172 | $call .= ' --no-primary ' if $primary; |
| 173 | $call .= ' -y ' . $pretty if $pretty; |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 174 | $call .= ' -a ' . $_ foreach @anno; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 175 | $call .= ' -s ' . $_ foreach @skip; |
| 176 | system($call); |
| 177 | return "$file"; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 178 | }; |
| 179 | |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 180 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 181 | # Convert sigle to path construct |
| 182 | s!^\s*([^_]+?)_([^\.]+?)\.(.+?)\s*$!$1/$2/$3! foreach @sigle; |
| 183 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 184 | # Process a single file |
| 185 | unless ($cmd) { |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 186 | my $input = $input[0]; |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 187 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 188 | # Can't print gzip to STDOUT |
| 189 | pod2usage(%ERROR_HASH) if $gzip && !$output; |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 190 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 191 | my %skip; |
| 192 | $skip{lc($_)} = 1 foreach @skip; |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 193 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 194 | # Ignore processing |
| 195 | if (!$overwrite && $output && -e $output) { |
| 196 | $log->trace($output . ' already exists'); |
| 197 | exit(0); |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 198 | }; |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 199 | |
| 200 | BEGIN { |
| 201 | $main::TIME = Benchmark->new; |
| 202 | $main::LAST_STOP = Benchmark->new; |
| 203 | }; |
| 204 | |
| 205 | sub stop_time { |
| 206 | my $new = Benchmark->new; |
| 207 | $log->trace( |
| 208 | 'The code took: '. |
| 209 | timestr(timediff($new, $main::LAST_STOP)) . |
| 210 | ' (overall: ' . timestr(timediff($new, $main::TIME)) . ')' |
| 211 | ); |
| 212 | $main::LAST_STOP = $new; |
| 213 | }; |
| 214 | |
| 215 | # Create and parse new document |
| 216 | $input =~ s{([^/])$}{$1/}; |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 217 | my $doc = KorAP::XML::Krill->new( |
| 218 | path => $input, |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 219 | meta_type => ($meta // 'I5'), |
| 220 | cache => Cache::FastMmap->new( |
| 221 | share_file => $cache_file, |
| 222 | cache_size => $cache_size, |
| 223 | init_file => $cache_init |
| 224 | ) |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 225 | ); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 226 | |
| 227 | unless ($doc->parse) { |
| 228 | $log->warn($output . " can't be processed - no document data"); |
| 229 | exit(0); |
| 230 | }; |
| 231 | |
| 232 | my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/); |
| 233 | if ($token_base) { |
| 234 | ($token_base_foundry, $token_base_layer) = split /#/, $token_base; |
| 235 | }; |
| 236 | |
| 237 | # Get tokenization |
| 238 | my $tokens = KorAP::XML::Tokenizer->new( |
| 239 | path => $doc->path, |
| 240 | doc => $doc, |
| 241 | foundry => $token_base_foundry, |
| 242 | layer => $token_base_layer, |
| 243 | name => 'tokens' |
| 244 | ); |
| 245 | |
| 246 | # Unable to process base tokenization |
| 247 | unless ($tokens->parse) { |
| 248 | $log->error($output . " can't be processed - no base tokenization"); |
| 249 | exit(0); |
| 250 | }; |
| 251 | |
| 252 | my @layers; |
| 253 | push(@layers, ['Base', 'Sentences']); |
| 254 | push(@layers, ['Base', 'Paragraphs']); |
| 255 | |
| 256 | # Connexor |
| 257 | push(@layers, ['Connexor', 'Morpho']); |
| 258 | push(@layers, ['Connexor', 'Syntax']); |
| 259 | push(@layers, ['Connexor', 'Phrase']); |
| 260 | push(@layers, ['Connexor', 'Sentences']); |
| 261 | |
| 262 | # CoreNLP |
| 263 | push(@layers, ['CoreNLP', 'NamedEntities']); |
| 264 | push(@layers, ['CoreNLP', 'Sentences']); |
| 265 | push(@layers, ['CoreNLP', 'Morpho']); |
| 266 | push(@layers, ['CoreNLP', 'Constituency']); |
| 267 | |
| 268 | # DeReKo |
| 269 | push(@layers, ['DeReKo', 'Structure']); |
| 270 | |
| 271 | # Glemm |
| 272 | push(@layers, ['Glemm', 'Morpho']); |
| 273 | |
| 274 | # Malt |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 275 | push(@layers, ['Malt', 'Dependency']); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 276 | |
Akron | 8b99052 | 2016-07-06 16:45:57 +0200 | [diff] [blame] | 277 | # MDParser |
| 278 | push(@layers, ['MDParser', 'Dependency']); |
| 279 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 280 | # Mate |
| 281 | push(@layers, ['Mate', 'Morpho']); |
| 282 | push(@layers, ['Mate', 'Dependency']); |
| 283 | |
| 284 | # OpenNLP |
| 285 | push(@layers, ['OpenNLP', 'Morpho']); |
| 286 | push(@layers, ['OpenNLP', 'Sentences']); |
| 287 | |
| 288 | # Schreibgebrauch |
| 289 | push(@layers, ['Sgbr', 'Lemma']); |
| 290 | push(@layers, ['Sgbr', 'Morpho']); |
| 291 | |
| 292 | # TreeTagger |
| 293 | push(@layers, ['TreeTagger', 'Morpho']); |
| 294 | push(@layers, ['TreeTagger', 'Sentences']); |
| 295 | |
| 296 | # XIP |
| 297 | push(@layers, ['XIP', 'Morpho']); |
| 298 | push(@layers, ['XIP', 'Constituency']); |
| 299 | push(@layers, ['XIP', 'Sentences']); |
| 300 | push(@layers, ['XIP', 'Dependency']); |
| 301 | |
| 302 | |
| 303 | if ($skip{'#all'}) { |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 304 | foreach (@anno) { |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 305 | $tokens->add(split('#', $_)); |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 306 | stop_time; |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 307 | }; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 308 | } |
| 309 | else { |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 310 | # Add to index file - respect skipping |
| 311 | foreach my $info (@layers) { |
| 312 | # Skip if Foundry or Foundry#Layer should be skipped |
| 313 | unless ($skip{lc($info->[0])} || $skip{lc($info->[0]) . '#' . lc($info->[1])}) { |
| 314 | $tokens->add(@$info); |
| 315 | stop_time; |
| 316 | }; |
| 317 | }; |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 318 | }; |
| 319 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 320 | my $file; |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 321 | my $print_text = ($pretty ? $tokens->to_pretty_json($primary) : $tokens->to_json($primary)); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 322 | |
| 323 | if ($output) { |
| 324 | |
| 325 | if ($gzip) { |
| 326 | $file = IO::Compress::Gzip->new($output, Minimal => 1); |
| 327 | } |
| 328 | else { |
| 329 | $file = IO::File->new($output, "w"); |
| 330 | }; |
| 331 | |
| 332 | $file->print($print_text); |
| 333 | $file->close; |
| 334 | } |
| 335 | |
| 336 | else { |
| 337 | print $print_text . "\n"; |
| 338 | }; |
| 339 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 340 | # Delete cache file |
| 341 | unlink($cache_file) if $cache_delete; |
| 342 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 343 | stop_time; |
Nils Diewald | 7364d1f | 2013-11-05 19:26:35 +0000 | [diff] [blame] | 344 | } |
Nils Diewald | 59094f2 | 2014-11-05 18:20:50 +0000 | [diff] [blame] | 345 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 346 | # Extract XML files |
| 347 | elsif ($cmd eq 'extract') { |
| 348 | |
| 349 | pod2usage(%ERROR_HASH) unless $output; |
| 350 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 351 | if ($output && (!-e $output || !-d $output)) { |
| 352 | print "Directory '$output' does not exist.\n\n"; |
| 353 | exit(0); |
| 354 | }; |
| 355 | |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 356 | # TODO: Support sigles and full archives |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 357 | |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 358 | if (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 359 | |
| 360 | unless ($archive->test_unzip) { |
| 361 | print "Unzip is not installed or incompatible.\n\n"; |
| 362 | exit(1); |
| 363 | }; |
| 364 | |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 365 | # Add further annotation archived |
| 366 | $archive->attach($_) foreach @input; |
| 367 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 368 | # Iterate over all given sigles and extract |
| 369 | foreach (@sigle) { |
| 370 | print "$_ "; |
Akron | b0c88db | 2016-06-29 16:33:18 +0200 | [diff] [blame] | 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 |