Example BCE Compatible Scripts

From Wings Wiki

Jump to: navigation, search

Contents

Example Scripts

These scripts were automatically created from Java classes using our BCE#Software. This software allows the user to define simple Java classes that describe a components from which they can:

  1. generate the BCE specification for the component
  2. generate BCE compatible components in the form of Unix scripts
  3. automatically execute the component unit tests.

Discretize

#!/bin/sh

FATAL_EXIT_CODE=1
FATAL_EXIT_MESSAGE=Failure
SUCCESS_EXIT_CODE=0
SUCCESS_EXIT_MESSAGE=Success
COMMAND_EXIT_CODE=0
ERROR_LOG_FILE_NAME=error.log
BASEDIR=`dirname $0`

WEKAHOME=$BASEDIR/../lib
export CLASSPATH="$WEKAHOME/weka.jar:."

rm -f $ERROR_LOG_FILE_NAME

if [ -z "$1" ] || [ "$1" = "-h" ]; then
  echo "Argument list for Discretize version:  3.6.2"
  echo "-i inputData"
  echo "-o outputData"
  echo "-B numberOfBins"
  echo "-c classIndex"
  echo "Use ./Discretize --help for more details."
  exit 0
elif [ "$1" = "--help" ]; then
  echo "Docstring for Discretize version:  3.6.2"
  echo "An instance filter that discretizes a range of numeric "
  echo "attributes in the dataset into nominal attributes. "
  echo "Discretization is by Fayyad and Irani's MDL method (the default)."
  echo ""
  echo "-i inputData"
  echo "-o outputData"
  echo "-B numberOfBins"
  echo "-c classIndex"
  exit 0
elif [ "$1" = "--version" ]; then
  echo Discretize 3.6.2
  exit 0
elif [ "$1" = "--BCE" ]; then
  echo "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>"
  echo "<component author="Fayyad and Irani" vendor="WEKA" version="3.6.2">"
  echo "    <description>"
  echo "        <environment>"
  echo "            <name>JAVA_HOME</name>"
  echo "            <name>CLASSPATH</name>"
  echo "            <name>WEKAHOME</name>"
  echo "        </environment>"
  echo "        <files>"
  echo "            <file type="input" id="inputData"/>"
  echo "            <file type="output" id="outputData"/>"
  echo "        </files>"
  echo "        <parameters>"
  echo "            <param type="int" id="numberOfBins"/>"
  echo "            <param type="int" id="classIndex"/>"
  echo "        </parameters>"
  echo "        <arguments>"
  echo "            <arg option="-i" type="file">"
  echo "                <file idref="inputData"/>"
  echo "            </arg>"
  echo "            <arg option="-o" type="file">"
  echo "                <file idref="outputData"/>"
  echo "            </arg>"
  echo "            <arg option="-B" type="parameter">"
  echo "                <param idref="numberOfBins"/>"
  echo "            </arg>"
  echo "            <arg option="-c" type="parameter">"
  echo "                <param idref="classIndex"/>"
  echo "            </arg>"
  echo "        </arguments>"
  echo "        <exitcodes>"
  echo "            <exit code="0">Success</exit>"
  echo "            <exit code="1">Failure</exit>"
  echo "        </exitcodes>"
  echo "    </description>"
  echo "    <unit_test>"
  echo "        <file idref="inputData">iris.arff</file>"
  echo "        <file idref="outputData">iris-binned.arff</file>"
  echo "        <param idref="numberOfBins">10</param>"
  echo "        <param idref="classIndex">5</param>"
  echo "        <invocation_string>Discretize -i iris.arff -o iris-binned.arff -B 10 -c 5</invocation_string>"
  echo "        <exit code="0">Success</exit>"
  echo "    </unit_test>"
  echo "    <unit_test>"
  echo "        <file idref="inputData">iris.arff</file>"
  echo "        <file idref="outputData">iris-binned.arff</file>"
  echo "        <param idref="numberOfBins">10</param>"
  echo "        <param idref="classIndex">10</param>"
  echo "        <invocation_string>Discretize -i iris.arff -o iris-binned.arff -B 10 -c 10</invocation_string>"
  echo "        <exit code="1">Failure</exit>"
  echo "    </unit_test>"
  echo "</component>"
elif [ "$#" != 8 ]; then
  counter=0
  for arg in "$@"; do
    counter=`expr $counter + 1`
  done
  pairnumber=`expr $counter / 2`
  echo "Discretize was passed $pairnumber option/argument pairs, but requires 4"
  echo "Use --help for more information."
  echo $FATAL_EXIT_MESSAGE
  exit $FATAL_EXIT_CODE
