0% found this document useful (0 votes)
64 views9 pages

Short Tutorial On Generative Grammars: - A Generative Grammar Is Given by

A GENERATIVE grammar is given by: - NTE, TE, S, P where NTE : nonterminal symbols (usually capital letters) TE : terminal symbols (usually lowercase underscored strings) S : start symbol (usually S) P : set of productions like X -> Y A B C or "z" a grammar like this can be used to generate a variety of sentences starting with S.

Uploaded by

knowman1
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views9 pages

Short Tutorial On Generative Grammars: - A Generative Grammar Is Given by

A GENERATIVE grammar is given by: - NTE, TE, S, P where NTE : nonterminal symbols (usually capital letters) TE : terminal symbols (usually lowercase underscored strings) S : start symbol (usually S) P : set of productions like X -> Y A B C or "z" a grammar like this can be used to generate a variety of sentences starting with S.

Uploaded by

knowman1
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Short Tutorial on Generative Grammars

A GENERATIVE GRAMMAR is given by:


{NTE, TE, S, P} where
NTE : nonterminal symbols (usually capital letters) TE : terminal symbols (usually lowercase underscored strings) S : Start symbol (usually S) P : set of productions like X -> Y | A B C | Z which means symbol X can be replaced by the string "Y" or "A B C" or "Z" in the current sentence that is being generated. You can use any of these 3 options for replacement.

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

Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved

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


S ACA BCA B or A B or I B B or indeed B B or indeed E B or indeed T B or indeed young E or indeed young HT or indeed young very T or indeed young very old or indeed young start symbol apply rule 1, option 2 rule 2, option 1 rule 4, option 2 rule 2, option 3 rule 8, option 1 rule 3, option 1 rule 5, option 1 rule 12, option 1 rule 3, option 1 rule 4, option 2 rule 10, option 1 rule 12, option 3

Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved

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

Short Tutorial on Generative Grammars

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

Production Tree (Semantic Constraints)


S
A1(x) = B1 (x) B1(x) = E1 (x) E1(x) = [T1(x) ]2 S(x) =Max{ A1(x), A2(x) }

A1 B1 E1

A2 I

A2(x) = INTENSIFIER{ B2(x) }

or

B2

B2(x) = E2 (x) E2(x) = T2(x) T2(x) = young(x)

indeed E2
T2

T1 T1(x) = old(x)

very old
Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved

young

Short Tutorial on Generative Grammars

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.

Copyright 1998, Dr. Piero P. Bonissone, All Rights Reserved

You might also like