URGENT URGENT!!!
anyone can help me out with this complicated problem??
i have no idea how to start...
thank you very much..
__________________________________________________________
chat.pro was provided that contains a Prolog solution to the problem of understanding simple English sentence types.
I was asked to add the necessary rules to the program to understand the following sentence types in addition to the those already programmed.
___ is the ___ of ___. Example: Alfred is the brother of Fred.
Is ___ the ___ of ___? Example: Is Alice the mother of Mary?
Who is the ___ of ___? Example: Who is the father of Eliza?
The last case is more complex. The three "blanks" must be different.
X is the ___ of Y if X is the ___ of Z and Z is the ___ of Y.
Example using people named X, Y and Z (they are not variables!).
X is the aunt of Y if X is the sister of Z and
Z is the parent of Y.
Example using people named Alice, Mary and Eliza.
Alice is the aunt of Mary if Alice is the sister of Eliza
and Eliza is the parent of Mary.
----------------
Example dialogue. Notice the responses, especially the response for
the "Who" question.
| ?- chat.
|: Alfred is the brother of Fred.
Ok
|: Is Alfred the brother of Fred?
Yes
|: Who is the brother of Fred?
Alfred is.
|: Is Fred the brother of Alfred?
No
|: Alice is the aunt of Mary if Alice is the sister <== should be
of Eliza and Eliza is the parent of Mary. <== one line
Ok
|: Who is the aunt of Mary?
! Existence error in sister/2
! procedure user:sister/2 does not exist
! goal: sister('Alice','Eliza')
| ?- /* sister has not been defined yet. The database still exists so
we can restart chat. This comment causes the following message. */
! Syntax error
! between lines 53 and 54
! <>
| ?- chat.
|: Alice is the sister of Eliza.
Ok
|: Eliza is the parent of Mary.
Ok
|: Who is the aunt of Mary?
Alice is.
|: Is Alice the aunt of Mary?
Yes
|: Who is the aunt of Tom?
Cannot find one.
|: Fred is the sister of Derek.
Ok
|: Derek is the parent of Tom.
Ok
|: Who is the aunt of Tom? <== Notice the rule for aunt is
Cannot find one. <== specific to Alice, Mary and Eliza.
|: Stop.
All done.
yes
| ?-
*** Warning *** Since chat adds clauses to the database it is necessary to exit prolog and restart it to clear the database, otherwise you may end up using old rules.
Another way out is to have "dummy" predicates in chat which replace the ones used in testing. For example the statement "John is a person." adds the clause person(John). to the database which remains until you exit Prolog. If you add the clause person(zzzzz). to chat.pro, then when you reconsult chat.pro all clauses for person are replaced with the dummy clause.
Another way is to write a predicate to retract all clauses of a particular form, such as person(X).
Note that you may not want to dummy out all predicates because some you can use across tests. For example, when testing the aunt predicate you may want to save the predicates for sister and parent to avoid having to reenter them, and thus, save test time, effort and errors.
___________________________________________________________
anyone can help me out with this complicated problem??
i have no idea how to start...
thank you very much..
__________________________________________________________
chat.pro was provided that contains a Prolog solution to the problem of understanding simple English sentence types.
I was asked to add the necessary rules to the program to understand the following sentence types in addition to the those already programmed.
___ is the ___ of ___. Example: Alfred is the brother of Fred.
Is ___ the ___ of ___? Example: Is Alice the mother of Mary?
Who is the ___ of ___? Example: Who is the father of Eliza?
The last case is more complex. The three "blanks" must be different.
X is the ___ of Y if X is the ___ of Z and Z is the ___ of Y.
Example using people named X, Y and Z (they are not variables!).
X is the aunt of Y if X is the sister of Z and
Z is the parent of Y.
Example using people named Alice, Mary and Eliza.
Alice is the aunt of Mary if Alice is the sister of Eliza
and Eliza is the parent of Mary.
----------------
Example dialogue. Notice the responses, especially the response for
the "Who" question.
| ?- chat.
|: Alfred is the brother of Fred.
Ok
|: Is Alfred the brother of Fred?
Yes
|: Who is the brother of Fred?
Alfred is.
|: Is Fred the brother of Alfred?
No
|: Alice is the aunt of Mary if Alice is the sister <== should be
of Eliza and Eliza is the parent of Mary. <== one line
Ok
|: Who is the aunt of Mary?
! Existence error in sister/2
! procedure user:sister/2 does not exist
! goal: sister('Alice','Eliza')
| ?- /* sister has not been defined yet. The database still exists so
we can restart chat. This comment causes the following message. */
! Syntax error
! between lines 53 and 54
! <>
| ?- chat.
|: Alice is the sister of Eliza.
Ok
|: Eliza is the parent of Mary.
Ok
|: Who is the aunt of Mary?
Alice is.
|: Is Alice the aunt of Mary?
Yes
|: Who is the aunt of Tom?
Cannot find one.
|: Fred is the sister of Derek.
Ok
|: Derek is the parent of Tom.
Ok
|: Who is the aunt of Tom? <== Notice the rule for aunt is
Cannot find one. <== specific to Alice, Mary and Eliza.
|: Stop.
All done.
yes
| ?-
*** Warning *** Since chat adds clauses to the database it is necessary to exit prolog and restart it to clear the database, otherwise you may end up using old rules.
Another way out is to have "dummy" predicates in chat which replace the ones used in testing. For example the statement "John is a person." adds the clause person(John). to the database which remains until you exit Prolog. If you add the clause person(zzzzz). to chat.pro, then when you reconsult chat.pro all clauses for person are replaced with the dummy clause.
Another way is to write a predicate to retract all clauses of a particular form, such as person(X).
Note that you may not want to dummy out all predicates because some you can use across tests. For example, when testing the aunt predicate you may want to save the predicates for sister and parent to avoid having to reenter them, and thus, save test time, effort and errors.
___________________________________________________________