blob: 2e0d90876eb35f7521d27566b3d58ab038b1a482 [file] [log] [blame]
Harald Lüngen5bebb0c2024-08-27 16:44:34 +03001#/bin/bash
2
3EURECO="/scratch/project_2010889/eureco"
Harald Lüngen197aa202024-09-04 17:42:31 +03004TEST="/scratch/project_2010889/TEST"
Harald Lüngen5bebb0c2024-08-27 16:44:34 +03005
6CORPUS="$EURECO/klk-fi-v2-vrt"
7TEIDTD="$EURECO/tei/tei_all.dtd"
8
9DAT="$CORPUS/data" # input vrt files of klk-fi by year
Harald Lüngen197aa202024-09-04 17:42:31 +030010XML="$CORPUS/XML" # output zipped vrtxml files of selection of newspapers
11#XML="$TEST/XML" # output zipped vrtxml files of selection of newspapers
12#TEI="$CORPUS/TEI" # output zipped tei files of the selection
13TEI="$TEST/TEI" # output zipped tei files of the selection
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030014
Harald Lüngen197aa202024-09-04 17:42:31 +030015mkdir -p $TEST
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030016mkdir -p $XML
17mkdir -p $TEI
18
19
20
21# Multiple threads for a loop in bash:
22
23## for stuff in things
24## do
25## ( something
26## with
27## stuff ) &
28## done
29## wait # for all the something with stuff
30
31
32
33# Generate corpus files by year and source in vrt
34
35# for VRT in "$DAT/*.vrt"
36for VRT in "$DAT/klk_fi_v2_2021.vrt" # to be applied to yearly files
37do # (
38
39 BASENAME=`basename $VRT .vrt`
40 YY=`echo $BASENAME | gawk 'BEGIN {FS="_"} {print $4}'`
41
Harald Lüngen197aa202024-09-04 17:42:31 +030042 #echo "Generating proper XML files from $VRT in $XML/$YY by source..."
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030043 #gawk -v OUTDIR="$XML" -v YEAR="$YY" -f vrt2xml.awk $VRT # will generate corpus files for different sources in the YEAR dir
44
Harald Lüngen6feedd22024-08-29 13:33:59 +030045 # Checking Wellformedness of the XML and generating TEI
46 # for s in $XML/*/
Harald Lüngen197aa202024-09-04 17:42:31 +030047 for s in $XML/Suomen_Kuvalehti/
48 # for s in $XML/Helsingin_Sanomat/
49 # for s in $XML/Aamulehti/ $XML/Etela-Suomen_Sanomat/ $XML/Hameen_Sanomat/ $XML/Helsingin_Sanomat/ $XML/Ilkka-Pohjalainen/ $XML/Ilta-Sanomat/ $XML/Kaleva/ $XML/Keskipohjanmaa/ $XML/Satakunnan_Kansa/ $XML/Savon_Sanomat/ $XML/Turun_Sanomat/
Harald Lüngen6feedd22024-08-29 13:33:59 +030050 do # ( # threading
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030051 SOURCE=`basename $s`
52 x=$s/$SOURCE$YY.xml
53
Harald Lüngen6feedd22024-08-29 13:33:59 +030054 ## echo " checking wellformedness of $x"
Harald Lüngen86cbd932024-09-10 15:52:18 +030055 ## xmllint --noout $x # ToDo: make if condition for continuing only if well-formed
Harald Lüngen6feedd22024-08-29 13:33:59 +030056 # if($R != 0){
Harald Lüngen86cbd932024-09-10 15:52:18 +030057 # echo "Error: xmllint error with error return code $R" >&2;
Harald Lüngen6feedd22024-08-29 13:33:59 +030058 # break;
59 # }
60
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030061 BASENAME=`basename $x .xml`
62 mkdir -p $TEI/$SOURCE
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030063 t="$TEI/$SOURCE/$BASENAME.tei.xml"
Harald Lüngen6feedd22024-08-29 13:33:59 +030064 t0="$TEI/$SOURCE/$BASENAME.tei.0.xml"
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030065
Harald Lüngen197aa202024-09-04 17:42:31 +030066 echo " generating $t using vrt2tei.pl, and prettifying..."
Harald Lüngen86cbd932024-09-10 15:52:18 +030067 ./vrt2tei.pl $x | xml_pp > $t # xml_pp works but takes ages; xmllint- format geht out of memory und --stream machen funktioniert nicht
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030068
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030069 ls -l $t
Harald Lüngen6feedd22024-08-29 13:33:59 +030070
71 echo " validating..."
72 xmllint --stream --noout --dtdvalid $TEIDTD $t # scheint so zu funktioneren - nicht kombinieren mit --format!
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030073
Harald Lüngen6feedd22024-08-29 13:33:59 +030074 # echo " zipping $x..."
75 # gzip -f $x
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030076
Harald Lüngen6feedd22024-08-29 13:33:59 +030077 # echo " zipping $t..."
78 # gzip -f $t
79
80 echo # ) &
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030081 done
Harald Lüngen6feedd22024-08-29 13:33:59 +030082 # wait # ) & # wait does not seem to make sense if nothing follows
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030083
84done
85# wait
86
87
88