Short Tutorial On Generative Grammars: - A Generative Grammar Is Given by
Short Tutorial On Generative Grammars: - A Generative Grammar Is Given by
A grammar like this can be used to generate a variety of sentences starting with S, and repeatedly using any of the productions which are applicable.
Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved
Grammar
(Rule 1): (Rule 2): (Rule 3): (Rule 4): (Rule 5): (Rule 6): (Rule 7): (Rule 8): (Rule 9): (Rule 10): (Rule 11): (Rule 12): (Rule 13): S-> A-> B-> E-> C-> R-> N-> I -> D-> H-> V-> T-> U-> A|ACA|U B | R(B)(B) | I B E|NE|DE T|HT|VT and | or in-between | from-to not indeed | hardly younger-than | older-than very | more-or-less extremely young | middle-aged | old any-age | no-age | unknown-age
Short Tutorial on Generative Grammars You initialize the current string as start symbol S. Replace any nonterminal symbol in this string by using a production rule that has that symbol on its left hand side. For instance,
S gets replaced by A C A. Then A gets replaced by B, C by or, and the second A by I B. The I then gets replaced by indeed, the second B by E, which is replaced by T, and the T by "young". The first B gets replaced by E, which gets replaced by H T; H gets replaced by very , and the T gets replaced by old.
At each stage the process looks like the following production tree:
Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved
Production Tree
S
rule 1, option 2
A
rule 2, option 1
C
rule 5, option 2
A
rule 2, option 3
B
rule 3, option 1
or
B
rule 3, option 1
rule 8, option 1
E
rule 4, option 3
indeed E
rule 4, option 1
H
rule 10, option 1
T
rule 12, option 3
T
rule 12, option 1
very old
Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved
young
Short Tutorial on Generative Grammars This process also needs to keep track of which rules were applied where, and you can do that by the derivation tree, which I talked about in class. So that is what the sentence generator does. Everytime a production rule is applied, there is also an implicit meaning transformation.
For instance, when I applied A -> I B ->... -> indeed young above, I can figure out that the meaning of A. In this case, A(x) derives from T_I( young), which is obtained by applying the transformation associated with "indeed" (T_I) to the fuzzy set represented by "young" young(x).
Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved
This sort of reasoning can be automated if you have the derivation tree. Each leaf of the derivation tree is a terminal string. It is either a primary term or a linguistic hedge or an operator. In all these cases, it is easy to replace it by the appropriate functional transformation on the membership functions. Bubbling this process up leads to a S() function which is the meaning of the sentence. E.g.:
B C A got changed to B or A above, so (B C A)() = max { B() , A() } is the transformation applied at the node where C is replaced by "or".
Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved
A1 B1 E1
A2 I
or
B2
indeed E2
T2
T1 T1(x) = old(x)
very old
Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved
young
That's the semantic interpretation part. Try to work out some of this procedure by hand to make sure you understand it, then automate it by writing a program to do it. If you want to avoid the nitty-gritty of implementation, you could try using lex and yacc instead (UNIX tools which generate code for you). My purpose is not to get you to hack compilers but to understand how to easily manipulate fuzzy sentences.