Using GF grammars in Java and OAA

Björn Bringert, bringert@cs.chalmers.se

Introduction

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.

Download

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.

Documentation

Building

The README file describes how to build the library and included demo applications.

Java API

JavaDoc for the GF API.

JavaDoc for the API can also be built using make javadoc.

OAA interface

See "GF OAA Agent".

Producing a grammar for the interpreter

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.

  1. Load all the source modules into GF:

    > i TestEng.gf
    > i TestSwe.gf
    
  2. 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.

  3. 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.

  4. 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-gramlet script for an example of how to do this automatically.

Demos and examples

Numerals translator

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

Tramdemo demonstrates the use of multimodal grammars as a method of implementing multimodal dialog systems.

Typed abstract syntax trees

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.

Known issues