Subject: Re: [Re: parsing using difference lists]

From: j s <[email-masked]>
Date: 22 Nov 00 16:21:48 EST

> You Read The Fine Textbook.

I'm not sure what this means. 

> expn(S) :-
>     expn(S, _, S, []).
> 
> expn(D0, D, S0, S) :-
>     nomen(D0, D, S0, S).
> expn([_,_|D0], D, [the|S0], S) :-
>     reln(D0, D1, S0, [of|S1]),
>     expn(D1, D, S1, S).
> expn([_|D0], D, S0, S) :-
>     expn(D0, D1, S0, [poss|S1]),
>     expn(D1, D, S1, S).
> 
> reln([_|D], D, [W|S], S) :-
>     ( W = mother ; W = sister  ; W = daughter
>     ; W = father ; W = brother ; W = son
>     ).
> 
> nomen([_|D], D, [W|S], S) :-
>     ( W = jack ; W = jill ).
> 

Question1:

Hmm. Now what if I wanted to extend this parser to build parse trees. I mean
say I wanted to write a predicate parseTree(E,Tree) that succeeds iff E is a
List, the expression represented by E is accepted by the grammar, and Tree is
the parse tree that the grammar generates for E. For instance, if E is
[the,mother,of,junaid], Tree should be
"expn(the,reln(mother),of,expn(name(junaid)))". Or say, E is
[the,son,of,bod,poss,aunt], which would have a parse Tree
"expn(expn(the,reln(son),of,expn(name(bod))),poss,reln(aunt))".  (Note that I
am using non-terminal from the grammar as the functor name). 

This is actually what I eventually wanted to do, but I thought that this task
was a by-product of writing a parser. Anyhow, my question (as in previous
para) is what do I do now to build a parse tree. (maybe extend the parser??).

Question2:

Finally, if I wanted to write a predicate interpret(E,Tree,Person) that
succeeds iff E is a list, the expression represented by E is accepted by the
grammar, Tree is the parse tree that the grammar generates for E, and Person
is a person referred to by that expression. 

Of course in order to determine who is "the brother of michael poss aunt", for
example, I will need a database of facts and rules about people and their
relationships. I have already written some facts for people who male(X),
female(X), and parent(X,Y) predicates for fact. And also defined the
relationship predicates mother, sister, brother, etc. 

thanx. 

____________________________________________________________________
Get free email and a permanent address at http://www.amexmail.com/?A=1