else

  options=""
  args=("$@")
  counter=0
  for arg in $args; do
    options="$options ${args[$counter]}"
    counter=`expr $counter + 2`
  done

  for option in $options; do
    case $option in
     -i) ;;
     -o) ;;
     -B) ;;
     -c) ;;
      *)  echo "Option $option is not valid.  Valid options are: -i, -o, -B, -c"
          echo "Use --help for more information."
          echo $FATAL_EXIT_MESSAGE
          exit $FATAL_EXIT_CODE ;;
    esac
  done

  args=("$@")
  valueCounter=0
  for arg in $@; do
    valueCounter=`expr $valueCounter + 1`
    if [ "$arg" == "-i" ]; then arg1=${args[$valueCounter]}; fi
    if [ "$arg" == "-o" ]; then arg2=${args[$valueCounter]}; fi
    if [ "$arg" == "-B" ]; then arg3=${args[$valueCounter]}; fi
    if [ "$arg" == "-c" ]; then arg4=${args[$valueCounter]}; fi
  done

  OUTPUT=`java weka.filters.unsupervised.attribute.Discretize -i $arg1 -o $arg2 -B $arg3 -c $arg4  2> $ERROR_LOG_FILE_NAME`
  COMMAND_EXIT_CODE=$?
  LINES_IN_ERROR_LOG=`cat $ERROR_LOG_FILE_NAME|wc -l`
fi

if [ "$COMMAND_EXIT_CODE" -ne 0 ] ||  [ "$LINES_IN_ERROR_LOG" -ne 0 ]; then
  cat $ERROR_LOG_FILE_NAME | while read linevar
  do
    echo $linevar
  done
  rm -f $ERROR_LOG_FILE_NAME
  echo $FATAL_EXIT_MESSAGE
  exit $FATAL_EXIT_CODE
else
  rm -f $ERROR_LOG_FILE_NAME
  echo $SUCCESS_EXIT_MESSAGE
  exit $SUCCESS_EXIT_CODE
fi

J48Classifier

#!/bin/sh

FATAL_EXIT_CODE=1
FATAL_EXIT_MESSAGE=Failure
SUCCESS_EXIT_CODE=0
SUCCESS_EXIT_MESSAGE=Success
COMMAND_EXIT_CODE=0
ERROR_LOG_FILE_NAME=error.log
BASEDIR=`dirname $0`

WEKAHOME=$BASEDIR/../lib
export CLASSPATH="$WEKAHOME/weka.jar:."

rm -f $ERROR_LOG_FILE_NAME

if [ -z "$1" ] || [ "$1" = "-h" ]; then
  echo "Argument list for J48Classifier version:  3.6.2"
  echo "-T testData"
  echo "-l model"
  echo "-O classification"
  echo "-c classIndex"
  echo "Use ./J48Classifier --help for more details."
  exit 0
elif [ "$1" = "--help" ]; then
  echo "Docstring for J48Classifier version:  3.6.2"
  echo "Class for generating an unpruned or a pruned C4.5 decision tree. For more "
  echo "information, see Ross Quinlan (1993). C4.5: Programs for Machine Learning, "
  echo "Morgan Kaufmann Publishers, San Mateo, CA."
  echo ""
  echo "-T testData"
  echo "-l model"
  echo "-O classification"
  echo "-c classIndex"
  exit 0
elif [ "$1" = "--version" ]; then
  echo J48Classifier 3.6.2
  exit 0
