1
0
forked from GitHub/gf-core

work on tutorial

This commit is contained in:
aarne
2005-12-16 14:10:32 +00:00
parent 6365f744ba
commit ffadb3a49f
3 changed files with 58 additions and 74 deletions

View File

@@ -7,38 +7,35 @@
<P ALIGN="center"><CENTER><H1>Grammatical Framework Tutorial</H1>
<FONT SIZE="4">
<I>Author: Aarne Ranta &lt;aarne (at) cs.chalmers.se&gt;</I><BR>
Last update: Thu Dec 15 16:43:59 2005
Last update: Fri Dec 16 15:10:23 2005
</FONT></CENTER>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<UL>
<LI><A HREF="#toc1">Grammatical Framework Tutorial</A>
<UL>
<LI><A HREF="#toc2">GF = Grammatical Framework</A>
<LI><A HREF="#toc1">GF = Grammatical Framework</A>
<UL>
<LI><A HREF="#toc3">Getting the GF program</A>
<LI><A HREF="#toc2">Getting the GF program</A>
</UL>
<LI><A HREF="#toc4">My first grammar</A>
<LI><A HREF="#toc3">My first grammar</A>
<UL>
<LI><A HREF="#toc5">Importing grammars and parsing strings</A>
<LI><A HREF="#toc6">Generating trees and strings</A>
<LI><A HREF="#toc7">Some random-generated sentences</A>
<LI><A HREF="#toc8">Systematic generation</A>
<LI><A HREF="#toc9">More on pipes; tracing</A>
<LI><A HREF="#toc10">Writing and reading files</A>
<LI><A HREF="#toc11">Labelled context-free grammars</A>
<LI><A HREF="#toc4">Importing grammars and parsing strings</A>
<LI><A HREF="#toc5">Generating trees and strings</A>
<LI><A HREF="#toc6">Some random-generated sentences</A>
<LI><A HREF="#toc7">Systematic generation</A>
<LI><A HREF="#toc8">More on pipes; tracing</A>
<LI><A HREF="#toc9">Writing and reading files</A>
<LI><A HREF="#toc10">Labelled context-free grammars</A>
</UL>
<LI><A HREF="#toc12">The GF grammar format</A>
<LI><A HREF="#toc11">The GF grammar format</A>
<UL>
<LI><A HREF="#toc13">Abstract and concrete syntax</A>
<LI><A HREF="#toc14">Resource modules</A>
<LI><A HREF="#toc15">Opening a ``resource``</A>
<LI><A HREF="#toc12">Abstract and concrete syntax</A>
<LI><A HREF="#toc13">Resource modules</A>
<LI><A HREF="#toc14">Opening a ``resource``</A>
</UL>
<LI><A HREF="#toc16">Topics still to be written</A>
<LI><A HREF="#toc15">Topics still to be written</A>
</UL>
</UL>
<P></P>
<HR NOSHADE SIZE=1>
@@ -47,17 +44,6 @@ Last update: Thu Dec 15 16:43:59 2005
<IMG ALIGN="middle" SRC="../gf-logo.gif" BORDER="0" ALT="">
</P>
<A NAME="toc1"></A>
<H1>Grammatical Framework Tutorial</H1>
<P>
<B>3rd Edition, for GF version 2.2 or later</B>
</P>
<P>
<A HREF="http://www.cs.chalmers.se/~aarne">Aarne Ranta</A>
</P>
<P>
<CODE>aarne@cs.chalmers.se</CODE>
</P>
<A NAME="toc2"></A>
<H2>GF = Grammatical Framework</H2>
<P>
The term GF is used for different things:
@@ -79,7 +65,7 @@ It will guide you
<LI>to write programs in which GF grammars are used as components
</UL>
<A NAME="toc3"></A>
<A NAME="toc2"></A>
<H3>Getting the GF program</H3>
<P>
The program is open-source free software, which you can download via the
@@ -109,19 +95,19 @@ To start the GF program, assuming you have installed it, just type
<P>
in the shell. You will see GF's welcome message and the prompt <CODE>&gt;</CODE>.
</P>
<A NAME="toc4"></A>
<A NAME="toc3"></A>
<H2>My first grammar</H2>
<P>
Now you are ready to try out your first grammar.
We start with one that is not written in GF language, but
in the EBNF notation (Extended Backus Naur Form), which GF can also
in the ubiquitous BNF notation (Backus Naur Form), which GF can also
understand. Type (or copy) the following lines in a file named
<CODE>paleolithic.ebnf</CODE>:
</P>
<PRE>
S ::= NP VP ;
VP ::= V | TV NP | "is" A ;
NP ::= ("this" | "that" | "the" | "a") CN ;
NP ::= "this" CN | "that" CN | "the" CN | "a" CN ;
CN ::= A CN ;
CN ::= "boy" | "louse" | "snake" | "worm" ;
A ::= "green" | "rotten" | "thick" | "warm" ;
@@ -129,7 +115,17 @@ understand. Type (or copy) the following lines in a file named
TV ::= "eats" | "kills" | "washes" ;
</PRE>
<P></P>
<A NAME="toc5"></A>
<P>
(The name <CODE>paleolithic</CODE> refers to a larger package
<A HREF="http://www.cs.chalmers.se/~aarne/GF/examples/stoneage/">stoneage</A>,
which implements a fragment of primitive language. This fragment
was defined by the linguist Morris Swadesh as a tool for studying
the historical relations of languages. But as pointed out
in the Wiktionary article on
<A HREF="http://en.wiktionary.org/wiki/Wiktionary:Swadesh_list">Swadesh list</A>, the
fragment is also usable for basic communication with foreigners.)
</P>
<A NAME="toc4"></A>
<H3>Importing grammars and parsing strings</H3>
<P>
The first GF command when using a grammar is to <B>import</B> it.
@@ -169,7 +165,7 @@ you imported. Try parsing something else, and you fail
no tree found
</PRE>
<P></P>
<A NAME="toc6"></A>
<A NAME="toc5"></A>
<H3>Generating trees and strings</H3>
<P>
You can also use GF for <B>linearizing</B>
@@ -200,7 +196,7 @@ a <B>pipe</B>.
this worm is warm
</PRE>
<P></P>
<A NAME="toc7"></A>
<A NAME="toc6"></A>
<H3>Some random-generated sentences</H3>
<P>
Random generation can be quite amusing. So you may want to
@@ -220,7 +216,7 @@ generate ten strings with one and the same command:
a boy is green
</PRE>
<P></P>
<A NAME="toc8"></A>
<A NAME="toc7"></A>
<H3>Systematic generation</H3>
<P>
To generate &lt;i&gt;all&lt;i&gt; sentence that a grammar
@@ -250,7 +246,7 @@ You get quite a few trees but not all of them: only up to a given
<B>Quiz</B>. If the command <CODE>gt</CODE> generated all
trees in your grammar, it would never terminate. Why?
</P>
<A NAME="toc9"></A>
<A NAME="toc8"></A>
<H3>More on pipes; tracing</H3>
<P>
A pipe of GF commands can have any length, but the "output type"
@@ -273,7 +269,7 @@ This facility is good for test purposes: for instance, you
may want to see if a grammar is <B>ambiguous</B>, i.e.
contains strings that can be parsed in more than one way.
</P>
<A NAME="toc10"></A>
<A NAME="toc9"></A>
<H3>Writing and reading files</H3>
<P>
To save the outputs of GF commands into a file, you can
@@ -296,7 +292,7 @@ the file separately. Without the flag, the grammar could
not recognize the string in the file, because it is not
a sentence but a sequence of ten sentences.
</P>
<A NAME="toc11"></A>
<A NAME="toc10"></A>
<H3>Labelled context-free grammars</H3>
<P>
The syntax trees returned by GF's parser in the previous examples
@@ -393,7 +389,7 @@ old grammar from the GF shell state.
a louse is thick
</PRE>
<P></P>
<A NAME="toc12"></A>
<A NAME="toc11"></A>
<H2>The GF grammar format</H2>
<P>
To see what there really is in GF's shell state when a grammar
@@ -417,7 +413,7 @@ one more way of defining the same grammar as in
Then we will show how the full GF grammar format enables you
to do things that are not possible in the weaker formats.
</P>
<A NAME="toc13"></A>
<A NAME="toc12"></A>
<H3>Abstract and concrete syntax</H3>
<P>
A GF grammar consists of two main parts:
@@ -897,7 +893,7 @@ The graph uses
<P>
&lt;img src="Gatherer.gif"&gt;
</P>
<A NAME="toc14"></A>
<A NAME="toc13"></A>
<H3>Resource modules</H3>
<P>
Suppose we want to say, with the vocabulary included in
@@ -1043,7 +1039,7 @@ Resource modules can extend other resource modules, in the
same way as modules of other types can extend modules of the
same type.
</P>
<A NAME="toc15"></A>
<A NAME="toc14"></A>
<H3>Opening a ``resource``</H3>
<P>
Any number of <CODE>resource</CODE> modules can be
@@ -1390,7 +1386,7 @@ GF currently requires that all fields in linearization records that
have a table with value type <CODE>Str</CODE> have as labels
either <CODE>s</CODE> or <CODE>s</CODE> with an integer index.
</P>
<A NAME="toc16"></A>
<A NAME="toc15"></A>
<H2>Topics still to be written</H2>
<P>
Free variation
@@ -1419,11 +1415,7 @@ Dependent types, variable bindings, semantic definitions
<P>
Transfer rules
</P>
<P>
&lt;body&gt;
&lt;html&gt;
</P>
<!-- html code generated by txt2tags 2.3 (http://txt2tags.sf.net) -->
<!-- html code generated by txt2tags 2.0 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags -\-toc gf-tutorial2.txt -->
</BODY></HTML>

View File

@@ -10,20 +10,6 @@ Last update: %%date(%c)
[../gf-logo.gif]
=Grammatical Framework Tutorial=
**3rd Edition, for GF version 2.2 or later**
[Aarne Ranta http://www.cs.chalmers.se/~aarne]
``aarne@cs.chalmers.se``
%--!
@@ -84,13 +70,13 @@ in the shell. You will see GF's welcome message and the prompt ``>``.
Now you are ready to try out your first grammar.
We start with one that is not written in GF language, but
in the EBNF notation (Extended Backus Naur Form), which GF can also
in the ubiquitous BNF notation (Backus Naur Form), which GF can also
understand. Type (or copy) the following lines in a file named
``paleolithic.ebnf``:
```
S ::= NP VP ;
VP ::= V | TV NP | "is" A ;
NP ::= ("this" | "that" | "the" | "a") CN ;
NP ::= "this" CN | "that" CN | "the" CN | "a" CN ;
CN ::= A CN ;
CN ::= "boy" | "louse" | "snake" | "worm" ;
A ::= "green" | "rotten" | "thick" | "warm" ;
@@ -98,6 +84,15 @@ understand. Type (or copy) the following lines in a file named
TV ::= "eats" | "kills" | "washes" ;
```
(The name ``paleolithic`` refers to a larger package
[stoneage http://www.cs.chalmers.se/~aarne/GF/examples/stoneage/],
which implements a fragment of primitive language. This fragment
was defined by the linguist Morris Swadesh as a tool for studying
the historical relations of languages. But as pointed out
in the Wiktionary article on
[Swadesh list http://en.wiktionary.org/wiki/Wiktionary:Swadesh_list], the
fragment is also usable for basic communication with foreigners.)
%--!
===Importing grammars and parsing strings===
@@ -1314,7 +1309,3 @@ Dependent types, variable bindings, semantic definitions
Transfer rules
<body>
<html>

View File

@@ -41,10 +41,11 @@ To try out the grammar, do for example
> si -tr | p | l -multi -- translate speech input
[say:] I want to play Yesterday
```
The last command only works if you have installed
[ATK http://mi.eng.cam.ac.uk/~sjy/software.htm] and compiled
The last command only works if you have installed the
[ATK http://mi.eng.cam.ac.uk/~sjy/software.htm] speech recognition library
and compiled
[GF version 14/12/2005 http://www.cs.chalmers.se/Cs/Research/Language-technology/darcs/GF/doc/darcs.html]
or later.
or later, with support for ATK enabled.
==Structure==