updated tutorial and quickstart for 3.2

This commit is contained in:
aarne
2010-12-23 09:33:11 +00:00
parent d47da82d00
commit f117e7b3b7
6 changed files with 556 additions and 105 deletions

View File

@@ -9,7 +9,7 @@
<p>
Aarne Ranta
<p>
22 December 2010 (3 September, 2007)
December 2010 for GF 3.2
<p>
@@ -42,12 +42,12 @@ GF sources.
<li> <b>Translation</b>. Try your first translation by giving the GF command
<pre>
parse "this cheese is very very Italian" | tree_bank
parse "this cheese is very very Italian" | linearize -treebank
</pre>
<li> <b>Generation</b>. Random-generate sentences in two languages:
<pre>
generate_random | l -multi
generate_random | linearize
</pre>
<li> <b>Grammar development</b>. Add words to the <tt>Food</tt>
@@ -66,6 +66,35 @@ grammar development, go to the one of the tutorials:
<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, as shown in
<a href="http://www.grammaticalframework.org:41296/minibar/minibar.html">here</a>.
To build your own 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>

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
Grammatical Framework Tutorial
Aarne Ranta
December 2010 (November 2008)
December 2010 for GF 3.2
% NOTE: this is a txt2tags file.
@@ -64,6 +64,7 @@ December 2010 (November 2008)
%!postproc(tex): #MYTREE "input{mytree}"
%!preproc(html): #MYTREE [mytree.png]
%!preproc(html): #MYPARSE [myparse.png]
%!postproc(tex): #FOODMARKET "input{foodmarket}"
%!preproc(html): #FOODMARKET [foodmarket.png]
%!postproc(tex): #CATEGORIES "input{categories}"
@@ -1283,7 +1284,13 @@ program (from the Graphviz package).
```
% dot -Tpng _grph.dot > mytree.png
```
You can also visualize **parse trees**, which show categories and words instead of
function symbols. The command is ``visualize_parse = vp``:
```
> parse "this delicious cheese is very Italian" | visualize_parse
```
#MYPARSE
#NEW
@@ -1296,9 +1303,9 @@ You can give a **system command** without leaving GF:
> ! open mytree.png
```
A system command may also receive its argument from
a GF pipes. It then has the name ``sp`` = ``system_pipe``:
a GF pipes. It then uses the symbol ``?``:
```
> generate_trees -depth=4 | sp -command="wc -l"
> generate_trees -depth=4 | ? wc -l
```
This command example returns the number of generated trees.
@@ -2766,23 +2773,27 @@ Goals:
==The coverage of the library==
The current 12 resource languages are
The current 16 resource languages (GF version 3.2, December 2010) are
- ``Bul``garian
- ``Cat``alan
- ``Dan``ish
- ``Dut``ch
- ``Eng``lish
- ``Fin``nish
- ``Fre``nch
- ``Ger``man
- ``Ita``lian
- ``Nor``wegian
- ``Pol``ish
- ``Ron``, Romanian
- ``Rus``sian
- ``Spa``nish
- ``Swe``dish
- ``Urd``u
The first three letters (``Eng`` etc) are used in grammar module names
(ISO 639 standard).
(ISO 639-3 standard).
#NEW
@@ -2832,8 +2843,7 @@ Two kinds of lexical categories:
- structural words / function words, e.g.
```
Conj ; -- conjunction e.g. "and"
QuantSg ; -- singular quantifier e.g. "this"
QuantPl ; -- plural quantifier e.g. "this"
Det ; -- determiner e.g. "this"
```
- **open**:
@@ -2852,8 +2862,7 @@ Two kinds of lexical categories:
Closed classes: module ``Syntax``. In the ``Foods`` grammar, we need
```
this_QuantSg, that_QuantSg : QuantSg ;
these_QuantPl, those_QuantPl : QuantPl ;
this_Det, that_Det, these_Det, those_Det : Det ;
very_AdA : AdA ;
```
Naming convention: word followed by the category (so we can
@@ -2917,8 +2926,7 @@ Common nouns are made into noun phrases by adding determiners.
We need the following combinations:
```
mkCl : NP -> AP -> Cl ; -- e.g. "this pizza is very warm"
mkNP : QuantSg -> CN -> NP ; -- e.g. "this pizza"
mkNP : QuantPl -> CN -> NP ; -- e.g. "these pizzas"
mkNP : Det -> CN -> NP ; -- e.g. "this pizza"
mkCN : AP -> CN -> CN ; -- e.g. "warm pizza"
mkAP : AdA -> AP -> AP ; -- e.g. "very warm"
```
@@ -2944,7 +2952,7 @@ The sentence
can be built as follows:
```
mkCl
(mkNP these_QuantPl
(mkNP these_Det
(mkCN (mkAP very_AdA (mkAP warm_A)) (mkCN pizza_CN)))
(mkAP italian_AP)
```
@@ -2970,7 +2978,7 @@ Language-specific and language-independent parts - roughly,
Full API documentation on-line: the **resource synopsis**,
[``grammaticalframework.org/lib/resource/doc/synopsis.html`` http://grammaticalframework.org/lib/doc/synopsis.html]
[``grammaticalframework.org/lib/doc/synopsis.html`` http://grammaticalframework.org/lib/doc/synopsis.html]
#NEW
@@ -2983,8 +2991,7 @@ Full API documentation on-line: the **resource synopsis**,
| ``CN`` | common noun (without determiner) | //red house// |
| ``NP`` | noun phrase (subject or object) | //the red house// |
| ``AdA`` | adjective-modifying adverb, | //very// |
| ``QuantSg`` | singular quantifier | //these// |
| ``QuantPl`` | plural quantifier | //this// |
| ``Det`` | determiner | //these// |
| ``A`` | one-place adjective | //warm// |
| ``N`` | common noun | //house// |
@@ -2995,8 +3002,7 @@ Full API documentation on-line: the **resource synopsis**,
|| Function | Type | Example ||
| ``mkCl`` | ``NP -> AP -> Cl`` | //John is very old// |
| ``mkNP`` | ``QuantSg -> CN -> NP`` | //this old man// |
| ``mkNP`` | ``QuantPl -> CN -> NP`` | //these old man// |
| ``mkNP`` | ``Det -> CN -> NP`` | //these old man// |
| ``mkCN`` | ``N -> CN`` | //house// |
| ``mkCN`` | ``AP -> CN -> CN`` | //very big blue house// |
| ``mkAP`` | ``A -> AP`` | //old// |
@@ -3007,10 +3013,10 @@ Full API documentation on-line: the **resource synopsis**,
===A miniature resource API: structural words===
|| Function | Type | In English ||
| ``this_QuantSg`` | ``QuantSg`` | //this// |
| ``that_QuantSg`` | ``QuantSg`` | //that// |
| ``these_QuantPl`` | ``QuantPl`` | //this// |
| ``those_QuantPl`` | ``QuantPl`` | //that// |
| ``this_Det`` | ``Det`` | //this// |
| ``that_Det`` | ``Det`` | //that// |
| ``these_Det`` | ``Det`` | //this// |
| ``those_Det`` | ``Det`` | //that// |
| ``very_AdA`` | ``AdA`` | //very// |
@@ -3112,10 +3118,10 @@ Now the combination rules we need almost write themselves automatically:
```
lin
Is item quality = mkCl item quality ;
This kind = mkNP this_QuantSg kind ;
That kind = mkNP that_QuantSg kind ;
These kind = mkNP these_QuantPl kind ;
Those kind = mkNP those_QuantPl kind ;
This kind = mkNP this_Det kind ;
That kind = mkNP that_Det kind ;
These kind = mkNP these_Det kind ;
Those kind = mkNP those_Det kind ;
QKind quality kind = mkCN quality kind ;
Very quality = mkAP very_AdA quality ;
```
@@ -3234,10 +3240,10 @@ we can write a **functor instantiation**,
Quality = AP ;
lin
Is item quality = mkCl item quality ;
This kind = mkNP this_QuantSg kind ;
That kind = mkNP that_QuantSg kind ;
These kind = mkNP these_QuantPl kind ;
Those kind = mkNP those_QuantPl kind ;
This kind = mkNP this_Det kind ;
That kind = mkNP that_Det kind ;
These kind = mkNP these_Det kind ;
Those kind = mkNP those_Det kind ;
QKind quality kind = mkCN quality kind ;
Very quality = mkAP very_AdA quality ;
@@ -4530,10 +4536,10 @@ This facility is based on several components:
The portable format is called PGF, "Portable Grammar Format".
This format is produced by the GF batch compiler ``gf``,
executable from the operative system shell:
This format is produced by using GF as batch compiler, with the option ``-make``,
from the operative system shell:
```
% gf --make SOURCE.gf
% gf -make SOURCE.gf
```
PGF is the recommended format in
which final grammar products are distributed, because they
@@ -4598,7 +4604,7 @@ translate gr s = case parseAllLang gr (startCat gr) s of
```
To run the translator, first compile it by
```
% ghc --make -o trans Translator.hs
% ghc -make -o trans Translator.hs
```
For this, you need the Haskell compiler [GHC http://www.haskell.org/ghc].
@@ -4610,7 +4616,7 @@ For this, you need the Haskell compiler [GHC http://www.haskell.org/ghc].
Then produce a PGF file. For instance, the ``Food`` grammar set can be
compiled as follows:
```
% gf --make FoodEng.gf FoodIta.gf
% gf -make FoodEng.gf FoodIta.gf
```
This produces the file ``Food.pgf`` (its name comes from the abstract syntax).
@@ -4718,7 +4724,7 @@ abstract syntax to a system of Haskell datatypes:
```
It is also possible to produce the Haskell file together with PGF, by
```
% gf --make --output-format=haskell QueryEng.gf
% gf -make --output-format=haskell QueryEng.gf
```
The result is a file named ``Query.hs``, containing a
module named ``Query``.
@@ -4871,7 +4877,7 @@ translate tr gr s = case parseAllLang gr (startCat gr) s of
To automate the production of the system, we write a ``Makefile`` as follows:
```
all:
gf --make --output-format=haskell QueryEng
gf -make --output-format=haskell QueryEng
ghc --make -o ./math TransferLoop.hs
strip math
```
@@ -4928,7 +4934,7 @@ program compiled from GF grammars as run on an iPhone.
JavaScript is one of the output formats of the GF batch compiler. Thus the following
command generates a JavaScript file from two ``Food`` grammars.
```
% gf --make --output-format=js FoodEng.gf FoodIta.gf
% gf -make --output-format=js FoodEng.gf FoodIta.gf
```
The name of the generated file is ``Food.js``, derived from the top-most abstract
syntax name. This file contains the multilingual grammar as a JavaScript object.
@@ -4974,7 +4980,7 @@ GSL is produced from GF by running ``gf`` with the flag
Example: GSL generated from ``FoodsEng.gf``.
```
% gf --make --output-format=gsl FoodsEng.gf
% gf -make --output-format=gsl FoodsEng.gf
% more FoodsEng.gsl
;GSL2.0

View File

@@ -35,10 +35,10 @@ incomplete concrete ExtFoodsI of ExtFoods = FoodsI ** open Syntax, LexFoods in {
You = mkNP youPol_Pron ;
We = mkNP we_Pron ;
GThis = mkNP this_QuantSg ;
GThat = mkNP that_QuantSg ;
GThese = mkNP these_QuantPl ;
GThose = mkNP those_QuantPl ;
GThis = mkNP this_Det ;
GThat = mkNP that_Det ;
GThese = mkNP these_Det ;
GThose = mkNP those_Det ;
Eat = eat_V2 ;
Drink = drink_V2 ;

View File

@@ -8,10 +8,10 @@ concrete FoodsEng of Foods = open SyntaxEng,ParadigmsEng in {
Quality = AP ;
lin
Is item quality = mkCl item quality ;
This kind = mkNP this_Quant kind ;
That kind = mkNP that_Quant kind ;
These kind = mkNP this_Quant plNum kind ;
Those kind = mkNP that_Quant plNum kind ;
This kind = mkNP this_Det kind ;
That kind = mkNP that_Det kind ;
These kind = mkNP these_Det kind ;
Those kind = mkNP those_Det kind ;
QKind quality kind = mkCN quality kind ;
Wine = mkCN (mkN "wine") ;
Pizza = mkCN (mkN "pizza") ;

View File

@@ -9,10 +9,10 @@ incomplete concrete FoodsI of Foods = open Syntax, LexFoods in {
lin
Is item quality = mkUtt (mkCl item quality) ;
Isnt item quality = mkUtt (mkS negativePol (mkCl item quality)) ;
This kind = mkNP this_Quant kind ;
That kind = mkNP that_Quant kind ;
These kind = mkNP this_Quant plNum kind ;
Those kind = mkNP that_Quant plNum kind ;
This kind = mkNP this_Det kind ;
That kind = mkNP that_Det kind ;
These kind = mkNP these_Det kind ;
Those kind = mkNP those_Det kind ;
QKind quality kind = mkCN quality kind ;
Very quality = mkAP very_AdA quality ;