2007-07-18 09:11:18 +08:00
|
|
|
#!/bin/bash
|
2016-11-19 07:53:11 +08:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2007-07-18 09:11:18 +08:00
|
|
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
then
|
|
|
|
echo "Usage:$0 scantype"
|
|
|
|
echo "UNLV data comes in several scan types:"
|
|
|
|
echo "3B=300 dpi binary"
|
|
|
|
echo "3A=adaptive thresholded 300 dpi"
|
|
|
|
echo "3G=300 dpi grey"
|
|
|
|
echo "4B=400dpi binary"
|
|
|
|
echo "2B=200dpi binary"
|
|
|
|
echo "For now we only use 3B"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
ext=$1
|
|
|
|
|
|
|
|
#There are several test sets without meaningful names, so rename
|
|
|
|
#them with something a bit more meaningful.
|
|
|
|
#Each s is oldname/newname
|
|
|
|
for s in 3/doe3 B/bus M/mag N/news L/legal R/rep S/spn Z/zset
|
|
|
|
do
|
|
|
|
old=${s%/*}
|
|
|
|
#if this set was downloaded then process it.
|
|
|
|
if [ -r "$old/PAGES" ]
|
|
|
|
then
|
|
|
|
new=${s#*/}.$ext
|
2017-04-08 16:18:01 +08:00
|
|
|
mkdir -p "$new"
|
2007-07-18 09:11:18 +08:00
|
|
|
echo "Set $old -> $new"
|
|
|
|
#The pages file had - instead of _ so fix it and add the extension.
|
2016-12-14 21:11:24 +08:00
|
|
|
for page in $(cat $old/PAGES)
|
2007-07-18 09:11:18 +08:00
|
|
|
do
|
|
|
|
echo "${page%-*}_${page#*-}.$ext"
|
2017-04-08 16:18:01 +08:00
|
|
|
done >"$new/pages"
|
|
|
|
for f in $(cat "$new/pages")
|
2007-07-18 09:11:18 +08:00
|
|
|
do
|
|
|
|
#Put a tif extension on the tif files.
|
2017-04-08 16:18:01 +08:00
|
|
|
cp "$old/${old}_B/$f" "$new/$f.tif"
|
2007-07-18 09:11:18 +08:00
|
|
|
#Put a uzn extension on the zone files.
|
2017-04-08 16:18:01 +08:00
|
|
|
cp "$old/${old}_B/${f}Z" "$new/$f.uzn"
|
2007-07-18 09:11:18 +08:00
|
|
|
#Cat all the truth files together and put into a single txt file.
|
2017-04-08 16:18:01 +08:00
|
|
|
cat "$old/${old}_GT/${f%.$ext}".Z* >"$new/$f.txt"
|
2007-07-18 09:11:18 +08:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|