elif [ "$1" = "--BCE" ]; then
  echo "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>"
  echo "<component author="Eibe Frank" vendor="WEKA" version="3.6.2">"
  echo "    <description>"
  echo "        <environment>"
  echo "            <name>JAVA_HOME</name>"
  echo "            <name>CLASSPATH</name>"
  echo "            <name>WEKAHOME</name>"
  echo "        </environment>"
  echo "        <files>"
  echo "            <file type="input" id="testData"/>"
  echo "            <file type="input" id="model"/>"
  echo "            <file type="output" id="classification"/>"
  echo "        </files>"
  echo "        <parameters>"
  echo "            <param type="int" id="classIndex"/>"
  echo "        </parameters>"
  echo "        <arguments>"
  echo "            <arg option="-T" type="file">"
  echo "                <file idref="testData"/>"
  echo "            </arg>"
  echo "            <arg option="-l" type="file">"
  echo "                <file idref="model"/>"
  echo "            </arg>"
  echo "            <arg option="-O" type="file">"
  echo "                <file idref="classification"/>"
  echo "            </arg>"
  echo "            <arg option="-c" type="parameter">"
  echo "                <param idref="classIndex"/>"
  echo "            </arg>"
  echo "        </arguments>"
  echo "        <exitcodes>"
  echo "            <exit code="0">Success</exit>"
  echo "            <exit code="1">Failure</exit>"
  echo "        </exitcodes>"
  echo "    </description>"
  echo "    <unit_test>"
  echo "        <file idref="testData">soybean.arff</file>"
  echo "        <file idref="model">j48-soybean.model</file>"
  echo "        <file idref="classification">j48-soybean.classification</file>"
  echo "        <param idref="classIndex">36</param>"
  echo "        <invocation_string>J48Classifier -T soybean.arff -l j48-soybean.model -O j48-soybean.classification -c 36</invocation_string>"
  echo "        <exit code="0">Success</exit>"
  echo "    </unit_test>"
  echo "    <unit_test>"
  echo "        <file idref="testData">soybean.arff</file>"
  echo "        <file idref="model">id3-weather.nominal.model</file>"
  echo "        <file idref="classification">j48-soybean.classification</file>"
  echo "        <param idref="classIndex">36</param>"
  echo "        <invocation_string>J48Classifier -T soybean.arff -l id3-weather.nominal.model -O j48-soybean.classification -c 36</invocation_string>"
  echo "        <exit code="1">Failure</exit>"
  echo "    </unit_test>"
  echo "</component>"
elif [ "$#" != 8 ]; then
  counter=0
  for arg in "$@"; do
    counter=`expr $counter + 1`
  done
  pairnumber=`expr $counter / 2`
  echo "J48Classifier was passed $pairnumber option/argument pairs, but requires 4"
  echo "Use --help for more information."
  echo $FATAL_EXIT_MESSAGE
  exit $FATAL_EXIT_CODE
else

  options=""
  args=("$@")
  counter=0
  for arg in $args; do
    options="$options ${args[$counter]}"
    counter=`expr $counter + 2`
  done

  for option in $options; do
    case $option in
     -T) ;;
     -l) ;;
     -O) ;;
     -c) ;;
      *)  echo "Option $option is not valid.  Valid options are: -T, -l, -O, -c"
          echo "Use --help for more information."
          echo $FATAL_EXIT_MESSAGE
          exit $FATAL_EXIT_CODE ;;
    esac
  done

  args=("$@")
  valueCounter=0
  for arg in $@; do
    valueCounter=`expr $valueCounter + 1`
    if [ "$arg" == "-T" ]; then arg1=${args[$valueCounter]}; fi
    if [ "$arg" == "-l" ]; then arg2=${args[$valueCounter]}; fi
    if [ "$arg" == "-c" ]; then arg3=${args[$valueCounter]}; fi
    if [ "$arg" == "-O" ]; then arg4=${args[$valueCounter]}; fi
  done

  OUTPUT=`java weka.classifiers.trees.J48 -T $arg1 -l $arg2 -c $arg3 > $arg4  2> $ERROR_LOG_FILE_NAME`
  COMMAND_EXIT_CODE=$?
  LINES_IN_ERROR_LOG=`cat $ERROR_LOG_FILE_NAME|wc -l`
fi

if [ "$COMMAND_EXIT_CODE" -ne 0 ] ||  [ "$LINES_IN_ERROR_LOG" -ne 0 ]; then
  cat $ERROR_LOG_FILE_NAME | while read linevar
  do
    echo $linevar
  done
  rm -f $ERROR_LOG_FILE_NAME
  echo $FATAL_EXIT_MESSAGE
  exit $FATAL_EXIT_CODE
else
  rm -f $ERROR_LOG_FILE_NAME
  echo $SUCCESS_EXIT_MESSAGE
  exit $SUCCESS_EXIT_CODE
fi

NaiveBayesModeler

#!/bin/sh

FATAL_EXIT_CODE=1
FATAL_EXIT_MESSAGE=Failure
SUCCESS_EXIT_CODE=0
SUCCESS_EXIT_MESSAGE=Success
COMMAND_EXIT_CODE=0
ERROR_LOG_FILE_NAME=error.log
BASEDIR=`dirname $0`

