Permalink
Cannot retrieve contributors at this time
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?
eoa-publication-model/scripts/rnc_analysis_to_odd.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
117 lines (101 sloc)
2.56 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) | |
input_dir_absolute=$(readlink -f "$input_dir") | |
debug_modules_options="debug_modules=${debug_modules[@]}" | |
echo "analysis -> tei: '$input_dir -> $output_dir/*.tei'" | |
$SCRIPT_DIR/local_stylesheet.sh \ | |
--input-dir "$input_dir" \ | |
--output-dir "$output_dir" \ | |
--suffix ".odd" \ | |
--options "analysis_dir=$input_dir_absolute input_filename=$input_filename verbosity=$verbosity $module_param $debug_modules_options" \ | |
rng_to_odd/analysis_to_odd.xsl \ | |
1_simple.xml | |
# filename is just given to avoid the script | |
# being run for every file in "$input_dir" | |
# (it's not actually used by the stylesheet) |