📄 htestrm
字号:
#!/bin/csh#---------------------------------------------------------------## HTK Unix Shell Script: htestrm ## ## Usage: htestrm env type set hmmdir ## ## htestrm uses the HTK environment settings to recognise the ## specified set of test files and then compares them with the ## reference labels using HResults. ## type is used to select a type of test of conditions from the ## env file. set selects the test data independently of type. ## The test results are stored in a directory called ## test_type_set.k inside the source hmm directory hmmdir ## where k is the repetition idx. ## A copy of the env file containing the test parameters is left ##in the test directory (typically changed for different indexes)# # The shell variable TESTSET is set equal to set & is used to ## specify the test data in the HTE file. ## Others variables in the HTE file are indexed to reflect ## values with different type the different type in an order ## given by the HTE variable TYPELIST ## ## TYPELIST - name of possible type values ## SETLIST - list of possible TESTSET & set values ## TESTDATALIST- list of test files (TESTSET) ## TESTMLF - MLF for reference labs (if used) (TESTSET) ## TESTLABDIR - dir holding reference lab files ## HMMLIST - list of models to use in testing ## HVTRACE - trace level ## HVPRUNE - pruning threshold (indexed) ## HVWEPRUNE - word-end pruning threshold (indexed) ## HVMAXACTIVE - max number of phone insts active (indexed) ## HVGSCALE - grammar scale factor (indexed) ## HVIMPROB - inter-model log probability addition(indexed) ## HVNET - network definition file (indexed) ## WORDLIST- list of vocabulary items ## HRNIST - run HResults in NIST mode ## NISTSCORE - run the NIST scoring software ## NICE - nice level to run at ##---------------------------------------------------------------### Copyright (c) Phil Woodland & Steve Young, 1992, 1993# Last Updated 19/10/93## Check Number of Args if (( $#argv != 4) && ( $#argv != 5)) then echo "Usage: htestrm env tsttype tstset hmmdir [inxformdir]" exit 1endif# Read the environment fileif ( ! -f $1 ) then echo "Cannot find environment file $1" exit 1endifset TYPE=$2set SET=$3set TESTSET=$SET# Load in the environment filesource $1# Check the typeif (! $?TYPELIST) then echo "htestrm: TYPELIST not set" exitendifunset INDEXset count=0foreach i ($TYPELIST) @ count++ if ($i == $TYPE) then set INDEX=$count endifendif (! $?INDEX) then echo "htestrm: $TYPE not in TYPELIST" exitendif# Check the test setunset setfoundif (! $?SETLIST) then echo "htestrm: SETLIST not set" exitendifforeach i ($SETLIST) if ($i == $SET) then set setfound endifendif ( (! $?setfound) && ( $SET != dms0_tst ) ) then echo "htestrm: $SET not in SETLIST\n"; exitendif# Check hmmsource Existsset HMMSOURCE=$4if ( ! -d $HMMSOURCE ) then echo "htestrm: error - hmm directory $HMMSOURCE does not exist" exit 1endif# Set test dirunset TESTDIRSETset TESTEXTN=1while (! $?TESTDIRSET) if ($?HVALIGN) then set TESTDIR=$HMMSOURCE/align_"$TYPE"_"$SET"."$TESTEXTN" else set TESTDIR=$HMMSOURCE/test_"$TYPE"_"$SET"."$TESTEXTN" endif if ( ! -d $TESTDIR ) then mkdir $TESTDIR set TESTDIRSET else @ TESTEXTN++ endifend# Define the file to log all output/errors toset LOG=$TESTDIR/LOG# Copy the test HTE file as a recordcp $1 $TESTDIR/HTE# Check the equates file and load equatesif ($?HREQSETS) then set EQFILE="$HREQSETS[$INDEX]" if ( ! -f $EQFILE ) then echo "Cannot find HResults equates file $EQFILE" exit 1 endif set EQSETS=`cat $EQFILE`endif# Set HVite Optionsset OPT = ( -H $HMMSOURCE/MODELS )if ( $#argv == 5 ) then set INXFDIR=$5 set OPT = ( $OPT -k -J $INXFDIR ) if ($?HVINXFORMEXT) then set OPT = ($OPT $HVINXFORMEXT) endifendif if ( $?HVFORCEXFORMDIR ) then while ( $#HVFORCEXFORMDIR > 0 ) set OPT = ($OPT -J $HVFORCEXFORMDIR[1]) shift HVFORCEXFORMDIR endendifif ($?HVFORCEMACRO) then while ( $#HVFORCEMACRO > 0 ) set OPT = ($OPT -H $HVFORCEMACRO[1]) shift HVFORCEMACRO endendifif ($?HVINCADAPT) then set OPT = ($OPT -j $HVINCADAPT -K $TESTDIR) if ($?HVOUTXFORMEXT) then set OPT = ($OPT $HVOUTXFORMEXT) endif else if ($?HVADAPT) then set OPT = ($OPT -K $TESTDIR) if ($?HVOUTXFORMEXT) then set OPT = ($OPT $HVOUTXFORMEXT) endifendifset HVOPFILE=$TESTDIR/"$TYPE"_"$SET".mlfset OPT = ( $OPT -i $HVOPFILE )set OPT = ( $OPT -X rec )if ($?HVTRACE) then set OPT = ($OPT -T $HVTRACE)endif# add the indexed optionsif ($?HVPRUNE) then set OPT = ($OPT -t $HVPRUNE[$INDEX])endifif ($?HVWEPRUNE) then set OPT = ($OPT -v $HVWEPRUNE[$INDEX])endifif ($?HVMAXACTIVE) then set OPT = ($OPT -u $HVMAXACTIVE[$INDEX])endifif ($?HVGSCALE) then set OPT = ($OPT -s $HVGSCALE[$INDEX])endifif ($?HVIMPROB) then set OPT = ($OPT -p $HVIMPROB[$INDEX])endifif ($?HVXFORMCONFIG) then set OPT = ($OPT -C $HVXFORMCONFIG )endifif ($?HVLABFORMAT) then set OPT = ($OPT -o $HVLABFORMAT )endifif ($?HVALIGN) then set OPT = ($OPT -m -o TPMFW -b \!SENT_START -a -y lab) if ($?ALIGNMLF) then set OPT = ( $OPT -I $ALIGNMLF ) else echo "Must specify an alignment MLF" exit 1 endifelse set OPT = ($OPT -w $HVNET[$INDEX] )endifset VOC=$HVVOC[$INDEX]# set processor nice levels set PR=(nice +$NICE)# -------------- Run HVite -----------------echo "HVite started at `date`" > $LOGif ($?HVSPKRMASK) then $PR HVite -h "$HVSPKRMASK" -A -D -V -C $HVCONFIG $OPT -S $TESTDATALIST $VOC $HMMLIST >>& $LOGelse $PR HVite -A -D -V -C $HVCONFIG $OPT -S $TESTDATALIST $VOC $HMMLIST >>& $LOGendifif ( $status != 0 ) then echo "HVite terminated abnormally at `date`" >> $LOG echo "" >> $LOG exit $statuselse echo "HVite finished at `date`" >> $LOG echo "" >> $LOGendif# ------------------------------------------# Now for results analysis## Set the equates if anyset EQ=""if ($?EQSETS) then unset I foreach x ( $EQSETS ) if (! $?I) then set EQ="$EQ -e " set I else unset I endif set EQ="$EQ $x" endendifset OPT=""if ($?TESTMLF) then set OPT=($OPT -I $TESTMLF)endifif ($?TESTLABDIR) then set OPT=($OPT -L $TESTLABDIR)endifif ($?HRNIST) then set OPT = ($OPT -n)endifecho "Running HResults at `date`" >> $LOG$PR HResults -A -z ':::' $OPT $EQ $WORDLIST $HVOPFILE >>& $LOGif ( $status != 0 ) then echo "HResults terminated abnormally at `date`" >> $LOGelse echo "HResults finished at `date`" >> $LOGendifecho "" >> $LOG# ------------------------------------------# Now for NIST scoring if required#if ($?NISTSCORE) then if ($TYPE != wp && $TYPE != ng) then echo "Cant Run NIST Scoring with type = $TYPE" >> $LOG exit 1 endif echo "Running HLab2Hyp at `date`" >> $LOG set HYP="$TYPE"_"$SET" $PR HLab2Hyp $TESTDIR/"$HYP".hyp $HVOPFILE >>& $LOG if ( $status != 0 ) then echo "HLab2Hyp terminated abnormally at `date`" >> $LOG echo "" >> $LOG exit $status else echo "HLab2Hyp finished at `date`" >> $LOG echo "" >> $LOG endif cd $TESTDIR if ( $TYPE == wp ) then wgscore "$HYP".hyp >> LOG else ngscore "$HYP".hyp >> LOG endif cat "$HYP".hyp.scr/"$HYP".sys >> LOG echo "" >> LOG cd ../..endifecho "htestrm finished at `date`" >> $LOG#---------------------------------------------------------------## End of Script: htestrm ##---------------------------------------------------------------#
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -