next up previous contents
Next: Issues Up: NATURAL LANGUAGE PROCESSING Previous: Semantics   Contents

Pragmatics

The pragmatics were simplified by the method of encoding the semantics, in that the first word of the string is the set of procedures to which the specific action belongs, and what follows is the name of, and number of parameters to, the specific action procedure.

The phrase ``walk forwards'' uttered by the user is clearly intended to be aimed at the agent, to get it to performing an action. As an example consider Figure 4.2.

Figure 4.2: Example translation of a spoken command to the procedure call
\begin{figure}{\centering\texttt{\footnotesize\begin{tabular}{rl}
{\small Spoken...
...tesize go({}\lq\lq forward'');}\\
\end{tabular}}\footnotesize\par }
\par\end{figure}

In this application there is a separate grammar for the animation commands (those spoken to the character) and for application commands (those spoken to the system). The semantics show explicitly from which grammar the command was chosen by prepending it's name to the semantic string. In the example, the word character is used to indicate the command is aimed at the character. If the spoken phrase had been ``world view'' then the semantics module would have used the word system as the first word of the semantic string.

The rest of the semantic string is built with the pragmatics of the system in mind. The first word is the number of arguments to follow (including the function name), then comes the name of the procedure that needs to be called and its parameters. In the example, this can be seen by the ``2, go, forward'' substring. The function call that is built up from reading the input string is go(``forwards'');, which then emits signals to the animation module in order to produce the desired effect. The decision tree is traversed to find the relevant function call. Continuing with the example, Figure 4.3 shows the relevant branches of the decision tree, along with the remaining input used to decide which subtree to examine, and the resulting high level animation procedure.

Figure 4.3: Decision tree summary

\begin{picture}(0,0)\includegraphics{images/decisionTree.eps}
\end{picture}

The reader familiar with Prolog will no doubt be wondering ``why not simply generate the procedure call directly from the spoken phrase?'', which is a very relevant question since languages such as Prolog allow high order functions. For the reader not familiar with Prolog, the main premise behind this is the ability to treat ground variables as predicates or functions themselves and hence 'call' or execute them. However, generating the string ``go(``forward'')'' as an output from Mercury, which is certainly possible, would only be of benefit if it could be treated as a higher order function, and be executed directly. Unfortunately, this higher order predicate approach, which is trivial in the language of Prolog, is far from trivial when using an imperative language such as C++ (see the paragraph on higher order functions in Section 4.1.2.3). Otherwise the string would have to be parsed once more in order to discover which function needs to be called.


next up previous contents
Next: Issues Up: NATURAL LANGUAGE PROCESSING Previous: Semantics   Contents
Andrew P Coates (UG) 2002-07-17