#!/usr/bin/perl # # mkContents.pl # # Version 1.0 # # (C) Copyright 1999, Chr. Draxler # # creates the CONTENT{0|1|2|3|S}.LST file # from the SAM label files in the SpeechDat-Car file system # # History # 1.0: initial release # -- change the following variables to suit your language and system ----- $langCode = 'DE'; # German $lblExt = ".$langCode" . 'C'; # label file extension "DEC" $dbName = 'VEHIC1' . $langCode; # Database name $fileDlm = ':'; # OS file system delimiter (UNIX:/, Windows:\) # -- command line arguments for work (=source) root directory and target directory --- # #if (int(@ARGV) < 2) { # die "\nusage: mkContents.pl WORKDIR TARGETDIR\n\n"; #} else { # $workDir = $ARGV[0]; # $targetDir = $ARGV[1]; #} # -- on the Mac, ask for these values interactively ------------------------ # $workDir = MacPerl::Ask('SAM label file root directory',':SAMFiles:VEHIC1DE:PLTM_C:' . $dbName . $fileDlm); $targetDir = MacPerl::Ask('Target directory',':SAMFiles:VEHIC1DE:INDEX:'); # -- create session table in target directory ------------------------------ # -- target directory must exist! $outFile = $targetDir . 'CONTENTS.LST'; $outFileOrg = $outFile; $cnt=0; while(-e $outFile) { $cnt++; $outFile = $outFileOrg . '.' . $cnt; } open(OUT,'>' . $outFile) || die "could not open $outFile"; printf OUT "DIR\tSRC\tCCD\tSCD\tSEX\tAGE\tACC\tSCC\tWTC\tLBO\015\012"; $lblFileCnt=0; # -- descend SpeechDat-Car directory BLOCKnn/SESSnnMM/ --------------------- $blockGlob = $workDir . 'BLOCK*'; while($blockDir = <${blockGlob}>) { $sessGlob = $blockDir . $fileDlm . 'SES*'; while($sessDir = <${sessGlob}>) { print "$sessDir\n"; $labelGlob = $sessDir . $fileDlm . "*$lblExt"; while($labelFile = <${labelGlob}>) { $lblFileCnt++; # --- read the label file ----------------------------------------- open(LBL,$labelFile) || die "Could not open SAM label file $lblFile in $sessDir"; while() { chop; s/[\r\n]//; ($lbl,$lblText) = split(/:/,$_,2); $sL{$lbl} = $lblText; } close(LBL); printf OUT "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\015\012", $sL{'DIR'},$sL{'SRC'},$sL{'CCD'},$sL{'SCD'},$sL{'SEX'},$sL{'AGE'},$sL{'ACC'},$sL{'SCC'},$sL{'WTC'},$sL{'LB0'}; } } } print "$lblFileCnt label file contents printed!\n"; close(OUT); exit(0);