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