Skip to content
Snippets Groups Projects
compile_automate.sh 1.82 KiB
Newer Older
#!/bin/bash

prefix=$1

WORDSYMB_I="--isymbols=""$prefix""_dico_word.txt"
WORDSYMB_O="--osymbols=""$prefix""_dico_word.txt"

Benoit Favre's avatar
Benoit Favre committed
# compile tail
fstcompile $WORDSYMB_I $WORDSYMB_O "$prefix""_clean_tail.txt" > "$prefix""_clean_tail.fst"
# compile glouton
fstcompile $WORDSYMB_I "$prefix""_glouton.txt" > "$prefix""_glouton.fst"
Benoit Favre's avatar
Benoit Favre committed
# compile section 0
Benoit Favre's avatar
Benoit Favre committed
cat "$prefix""_section0.txt" | fstcompile $WORDSYMB_I | fstunion - "$prefix""_glouton.fst" | fstclosure > "$prefix""_section0.fst"
Benoit Favre's avatar
Benoit Favre committed
# compilte exit and change section
cat "$prefix""_section0.txt" | fstcompile $WORDSYMB_I > "$prefix""_section0.basic.fst"
Benoit Favre's avatar
Benoit Favre committed

nbsect=1
while [ "$nbsect" != 80 ]
do
 if [ -e "$prefix""_section""$nbsect"".txt" ]
 then
  rm -f "$prefix""_section""$nbsect".fst
Benoit Favre's avatar
Benoit Favre committed
  if [ `cat "$prefix""_section""$nbsect""_exit.txt"| wc -l` == 0 ]
  then
   echo "Error: no $prefix""_section""$nbsect""_exit.txt file"
   exit
  fi
  cat "$prefix""_section""$nbsect""_exit.txt" | fstcompile $WORDSYMB_I > "$prefix""_section""$nbsect"".exit.fst"
  fstunion "$prefix""_section""$nbsect"".exit.fst" "$prefix""_section0.basic.fst" > "$prefix""_section""$nbsect"".exit.basic.fst"
  if [ `cat "$prefix""_section""$nbsect"".txt" | wc -l` != 0 ]
  then
Benoit Favre's avatar
Benoit Favre committed
   cat "$prefix""_section""$nbsect"".txt" | fstcompile $WORDSYMB_I > "$prefix""_section""$nbsect"".fst2"
   fstconcat "$prefix""_section""$nbsect"".fst2" "$prefix""_section""$nbsect"".exit.basic.fst" > "$prefix""_section""$nbsect"".fst4"
   fstunion "$prefix""_section""$nbsect"".fst4" "$prefix""_section""$nbsect"".exit.basic.fst" > "$prefix""_section""$nbsect"".fst"
  else
   cp "$prefix""_section""$nbsect"".exit.basic.fst" "$prefix""_section""$nbsect"".fst"
Benoit Favre's avatar
Benoit Favre committed
  rm -f "$prefix""_section""$nbsect"".exit.fst" -f "$prefix""_section""$nbsect"".exit.basic.fst" -f "$prefix""_section""$nbsect"".fst2" -f "$prefix""_section""$nbsect"".fst4"
 fi
 nbsect=$(($nbsect+1))
done