WEKAHOME=$BASEDIR/../lib
export CLASSPATH="$WEKAHOME/weka.jar:."

rm -f $ERROR_LOG_FILE_NAME

if [ -z "$1" ] || [ "$1" = "-h" ]; then
  echo "Argument list for NaiveBayesModeler version:  3.6.2"
  echo "-t trainingData"
  echo "-d model"
  echo "-Xmx javaHeapSize"
  echo "-c classIndex"
  echo "Use ./NaiveBayesModeler --help for more details."
  exit 0
elif [ "$1" = "--help" ]; then
  echo "Docstring for NaiveBayesModeler version:  3.6.2"
  echo "Class for a Naive Bayes classifier using estimator classes. Numeric estimator "
  echo "precision values are chosen based on analysis of the training data. For this "
  echo "reason, the classifier is not an UpdateableClassifier (which in typical usage "
  echo "are initialized with zero training instances) -- if you need the "
  echo "UpdateableClassifier functionality, use the NaiveBayesUpdateable classifier. "
  echo "The NaiveBayesUpdateable classifier will use a default precision of 0.1 for "
  echo "numeric attributes when buildClassifier is called with zero training instances."
  echo ""
  echo "-t trainingData"
  echo "-d model"
  echo "-Xmx javaHeapSize"
  echo "-c classIndex"
  exit 0
elif [ "$1" = "--version" ]; then
  echo NaiveBayesModeler 3.6.2
  exit 0
elif [ "$1" = "--BCE" ]; then
  echo "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>"
  echo "<component author="Len Trigg and Eibe Frank" vendor="WEKA" version="3.6.2">"
  echo "    <description>"
  echo "        <environment>"
  echo "            <name>JAVA_HOME</name>"
  echo "            <name>CLASSPATH</name>"
  echo "            <name>WEKAHOME</name>"
  echo "        </environment>"
  echo "        <files>"
  echo "            <file type="input" id="trainingData"/>"
  echo "            <file type="output" id="model"/>"
  echo "        </files>"
  echo "        <parameters>"
  echo "            <param type="int" id="javaHeapSize"/>"
  echo "            <param type="int" id="classIndex"/>"
  echo "        </parameters>"
  echo "        <arguments>"
  echo "            <arg option="-t" type="file">"
  echo "                <file idref="trainingData"/>"
  echo "            </arg>"
  echo "            <arg option="-d" type="file">"
  echo "                <file idref="model"/>"
  echo "            </arg>"
  echo "            <arg option="-Xmx" type="parameter">"
  echo "                <param idref="javaHeapSize"/>"
  echo "            </arg>"
  echo "            <arg option="-c" type="parameter">"
  echo "                <param idref="classIndex"/>"
  echo "            </arg>"
  echo "        </arguments>"
  echo "        <exitcodes>"
  echo "            <exit code="0">Success</exit>"
  echo "            <exit code="1">Failure</exit>"
  echo "        </exitcodes>"
  echo "    </description>"
  echo "    <unit_test>"
  echo "        <file idref="trainingData">soybean.arff</file>"
  echo "        <file idref="model">naivebayes-soybean.model</file>"
  echo "        <param idref="javaHeapSize">256M</param>"
  echo "        <param idref="classIndex">36</param>"
  echo "        <invocation_string>NaiveBayesModeler -t soybean.arff -d naivebayes-soybean.model -Xmx 256M -c 36</invocation_string>"
  echo "        <exit code="0">Success</exit>"
  echo "    </unit_test>"
  echo "    <unit_test>"
  echo "        <file idref="trainingData">soybean.arff</file>"
  echo "        <file idref="model">naivebayes-soybean.model</file>"
  echo "        <param idref="javaHeapSize">256M</param>"
  echo "        <param idref="classIndex">40</param>"
  echo "        <invocation_string>NaiveBayesModeler -t soybean.arff -d naivebayes-soybean.model -Xmx 256M -c 40</invocation_string>"
  echo "        <exit code="1">Failure</exit>"
  echo "    </unit_test>"
  echo "</component>"
elif [ "$#" != 8 ]; then
  counter=0
  for arg in "$@"; do
    counter=`expr $counter + 1`
  done
  pairnumber=`expr $counter / 2`
  echo "NaiveBayesModeler was passed $pairnumber option/argument pairs, but requires 4"
  echo "Use --help for more information."
  echo $FATAL_EXIT_MESSAGE
  exit $FATAL_EXIT_CODE
