5. A non-transitory computer-readable medium, having stored thereon a sequence of instructions, which when executed by a computer, cause the computer to perform a method for generating a finite state grammar, the method comprising: (a) receiving user input of a plurality of sample phrases each comprising a plurality of words; (b) representing each sample phrase as a node in a tree; (c) forming a mathematical expression for each pair of nodes in the tree to represent the sample phrases associated with the pair of nodes, the mathematical expression comprising a plurality of words found in the sample phrases of the pair of nodes and an indication of whether a word is a common word that occurs in each of the plurality of phrases or an optional word that occurs in some of the plurality of phrases for the pair of nodes; (d) generating a compact mathematical expression by comparing the mathematical expressions one pair at a time, wherein the compact mathematical expression includes each of the plurality of words found in the sample phrases and an indication of whether each of the plurality of words is a common word or an optional word; (e) displaying the compact mathematical expression to a user; (f) allowing the user to alter the compact mathematical expression; (g) generating a finite state grammar corresponding to the altered compact mathematical expression; and (h) displaying the finite state grammar to the user.
7. The non-transitory computer-readable medium of claim 5 , wherein step (f) comprises receiving user inputs selected from the group consisting of user input to add a word to the mathematical expression, user input to delete a word from the mathematical expression, user input to make a common word in the mathematical expression optional; and user input to make an optional word in the mathematical expression common.