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 | |
| 42 | echo "Checking Wellformedness and generating TEI..." |
| 43 | for s in $XML/*/ |
| 44 | # for s in $XML/Aamulehti/ |
| 45 | do ( # threading |
| 46 | |
| 47 | SOURCE=`basename $s` |
| 48 | x=$s/$SOURCE$YY.xml |
| 49 | |
| 50 | echo " checking wellformedness of $x" |
| 51 | xmllint --noout $x # ToDo: make if condition for continuing only if well-formed |
| 52 | |
| 53 | BASENAME=`basename $x .xml` |
| 54 | mkdir -p $TEI/$SOURCE |
| 55 | u="$TEI/$SOURCE/$BASENAME.tei.0.xml" |
| 56 | t="$TEI/$SOURCE/$BASENAME.tei.xml" |
| 57 | |
| 58 | echo " generating $u..." |
| 59 | ./vrt2tei.pl $x $u # ToDo: pipe in and out |
| 60 | |
| 61 | echo " zipping $x..." |
| 62 | gzip $x |
| 63 | |
| 64 | echo " validating and prettifying $u..." |
| 65 | xmllint --format --dtdvalid $TEIDTD $u > $t |
| 66 | ls -l $t |
| 67 | |
| 68 | echo " removing $u..." |
| 69 | rm $u; |
| 70 | echo " zipping $t..." |
| 71 | gzip $t |
| 72 | |
| 73 | echo ) & |
| 74 | done |
| 75 | wait # ) & |
| 76 | |
| 77 | done |
| 78 | # wait |
| 79 | |
| 80 | |
| 81 | |