-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview_in_larex.sh
executable file
·77 lines (64 loc) · 2.26 KB
/
view_in_larex.sh
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <path_to_zip_file> <file_group>"
exit 1
fi
SCRIPT_PATH="$(dirname "$(realpath "$0")")"
WORKSPACE="${1%.*}"
FILE_GROUP=$2
unzip -o $WORKSPACE -d "$WORKSPACE"_larex
# rename the files by removing OCR-D-OCR_
for FILE in "$WORKSPACE"_larex/data/OCR-D-OCR/OCR-D-OCR_*.xml; do
if [ ! -e "$FILE" ]; then
echo "No files matching the pattern in '$DIRECTORY'."
break
fi
NEW_FILE="${FILE/OCR-D-OCR_/}"
mv "$FILE" "$NEW_FILE"
echo "Renamed '$FILE' to '$NEW_FILE'"
done
# rename the files by removing _OCR-D-OCR
for FILE in "$WORKSPACE"_larex/data/OCR-D-OCR/*_OCR-D-OCR.xml; do
if [ ! -e "$FILE" ]; then
echo "No files matching the pattern in '$DIRECTORY'."
break
fi
NEW_FILE="${FILE/_OCR-D-OCR/}"
mv "$FILE" "$NEW_FILE"
echo "Renamed '$FILE' to '$NEW_FILE'"
done
# rename the images by removing _FILE_GROUP
for FILE in "$WORKSPACE"_larex/data/$FILE_GROUP/*_$FILE_GROUP.*; do
if [ ! -e "$FILE" ]; then
echo "No files matching the pattern in '$DIRECTORY'."
break
fi
NEW_FILE="${FILE/_$FILE_GROUP/}"
mv "$FILE" "$NEW_FILE"
echo "Renamed '$FILE' to '$NEW_FILE'"
done
# rename the images by removing FILE_GROU_
for FILE in "$WORKSPACE"_larex/data/$FILE_GROUP/${FILE_GROUP}_*; do
if [ ! -e "$FILE" ]; then
echo "No files matching the pattern in '$DIRECTORY'."
break
fi
NEW_FILE="${FILE/${FILE_GROUP}_/}"
mv "$FILE" "$NEW_FILE"
echo "Renamed '$FILE' to '$NEW_FILE'"
done
mkdir -p $SCRIPT_PATH/Larex_Data/
mkdir -p $SCRIPT_PATH/Larex_Data/$(basename "$WORKSPACE")
mv "$WORKSPACE"_larex/data/OCR-D-OCR/* $SCRIPT_PATH/Larex_Data/$(basename "$WORKSPACE")
mv "$WORKSPACE"_larex/data/$FILE_GROUP/* $SCRIPT_PATH/Larex_Data/$(basename "$WORKSPACE")
rm -r "$WORKSPACE"_larex
if [ ! "$(docker ps -q -f name=larex)" ]; then
echo "Larex is not running. Starting the container..."
docker run -d -p 1476:8080 --name larex -v $SCRIPT_PATH/Larex_Data:/home/books uniwuezpd/larex
if [ $? -ne 0 ]; then
log_error "Failed to start larex docker image."
exit 1
fi
fi
echo "the results are accessible now through Larex at http://localhost:1476/Larex/"