Speech:ParseDecode.pl

Summary
Title: parseDecode.pl

Author: unknown

Location: mnt/main/scripts/user/parseDecode.pl

Usage: parseDecode.pl

Description
rm: cannot remove `../etc/hyp.trans': No such file or directory
 * Takes all the lines that begin with FWDVIT and dump them into a temp file. These are the predicted lines that we need to look at to compare to the original statement.
 * Removes the parsed file if it exists.
 * Opens the temp file.
 * Reads and manipulates each line in the temp so that it matches the format that the transaction log is in and outputs the reformatted string.
 * PLEASE NOTE: When running parseDecode.pl, it isn't uncommon for it to return:
 * This is normal and is expected. The script should still have run successfully. The script is trying to remove an existing hypothesis file before making a new one. But of course, since we never ran the script before, the hypothesis file doesn't exist; thus returning an error. This is a bug that probably should be fixed.

Code

 * 1) !/usr/bin/perl

if ($#ARGV != 1) { print "usage: parseDecode.pl  [-v ]\n"; exit -1; }

$decode_file = $ARGV[0]; $output_file = $ARGV[1]; $temp_file = "temp.log";

$sysCmd = "cat $decode_file | grep FWDVIT >> $temp_file"; system($sysCmd);
 * 1) take all the lines that being with FWDVIT and dump them into a temp file
 * 2) these are the predicted lines that we need to look at to compare to the original statement

$sysCmd = "rm $output_file"; system($sysCmd);
 * 1) remove the parsed file if it exists

open(MYINPUTFILE, "<$temp_file"); open(MYOUTPUTFILE, ">>$output_file");
 * 1) open the temp file

while() { $line = $_;; chomp $line; $line =~ s/FWDVIT: //; $utteranceID = $line; $utteranceID =~ m/\(sw[0-9]*[A-B]-ms98-a-[0-9]*\)/; $utteranceID = $&; $line =~ s/\(sw[0-9]*[A-B]-ms98-a[0-9]\)//; $line =~ s/\($&\)//; $line = " ". $line. " " . $utteranceID; print MYOUTPUTFILE "$line\n"; } close(MYINPUTFILE); close(MYOUTPUTFILE);
 * 1) read and manipulate each line in the temp so that it matches the format
 * 2) that the transaction log is in and output the reformatted string
 * 1) close files

$sysCmd = "rm $temp_file"; system($sysCmd);
 * 1) remove the temp file