From 3155a82696ba533c4a59f84a495982b9eb1a9b83 Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 20 Apr 2005 19:55:00 +0000 Subject: smaller exx --- doc/tutorial/gf-tutorial2.html | 66 ++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 32 deletions(-) (limited to 'doc/tutorial/gf-tutorial2.html') diff --git a/doc/tutorial/gf-tutorial2.html b/doc/tutorial/gf-tutorial2.html index 67da66394..18e5342ab 100644 --- a/doc/tutorial/gf-tutorial2.html +++ b/doc/tutorial/gf-tutorial2.html @@ -108,10 +108,10 @@ representation, and shows a new prompt when it is ready. You can use GF for parsing:
   > parse "the boy eats a snake"
-  Mks_0 (Mks_6 Mks_10) (Mks_2 Mks_23 (Mks_7 Mks_13))
+  Mks_0 (Mks_6 Mks_9) (Mks_2 Mks_20 (Mks_7 Mks_11))
 
   > parse "the snake eats a boy"
-  Mks_0 (Mks_6 Mks_13) (Mks_2 Mks_23 (Mks_7 Mks_10))
+  Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
 
The parse (= p) command takes a string (in double quotes) and returns an abstract syntax tree - the thing @@ -137,7 +137,7 @@ You can also use GF for linearizing (linearize = l). This is the inverse of parsing, taking trees into strings:
-  > linearize Mks_0 (Mks_6 Mks_13) (Mks_2 Mks_23 (Mks_7 Mks_10))
+  > linearize Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
   the snake eats a boy
 
What is the use of this? Typically not that you type in a tree at @@ -153,7 +153,7 @@ Or, more efficiently, feed random generation into parsing by using a pipe.
   > gr | l
-  this man is big
+  this worm is warm
 
@@ -164,16 +164,16 @@ Random generation can be quite amusing. So you may want to generate ten strings with one and the same command:
   > gr -number=10 | l
+  this boy is green
   a snake laughs
-  that man laughs
-  the man swims
-  this man is warm
-  a louse is rotten
-  that worm washes a man
-  a boy swims
-  a snake laughs
-  a man washes this man
-  this louse kills the boy
+  the rotten boy is thick
+  a boy washes this worm
+  a boy is warm
+  this green warm boy is rotten
+  the green thick green louse is rotten
+  that boy is green
+  this thick thick boy laughs
+  a boy is green
 
@@ -183,13 +183,15 @@ generate ten strings with one and the same command: To generate all sentence that a grammar can generate, use the command generate_trees = gt.
-  this boy laughs
-  this boy sleeps
-  this boy swims
+  this louse laughs
+  this louse sleeps
+  this louse swims
+  this louse is green
+  this louse is rotten
   ...
-  a worm is rotten
-  a worm is thick
-  a worm is warm
+  a boy is rotten
+  a boy is thick
+  a boy is warm
 
You get quite a few trees but not all of them: only up to a given depth of trees. To see how you can get more, use the @@ -215,9 +217,9 @@ The intermediate results in a pipe can be observed by putting the want to see:
   > gr -tr | l -tr | p
-  Mks_0 (Mks_6 Mks_13) (Mks_1 Mks_20)
-  the snake laughs
-  Mks_0 (Mks_6 Mks_13) (Mks_1 Mks_20)
+  Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
+  a louse sleeps
+  Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
 
This facility is good for test purposes: for instance, you may want to see if a grammar is ambiguous, i.e. @@ -256,27 +258,27 @@ which rule, you can use the print_grammar = pg command with the printer flag set to cf (which means context-free):
   > print_grammar -printer=cf
-  Mks_10. CN ::= "boy" ;
-  Mks_11. CN ::= "man" ;
-  Mks_12. CN ::= "louse" ;
-  Mks_13. CN ::= "snake" ;
-  Mks_14. CN ::= "worm" ;
+  Mks_10. CN ::= "louse" ;
+  Mks_11. CN ::= "snake" ;
+  Mks_12. CN ::= "worm" ;
   Mks_8.  CN ::= A CN ;
-  Mks_9.  CN ::= "bird" ;
+  Mks_9.  CN ::= "boy" ;
   Mks_4.  NP ::= "this" CN ;
-  Mks_18. A  ::= "thick" ;
+  Mks_15. A  ::= "thick" ;
+  ...
 
A syntax tree such as
-  Mks_4 (Mks_8 Mks_18 Mks_14)
+  Mks_4 (Mks_8 Mks_15 Mks_12)
   this thick worm
 
encodes the sequence of grammar rules used for building the expression. If you look at this tree, you will notice that Mks_4 is the label of the rule prefixing this to a common noun, -Mks_18 is the label of the adjective thick, +Mks_15 is the label of the adjective thick, and so on. +

The labelled context-free format

@@ -574,7 +576,7 @@ Inspect the shell state (print_options = po):

Extending the grammar

-Neolithic +Neolithic: fire, wheel, think,... -- cgit v1.2.3