else

  options=""
  args=("$@")
  counter=0
  for arg in $args; do
    options="$options ${args[$counter]}"
    counter=`expr $counter + 2`
  done

  for option in $options; do
    case $option in
     -t) ;;
     -d) ;;
     -Xmx) ;;
     -c) ;;
      *)  echo "Option $option is not valid.  Valid options are: -t, -d, -Xmx, -c"
          echo "Use --help for more information."
          echo $FATAL_EXIT_MESSAGE
          exit $FATAL_EXIT_CODE ;;
    esac
  done

  args=("$@")
  valueCounter=0
  for arg in $@; do
    valueCounter=`expr $valueCounter + 1`
    if [ "$arg" == "-t" ]; then arg1=${args[$valueCounter]}; fi
    if [ "$arg" == "-d" ]; then arg2=${args[$valueCounter]}; fi
    if [ "$arg" == "-Xmx" ]; then arg3=${args[$valueCounter]}; fi
    if [ "$arg" == "-c" ]; then arg4=${args[$valueCounter]}; fi
  done

  OUTPUT=`java -Xmx$arg3 weka.classifiers.bayes.NaiveBayes -t $arg1 -d $arg2 -c $arg4  2> $ERROR_LOG_FILE_NAME`
  COMMAND_EXIT_CODE=$?
  LINES_IN_ERROR_LOG=`cat $ERROR_LOG_FILE_NAME|wc -l`
fi

if [ "$COMMAND_EXIT_CODE" -ne 0 ] ||  [ "$LINES_IN_ERROR_LOG" -ne 0 ]; then
  cat $ERROR_LOG_FILE_NAME | while read linevar
  do
    echo $linevar
  done
  rm -f $ERROR_LOG_FILE_NAME
  echo $FATAL_EXIT_MESSAGE
  exit $FATAL_EXIT_CODE
else
  rm -f $ERROR_LOG_FILE_NAME
  echo $SUCCESS_EXIT_MESSAGE
  exit $SUCCESS_EXIT_CODE
fi

Resample

#!/bin/sh

FATAL_EXIT_CODE=1
FATAL_EXIT_MESSAGE=Failure
SUCCESS_EXIT_CODE=0
SUCCESS_EXIT_MESSAGE=Success
COMMAND_EXIT_CODE=0
ERROR_LOG_FILE_NAME=error.log
BASEDIR=`dirname $0`

WEKAHOME=$BASEDIR/../lib
export CLASSPATH="$WEKAHOME/weka.jar:."

rm -f $ERROR_LOG_FILE_NAME

if [ -z "$1" ] || [ "$1" = "-h" ]; then
  echo "Argument list for Resample version:  3.6.2"
  echo "-i inputData"
  echo "-o outputData"
  echo "-N numberToSample"
  echo "-S randomSeed"
  echo "Use ./Resample --help for more details."
  exit 0
elif [ "$1" = "--help" ]; then
  echo "Docstring for Resample version:  3.6.2"
  echo "Produces a random subsample of a dataset using sampling with replacement. "
  echo "The original dataset must fit entirely in memory. The number of instances "
  echo "in the generated dataset may be specified using the -N option.  Note that "
  echo "the WEKA component uses -Z to specify a percentage of the dataset to sample. "
  echo "The wrapper script will compute the value of -Z from -N."
  echo ""
  echo "-i inputData"
  echo "-o outputData"
  echo "-N numberToSample"
  echo "-S randomSeed"
  exit 0
elif [ "$1" = "--version" ]; then
  echo Resample 3.6.2
  exit 0
