blob: 47a67b6fcc3116598cd8cf0a1f058e8a40fc0603 [file] [log] [blame]
Harald Lüngen5bebb0c2024-08-27 16:44:34 +03001#/bin/bash
2
3EURECO="/scratch/project_2010889/eureco"
4
5CORPUS="$EURECO/klk-fi-v2-vrt"
6TEIDTD="$EURECO/tei/tei_all.dtd"
7
8DAT="$CORPUS/data" # input vrt files of klk-fi by year
9XML="$CORPUS/XML" # output zipped vrtxml files of selection of papers
10TEI="$CORPUS/TEI" # output zipped tei files of the selection
11
12
13mkdir -p $XML
14mkdir -p $TEI
15
16
17
18# Multiple threads for a loop in bash:
19
20## for stuff in things
21## do
22## ( something
23## with
24## stuff ) &
25## done
26## wait # for all the something with stuff
27
28
29
30# Generate corpus files by year and source in vrt
31
32# for VRT in "$DAT/*.vrt"
33for VRT in "$DAT/klk_fi_v2_2021.vrt" # to be applied to yearly files
34do # (
35
36 BASENAME=`basename $VRT .vrt`
37 YY=`echo $BASENAME | gawk 'BEGIN {FS="_"} {print $4}'`
38
39 echo "Generating proper XML files from $VRT in $XML/$YY by source..."
40 #gawk -v OUTDIR="$XML" -v YEAR="$YY" -f vrt2xml.awk $VRT # will generate corpus files for different sources in the YEAR dir
41
Harald Lüngen6feedd22024-08-29 13:33:59 +030042 # Checking Wellformedness of the XML and generating TEI
43 # for s in $XML/*/
44 # for s in $XML/Suomen_Kuvalehti/
45 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/
46 do # ( # threading
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030047 SOURCE=`basename $s`
48 x=$s/$SOURCE$YY.xml
49
Harald Lüngen6feedd22024-08-29 13:33:59 +030050 ## echo " checking wellformedness of $x"
51 ## xmllint --noout $x # ToDo: make if condition for continuing only if well-formed
52 # if($R != 0){
53 # echo "Error: xmllint error with error return code $R" >&2; # to stderr
54 # break;
55 # }
56
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030057 BASENAME=`basename $x .xml`
58 mkdir -p $TEI/$SOURCE
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030059 t="$TEI/$SOURCE/$BASENAME.tei.xml"
Harald Lüngen6feedd22024-08-29 13:33:59 +030060 t0="$TEI/$SOURCE/$BASENAME.tei.0.xml"
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030061
Harald Lüngen6feedd22024-08-29 13:33:59 +030062 echo " generating $t0 using vrt2tei.pl"
63 ./vrt2tei.pl $x > $t0
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030064
Harald Lüngen6feedd22024-08-29 13:33:59 +030065 echo " prettifying..."
66 #xmllint --format $t0 > $t # geht out of memory und --stream machen funktioniert nicht
67 xml_pp $t0 > $t # works but takes ages
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030068 ls -l $t
Harald Lüngen6feedd22024-08-29 13:33:59 +030069
70 echo " validating..."
71 xmllint --stream --noout --dtdvalid $TEIDTD $t # scheint so zu funktioneren - nicht kombinieren mit --format!
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030072
Harald Lüngen6feedd22024-08-29 13:33:59 +030073 # echo " zipping $x..."
74 # gzip -f $x
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030075
Harald Lüngen6feedd22024-08-29 13:33:59 +030076 # echo " zipping $t..."
77 # gzip -f $t
78
79 echo # ) &
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030080 done
Harald Lüngen6feedd22024-08-29 13:33:59 +030081 # wait # ) & # wait does not seem to make sense if nothing follows
Harald Lüngen5bebb0c2024-08-27 16:44:34 +030082
83done
84# wait
85
86
87