Harald Lüngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 1 | #/bin/bash |
| 2 | |
| 3 | EURECO="/scratch/project_2010889/eureco" |
| 4 | |
| 5 | CORPUS="$EURECO/klk-fi-v2-vrt" |
| 6 | TEIDTD="$EURECO/tei/tei_all.dtd" |
| 7 | |
| 8 | DAT="$CORPUS/data" # input vrt files of klk-fi by year |
| 9 | XML="$CORPUS/XML" # output zipped vrtxml files of selection of papers |
| 10 | TEI="$CORPUS/TEI" # output zipped tei files of the selection |
| 11 | |
| 12 | |
| 13 | mkdir -p $XML |
| 14 | mkdir -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" |
| 33 | for VRT in "$DAT/klk_fi_v2_2021.vrt" # to be applied to yearly files |
| 34 | do # ( |
| 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üngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 42 | # 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üngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 47 | SOURCE=`basename $s` |
| 48 | x=$s/$SOURCE$YY.xml |
| 49 | |
Harald Lüngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 50 | ## 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üngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 57 | BASENAME=`basename $x .xml` |
| 58 | mkdir -p $TEI/$SOURCE |
Harald Lüngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 59 | t="$TEI/$SOURCE/$BASENAME.tei.xml" |
Harald Lüngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 60 | t0="$TEI/$SOURCE/$BASENAME.tei.0.xml" |
Harald Lüngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 61 | |
Harald Lüngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 62 | echo " generating $t0 using vrt2tei.pl" |
| 63 | ./vrt2tei.pl $x > $t0 |
Harald Lüngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 64 | |
Harald Lüngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 65 | 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üngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 68 | ls -l $t |
Harald Lüngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 69 | |
| 70 | echo " validating..." |
| 71 | xmllint --stream --noout --dtdvalid $TEIDTD $t # scheint so zu funktioneren - nicht kombinieren mit --format! |
Harald Lüngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 72 | |
Harald Lüngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 73 | # echo " zipping $x..." |
| 74 | # gzip -f $x |
Harald Lüngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 75 | |
Harald Lüngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 76 | # echo " zipping $t..." |
| 77 | # gzip -f $t |
| 78 | |
| 79 | echo # ) & |
Harald Lüngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 80 | done |
Harald Lüngen | 6feedd2 | 2024-08-29 13:33:59 +0300 | [diff] [blame^] | 81 | # wait # ) & # wait does not seem to make sense if nothing follows |
Harald Lüngen | 5bebb0c | 2024-08-27 16:44:34 +0300 | [diff] [blame] | 82 | |
| 83 | done |
| 84 | # wait |
| 85 | |
| 86 | |
| 87 | |