#!/bin/tcsh 

# overlap ratio submodule of MOCCA
set outputOfRPrediction = `Rscript $MOCCA_R_OVERLAPRATIO_QUALITY_SCRIPT $SOURCE $moccaArffFile $moccaPredFileOR >& /dev/stdout`

if($v > 2) echo "R outputted: $outputOfRPrediction"

set predictionOR = `cat $moccaPredFileOR`

# TODO check if value smaller than 0 and bigger than 1 -> ceiling
#if( $predictionOR > "1.0") then
    #echo "aha"
#endif

##############################
########## CHECKS ############
# check if the prediction array has the correct size/was read correctly
if("$#predictionOR" != "1") then
   echo "The output format of the prediction for the OR (generated by R) seems to be broken. Aborting!" >/dev/stderr
   exit 6
endif
######### END CHECKS ##########
###############################

if($v > 0) echo "MOCCA: predicted overlap ratio is $predictionOR"

set cmsTier = `printf "CMS:\t%i\t%.${NUMBER_OF_DECIMAL_PLACES}f\n" $targetWordIndex $predictionOR`

if($v > 0) echo "The generated CMS tier is:\n$cmsTier"
##########################################################################