elif [ "$1" = "--BCE" ]; then
  echo "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>"
  echo "<component author="Len Trigg" vendor="WEKA" version="3.6.2">"
  echo "    <description>"
  echo "        <environment>"
  echo "            <name>JAVA_HOME</name>"
  echo "            <name>CLASSPATH</name>"
  echo "            <name>WEKAHOME</name>"
  echo "        </environment>"
  echo "        <files>"
  echo "            <file type="input" id="inputData"/>"
  echo "            <file type="output" id="outputData"/>"
  echo "        </files>"
  echo "        <parameters>"
  echo "            <param type="int" id="numberToSample"/>"
  echo "            <param type="int" id="randomSeed"/>"
  echo "        </parameters>"
  echo "        <arguments>"
  echo "            <arg option="-i" type="file">"
  echo "                <file idref="inputData"/>"
  echo "            </arg>"
  echo "            <arg option="-o" type="file">"
  echo "                <file idref="outputData"/>"
  echo "            </arg>"
  echo "            <arg option="-N" type="parameter">"
  echo "                <param idref="numberToSample"/>"
  echo "            </arg>"
  echo "            <arg option="-S" type="parameter">"
  echo "                <param idref="randomSeed"/>"
  echo "            </arg>"
  echo "        </arguments>"
  echo "        <exitcodes>"
  echo "            <exit code="0">Success</exit>"
  echo "            <exit code="1">Failure</exit>"
  echo "        </exitcodes>"
  echo "    </description>"
  echo "    <unit_test>"
  echo "        <file idref="inputData">iris.arff</file>"
  echo "        <file idref="outputData">iris-sampled.arff</file>"
  echo "        <param idref="numberToSample">20</param>"
  echo "        <param idref="randomSeed">1</param>"
  echo "        <invocation_string>Resample -i iris.arff -o iris-sampled.arff -N 20 -S 1</invocation_string>"
  echo "        <exit code="0">Success</exit>"
  echo "    </unit_test>"
  echo "    <unit_test>"
  echo "        <file idref="inputData">iris.arff</file>"
  echo "        <file idref="outputData">iris-sampled.arff</file>"
  echo "        <param idref="numberToSample">-1</param>"
  echo "        <param idref="randomSeed"/>"
  echo "        <invocation_string>Resample -i iris.arff -o iris-sampled.arff -N -1 -S null</invocation_string>"
  echo "        <exit code="1">Failure</exit>"
  echo "    </unit_test>"
  echo "</component>"
elif [ "$#" != 8 ]; then
  counter=0
  for arg in "$@"; do
    counter=`expr $counter + 1`
  done
  pairnumber=`expr $counter / 2`
  echo "Resample was passed $pairnumber option/argument pairs, but requires 4"
  echo "Use --help for more information."
  echo $FATAL_EXIT_MESSAGE
  exit $FATAL_EXIT_CODE
else

  options=""
  args=("$@")
  counter=0
  for arg in $args; do
    options="$options ${args[$counter]}"
    counter=`expr $counter + 2`
  done

  for option in $options; do
    case $option in
     -i) ;;
     -o) ;;
     -N) ;;
     -S) ;;
      *)  echo "Option $option is not valid.  Valid options are: -i, -o, -N, -S"
          echo "Use --help for more information."
          echo $FATAL_EXIT_MESSAGE
          exit $FATAL_EXIT_CODE ;;
    esac
  done

  args=("$@")
  valueCounter=0
  for arg in $@; do
    valueCounter=`expr $valueCounter + 1`
    if [ "$arg" == "-i" ]; then arg1=${args[$valueCounter]}; fi
    if [ "$arg" == "-o" ]; then arg2=${args[$valueCounter]}; fi
    if [ "$arg" == "-N" ]; then arg3=${args[$valueCounter]}; fi
    if [ "$arg" == "-S" ]; then arg4=${args[$valueCounter]}; fi
  done


  NUMBER_OF_LINES=`cat $arg1|wc -l`
  EMPTY_LINES=`grep -c '^$' $arg1`
  COMMENT_LINES=`grep -c "%" $arg1`
  ATTRIBUTE_LINES=`grep -c "@" $arg1`
  DATA_LINES=`expr $NUMBER_OF_LINES - $EMPTY_LINES - $COMMENT_LINES - $ATTRIBUTE_LINES`
  PERCENT=`echo "scale=2; $arg3 / $DATA_LINES * 100" | bc -l`

  OUTPUT=`java weka.filters.unsupervised.instance.Resample -i $arg1 -o $arg2 -Z $PERCENT -S $arg4  2> $ERROR_LOG_FILE_NAME`
  COMMAND_EXIT_CODE=$?
  LINES_IN_ERROR_LOG=`cat $ERROR_LOG_FILE_NAME|wc -l`
fi

if [ "$COMMAND_EXIT_CODE" -ne 0 ] ||  [ "$LINES_IN_ERROR_LOG" -ne 0 ]; then
  cat $ERROR_LOG_FILE_NAME | while read linevar
  do
    echo $linevar
  done
  rm -f $ERROR_LOG_FILE_NAME
  echo $FATAL_EXIT_MESSAGE
  exit $FATAL_EXIT_CODE
else
  rm -f $ERROR_LOG_FILE_NAME
  echo $SUCCESS_EXIT_MESSAGE
  exit $SUCCESS_EXIT_CODE
fi
Personal tools