Björn Bringert, bringert@cs.chalmers.se
The Grammatical Framework (GF) is a grammar formalism well suited to writing multilingual grammars for natural languages. The system presented in this document implements parsing and linearization using GF grammars.
If you just need to run the interpreter, getting gfc2java.jar should be enough.
Get the source code for the latest version of the GF interpreter here.
There is also a gfc2java darcs repo with the development version. Get darcs here.
The README file describes how to build the library and included demo applications.
JavaDoc for the API can also be built using make javadoc.
See "GF OAA Agent".
The GF interpreter needs two representations of the grammar to do linearization and parsing. These two representations can be generated from a GF source grammar by using the GF system. This example assumes that we have the concrete syntax modules TestEng and TestSwe.
Load all the source modules into GF:
> i TestEng.gf > i TestSwe.gf
Create a GFCM file:
> pm -utf8 -printer=header | wf test.gfcm
Note that you might get an error message saying that header is not a valid value for the -printer flag. Ignore this message. This is a bug in GF's error reporting which will be fixed.
Create a CFGM file:
> pm -utf8 -printer=cfgm | wf test.cfgm
Note that you might get an error message saying that cfgm is not a valid value for the -printer flag. Ignore this message. This is a bug in GF's error reporting which will be fixed.
Create a properties file (here test.properties) so that the interpreter can find these files. The file should have these contents:
name: test gfcm: test.gfcm cfgm: test.cfgm
See the build-translet script for an example of how to do this automatically.
The Embedded GF Interpreter uses the Java Logging API to handle log messages. The following logging namespaces are used:
By default, little information is logged. To change the log level or other logging parameters, you can use the normal Logging API mechanisms. For example, to print FINE level message for the parse package and inearize packages to the standard error stream, create a file called logging.properties in the current directory:
# Log to System.err: handlers=java.util.logging.ConsoleHandler # Set the log level of the log handler to FINEST java.util.logging.ConsoleHandler.level=FINEST # Use our log formatter, which just prints the log messages java.util.logging.ConsoleHandler.formatter=se.chalmers.cs.gf.util.SimplestLogFormatter # Set global logging level .level=INFO # Set log levels for our packages se.chalmers.cs.gf.parse.level=FINE se.chalmers.cs.gf.linearize.level=FINE
Then instruct the logging API to use the properties from this file, for example:
$ java -Djava.util.logging.config.file=logging.properties -jar translate-numerals.jar
The Numerals translator is a demo applet which uses the Java GF interpreter and the GF numerals grammar to translate numerals between a number of languages.
Tramdemo demonstrates the use of multimodal grammars as a method of implementing multimodal dialog systems.
The standard parsing and linearization functions use untyped abstract syntax trees. The Grammar2API program in the gfc2java distribution generates Java classes which can represent an abstract syntax tree using typed trees.