<< Previous | - Up - | Next >> |
The parser can also be used without the GUI, e.g. as a syntactic module in a bigger NLP system. For instance, an earlier version of our parser has been used in a software project described in Building a Text Adventure on Description Logic. In this package, we provide the file "TEST.oz" which is an illustrative example of how to use the parser without the GUI. In the following, we give a walkthrough of "TEST.oz".
Firstly, to invoke the parser without the GUI, one needs to import or link the functor "Grammar.ozf", which must then be set up with a grammar file:
[Grammar] = {Module.link ['x-ozlib://duchier/coli/dg/Grammar.ozf']} {Grammar.set 'grammar-de.dg'} G = {Grammar.get}
As a result, the variable G
denotes the compiled grammar
file information of "grammar-de.dg".
Next, the functor "Script.ozf" must be imported or linked:
[Script] = {Module.link ['x-ozlib://duchier/coli/dg/Script.ozf']}
Optionally, a plugins file can also be imported or linked, as in the following example:
[Plugins] = {Module.link ['x-ozlib://duchier/coli/dg/Plugins-de.ozf']} proc {PluginsProc Signs G} {Plugins.plugins.relative.procedure Signs true G} {Plugins.plugins.root.procedure Signs norestr G} end
Here, we link the plugins file "Plugins-de.ozf". Then, we define the
procedure PluginsProc
which in turn calls the individual
constraints relative
and root
. The
relative
-constraint is given parameter true
and the root
-constraint the parameter
norestr
.
In the following code snipped, we set the parser's parameters:
Params = o( generate: false idacc: true idval: true idgamma: true lporder: true lpproj: true lpacc: true lpval: true lpnode: true lpgamma: true climbing: true subtrees: true barriers: true plugins: PluginsProc)
Any of these parameters can be omitted. If so, the parameter is
assigned precisely a default value as defined for the GUI (see chapter 5.4). If the plugins
parameter is omitted, no plugin constraints are applied.
Finally, we define the string Words
and initialize the
parser using the function Script.make
which returns a
parse script. This script must now be invoked by an Oz search engine:
in the example, we use the standard search engine to find all
solutions for the string (Search.base.all
):
Words = [maria liebt einen reichen mann] S = {Script.make Words Params G} Solutions = {Search.base.all S}
After parsing, the variable Solutions
is unified with the
list of all solutions. A solution is in turn a list of
Signs.
<< Previous | - Up - | Next >> |