blob: b214dce61b6546964f4d07e55e798b7c31050431 [file] [log] [blame]
Akron0c41ab32020-09-29 07:33:33 +02001=pod
2
3=encoding utf8
4
5=head1 NAME
6
7tei2korapxml - Conversion of TEI P5 based formats to KorAP-XML
8
9=head1 SYNOPSIS
10
Akron11484782021-11-03 20:12:14 +010011 cat corpus.i5.xml | tei2korapxml - > corpus.korapxml.zip
Akron0c41ab32020-09-29 07:33:33 +020012
13=head1 DESCRIPTION
14
15C<tei2korapxml> is a script to convert TEI P5 and
Akrond72baca2021-07-23 13:25:32 +020016L<I5|https://www.ids-mannheim.de/digspra/kl/projekte/korpora/textmodell>
Akron0c41ab32020-09-29 07:33:33 +020017based documents to the
18L<KorAP-XML format|https://github.com/KorAP/KorAP-XML-Krill#about-korap-xml>.
Akron0c41ab32020-09-29 07:33:33 +020019
20This program is usually called from inside another script.
21
22=head1 FORMATS
23
24=head2 Input restrictions
25
26=over 2
27
28=item
29
Akron0c41ab32020-09-29 07:33:33 +020030TEI P5 formatted input with certain restrictions:
31
32=over 4
33
34=item
35
36B<mandatory>: text-header with integrated textsigle, text-body
37
38=item
39
40B<optional>: corp-header with integrated corpsigle,
41doc-header with integrated docsigle
42
43=back
44
45=item
46
47All tokens inside the primary text may not be
48newline seperated, because newlines are removed
49(see L<KorAP::XML::TEI::Data>) and a conversion of newlines
50into blanks between 2 tokens could lead to additional blanks,
51where there should be none (e.g.: punctuation characters like C<,> or
52C<.> should not be seperated from their predecessor token).
Akron8a0c4bf2021-03-16 16:51:21 +010053(see also code section C<~ whitespace handling ~> in C<script/tei2korapxml>).
Akron0c41ab32020-09-29 07:33:33 +020054
Akron940ca6f2021-10-11 12:38:39 +020055=item
56
57Header types, like C<E<lt>idsHeader [...] type="document" [...] E<gt>>
58need to be defined in the same line as the header tag.
59
Akron0c41ab32020-09-29 07:33:33 +020060=back
61
62=head2 Notes on the output
63
64=over 2
65
66=item
67
68zip file output (default on C<stdout>) with utf8 encoded entries
69(which together form the KorAP-XML format)
70
71=back
72
73=head1 INSTALLATION
74
Marc Kupietze83a4e92021-03-16 20:51:26 +010075C<tei2korapxml> requires L<libxml2-dev> bindings and L<File::ShareDir::Install> to be installed.
76When these requirements are met, the preferred way to install the script is
Akron0c41ab32020-09-29 07:33:33 +020077to use L<cpanm|App::cpanminus>.
78
79 $ cpanm https://github.com/KorAP/KorAP-XML-TEI.git
80
81In case everything went well, the C<tei2korapxml> tool will
82be available on your command line immediately.
83
84Minimum requirement for L<KorAP::XML::TEI> is Perl 5.16.
85
86=head1 OPTIONS
87
88=over 2
89
Akron11484782021-11-03 20:12:14 +010090=item B<--input|-i>
91
92The input file to process. If no specific input is defined and a single
93dash C<-> is passed as an argument, data is read from C<STDIN>.
94
95
Akron0c41ab32020-09-29 07:33:33 +020096=item B<--root|-r>
97
98The root directory for output. Defaults to C<.>.
99
100=item B<--help|-h>
101
102Print help information.
103
104=item B<--version|-v>
105
106Print version information.
107
108=item B<--tokenizer-call|-tc>
109
110Call an external tokenizer process, that will tokenize
Akron11484782021-11-03 20:12:14 +0100111from STDIN and outputs the offsets of all tokens.
112
113Texts are separated using C<\x04\n>. The external process
114should add a new line per text.
115
116If the L</--use-tokenizer-sentence-splits> option is activated,
117sentences are marked by offset as well in new lines.
118
119To use L<Datok|https://github.com/KorAP/Datok> including sentence
120splitting, call C<tei2korap> as follows:
121
122 $ cat corpus.i5.xml | tei2korapxml -s \
123 $ -tc 'datok tokenize \
124 $ -t ./tokenizer.matok \
125 $ -p --newline-after-eot --no-sentences \
126 $ --no-tokens --sentence-positions -' - \
127 $ > corpus.korapxml.zip
Akron0c41ab32020-09-29 07:33:33 +0200128
129=item B<--tokenizer-korap|-tk>
130
131Use the standard KorAP/DeReKo tokenizer.
132
Akron6d7b8e42020-09-29 07:37:41 +0200133=item B<--tokenizer-internal|-ti>
Akron0c41ab32020-09-29 07:33:33 +0200134
135Tokenize the data using two embedded tokenizers,
136that will take an I<Aggressive> and a I<conservative>
137approach.
138
Akron75d63142021-02-23 18:40:56 +0100139=item B<--skip-inline-tokens>
140
141Boolean flag indicating that inline tokens should not
142be processed. Defaults to false (meaning inline tokens will be processed).
143
Akron692d17d2021-03-05 13:21:03 +0100144=item B<--skip-inline-token-annotations>
145
146Boolean flag indicating that inline token annotations should not
147be processed. Defaults to true (meaning inline token annotations
148won't be processed).
149
Akronca70a1d2021-02-25 16:21:31 +0100150=item B<--skip-inline-tags> <tags>
Akron54c3ff12021-02-25 11:33:37 +0100151
152Expects a comma-separated list of tags to be ignored when the structure
153is parsed. Content of these tags however will be processed.
154
Marc Kupietza671ae52022-12-22 16:28:14 +0100155=item B<--xmlid-to-textsigle> <from-regex>@<to-c/to-d/to-t>
156
157Expects a regular replacement expression (separated by a B<@> between the
158search and the replacement) to convert text id attributes to text sigles
159with three parts (separated by B</>).
160
161Example:
162
163 tei2korapxml \
164 --xmlid-to-textsigle 'ICC.German\.([^.]+\.[^.]+)\.(.+)@ICCGER/$1/$2' \
165 -tk - < t/data/icc_german_sample.p5.xml
166
167Converts text id `ICC.German.DeReKo.WPD17.G11.00238' to
168sigle `ICCGER/DeReKo.WPD17/G11.00238'.
169
Akron1a5271a2021-02-18 13:18:15 +0100170=item B<--inline-tokens> <foundry>#[<file>]
171
172Define the foundry and file (without extension)
173to store inline token information in.
Akron8a0c4bf2021-03-16 16:51:21 +0100174Unless C<--skip-inline-token-annotations> is set,
175this will contain annotations as well.
Akron1a5271a2021-02-18 13:18:15 +0100176Defaults to C<tokens> and C<morpho>.
177
Akrone2819a12021-10-12 15:52:55 +0200178The inline token data will also be stored in the
179inline structures file (see I<--inline-structures>),
180unless the inline token foundry is prepended
181by an B<!> exclamation mark, indicating that inline
182tokens are stored exclusively in the inline tokens
183file.
184
185Example:
186
187 tei2korapxml --inline-tokens '!gingko#morpho' < data.i5.xml > korapxml.zip
188
Akrondd0be8f2021-02-18 19:29:41 +0100189=item B<--inline-structures> <foundry>#[<file>]
190
191Define the foundry and file (without extension)
192to store inline structure information in.
193Defaults to C<struct> and C<structures>.
Akron75d63142021-02-23 18:40:56 +0100194
Akron26a71522021-02-19 10:27:37 +0100195=item B<--base-foundry> <foundry>
196
197Define the base foundry to store newly generated
198token information in.
199Defaults to C<base>.
200
201=item B<--data-file> <file>
202
203Define the file (without extension)
204to store primary data information in.
205Defaults to C<data>.
206
207=item B<--header-file> <file>
208
209Define the file name (without extension)
210to store header information on
211the corpus, document, and text level in.
212Defaults to C<header>.
Akrondd0be8f2021-02-18 19:29:41 +0100213
Marc Kupietz985da0c2021-02-15 19:29:50 +0100214=item B<--use-tokenizer-sentence-splits|-s>
215
216Replace existing with, or add new, sentence boundary information
Akron11484782021-11-03 20:12:14 +0100217provided by the tokenizer.
218Currently KorAP-tokenizer and certain external tokenizers support
219these boundaries.
Marc Kupietz985da0c2021-02-15 19:29:50 +0100220
Akron91705d72021-02-19 10:59:45 +0100221=item B<--tokens-file> <file>
222
223Define the file (without extension)
224to store generated token information in
225(either from the KorAP tokenizer or an externally called tokenizer).
226Defaults to C<tokens>.
227
Akron0c41ab32020-09-29 07:33:33 +0200228=item B<--log|-l>
229
230Loglevel for I<Log::Any>. Defaults to C<notice>.
231
232=back
233
Akronb3649472020-09-29 08:24:46 +0200234=head1 ENVIRONMENT VARIABLES
235
236=over 2
237
238=item B<KORAPXMLTEI_DEBUG>
239
240Activate minimal debugging.
241Defaults to C<false>.
242
Akronb3649472020-09-29 08:24:46 +0200243=back
244
Akron0c41ab32020-09-29 07:33:33 +0200245=head1 COPYRIGHT AND LICENSE
246
Marc Kupietz985da0c2021-02-15 19:29:50 +0100247Copyright (C) 2021, L<IDS Mannheim|https://www.ids-mannheim.de/>
Akron0c41ab32020-09-29 07:33:33 +0200248
249Author: Peter Harders
250
Akronaabd0952020-09-29 07:35:08 +0200251Contributors: Nils Diewald, Marc Kupietz, Carsten Schnober
Akron0c41ab32020-09-29 07:33:33 +0200252
253L<KorAP::XML::TEI> is developed as part of the L<KorAP|https://korap.ids-mannheim.de/>
254Corpus Analysis Platform at the
Akrond72baca2021-07-23 13:25:32 +0200255L<Leibniz Institute for the German Language (IDS)|https://www.ids-mannheim.de/>,
Akron0c41ab32020-09-29 07:33:33 +0200256member of the
257L<Leibniz-Gemeinschaft|http://www.leibniz-gemeinschaft.de/>.
258
259This program is free software published under the
Marc Kupietze955ecc2021-02-17 17:42:01 +0100260L<BSD-2 License|https://opensource.org/licenses/BSD-2-Clause>.
Akron0c41ab32020-09-29 07:33:33 +0200261
Akron692d17d2021-03-05 13:21:03 +0100262=cut