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