#!/bin/bash # Run transducer on textfile input and # $1 --> macrofile # $2 --> name of transducer # $3 --> inputfile if [ "$1" ] && [ "$2" ] && [ "$3" ] then if [ -e "$1" ] then if [ -e "$3" ] then name=$(basename $1 .pl) echo "" echo "..Run transducer $2 with input $3" # write number of outputs to $name.outputs and tranductions to $name.pho # for the cases with no output write a * to $name.pho fsa -aux $1 -raa "{"$2",~domain("$2") o (? +):[*]}" < $3 > $name.pho 2> $name.out grep 'outputs' $name.out | paste $3 - > $name.out2 # create an empty line for multiple outputs ([2,3,4] outputs) # (add more when necessary ...) sed '/2 out/G; /3 out/{G;G;}; /4 out/{G;G;G;}' $name.out2 > $name.out3 sed 's/|: //; /^$/d' $name.pho > $name.pho2 paste $name.out3 $name.pho2 > $name.out4 echo "..Create $name.g2p" # put multiple outputs back on one line ([2,3,4] outputs) # (add more when necessary ...) sed '/2 out/N;s/\n//; /3 out/{N;s/\n//; N;s/\n//;}; /4 out/{N;s/\n//; N;s/\n//; N;s/\n//;}' $name.out4 > $name.g2p echo "" rm $name.{out*,pho*} else echo "..input file $3 not found" fi else echo "..transducer file $1 not found" fi else echo "..Usage: testtd [filename] [transducer] [inputfile]" fi