blob: 9ee18b5f4fc0b436c0edd6a34df848e5dc54cd18 [file] [log] [blame]
Harald Lüngen9d4e0462024-08-23 09:34:22 +03001#! /usr/bin/perl -w
2
3
4###########################################################################################################################################################
5# vrt2tei.pl
6# eureco
7# leibniz-institut fuer deutsche sprache / csc finland esbo
8# august 2024
9#
10#
11# using XML::Twig , see http://www.xmltwig.org/, https://metacpan.org/pod/XML::Twiga
12#
Harald Lüngenccd84902024-08-27 16:03:47 +030013# usage: see below the usage fugnction
Harald Lüngencaab0802024-08-23 17:28:22 +030014# Usage: ./vrt2tei.pl <vrtxmlfile.xml> <outfile>
Harald Lüngen9d4e0462024-08-23 09:34:22 +030015# <vrtxmlfile>: xml-ised vrt file
16#
17#
18# TODO:
19# 1 insert dtd spec, or ref to TEI
20
21# 3a UPLOAD in GITHUB
22# 3b add @head and @deprel to I5 sowie auch @msd
23# 3c bearbeitung von @head und @deprel in tei2korapxml durch Nils?
24# 3d build 30 billion corpus
25
26# 4a take care of IDs
27# 4b see to the values of @xml:lang
28# 5 abfangen von unerwarteten elementen dh andere als <sentence> und <paragraph>
29# 5a wort reihenfolge nochmal checken
30# 6 checks and balances
31# 6a output nach stdout machen
32# 7 How to encode Kielipankki and National Library of Finland? in teiCorpus Header
33# 8 construct <idsDoc>s for the months (or go for TEI)
34# 9 parallelisation in bash and application on sub corpora of KLK
35# 10 re-implementation of the gawk code in the perl script
36# 12 re-implement creation of text header from xml file in another twig / parametrize TEI vs I5
37
38
39
40#remember
41#formatted.xml:105613: element w: validity error : No declaration for attribute deprel of element w
42#formatted.xml:105613: element w: validity error : No declaration for attribute head of element w
43
44
45#
46#
47############################################################################################################################################################
48
49
50use strict;
51use warnings;
52
53use XML::Twig;
54use XML::Generator ':pretty'; # apparently no effect when using flush();
55
56
57use locale; # diese drei Zeilen, damit \b im regex nicht Umlaute und ß matcht.
58use POSIX qw(locale_h); # to be able to use setlocale()
59#setlocale(LC_ALL,'de_DE');
60setlocale(LC_ALL, "fi_FI");
61use utf8;
62use open qw( :std :encoding(UTF-8) );
63
64use Time::Piece;
65use Tie::IxHash;
66
67#----------------------
68# check file arguments:
69#----------------------
70
71# arg0 infile: vrt-xml
72# arg1 outfile: tei
73
74unless($ARGV[1]) {&usage_message()}; # min arg0 und arg1
75if ($ARGV[2]) {&usage_message()}; # max arg1
76
77
78
79
80####################
81# GLOBAL VARIABLES
82####################
83
84my $encoding = "UTF-8";
85#my $encoding = "iso-8859-1"; # dieses $encoding ist NUR fuer das output s.u. twig funktion
Harald Lüngencaab0802024-08-23 17:28:22 +030086my $textcounter = 0;
Harald Lüngen9d4e0462024-08-23 09:34:22 +030087
88
89#####################
90# M A I N
91#####################
92
93
94# open result file and initialise filehandle
Harald Lüngenccd84902024-08-27 16:03:47 +030095open(my $OUT, "> $ARGV[1]") || die("cannot open file: $ARGV[1]");
Harald Lüngen9d4e0462024-08-23 09:34:22 +030096
97
98
99#-----------------------------------------------------------------------------------
100# start twig and call start tag handler for root and twig handler for each <text>
101#-----------------------------------------------------------------------------------
102
103my $twig="";
104
105$twig = new XML::Twig(
106 keep_spaces => 1, # dadurch auch whitespaces an ehemeligen elementgrenzen im output
107 keep_atts_order => 1, # requires Tie::IxHash
108 pretty_print => 'indented',
109 start_tag_handlers => {
110 texts => \&root
111 },
112 twig_handlers => {
113 text => \&text
114 },
115 # dtd_handlers => { # ToDo for I5
116 # \&set_dtd;
117 # }
118 output_encoding => $encoding,
119 );
120
121$twig->parsefile($ARGV[0]);
122
123close($OUT);
124
125
126###########
127# END MAIN
128###########
129
130
131
132
133##############################
134# S U B R O U T I N E S
135##############################
136
137# sub set_dtd [
138# my $twig, $dtd = @_;
139# my $internal = qq|\nPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n"DTD/xhtml1-strict.dtd"|;
140#
141# $twig->twig_doctype('html', undef, undef, $internal);
142# }
143
144
145
146sub root {
147 my ($twig, $root) =@_;
148
149 $root->set_gi('teiCorpus');
150 $root->set_att("xmlns", 'http://www.tei-c.org/ns/1.0');
151
152 &insertCorpusHeader($root);
153}
154
155
156sub insertCorpusHeader{
157 my ($root) =@_;
158
Harald Lüngenccd84902024-08-27 16:03:47 +0300159 my @array = split(/\//, $ARGV[0]);
160 my $l = scalar(@array);
161 my $source = $array[$l-1];
162 $source =~ s/\.xml//;
Harald Lüngen5bebb0c2024-08-27 16:44:34 +0300163 $source = $source . " from klk-fi-v2-vrt"; # for the time being; TODO
Harald Lüngenccd84902024-08-27 16:03:47 +0300164
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300165 my $teiHeader = $root ->insert_new_elt("first_child", 'teiHeader');
166 my $fileDesc = $teiHeader ->insert_new_elt("last_child", 'fileDesc');
Harald Lüngencaab0802024-08-23 17:28:22 +0300167 my $profileDesc = $teiHeader ->insert_new_elt("last_child", 'profileDesc');
168
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300169 my $titleStmt = $fileDesc ->insert_new_elt("last_child", 'titleStmt');
170 my $title = $titleStmt ->insert_new_elt("last_child", 'title');
Harald Lüngenccd84902024-08-27 16:03:47 +0300171 $title ->set_text($source . " from KLK-fi-2021 for EuReCo");
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300172
173 my $publicationStmt = $fileDesc ->insert_new_elt("last_child", 'publicationStmt');
174 my $distributor = $publicationStmt->insert_new_elt("last_child", 'distributor');
175 $distributor ->set_text("NOT FOR DISTRIBUTION - to be used locally in EuReCo");
176
177 my $sourceDesc = $fileDesc ->insert_new_elt("last_child", 'sourceDesc');
178 my $bibl = $sourceDesc ->insert_new_elt("last_child", 'bibl');
Harald Lüngenccd84902024-08-27 16:03:47 +0300179 $bibl ->set_text($source);
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300180
Harald Lüngencaab0802024-08-23 17:28:22 +0300181 my $langUsage = $profileDesc ->insert_new_elt("last_child", 'langUsage');
182 my $language = $langUsage ->insert_new_elt("last_child", 'language');
183 $language ->set_att("ident",'fi');
184 $language ->set_text("Finnish");
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300185}
186
187
188#----------------------------
189# handler &text for <text>
190#----------------------------
191
192sub text {
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300193 my ($twig, $text) = @_;
194
Harald Lüngencaab0802024-08-23 17:28:22 +0300195 $textcounter++; # global variable
196
197 # ToDo: catch all other, unexpected children of root
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300198
199 #--------------------------------------------------------------------------
200 # Get text metadata (attributes of <text>) and create teiHeader for <text>
201 #--------------------------------------------------------------------------
202
203 my $textattsref = $text->atts(); # $textattsref is now a reference to a hash and should be used with '->'
204
205 &createTextHeader($text, $textattsref);
206
207 #--------------------------
208 # create <TEI> from <text>
209 #--------------------------
210
211 # set vrt <text> to <TEI> and delete all attributes after they were were saved above
212 $text->del_atts;
213 $text->set_gi("TEI");
Harald Lüngencaab0802024-08-23 17:28:22 +0300214
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300215 #------------------------------------------------------------------
216 # create the <tei:text>, <body>, <div> elements inside <TEI>
217 #------------------------------------------------------------------
218
219 my $ttext_element = XML::Twig::Elt->new('text');
220 my $body_element = XML::Twig::Elt->new('body');
221 my $div_element = XML::Twig::Elt->new('div');
222
223 # set atts
Harald Lüngencaab0802024-08-23 17:28:22 +0300224 $div_element ->set_att("type", "page"); # ToDo: this is specific to KLK
225 $ttext_element->set_att("xml:lang", 'fi'); # as in ICC-NOR
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300226
227 # paste
228 $ttext_element->paste('last_child', $text);
229 $body_element ->paste('last_child', $ttext_element);
230 $div_element ->paste('last_child', $body_element);
231
232
233 #-------------------------------
234 # create <p> from <paragraph>
235 #-------------------------------
236
237 my @paragraphs = $text->children( 'paragraph');
238
239 foreach my $paragraph (@paragraphs) {
240
241 &setP($paragraph);
242
243 $paragraph->move('last_child', $div_element);
244
245
246 #------------------------------
247 # create <s> from <sentence>
248 #------------------------------
249
250 my @sentences = $paragraph->children('sentence');
251 foreach my $sentence (@sentences) {
252
253 &setS($sentence);
254
255
256 #--------------------------------------
257 # create <w> (word) from each $line
258 #--------------------------------------
259
260 my @lines = split(/\n+/, $sentence->xml_text);
261 $sentence->set_text("\n");
262
263 for my $line (@lines){ # Todo: Reihenfolge checken
264 if($line ne "" ){
265 my $w_element = XML::Twig::Elt->new('w');
266 &createW($w_element, $line);
267 $w_element->paste('last_child', $sentence);
268 }
Harald Lüngencaab0802024-08-23 17:28:22 +0300269 } # end words
270 } # end sentences
271 } # end paragraphs
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300272
Harald Lüngencaab0802024-08-23 17:28:22 +0300273 $twig->flush($OUT);
274} # end texts
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300275
276
277sub createTextHeader{
278 my ($text, $textattsref) = @_;
279
280 # USE 01 binding_id="2246025"
281 # USE 02 date="2021-01-15"
282 # 03 datefrom="20210115"
283 # 04 dateto="20210115"
284 # 05 elec_date="_"
285 # 06 file=""
286 # USE 07 filename_metadata="finclarin_siirto_k2021/0039-5552/2021/alto/2246025_0039-5552_2021-01-15_SK0221_mets.xml"
287 # USE 08 filename_orig ="finclarin_siirto_k2021/0039-5552/2021/alto/2246025_0039-5552_2021-01-15_SK0221_page-2021011502210030301.xml
288 # USE 09 id="t-bcd0f3fa-bbd3dac4"
289 # 10 img_url=""
290 # USE 11 issue_date="15.01.2021"
291 # USE 12 issue_no="SK0221"
292 # USE 13 issue_title="Suomen Kuvalehti"
293 # USE 14 label="Suomen Kuvalehti no. SK0221 15.01.2021"
294 # USE 16 language="fi"
295 # USE 17 page_id="p1"
296 # USE 18 page_no="None"
297 # 19 part_name="_"
298 # 20 publ_id="0039-5552"
299 # 21 publ_part=""
300 # USE 22 publ_title="Suomen Kuvalehti"
301 # USE 23 publ_type="aikakausi"
302 # USE 24 sentcount="70"
303 # USE 25 sum_lang="|xxx:44|fin:23|eng:3|"
304 # 26 timefrom="000000"
305 # 27 timeto="235959"
306 # USE 28 tokencount="304"
307 # 29 version_added="KLK-fi-2021">
308
309
310 my $BID = $textattsref->{'binding_id'};
311 my $DATE = $textattsref->{'date'};
312 my $METAFILENAME = $textattsref->{'filename_metadata'};
313 my $ORIGFILENAME = $textattsref->{'filename_orig'};
314 my $ID = $textattsref->{'id'};
315 my $ISSUEDATE = $textattsref->{'issue_date'};
316 my $ISSUENO = $textattsref->{'issue_no'};
317 my $ISSUETITLE = $textattsref->{'issue_title'};
318 my $LABEL = $textattsref->{'label'};
319 my $LANGUAGE = $textattsref->{'language'};
320 my $PAGEID = $textattsref->{'page_id'};
321 my $PAGENO = $textattsref->{'page_no'};
322 my $PUBLTITLE = $textattsref->{'publ_title'};
323 my $PUBLTYPE = $textattsref->{'publ_type'};
324 my $SENTCOUNT = $textattsref->{'sentcount'};
325 my $SUMLANG = $textattsref->{'sum_lang'};
326 my $TOKENCOUNT = $textattsref->{'tokencount'};
327
328
329 #-----------------------------
330 # Derived Metadata variables
331 #-----------------------------
332
333 my @datearray = split("-", $DATE);
334 my @langarray = split("|", $SUMLANG);
335 my @namearray = split(/[\.\/]/, $ORIGFILENAME); # use $namearray[4] as ID for the page
336
337
338 #-----------------------------------------------------------------------
339 # CREATE text-teiHeader ACCORDING TO THE SKELETON in klk-header.tei.xml
340 #-----------------------------------------------------------------------
341
342 # create <teiHeader> inside <TEI>
343 my $teiHeader = XML::Twig::Elt->new('teiHeader');
344 $teiHeader->paste('first_child', $text);
345
346 ## insert_new_elt is a combo of new and paste, cf. xml::twig docu:
347 ## insert_new_elt ($opt_position, $gi, $opt_atts_hashref, @opt_content)
348
349 my $fileDesc = $teiHeader->insert_new_elt('fileDesc' => {n => "EuReCo_KLK-fi_" . $namearray[4]});
350 my $encodingDesc = $teiHeader->insert_new_elt("last_child", 'encodingDesc');
351 my $profileDesc = $teiHeader->insert_new_elt("last_child", 'profileDesc');
352 my $revisionDesc = $teiHeader->insert_new_elt("last_child", 'revisionDesc');
353
354 #---------------------
355 # fileDesc/titleStmt
356 #---------------------
357 my $titleStmt = $fileDesc ->insert_new_elt('titleStmt');
358 my $title = $titleStmt->insert_new_elt("last_child", 'title');
359 my $respStmt = $titleStmt->insert_new_elt("last_child", 'respStmt');
360 my $resp = $respStmt ->insert_new_elt("last_child", 'resp');
361 my $name = $respStmt ->insert_new_elt("last_child", 'name');
362
363 # set texts for titleStmt
Harald Lüngencaab0802024-08-23 17:28:22 +0300364 # $title->set_text($LABEL . ", page " . $PAGENO); # Achtung - PAGENO scheint meist "None" zu sein
365 $title->set_text($LABEL . ", Text #" . $textcounter); # at least for Suomen Kuvalehti
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300366 $resp ->set_text("compiled by EuReCo");
367 $name ->set_text("EuReCo: HL");
368
369 #--------------------------
370 # fileDesc/publicationStmt
371 #--------------------------
372 my $publicationStmt = $fileDesc ->insert_new_elt("last_child", 'publicationStmt');
373 my $distributor = $publicationStmt->insert_new_elt("last_child", 'distributor');
374 my $note = $distributor ->insert_new_elt("last_child", 'note');
375 my $availability = $publicationStmt->insert_new_elt("last_child", 'availability');
376 my $licence = $availability ->insert_new_elt("last_child", 'licence');
377
378 # set texts for publicationStmt
379 $note ->set_text("NOT FOR DISTRIBUTION - to be used locally in EuReCo");
380 $licence->set_text("CLARIN-RES"); # TODO: Ausfuherlichere Licence info in KLK Metadata Record
381
382 #------------------------------
383 # fileDesc/sourceDesc/biblStruct
384 #------------------------------
385 my $sourceDesc = $fileDesc ->insert_new_elt("last_child", 'sourceDesc');
386 my $biblStruct = $sourceDesc->insert_new_elt("last_child", 'biblStruct');
387
388 # fileDesc/sourceDesc/biblStruct/analytic
389 my $analytic = $biblStruct->insert_new_elt("last_child", 'analytic');
390 my $analytic_title = $analytic->insert_new_elt("last_child", 'title' => {type => "main"} );
391# my $analytic_date = $analytic->insert_new_elt("last_child", 'date');
392 my $analytic_date_year = $analytic->insert_new_elt("last_child", 'date' => {type => "year"});
393 my $analytic_date_month = $analytic->insert_new_elt("last_child", 'date' => {type => "month"});
394 my $analytic_date_day = $analytic->insert_new_elt("last_child", 'date' => {type => "day"});
395 my $analytic_idno_pageid = $analytic->insert_new_elt("last_child", 'idno' => {type => "PAGEID"});
396 my $analytic_idno_bindingid = $analytic->insert_new_elt("last_child", 'idno' => {type => "BINDINGID"});
397 my $analytic_idno_id = $analytic->insert_new_elt("last_child", 'idno' => {type => "ID"});
398 my $analytic_idno_metafile = $analytic->insert_new_elt("last_child", 'idno' => {type => "KIELIPANKKI_METAFILENAME"});
399 my $analytic_idno_origfile = $analytic->insert_new_elt("last_child", 'idno' => {type => "KIELIPANKKI_ORIGFILENAME"});
400 my $analytic_textlang = $analytic->insert_new_elt("last_child", 'textLang');
401
402 # set texts for analytic
Harald Lüngencaab0802024-08-23 17:28:22 +0300403# $analytic_title ->set_text($LABEL . ", page " . $PAGENO); # Achtung $PAGENO scheint meist "None zu sein"
404 $analytic_title ->set_text($LABEL . ", Text #" . $textcounter); # Achtung $PAGENO scheint meist "None zu sein"
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300405# $analytic_date ->set_text($DATE);
406 $analytic_date_year ->set_text($datearray[0]);
407 $analytic_date_month ->set_text($datearray[1]);
408 $analytic_date_day ->set_text($datearray[2]);
409 $analytic_idno_pageid ->set_text($PAGEID);
410 $analytic_idno_bindingid->set_text($BID);
411 $analytic_idno_id ->set_text($ID);
412 $analytic_idno_metafile ->set_text($METAFILENAME);
413 $analytic_idno_origfile ->set_text($ORIGFILENAME);
414 $analytic_textlang ->set_text($LANGUAGE);
415
416 #-------------------------------------
417 # fileDesc/sourceDesc/biblStruct/monogr
418 #-------------------------------------
419 my $monogr = $biblStruct->insert_new_elt("last_child", 'monogr');
420 my $monogr_title = $monogr ->insert_new_elt("last_child", 'title');
421 my $imprint = $monogr ->insert_new_elt("last_child", 'imprint'); # imprint is needed for valididty
422 my $pubPlace = $imprint ->insert_new_elt("last_child", 'pubPlace'); # imprint is needed for validity
423 my $publisher = $imprint ->insert_new_elt("last_child", 'publisher'); # imprint is needed for validity
424 my $biblScope_issuetitle = $monogr ->insert_new_elt("last_child", 'biblScope' => {unit => 'ISSUETITLE'} );
425 my $biblScope_issueno = $monogr ->insert_new_elt("last_child", 'biblScope' => {unit => 'ISSUENO'} );
426 my $biblScope_issuedate = $monogr ->insert_new_elt("last_child", 'biblScope' => {unit => 'ISSUEDATE'} );
427 my $biblScope_pp = $monogr ->insert_new_elt("last_child", 'biblScope' => {unit => 'PAGENO'} ); # Achtung PAGENO ist meist "None" ?
428
429 # set texts for monogr
430 $monogr_title ->set_text($PUBLTITLE);
431 $pubPlace ->set_text("TODO");
Harald Lüngencaab0802024-08-23 17:28:22 +0300432 $pubPlace ->set_att("key",'FI');
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300433 $publisher ->set_text("TODO");
434 $biblScope_issuetitle->set_text($ISSUETITLE);
435 $biblScope_issueno ->set_text($ISSUENO);
436 $biblScope_issuedate ->set_text($ISSUEDATE);
437 $biblScope_pp ->set_text($PAGENO);
438
439 #---------------
440 # encodingDesc
441 #---------------
442 my $tagsDecl = $encodingDesc->insert_new_elt("last_child", 'tagsDecl');
443 my $namespace = $tagsDecl ->insert_new_elt("last_child", 'namespace' => {name => 'http://www.tei-c.org/ns/1.0'});
444 my $tagUsage_s = $namespace ->insert_new_elt("last_child", 'tagUsage' => {gi => 's', occurs => $SENTCOUNT});
445 my $tagUsage_w = $namespace ->insert_new_elt("last_child", 'tagUsage' => {gi => 'w', occurs => $TOKENCOUNT});
446
447 #-------------
448 # profileDesc
449 #-------------
450 my $langUsage = $profileDesc ->insert_new_elt("last_child", 'langUsage');
451 my $language = $langUsage ->insert_new_elt("last_child", 'language' => {ident => $LANGUAGE, usage => $SUMLANG});
452 # Achtung in @usage muss eigt. ein integer; am besten inhalt von SUMLANG aufdroeseln und mehrere <language> machen
453 my $textClass = $profileDesc ->insert_new_elt("last_child", 'textClass');
454 my $classCode_fi = $textClass ->insert_new_elt("last_child", 'classCode' => {scheme => "KLK_PUBLTYPE"});
455# my $classCode_en = $textClass ->insert_new_elt("last_child", 'classCode' => {scheme => "KLK_PUBLTYPE_MAPPED"});
456
457 #---------------------------
458 # set texts for profileDesc
459 #---------------------------
460 $classCode_fi ->set_text($PUBLTYPE);
461# $classCode_en->set_text($PUBLTYPETRANSL);
462
463 #---------------
464 # revisionDesc
465 #---------------
466 my $change = $revisionDesc ->insert_new_elt("last_child", 'change' => {when => localtime->ymd('-'), who => 'HL' });
467
468 # set texts for revisionDesc
469 $change->set_text("TEI version for EuReCo");
470
471
472 ###################################
473 # END OF CREATING TEIHEADER
474 ###################################
475
476}
477
478sub setP {
479 my ($paragraph) = @_;
480
481 $paragraph->set_gi('p');
482
483 # <paragraph id="p-bcd0f3fa-bbd3dac4-815ead7a" sum_lang="|fin:1|">
484 # atts of <paragraph>:
485 # @id USE
486 # @sum_lang USE: put in xml:lang and prefix the value with "x-" for private value
487
488 $paragraph->set_att("xml:lang", "x-" . $paragraph->att("sum_lang"));
489 $paragraph->del_att("sum_lang");
490 $paragraph->change_att_name('id', 'xml:id');
491}
492sub setS {
493 my ($sentence) = @_;
494
495 $sentence->set_gi('s');
496
497 # the atts of <sentence>:
498 # USE 1 @id="s-bcd0f3fa-bbd3dac4-f7429090"
499 # USE 2 @lang="fin" -> xml:lang
500 # ? 3 @lang_conf="0.6734853"> -> ToDo @cert ?
501
502 # set attrs of <s>
503 $sentence->set_att("xml:lang", $sentence->att("lang")); # ToDo: convert the value / introduce a hash for lookup (input values: "fin", "xxx", ....)
Harald Lüngenfaf8d482024-08-27 21:19:47 +0300504 # $sentence->change_att_name('id', 'xml:id'); # nicht eindeutig
505 $sentence->del_att('id');
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300506 $sentence->del_att("lang"); # replaced by xml:lang
507 $sentence->del_att("lang_conf"); # for the time being
508
509}
510
511sub createW {
512 my ($w_element, $line) = @_;
513
514 #---------------------------
515 # Get the tags (=columns)
516 #---------------------------
517
518 my @tags = split(/\t/, $line);
519
520 # set content of <w> i.e. the token
521 $w_element->set_text($tags[0]);
522
523 # vrt positional-attributes in corpus KLK:
524 # USE [0] word
525 # USE [1] ref (id for reference of dephead)
526 # USE [2] lemma
527 # ? [3] lemmacomp (lemma with compound info - could go in @norm, as tag abuse?)
528 # USE [4] pos
529 # USE [5] msd
530 # USE [6] dephead
531 # USE [7] deprel
532 # [8] content (ocr-process)
533 # [9] vpos (ocr-process)
534 # [10] ocr (ocr-process)
535 # [11] cc (ocr-process)
536 # [12] hyph (ocr-process)
537 # [13] style (ocr-process)
538 # [14] lex (korp semantic disambiguation from G"oteborg)
539
540 # set the attributes of <w>:
541 $w_element->set_att("n", $tags[1]);
542 # $w_element->set_att("id", "w_" . $namearray[4] . $sentence->att("xml:id") . "_" . $tags[1]);
543 # so zusammengebaute ID ist auch nicht eindeutig...
Harald Lüngenfaf8d482024-08-27 21:19:47 +0300544 $w_element->del_att("id");
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300545 $w_element->set_att("lemma", $tags[2]);
546 # $w_element->set_att("norm", $tags[3]); # tag abuse of @norm
547 $w_element->set_att("pos", $tags[4]);
548 $w_element->set_att("msd", $tags[5]);
Harald Lüngenccd84902024-08-27 16:03:47 +0300549#TMP $w_element->set_att("head", $tags[6]);
550#TMP $w_element->set_att("deprel", $tags[7]);
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300551
552}
553
554#################
555## usage_message
556#################
557
558
559sub usage_message {
Harald Lüngena7e91622024-08-23 17:33:11 +0300560 print " Usage: ./vrt2tei.pl <file.vrt.xml> <outfile>\n";
Harald Lüngen9d4e0462024-08-23 09:34:22 +0300561 print " <file.vrt.xml> is a VRT file converted to proper XML\n";
562 exit;
563}
564
565