name: grammar_compiler
synopsis: grammar_compiler [options] [arguments]

description:  

this is the isip grammar compiler. it generates a lattice file from the 
input grammar. the input grammar can be a probabilistic grammar. if some 
transitional probabilities are missing, the grammar compiler calculates these
automatically by assuming the missing ones to be equally probable. this output 
lattice file can be used as the input to the isip prototype decoder. 

arguments:
   -input grammar    : input grammar file
   -output lattice   : output lattice file
   -probabilistic    : flag to make all words equiprobable if 
                       non-probabilistic grammar

The two cases for probabilistic as well as non-probabilistic grammar are 
handled as
  1) Non-probabilistic or Equiprobable Grammar
     If the probabilistic flag is not set, the probability is taken as one for
     all words. This is for backward compatibility. 
     If the probabilistic flag is set, all the words are taken to be 
     equiprobable. This probability is calculated by dividing one by number of
     equiprobable words.
  2) Probabilistic grammar
     Irrespective of whether the probabilistic flag is set or not, the 
     probabilities are automatically detected from the grammar file.

options:
   -help             : to view this message

examples:
   grammar_compiler -input grammar.text -output lattice.text
   grammar_compiler -probabilistic -input grammar.text -output lattice.text

input grammar file format :

  * The main grammar is defined in $isip_utterance = expression;
    which can consist of words, regular expression symbols and
    other variables.
  
  * Variable name starts with a '$' and the definitions is terminated by
    a semi_colon, ';'. Thus the variable definition can be written in 
    several lines.


  * Regular Expression Symbols:

        ( ) denotes bracket sub-expressions; 
        { } denotes zero or more repetitions;
        <>  denotes one or more repetitions;
        []  denotes optional;
        |   denotes alternatives;
	~   denotes probabilities.

  * Grammar-compiler accepts any combination of sub-expression "()" 
    and alternative operation "|" with "~" symbol and a corresponding
    probability.
    Any combination of "]~" or "}~" or ">~" will result in an error message.

  * example:
        non-probabilistic grammar
        $isip_alpha =  a | b | c | d | e | f | g | h | i | j | k | l | m |
                       n |  o | p | q | r | s | t | u | v | w | x | y | z;
        $isip_digit = zero | one | two | three | four | five | six | seven | 
                      eight | nine;
        $isip_utterance = !SENT_START < $isip_alpha | $isip_digit > !SENT_END;

        probabilistic grammar
        $isip_alpha =  a~0.001 | b~0.002 | c~0.001 | d~0.012 | e | f | g |
                       h | i | j | k | l | m~0.003 | n |  o~0.0005 | p | 
                       q | r~0.1 | s | t | u | v~0.0021 | w | x | y | z;
        $isip_digit = zero~0.0052 | one~0.2 | two | three | four | five | 
                      six | seven | eight~0.0021 | nine;
        $isip_utterance = !SENT_START < $isip_alpha | $isip_digit > !SENT_END;

Output word graph format: 
   VERSION=1.0
   lmscale=12.00
   wdpenalty=-10.00
   N=104 L=198
   I=0    t=0.00  
   I=1    t=0.02  
   I=2    t=0.03  
   I=3    t=0.04  
   I=4    t=0.05  
   ...
   I=99   t=0.11  
   I=100  t=0.11  
   I=101  t=0.11  
   I=102  t=0.11  
   I=103  t=0.13  
   J=0 S=0 E=1 W=!SENT_START v=1 a=-343.71 l=0.833 
   J=1 S=0 E=2 W=!SENT_START v=1 a=-512.87 l=0.833 
   J=2 S=0 E=3 W=!SENT_START v=1 a=-674.47 l=0.833 
   J=3 S=0 E=4 W=!SENT_START v=1 a=-836.46 l=0.833 
   J=4     S=1    E=5    W=OOH   v=1  a=-552.81   l=-7.976 
   J=5     S=1    E=6    W=OH    v=1  a=-539.26   l=-3.208 
   J=6     S=1    E=7    W=AH    v=1  a=-545.93   l=-9.991 
   J=7     S=1    E=8    W=E     v=1  a=-676.17   l=-11.324 
   J=8     S=1    E=9    W=A     v=1  a=-666.94   l=-6.124 
   J=9     S=1    E=10   W=ARE   v=3  a=-666.94   l=-12.294
   ...
   
   J=194 S=99 E=103 W=!SENT_END v=1 a=-328.44 l=-3.602 
   J=195 S=100 E=103 W=!SENT_END v=1 a=-328.44 l=-2.137
   J=196 S=101 E=103 W=!SENT_END v=1 a=-328.44 l=-3.215
   J=197 S=102 E=103 W=!SENT_END v=1 a=-328.44 l=-0.005
   
   Note: N    --    the number of nodes
         L    --    the number of arcs
         I    --    the index of node
         J    --    the index of arc
         S    --    the start node index
         E    --    the end node index
         W    --    the word associated with the node
         t    --    time
         v    --    the index of pronunciation corresponding to lexicon
                    in the case that one word may have multi pronunciations
         a    --    acoustic score
         l    --    language model score
         lmscale -- language model scale
         wdpenalty - word penalty


man page: http://www.isip.msstate.edu/projects/speech/education/toolkits/asr/language_models/grammar_compiler/index.html
