forked from GitHub/gf-core
159 lines
4.4 KiB
HTML
159 lines
4.4 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>GF Quickstart</title>
|
|
<link rel=stylesheet href="../css/style.css">
|
|
<meta name = "viewport" content = "width = device-width">
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
<center>
|
|
<img src="Logos/gf0.png">
|
|
<p>
|
|
Aarne Ranta
|
|
<p>
|
|
October 2011 for GF 3.3
|
|
|
|
<p>
|
|
|
|
<h1>Grammatical Framework Quick Start</h1>
|
|
|
|
</center>
|
|
|
|
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 <tt>gf</tt> works for you. See download and install
|
|
instructions <a href="../download/index.html">here</a>.
|
|
|
|
<h2>Want to try without downloading?</h2>
|
|
|
|
<a href="../demos/phrasebook/">Using GF translation</a> with an existing grammar.
|
|
|
|
<p>
|
|
|
|
<a href="../demos/gfse/">Writing GF grammars</a> in the cloud, without installing GF.
|
|
|
|
|
|
|
|
|
|
<h2>Using GF for translation and generation</h2>
|
|
|
|
When you have downloaded and installed GF:
|
|
<ol>
|
|
<li> Copy the files
|
|
<a href="../examples/tutorial/food/Food.gf"><tt>Food.gf</tt></a>,
|
|
<a href="../examples/tutorial/food/FoodEng.gf"><tt>FoodEng.gf</tt></a>, and
|
|
<a href="../examples/tutorial/food/FoodIta.gf"><tt>FoodIta.gf</tt></a>.
|
|
Or go to <tt>GF/examples/tutorial/food/</tt>, if you have downloaded the
|
|
GF sources.
|
|
|
|
<li> Start GF with the shell command (without the prompt <tt>$</tt>)
|
|
<pre>
|
|
$ gf FoodIta.gf FoodEng.gf
|
|
</pre>
|
|
Alternatively, start GF with <tt>gf</tt> and give the GF command <tt>import FoodIta.gf FoodEng.gf</tt>.
|
|
|
|
<li> <b>Translation</b>. Try your first translation by giving the GF command
|
|
<pre>
|
|
parse "this cheese is very very Italian" | linearize
|
|
</pre>
|
|
Notice that the parser accept the tabulator for word completion.
|
|
|
|
<li> <b>Generation</b>. Random-generate sentences in two languages:
|
|
<pre>
|
|
generate_random | linearize
|
|
</pre>
|
|
|
|
<li> <b>Other commands</b>. Use the help command
|
|
<pre>
|
|
help
|
|
</pre>
|
|
<li> <b>More examples</b>. Go to <tt>GF/examples/phrasebook</tt> or some other
|
|
subdirectory of <tt>GF/examples/</tt>. Or try a resource grammar by, for instance,
|
|
<pre>
|
|
import alltenses/LangEng.gfo alltenses/LangGer.gfo
|
|
|
|
parse -lang=Eng "I love you" | linearize -treebank
|
|
</pre>
|
|
The resource grammars are found relative to the value of <tt>GF_LIB_PATH</tt>, which
|
|
you may have to set; see <a href="../download/index.html">here</a> for instructions.
|
|
|
|
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
<h2>Grammar development</h2>
|
|
|
|
Add words to the <tt>Food</tt>
|
|
grammars and try the above commands again. For instance, add the following lines:
|
|
<pre>
|
|
Bread : Kind ; -- in Food.gf
|
|
Bread = {s = "bread"} ; -- in FoodEng.gf
|
|
Bread = {s = "pane"} ; -- in FoodIta.gf
|
|
</pre>
|
|
and start GF again with the same command. Now you can even translate
|
|
<i>this bread is very Italian</i>.
|
|
</ol>
|
|
To lear more on GF commands and
|
|
grammar development, go to the one of the tutorials:
|
|
<ul>
|
|
<li> <a href="tutorial/gf-tutorial.html">GF Tutorial</a>: older, more programmer-oriented
|
|
<li> <a href="gf-lrec-2010.pdf">GF Resource Tutorial</a>: newer, more linguist-oriented
|
|
</ul>
|
|
To learn about how GF is used for easily writing grammars for 16 languages, consult the
|
|
<ul>
|
|
<li> <a href="../lib/doc/synopsis.html">GF Resource Grammar Library</a>.
|
|
</ul>
|
|
|
|
|
|
|
|
<h2>Run-time grammars and web applications</h2>
|
|
|
|
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
|
|
<pre>
|
|
gf -make FoodIta.gf FoodEng.gf
|
|
wrote Food.pgf
|
|
</pre>
|
|
You can use this in Haskell and Java programs, and also on web services, such as
|
|
<ul>
|
|
<li> the
|
|
<a href="http://cloud.grammaticalframework.org/minibar/minibar.html">minibar</a>
|
|
fridge magnets
|
|
</ul>
|
|
|
|
The quickest way to provide a GF web service is to start GF with the <tt>-server</tt> option:
|
|
<pre>
|
|
$ gf -server
|
|
This is GF version 3.3
|
|
Built on linux/i386 with ghc-7.0, flags: interrupt server cclazy
|
|
Document root = /usr/local/share/gf-3.3/www
|
|
Starting HTTP server, open http://localhost:41296/ in your web browser.
|
|
</pre>
|
|
You can view it locally by pointing your
|
|
browser to the URL shown. You can add your own <tt>.pgf</tt> grammar to the service by
|
|
copying it over to the <tt>documentRoot</tt> directory. Just push "reload" in
|
|
your browser after each such update.
|
|
|
|
<p>
|
|
|
|
To build more customized web application, consult the
|
|
<a href="http://code.google.com/p/grammatical-framework/wiki/SideBar?tm=6">developer wiki</a>.
|
|
|
|
|
|
<h2>User group</h2>
|
|
|
|
You are welcome to join the <A HREF="http://groups.google.com/group/gf-dev">User Group</A>
|
|
to get help and discuss GF-related issues!
|
|
|
|
|
|
|
|
|
|
|
|
</body></html>
|