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 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 342 | my $input = $input[0]; |
| 343 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 344 | pod2usage(%ERROR_HASH) unless $output; |
| 345 | |
| 346 | # TODO: Support sigles and full archives |
| 347 | |
| 348 | if ($output && (!-e $output || !-d $output)) { |
| 349 | print "Directory '$output' does not exist.\n\n"; |
| 350 | exit(0); |
| 351 | }; |
| 352 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 353 | #TODOOOOOO |
| 354 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 355 | if (-f($input) && (my $archive = KorAP::XML::Archive->new($input))) { |
| 356 | |
| 357 | unless ($archive->test_unzip) { |
| 358 | print "Unzip is not installed or incompatible.\n\n"; |
| 359 | exit(1); |
| 360 | }; |
| 361 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 362 | # Iterate over all given sigles and extract |
| 363 | foreach (@sigle) { |
| 364 | print "$_ "; |
| 365 | print '' . ($archive->extract('./'. $_, $output) ? '' : 'not '); |
| 366 | print "extracted.\n"; |
| 367 | }; |
| 368 | |
| 369 | print "\n"; |
| 370 | exit(1); |
| 371 | }; |
| 372 | } |
| 373 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 374 | # Process an archive |
| 375 | elsif ($cmd eq 'archive') { |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 376 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 377 | # TODO: Support sigles |
| 378 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 379 | pod2usage(%ERROR_HASH) unless $output; |
| 380 | |
| 381 | if ($output && (!-e $output || !-d $output)) { |
| 382 | print "Directory '$output' does not exist.\n\n"; |
| 383 | exit(0); |
| 384 | }; |
| 385 | |
| 386 | # Zero means: everything runs in the parent process |
| 387 | my $pool = Parallel::ForkManager->new($jobs); |
| 388 | |
| 389 | my $count = 0; # Texts to process |
| 390 | my $iter = 1; # Current text in process |
| 391 | |
| 392 | # Report on fork message |
| 393 | $pool->run_on_finish ( |
| 394 | sub { |
| 395 | my ($pid, $code) = shift; |
| 396 | my $data = pop; |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 397 | print 'Convert ['. ($jobs > 0 ? "\$$pid:" : '') . |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 398 | ($iter++) . "/$count]" . |
| 399 | ($code ? " $code" : '') . |
| 400 | " $$data\n"; |
| 401 | } |
| 402 | ); |
| 403 | |
| 404 | my $t; |
| 405 | print "Reading data ...\n"; |
| 406 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 407 | unless (Cache::FastMmap->new( |
| 408 | share_file => $cache_file, |
| 409 | cache_size => $cache_size, |
| 410 | init_file => $cache_init |
| 411 | )) { |
| 412 | print "Unable to intialize cache '$cache_file'\n\n"; |
| 413 | exit(1); |
| 414 | }; |
| 415 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 416 | # Input is a directory |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 417 | if (-d $input[0]) { |
| 418 | my $it = Directory::Iterator->new($input[0]); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 419 | my @dirs; |
| 420 | my $dir; |
| 421 | |
| 422 | while (1) { |
| 423 | if (!$it->is_directory && ($dir = $it->get) && $dir =~ s{/data\.xml$}{}) { |
| 424 | push @dirs, $dir; |
| 425 | $it->prune; |
| 426 | }; |
| 427 | last unless $it->next; |
| 428 | }; |
| 429 | |
| 430 | print "Start processing ...\n"; |
| 431 | $t = Benchmark->new; |
| 432 | $count = scalar @dirs; |
| 433 | |
| 434 | DIRECTORY_LOOP: |
| 435 | for (my $i = 0; $i < $count; $i++) { |
| 436 | |
| 437 | unless ($overwrite) { |
| 438 | my $filename = catfile( |
| 439 | $output, |
| 440 | get_file_name($dirs[$i]) . '.json' . ($gzip ? '.gz' : '') |
| 441 | ); |
| 442 | |
| 443 | if (-e $filename) { |
| 444 | $iter++; |
| 445 | print "Skip $filename\n"; |
| 446 | next; |
| 447 | }; |
| 448 | }; |
| 449 | |
| 450 | # Get the next fork |
| 451 | my $pid = $pool->start and next DIRECTORY_LOOP; |
| 452 | my $msg; |
| 453 | |
| 454 | $msg = write_file($dirs[$i]); |
| 455 | $pool->finish(0, \$msg); |
| 456 | }; |
| 457 | } |
| 458 | |
| 459 | # Input is a file |
Akron | 29866ac | 2016-06-24 16:40:47 +0200 | [diff] [blame] | 460 | elsif (-f($input[0]) && (my $archive = KorAP::XML::Archive->new($input[0]))) { |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 461 | unless ($archive->test_unzip) { |
| 462 | print "Unzip is not installed or incompatible.\n\n"; |
| 463 | exit(1); |
| 464 | }; |
| 465 | |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 466 | # Add further annotation archived |
Akron | 29866ac | 2016-06-24 16:40:47 +0200 | [diff] [blame] | 467 | $archive->attach($_) foreach @input; |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 468 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 469 | print "Start processing ...\n"; |
| 470 | $t = Benchmark->new; |
| 471 | my @dirs = $archive->list_texts; |
| 472 | $count = scalar @dirs; |
| 473 | |
| 474 | ARCHIVE_LOOP: |
| 475 | for (my $i = 0; $i < $count; $i++) { |
| 476 | |
| 477 | # Split path information |
| 478 | my ($prefix, $corpus, $doc, $text) = $archive->split_path($dirs[$i]); |
| 479 | |
| 480 | unless ($overwrite) { |
Akron | 6255760 | 2016-06-27 14:10:13 +0200 | [diff] [blame] | 481 | |
| 482 | # This is not correct!! |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 483 | my $filename = catfile( |
| 484 | $output, |
Akron | 6255760 | 2016-06-27 14:10:13 +0200 | [diff] [blame] | 485 | get_file_name( |
| 486 | catfile($corpus, $doc, $text) |
| 487 | . '.json' . ($gzip ? '.gz' : '') |
| 488 | ) |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 489 | ); |
| 490 | |
| 491 | if (-e $filename) { |
| 492 | $iter++; |
| 493 | print "Skip $filename\n"; |
| 494 | next; |
| 495 | }; |
| 496 | }; |
| 497 | |
| 498 | # Get the next fork |
| 499 | my $pid = $pool->start and next ARCHIVE_LOOP; |
| 500 | |
| 501 | # Create temporary file |
| 502 | my $temp = File::Temp->newdir; |
| 503 | |
| 504 | my $msg; |
| 505 | |
| 506 | # Extract from archive |
| 507 | if ($archive->extract($dirs[$i], $temp)) { |
| 508 | |
| 509 | # Create corpus directory |
Akron | 08385f6 | 2016-03-22 20:37:04 +0100 | [diff] [blame] | 510 | my $input = catdir("$temp", $corpus); |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 511 | |
| 512 | # Temporary directory |
| 513 | my $dir = catdir($input, $doc, $text); |
| 514 | |
| 515 | # Write file |
| 516 | $msg = write_file($dir); |
| 517 | |
| 518 | $temp = undef; |
| 519 | $pool->finish(0, \$msg); |
| 520 | } |
| 521 | else { |
| 522 | |
| 523 | $temp = undef; |
| 524 | $msg = "Unable to extract " . $dirs[$i] . "\n"; |
| 525 | $pool->finish(1, \$msg); |
| 526 | }; |
| 527 | }; |
| 528 | } |
| 529 | |
| 530 | else { |
| 531 | print "Input is neither a directory nor an archive.\n\n"; |
| 532 | }; |
| 533 | |
| 534 | $pool->wait_all_children; |
| 535 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 536 | # Delete cache file |
| 537 | unlink($cache_file) if $cache_delete; |
| 538 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 539 | print "Done.\n"; |
| 540 | print timestr(timediff(Benchmark->new, $t))."\n\n"; |
| 541 | } |
| 542 | |
| 543 | # Unknown command |
| 544 | else { |
| 545 | warn "Unknown command '$cmd'.\n\n"; |
| 546 | pod2usage(%ERROR_HASH); |
| 547 | } |
Nils Diewald | 2db9ad0 | 2013-10-29 19:26:43 +0000 | [diff] [blame] | 548 | |
| 549 | __END__ |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 550 | |
| 551 | =pod |
| 552 | |
| 553 | =encoding utf8 |
| 554 | |
| 555 | =head1 NAME |
| 556 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 557 | korapxml2krill - Merge KorapXML data and create Krill documents |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 558 | |
| 559 | |
| 560 | =head1 SYNOPSIS |
| 561 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 562 | $ korapxml2krill -z --input <directory> --output <filename> |
| 563 | $ korapxml2krill archive -z --input <directory> --output <directory> |
| 564 | $ korapxml2krill extract --input <directory> --output <filename> --sigle <SIGLE> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 565 | |
| 566 | |
| 567 | =head1 DESCRIPTION |
| 568 | |
| 569 | L<KorAP::XML::Krill> is a library to convert KorAP-XML documents to files |
| 570 | compatible with the L<Krill|https://github.com/KorAP/Krill> indexer. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 571 | The C<korapxml2krill> command line tool is a simple wrapper to the library. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 572 | |
| 573 | |
| 574 | =head1 INSTALLATION |
| 575 | |
| 576 | The preferred way to install L<KorAP::XML::Krill> is to use L<cpanm|App::cpanminus>. |
| 577 | |
| 578 | $ cpanm https://github.com/KorAP/KorAP-XML-Krill |
| 579 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 580 | In case everything went well, the C<korapxml2krill> tool will |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 581 | be available on your command line immediately. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 582 | |
| 583 | |
| 584 | =head1 ARGUMENTS |
| 585 | |
| 586 | =over 2 |
| 587 | |
| 588 | =item B<archive> |
| 589 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 590 | Process an archive as a Zip-file or a folder of KorAP-XML documents. |
| 591 | |
| 592 | =item B<extract> |
| 593 | |
| 594 | Extract KorAP-XML files from a Zip-file. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 595 | |
| 596 | =back |
| 597 | |
| 598 | |
| 599 | =head1 OPTIONS |
| 600 | |
| 601 | =over 2 |
| 602 | |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 603 | =item B<--input|-i> <directory|file|files> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 604 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 605 | Directory or archive file of documents to convert. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 606 | |
Akron | 0c3e375 | 2016-06-28 15:55:53 +0200 | [diff] [blame^] | 607 | Archiving supports multiple input archives with the constraint, |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 608 | that the first archive listed contains all primary data files |
| 609 | and all meta data files. |
Akron | 2cfe809 | 2016-06-24 17:48:49 +0200 | [diff] [blame] | 610 | |
| 611 | -i file/news.zip -i file/news.malt.zip -i #file/news.tt.zip |
| 612 | |
Akron | 0c3e375 | 2016-06-28 15:55:53 +0200 | [diff] [blame^] | 613 | (The directory structure follows the base directory format, |
| 614 | that may include a C<.> root folder. |
| 615 | In this case further archives lacking a C<.> root folder |
| 616 | 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] | 617 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 618 | =item B<--output|-o> <directory|file> |
| 619 | |
| 620 | Output folder for archive processing or |
| 621 | document name for single output (optional), |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 622 | writes to C<STDOUT> by default |
| 623 | (in case C<output> is not mandatory due to further options). |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 624 | |
| 625 | =item B<--overwrite|-w> |
| 626 | |
| 627 | Overwrite files that already exist. |
| 628 | |
| 629 | =item B<--token|-t> <foundry>[#<file>] |
| 630 | |
| 631 | Define the default tokenization by specifying |
| 632 | the name of the foundry and optionally the name |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 633 | of the layer-file. Defaults to C<OpenNLP#tokens>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 634 | |
| 635 | =item B<--skip|-s> <foundry>[#<layer>] |
| 636 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 637 | Skip specific annotations by specifying the foundry |
| 638 | (and optionally the layer with a C<#>-prefix), |
| 639 | 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] | 640 | Can be set multiple times. |
| 641 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 642 | =item B<--anno|-a> <foundry>#<layer> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 643 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 644 | Convert specific annotations by specifying the foundry |
| 645 | (and optionally the layer with a C<#>-prefix), |
| 646 | e.g. C<Mate> or C<Mate#Morpho>. |
| 647 | Can be set multiple times. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 648 | |
| 649 | =item B<--primary|-p> |
| 650 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 651 | Output primary data or not. Defaults to C<true>. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 652 | Can be flagged using C<--no-primary> as well. |
| 653 | This is I<deprecated>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 654 | |
| 655 | =item B<--jobs|-j> |
| 656 | |
| 657 | Define the number of concurrent jobs in seperated forks |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 658 | for archive processing. |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 659 | Defaults to C<0> (everything runs in a single process). |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 660 | This is I<experimental>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 661 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 662 | =item B<--meta|-m> |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 663 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 664 | Define the metadata parser to use. Defaults to C<I5>. |
| 665 | Metadata parsers can be defined in the C<KorAP::XML::Meta> namespace. |
| 666 | This is I<experimental>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 667 | |
| 668 | =item B<--pretty|-y> |
| 669 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 670 | Pretty print JSON output. Defaults to C<false>. |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 671 | This is I<deprecated>. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 672 | |
| 673 | =item B<--gzip|-z> |
| 674 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 675 | Compress the output. |
| 676 | Expects a defined C<output> file in single processing. |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 677 | |
Akron | 11c8030 | 2016-03-18 19:44:43 +0100 | [diff] [blame] | 678 | =item B<--cache|-c> |
| 679 | |
| 680 | File to mmap a cache (using L<Cache::FastMmap>). |
| 681 | Defaults to C<korapxml2krill.cache> in the calling directory. |
| 682 | |
| 683 | =item B<--cache-size|-cs> |
| 684 | |
| 685 | Size of the cache. Defaults to C<50m>. |
| 686 | |
| 687 | =item B<--cache-init|-ci> |
| 688 | |
| 689 | Initialize cache file. |
| 690 | Can be flagged using C<--no-cache-init> as well. |
| 691 | Defaults to C<true>. |
| 692 | |
| 693 | =item B<--cache-delete|-cd> |
| 694 | |
| 695 | Delete cache file after processing. |
| 696 | Can be flagged using C<--no-cache-delete> as well. |
| 697 | Defaults to C<true>. |
| 698 | |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 699 | =item B<--sigle|-sg> |
| 700 | |
| 701 | Extract the given text sigles. |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 702 | Can be set multiple times. |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 703 | I<Currently only supported on C<extract>.> |
Akron | e10ad32 | 2016-02-27 10:54:26 +0100 | [diff] [blame] | 704 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 705 | =item B<--log|-l> |
| 706 | |
| 707 | The L<Log4perl> log level, defaults to C<ERROR>. |
| 708 | |
| 709 | =item B<--help|-h> |
| 710 | |
| 711 | Print this document. |
| 712 | |
| 713 | =item B<--version|-v> |
| 714 | |
| 715 | Print version information. |
| 716 | |
| 717 | =back |
| 718 | |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 719 | =head1 ANNOTATION SUPPORT |
| 720 | |
| 721 | L<KorAP::XML::Krill> has built-in importer for some annotation foundries and layers |
| 722 | developed in the KorAP project that are part of the KorAP preprocessing pipeline. |
| 723 | The base foundry with paragraphs, sentences, and the text element are mandatory for |
| 724 | L<Krill|https://github.com/KorAP/Krill>. |
| 725 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 726 | =over 2 |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 727 | |
| 728 | =item B<Base> |
| 729 | |
| 730 | =over 4 |
| 731 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 732 | =item #Paragraphs |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 733 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 734 | =item #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 735 | |
| 736 | =back |
| 737 | |
| 738 | =item B<Connexor> |
| 739 | |
| 740 | =over 4 |
| 741 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 742 | =item #Morpho |
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 #Phrase |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 745 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 746 | =item #Sentences |
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 #Syntax |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 749 | |
| 750 | =back |
| 751 | |
| 752 | =item B<CoreNLP> |
| 753 | |
| 754 | =over 4 |
| 755 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 756 | =item #Constituency |
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 #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 759 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 760 | =item #NamedEntities |
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 #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 763 | |
| 764 | =back |
| 765 | |
| 766 | =item B<DeReKo> |
| 767 | |
| 768 | =over 4 |
| 769 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 770 | =item #Structure |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 771 | |
| 772 | =back |
| 773 | |
| 774 | =item B<Glemm> |
| 775 | |
| 776 | =over 4 |
| 777 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 778 | =item #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 779 | |
| 780 | =back |
| 781 | |
| 782 | =item B<Mate> |
| 783 | |
| 784 | =over 4 |
| 785 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 786 | =item #Dependency |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 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<OpenNLP> |
| 793 | |
| 794 | =over 4 |
| 795 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 796 | =item #Morpho |
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 #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 799 | |
| 800 | =back |
| 801 | |
| 802 | =item B<Sgbr> |
| 803 | |
| 804 | =over 4 |
| 805 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 806 | =item #Lemma |
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 #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 809 | |
| 810 | =back |
| 811 | |
| 812 | =item B<TreeTagger> |
| 813 | |
| 814 | =over 4 |
| 815 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 816 | =item #Morpho |
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 #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 819 | |
| 820 | =back |
| 821 | |
| 822 | =item B<XIP> |
| 823 | |
| 824 | =over 4 |
| 825 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 826 | =item #Constituency |
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 #Morpho |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 829 | |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 830 | =item #Sentences |
Akron | c13a170 | 2016-03-15 19:33:14 +0100 | [diff] [blame] | 831 | |
| 832 | =back |
| 833 | |
| 834 | =back |
| 835 | |
| 836 | More importers are in preparation. |
| 837 | New annotation importers can be defined in the C<KorAP::XML::Annotation> namespace. |
| 838 | See the built-in annotation importers as examples. |
| 839 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 840 | =head1 AVAILABILITY |
| 841 | |
| 842 | https://github.com/KorAP/KorAP-XML-Krill |
| 843 | |
| 844 | |
| 845 | =head1 COPYRIGHT AND LICENSE |
| 846 | |
| 847 | Copyright (C) 2015-2016, L<IDS Mannheim|http://www.ids-mannheim.de/> |
Akron | f7ad89e | 2016-03-16 18:22:47 +0100 | [diff] [blame] | 848 | |
Akron | 941c1a6 | 2016-02-23 17:41:41 +0100 | [diff] [blame] | 849 | Author: L<Nils Diewald|http://nils-diewald.de/> |
| 850 | |
| 851 | L<KorAP::XML::Krill> is developed as part of the L<KorAP|http://korap.ids-mannheim.de/> |
| 852 | Corpus Analysis Platform at the |
| 853 | L<Institute for the German Language (IDS)|http://ids-mannheim.de/>, |
| 854 | member of the |
| 855 | L<Leibniz-Gemeinschaft|http://www.leibniz-gemeinschaft.de/en/about-us/leibniz-competition/projekte-2011/2011-funding-line-2/>. |
| 856 | |
| 857 | This program is free software published under the |
| 858 | L<BSD-2 License|https://raw.githubusercontent.com/KorAP/KorAP-XML-Krill/master/LICENSE>. |
| 859 | |
| 860 | =cut |