upload.sh
893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/zsh
if [ ! -d "$1" -o "$2" ]; then
echo "Syntax: $0 <folder>"
exit
fi
IN=$(realpath $1)
REMOTE=korektor:/var/www/korektor/doc
CORRECTIONS=~/Programowanie/clarin/korekta
TEI=output/_export
# Compress files if needed
if [ -e "$IN/**/*.xml" ]; then
echo -n "Compressing files..."
gzip "$IN/**/*.xml"
echo "OK"
fi
# Recreate structure
echo -n "Renaming folders..."
rm -rf $TEI
mkdir -p $TEI
for folder in $1/*/; do
OUT="$TEI/$(python odt2tei/kdppath.py $folder)"
mkdir -p $(dirname "$OUT")
cp -R $folder "$OUT"
done
echo "OK"
echo -n "Compressing..."
gzip $TEI/**/*.xml
echo "OK"
echo -n "Uploading files..."
rsync -a --delete $TEI/ korektor:export
echo "OK"
# Find corrections
TEI_ABSOLUTE=$(realpath $TEI)
echo -n "Finding corrections..."
cd $CORRECTIONS
python korekta.py -o bugs.json $TEI_ABSOLUTE
scp -q bugs.json $REMOTE
echo "$(rg -cw 'id":' bugs.json) corrections"
cd -