% html: Beginning of file: `gf-oaa.html'
% DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
\chapter{Embedded GF Interpreter OAA Agent}
\label{appendix-oaa-solvables}
\label{f0}
\section{Introduction}
The Open Agent Architecture
(OAA) is ``a framework for integrating a community of heterogeneous
software agents in a distributed environment''.
This document describes the GF OAA Agent included with the
Embedded GF Interpreter.
\section{Running}
If the grammar properties file is {\tt test.properties} and
the facilitator is running on {\tt \$FAC\_HOST}, port
{\tt \$FAC\_PORT}, the GF agent is started with:
\begin{verbatim}
$ java -cp gfc2java.jar:. se.chalmers.cs.gf.oaa.GFAgent \
/test.properties -oaa_connect "tcp('${FAC_HOST}',${FAC_PORT})"
\end{verbatim}
\subsection{Notes}
\begin{itemize}\item
The path to the properties file is loaded as a java resource, so
the leading slash means to look look at the root of the package
hierarchy to find the file in the current directory.
\item
The following must be on the classpath:
\begin{itemize}
\item OAA 2.3.0 and all its requirements
\item The Trindikit Java library (for the OAAAgent class)
\end{itemize}
\end{itemize}
\section{Solvables}
The OAA agent declares these solvables:
\begin{itemize}
\item parse (cf.\ Section~\ref{f0:parse})
\item linearize (cf.\ Section~\ref{f0:linearize})
\item translate (cf.\ Section~\ref{f0:translate})
\item list\_grammars (cf.\ Section~\ref{f0:list.grammars})
\item list\_languages (cf.\ Section~\ref{f0:list.languages})
\end{itemize}
\subsection{parse}
\label{f0:parse}
{\tt parse(Grammar,Lang,Text,Tree)}
\subsubsection{Parameters}
\begin{description}\item[Grammar]
The name of the grammar. This is the value of the name parameter
in the properties file.
\item[Lang]
The name of the concrete syntax that should be used for
parsing. If Lang is not instantiated, the parser
will try all available languages in the given grammar,
and return results for each language that the text can be parsed in.
\item[Text]
The text to parse. Must be instantiated.
\item[Tree]
The parse tree. Normally not instantiated.
The parse tree from the parser is unified with
this value. Parse trees are represented as ICL structs.
\end{description}
\subsubsection{Examples}
\begin{itemize}\item
Language given, unambiguous parse:
\begin{verbatim}
parse(numerals, german, 'drei hundert', Tree)
=>
parse(numerals, german, 'drei hundert',
num(pot2as3(pot2(pot0(n3)))))
\end{verbatim}
\item
Language uninstantiated, unambiguous parse:
\begin{verbatim}
parse(numerals, Lang, 'three hundred', Tree)
=>
parse(numerals, english, 'three hundred',
num(pot2as3(pot2(pot0(n3)))))
\end{verbatim}
\item
Language uninstantiated, parses with several languages to same
parse tree:
\begin{verbatim}
parse(numerals, Lang, 'tre', Tree)
=>
parse(numerals, albanian, tre,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))))
parse(numerals, danish, tre,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))))
parse(numerals, italian, tre,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))))
parse(numerals, norwegian_book, tre,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))))
parse(numerals, swedish, tre,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))))
\end{verbatim}
\item
Language uninstantiated, parses with several languages to
different parse trees:
\begin{verbatim}
parse(numerals, Lang, 'tres', Tree)
=>
parse(numerals,catalan,tres,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))))
parse(numerals,danish,tres,
num(pot2as3(pot1as2(pot1(n6)))))
parse(numerals,spanish,tres,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))))
\end{verbatim}
\end{itemize}
\subsection{linearize}
\label{f0:linearize}
{\tt linearize(Grammar,Lang,Tree,Text)}
\subsubsection{Parameters}
\begin{description}\item[Grammar]
The name of the grammar. This is the value of the name parameter
in the properties file.
\item[Lang]
The name of the concrete syntax that should be used for linearization.
If Lang is not instantiated, linearizations for
all available languages in the given grammar will
be returned.
\item[Tree]
The abstract syntax tree to linearize. Must be instantiated.
\item[Text]
The linearization of the given tree.
\end{description}
\subsubsection{Examples}
\begin{itemize}\item
Language given:
\begin{verbatim}
linearize(numerals, english,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))), Str)
=>
linearize(numerals, english,
num(pot2as3(pot1as2(pot0as1(pot0(n3))))), three)
\end{verbatim}
\end{itemize}
\subsection{translate}
\label{f0:translate}
{\tt translate(Grammar,FromLang,Input,ToLang,Output)}
\subsubsection{Parameters}
\begin{description}\item[Grammar]
The name of the grammar. This is the value of the name parameter
in the properties file.
\item[FromLang]
The name of the concrete syntax that should be used for parsing the input text.
If Lang is not instantiated, all available languages in the given grammar will
be tried.
\item[Input]
The input text. Must be instantiated.
\item[ToLang]
The name of the concrete syntax that should be used for linearizing the output.
\item[Output]
The output text. Normally not instantiated.
\end{description}
\subsubsection{Examples}
\begin{itemize}\item
Input language not given:
\begin{verbatim}
translate(numerals, Lang, 'tres', english, Str)
=>
translate(numerals,catalan,tres,english,three)
translate(numerals,danish,tres,english,sixty)
translate(numerals,spanish,tres,english,three)
\end{verbatim}
\end{itemize}
\subsection{list\_grammars}
\label{f0:list.grammars}
{\tt list\_grammars(Grammars)}
\subsubsection{Parameters}
\begin{description}\item[Grammars]
The list of available grammars.
\end{description}
\subsubsection{Examples}
\begin{itemize}\item
Get all grammars:
\begin{verbatim}
list_grammars(Grammars)
=>
list_grammars([query,answer])
\end{verbatim}
\end{itemize}
\subsection{list\_languages}
\label{f0:list.languages}
{\tt list\_languages(Grammar, InputLangs, OutputLangs)}
\subsubsection{Parameters}
\begin{description}\item[Grammar]
The grammar to get the languages for. If uninstantiated,
there will be one answer for each available grammar.
\item[InputLangs]
A list of the available input languages for the grammar.
\item[OutputLangs]
A list of the available output languages for the grammar.
\end{description}
\subsubsection{Examples}
\begin{itemize}\item
Get languages for all grammars (Grammar uninstantiated):
\begin{verbatim}
list_languages(Grammar, InputLangs, OutputLangs)
=>
list_languages(query,
['*all*','GbgQueryEng','GbgQuerySwe'],
['*all*','GbgQueryEng','GbgQuerySwe'])
list_languages(answer,
['*all*','GbgRouteEng','GbgRouteMap',
'GbgRouteSwe'],
['*all*','GbgRouteEng','GbgRouteMap',
'GbgRouteSwe'])
\end{verbatim}
\item
Get languages for the query grammar (Grammar instantiated):
\begin{verbatim}
list_languages('query', InputLangs, OutputLangs)
=>
list_languages(query,
['*all*','GbgQueryEng','GbgQuerySwe'],
['*all*','GbgQueryEng','GbgQuerySwe'])
\end{verbatim}
\end{itemize}
% html: End of file: `gf-oaa.html'