Blame view

main_tools/CheckResults.sh 3.09 KB
1fd315c89   Jean-François Rey   add Extract audio...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  #!/bin/bash
  
  #################################
  # File : CheckResults.sh        #
  # Brief : Check the results     #
  # Autohr : Jean-François Rey    #
  # Date : 30/07/2013             #
  # Version : 1.0                 #
  #################################
  
  
  # CheckDir( dir )
  # dir : a directory path
  # Brief : Check $dir results
  function CheckDir()
  {
      if [ $# -eq 1 ]
      then
          plp=$(ls $1/PLP/*.plp 2> /dev/null | wc -l)
          res_p1=$(ls $1/res_p1/*.res 2> /dev/null | wc -l)
          res_p2=$(ls $1/res_p2/*.treil 2> /dev/null | wc -l)
          res_p3=$(ls $1/res_p3/*.treil 2> /dev/null | wc -l)
          usf_p2=$1/$(basename $1).res_p2.usf
          usf_p3=$1/$(basename $1).res_p3.usf
  
          if [ -e $usf_p2 ]
          then
              casix=`grep -c -E 'confidence="0.600"' ${usf_p2}`
              call=`grep -c -E 'confidence=' ${usf_p2}`
              if [ $call -eq 0 ]
              then
                  pourcentage_p2=100
              else
                  pourcentage_p2=$((($casix*100)/$call))
              fi
              if [ $pourcentage_p2 -gt 49 ]
              then
                  usf2="ERR"
              else
                  usf2="OK"
              fi
          else
              usf2="NAN"
          fi
          if [ -e $usf_p3 ]
          then
              casix=`grep -c -E 'confidence="0.600"' ${usf_p3}`
              call=`grep -c -E 'confidence=' ${usf_p3}`
              if [ $call -eq 0 ]
              then
                  pourcentage_p3=100
              else
                  pourcentage_p3=$((($casix*100)/$call))
              fi
              if [ $pourcentage_p3 -gt 49 ]
              then
                  usf3="ERR"
              else
                  usf3="OK"
              fi
          else
              usf3="NAN"
          fi
      fi
      echo -e "$(basename $1)\t$plp\t$res_p1\t$res_p2\t\t$res_p3\t\t$usf2\t$usf3"
  
  }
  
  
  # Check OTMEDIA_HOME env var
  if [ -z ${OTMEDIA_HOME} ]
  then
      OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0)))
      export OTMEDIA_HOME=$OTMEDIA_HOME
  fi
  
  # where is CheckResults.sh
  MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0))
  
  
  RECURSIVE=0
  
  #---------------#
  # Parse Options #
  #---------------#
  while getopts ":hr" opt
  do
  	case $opt in
  		h)
  			echo -e "$0 [OPTIONS] <DIRECTORY>
  "
              echo -e "\t Options:"
              echo -e "\t\t-h :\tprint this message"
              echo -e "\t\t-r :\trecursive mode"
  			exit 1
  			;;
          r)
              RECURSIVE=1
              ;;
  		:)
  			echo "Option -$OPTARG requires an argument." >&2
  			exit 1
  			;;
  		\?)
  			echo "BAD USAGE : unknow opton -$OPTARG"
  			exit 1
  			;;
  	esac
  done
  
  # Check USAGE by arguments number
  if [ $(($#-($OPTIND-1))) -ne 1 ]
  then
  	echo "BAD USAGE : FirstPass.sh [OPTIONS] <DIRECTORY>"
  	echo "$0 -h for more info"
  	exit 1
  fi
  
  shift $((OPTIND-1))
  # check Directory - First argument
  if [ -e $1 ] && [ -s $1 ]
  then
      DIR=$(readlink -e $1)
  else
      echo "ERROR : can't open directory $1"
      exit 1    
  fi
  
  
  # Check directory results
  echo -e "Directory name\t\t#plp\t#res_p1\t#treil_p2\t#treil_p3\tusf_p2\tusf_p3"
  if [ $RECURSIVE -eq 0 ]
  then
      CheckDir "$DIR"
  else
      for d in `ls $DIR`
      do
          if [ -d "$DIR/$d" ]; then CheckDir "$DIR/$d"; fi
      done
  fi