blob: 47a67b6fcc3116598cd8cf0a1f058e8a40fc0603 [file] [log] [blame]
#/bin/bash
EURECO="/scratch/project_2010889/eureco"
CORPUS="$EURECO/klk-fi-v2-vrt"
TEIDTD="$EURECO/tei/tei_all.dtd"
DAT="$CORPUS/data" # input vrt files of klk-fi by year
XML="$CORPUS/XML" # output zipped vrtxml files of selection of papers
TEI="$CORPUS/TEI" # output zipped tei files of the selection
mkdir -p $XML
mkdir -p $TEI
# Multiple threads for a loop in bash:
## for stuff in things
## do
## ( something
## with
## stuff ) &
## done
## wait # for all the something with stuff
# Generate corpus files by year and source in vrt
# for VRT in "$DAT/*.vrt"
for VRT in "$DAT/klk_fi_v2_2021.vrt" # to be applied to yearly files
do # (
BASENAME=`basename $VRT .vrt`
YY=`echo $BASENAME | gawk 'BEGIN {FS="_"} {print $4}'`
echo "Generating proper XML files from $VRT in $XML/$YY by source..."
#gawk -v OUTDIR="$XML" -v YEAR="$YY" -f vrt2xml.awk $VRT # will generate corpus files for different sources in the YEAR dir
# Checking Wellformedness of the XML and generating TEI
# for s in $XML/*/
# for s in $XML/Suomen_Kuvalehti/
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/
do # ( # threading
SOURCE=`basename $s`
x=$s/$SOURCE$YY.xml
## echo " checking wellformedness of $x"
## xmllint --noout $x # ToDo: make if condition for continuing only if well-formed
# if($R != 0){
# echo "Error: xmllint error with error return code $R" >&2; # to stderr
# break;
# }
BASENAME=`basename $x .xml`
mkdir -p $TEI/$SOURCE
t="$TEI/$SOURCE/$BASENAME.tei.xml"
t0="$TEI/$SOURCE/$BASENAME.tei.0.xml"
echo " generating $t0 using vrt2tei.pl"
./vrt2tei.pl $x > $t0
echo " prettifying..."
#xmllint --format $t0 > $t # geht out of memory und --stream machen funktioniert nicht
xml_pp $t0 > $t # works but takes ages
ls -l $t
echo " validating..."
xmllint --stream --noout --dtdvalid $TEIDTD $t # scheint so zu funktioneren - nicht kombinieren mit --format!
# echo " zipping $x..."
# gzip -f $x
# echo " zipping $t..."
# gzip -f $t
echo # ) &
done
# wait # ) & # wait does not seem to make sense if nothing follows
done
# wait