diff --git a/doc/tutorial/Paleolithic.gf b/doc/tutorial/Paleolithic.gf index dadfd5140..05158ba18 100644 --- a/doc/tutorial/Paleolithic.gf +++ b/doc/tutorial/Paleolithic.gf @@ -7,10 +7,10 @@ fun UseV : V -> VP ; ComplTV : TV -> NP -> VP ; UseA : A -> VP ; - This, That, Def, Indef : CN -> NP ; ModA : A -> CN -> CN ; - Bird, Boy, Man, Louse, Snake, Worm : CN ; - Big, Green, Rotten, Thick, Warm : A ; + This, That, Def, Indef : CN -> NP ; + Boy, Louse, Snake, Worm : CN ; + Green, Rotten, Thick, Warm : A ; Laugh, Sleep, Swim : V ; Eat, Kill, Wash : TV ; } \ No newline at end of file diff --git a/doc/tutorial/PaleolithicEng.gf b/doc/tutorial/PaleolithicEng.gf index 4bbf81707..ac78f9d9d 100644 --- a/doc/tutorial/PaleolithicEng.gf +++ b/doc/tutorial/PaleolithicEng.gf @@ -11,13 +11,10 @@ lin Def cn = {s = "the" ++ cn.s} ; Indef cn = {s = "a" ++ cn.s} ; ModA a cn = {s = a.s ++ cn.s} ; - Bird = {s = "bird"} ; Boy = {s = "boy"} ; Louse = {s = "louse"} ; - Man = {s = "man"} ; Snake = {s = "snake"} ; Worm = {s = "worm"} ; - Big = {s = "big"} ; Green = {s = "green"} ; Rotten = {s = "rotten"} ; Thick = {s = "thick"} ; diff --git a/doc/tutorial/PaleolithicIta.gf b/doc/tutorial/PaleolithicIta.gf index 2b7648767..242c615d7 100644 --- a/doc/tutorial/PaleolithicIta.gf +++ b/doc/tutorial/PaleolithicIta.gf @@ -11,13 +11,10 @@ lin Def cn = {s = "il" ++ cn.s} ; Indef cn = {s = "un" ++ cn.s} ; ModA a cn = {s = cn.s ++ a.s} ; - Bird = {s = "uccello"} ; Boy = {s = "ragazzo"} ; Louse = {s = "pidocchio"} ; - Man = {s = "uomo"} ; Snake = {s = "serpente"} ; Worm = {s = "verme"} ; - Big = {s = "grande"} ; Green = {s = "verde"} ; Rotten = {s = "marcio"} ; Thick = {s = "grosso"} ; 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 boyWhat 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 warmYou 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 wormencodes 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. +