blob: 5dff430a2006d39df89e145f2df324f0bb6fd92f [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
Akron1a5271a2021-02-18 13:18:15 +0100155=item B<--inline-tokens> <foundry>#[<file>]
156
157Define the foundry and file (without extension)
158to store inline token information in.
Akron8a0c4bf2021-03-16 16:51:21 +0100159Unless C<--skip-inline-token-annotations> is set,
160this will contain annotations as well.
Akron1a5271a2021-02-18 13:18:15 +0100161Defaults to C<tokens> and C<morpho>.
162
Akrone2819a12021-10-12 15:52:55 +0200163The inline token data will also be stored in the
164inline structures file (see I<--inline-structures>),
165unless the inline token foundry is prepended
166by an B<!> exclamation mark, indicating that inline
167tokens are stored exclusively in the inline tokens
168file.
169
170Example:
171
172 tei2korapxml --inline-tokens '!gingko#morpho' < data.i5.xml > korapxml.zip
173
Akrondd0be8f2021-02-18 19:29:41 +0100174=item B<--inline-structures> <foundry>#[<file>]
175
176Define the foundry and file (without extension)
177to store inline structure information in.
178Defaults to C<struct> and C<structures>.
Akron75d63142021-02-23 18:40:56 +0100179
Akron26a71522021-02-19 10:27:37 +0100180=item B<--base-foundry> <foundry>
181
182Define the base foundry to store newly generated
183token information in.
184Defaults to C<base>.
185
186=item B<--data-file> <file>
187
188Define the file (without extension)
189to store primary data information in.
190Defaults to C<data>.
191
192=item B<--header-file> <file>
193
194Define the file name (without extension)
195to store header information on
196the corpus, document, and text level in.
197Defaults to C<header>.
Akrondd0be8f2021-02-18 19:29:41 +0100198
Marc Kupietz985da0c2021-02-15 19:29:50 +0100199=item B<--use-tokenizer-sentence-splits|-s>
200
201Replace existing with, or add new, sentence boundary information
Akron11484782021-11-03 20:12:14 +0100202provided by the tokenizer.
203Currently KorAP-tokenizer and certain external tokenizers support
204these boundaries.
Marc Kupietz985da0c2021-02-15 19:29:50 +0100205
Akron91705d72021-02-19 10:59:45 +0100206=item B<--tokens-file> <file>
207
208Define the file (without extension)
209to store generated token information in
210(either from the KorAP tokenizer or an externally called tokenizer).
211Defaults to C<tokens>.
212
Akron0c41ab32020-09-29 07:33:33 +0200213=item B<--log|-l>
214
215Loglevel for I<Log::Any>. Defaults to C<notice>.
216
217=back
218
Akronb3649472020-09-29 08:24:46 +0200219=head1 ENVIRONMENT VARIABLES
220
221=over 2
222
223=item B<KORAPXMLTEI_DEBUG>
224
225Activate minimal debugging.
226Defaults to C<false>.
227
Akronb3649472020-09-29 08:24:46 +0200228=back
229
Akron0c41ab32020-09-29 07:33:33 +0200230=head1 COPYRIGHT AND LICENSE
231
Marc Kupietz985da0c2021-02-15 19:29:50 +0100232Copyright (C) 2021, L<IDS Mannheim|https://www.ids-mannheim.de/>
Akron0c41ab32020-09-29 07:33:33 +0200233
234Author: Peter Harders
235
Akronaabd0952020-09-29 07:35:08 +0200236Contributors: Nils Diewald, Marc Kupietz, Carsten Schnober
Akron0c41ab32020-09-29 07:33:33 +0200237
238L<KorAP::XML::TEI> is developed as part of the L<KorAP|https://korap.ids-mannheim.de/>
239Corpus Analysis Platform at the
Akrond72baca2021-07-23 13:25:32 +0200240L<Leibniz Institute for the German Language (IDS)|https://www.ids-mannheim.de/>,
Akron0c41ab32020-09-29 07:33:33 +0200241member of the
242L<Leibniz-Gemeinschaft|http://www.leibniz-gemeinschaft.de/>.
243
244This program is free software published under the
Marc Kupietze955ecc2021-02-17 17:42:01 +0100245L<BSD-2 License|https://opensource.org/licenses/BSD-2-Clause>.
Akron0c41ab32020-09-29 07:33:33 +0200246
Akron692d17d2021-03-05 13:21:03 +0100247=cut