Aarne Ranta

December 2010 for GF 3.2

# Grammatical Framework Quick Start

This Quick Start shows a few examples of how GF can be used. We assume that you have downloaded and installed GF, so that the command `gf` works for you. See download and install instructions here.

## Using GF for translation and generation

When you have downloaded and installed GF:

1. Copy the files `Food.gf`, `FoodEng.gf`, and `FoodIta.gf`. Or go to `GF/examples/tutorial/food/`, if you have downloaded the GF sources.
2. Start GF with the shell command (without the prompt `$`)

         $ gf FoodIta.gf FoodEng.gf

3. Translation. Try your first translation by giving the GF command

         parse "this cheese is very very Italian" | linearize

   Notice that the parser accept the tabulator for word completion.
4. Generation. Random-generate sentences in two languages:

         generate_random | linearize

5. Other commands. Use the help command

         help

6. More examples. Go to `GF/examples/phrasebook` or some other subdirectory of `GF/examples/`. Or try a resource grammar by, for instance,

         import alltenses/LangEng.gfo alltenses/LangGer.gfo

         parse -lang=Eng "I love you" | linearize -treebank

   The resource grammars are found relative to the value of `GF_LIB_PATH`, which you may have to set; see here for instructions.

## Grammar development

Add words to the `Food` grammars and try the above commands again. For instance, add the following lines:

      Bread : Kind ;          -- in Food.gf
      Black = {s = "bread"} ; -- in FoodEng.gf
      Black = {s = "pane"} ;  -- in FoodIta.gf

and start GF again with the same command. Now you can even translate this bread is very Italian. To lear more on GF commands and grammar development, go to the one of the tutorials:

- GF Tutorial: older, more programmer-oriented
- GF Resource Tutorial: newer, more linguist-oriented

To learn about how GF is used for easily writing grammars for 16 languages, consult the

- GF Resource Grammar Library.

## Run-time grammars and web applications

GF has its own "machine language", PGF (Portable Grammar Format), which is recommended for use in applications at run time. To produce a PGF file from the two grammars above, do

      gf -make FoodIta.gf FoodEng.gf
      wrote Food.pgf

You can use this in Haskell and Java programs, and also on web services, such as

- the minibar fridge magnets

The quickest way to provide a GF web service is to start the program `pgh-http`

      $ pgh-http
      Starting HTTP server, open http://localhost:41296/ in your web browser

      Options {documentRoot = "/home/aarne/.cabal/share/gf-server-1.0/www", port = 41296}

which resides next to your `gf` program. You can view it locally by pointing your browser to the URL shown. You can add your own `.pgf` grammar to the service by copying it over to the `documentRoot` directory. Just push "reload" in your browser after each such update.

To build more customized web application, consult the developer wiki.

## User group

You are welcome to join the User Group to get help and discuss GF-related issues!