summaryrefslogtreecommitdiff
path: root/doc/gf-quickstart.html
blob: e71357cf36ebd36d2904ecd12bc403b7b514c8a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!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://www.grammaticalframework.org:41296/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>