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 Embedded GF Interpreter is distributed under the GNU Lesser General Public License.
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 -utf8id -printer=header | wf test.gfcm
Create a CFGM file:
> pm -utf8 -utf8id -printer=cfgm | wf test.cfgm
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 build-translet script will create a JAR-file which runs the translation GUI.
To run the translation GUI on files you have created manually, as in the description above, run:
$ java -cp gfc2java.jar:. se.chalmers.cs.gf.translategui.TranslateApp test.properties
Note that the current directory must be included in the classpath, since properties file is loaded as a Java resource from the classpath.
Have a look at the simple demo program. Given the files created above, you can run the program with:
$ java -cp gfc2java.jar:. se.chalmers.cs.gf.translategui.Test test.properties TestSwe TestEng
Note that the current directory must be included in the classpath, since properties file is loaded as a Java resource from the classpath.
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=FINEST se.chalmers.cs.gf.linearize.level=FINEST
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.