Skip to content
Permalink
968822242a
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 132 lines (114 sloc) 2.81 KB
#!/bin/bash
BASE_DIR=$(dirname $0)/..
SCRIPT_DIR=$(dirname $0)
#######################################
# variables
#######################################
input_dir="$BASE_DIR/schema/legacy/generated/analysis"
output_dir="$BASE_DIR/schema/legacy/generated"
verbosity="2"
modules=
debug_modules=()
#######################################
# functions
#######################################
function print_help {
echo "create output from rnc analysis results"
echo
echo "usage: $0 [OPTIONS]"
echo
echo "ARGS:"
echo " OUTPUT_FORMAT: odd. default: $output_format"
echo
echo "OPTIONS:"
echo " -h | --help: print this help"
echo " -i|--input-dir INPUT. directory containing analysis results created by $SCRIPT_DIR/rnc_analyse.sh. default: '$input_dir'"
echo " -o|--output-dir OUTPUT_DIR. default: '$output_dir'"
echo " -m|--modules 'MODULE1,MODULE2'. Overwrite which TEI modules to include"
echo " -v|--verbosity (0: only errors, 1: warnings, 2: info, 3: debug). default: $verbosity"
echo " -d|--debug-module VAL (multiple options accumulate): send debug messages for the specific module"
}
#######################################
# parse command line arguments
#######################################
while [[ $# > 0 ]]; do
key="$1"
case $key in
-h | --help)
print_help
exit 0
;;
-i | --input-dir)
shift
input_dir="$1"
shift
;;
-o | --output-dir)
shift
output_dir="$1"
shift
;;
-v | --verbosity)
shift
verbosity="$1"
shift
;;
-m | --modules)
shift
modules="$1"
shift
;;
-d | --debug-module)
shift
debug_modules+=("$1")
shift
;;
-* )
echo "wrong syntax!"
print_help
exit 1
;;
*)
break
;;
esac
done
if [[ "$#" > "0" ]]; then
echo "too many arguments: $@"
print_help
exit 1
fi
if [[ "$modules" != "" ]]; then
module_param="modules=$modules"
else
module_param=
fi
mkdir -p "$output_dir"
echo "input_dir: $input_dir"
input_filename=$(cat $input_dir/info.cfg | grep 'SOURCE' | cut -d' ' -f2)
if [ $(uname) == "Darwin" ] ; then
if which 'greadlink'; then
input_dir_absolute=$(greadlink -f "$input_dir")
else
echo "readlink not found (also 'greadlink' is not available)."
echo "On mac, please install 'coreutils', e.g. using homebrew"
exit 1
fi
else
input_dir_absolute=$(readlink -f "$input_dir")
fi
debug_modules_options="debug_modules=${debug_modules[@]}"
echo "analysis -> tei: '$input_dir -> $output_dir/*.tei'"
$SCRIPT_DIR/utils/for_each_input.sh \
--input-dir "$input_dir" \
--output-dir "$output_dir" \
--filter '1_simple.xml' \
--suffix '.odd' \
-- \
$SCRIPT_DIR/saxon.sh \
"$BASE_DIR/stylesheets/rng_to_odd/analysis_to_odd.xsl" '-s:$INPUT' '-o:$OUTPUT' \
"analysis_dir=$input_dir_absolute" \
"input_filename=$input_filename" \
"verbosity=$verbosity" \
"$module_param" \
"$debug_modules_options"