if an input has 2 properties, how can i handle it?
exp:
mary is a proper_noun or the true case can also be a pronoun. how will i define it?
when i write the codes like:
////////////////////////////////////
pronoun(she).
pronoun(he).
female(mary).
male(john).
proper_noun(mary).
proper_noun(john).
verb(slept).
is_Sentence(Person,Verb):-
pronoun(Person),
proper_noun(Person),
verb(Verb).
////////////////////////////////////
when i ask the program:
is_Sentence(mary,slept).
it says 'no'.
what can i do to get the answer 'yes'? because mary or a pronoun should make program say 'yes'. "he slept" also must be true.
plz help
thanks all.
Prolog 2 properties must be true
Started by asilter79, Dec 15 2004 08:53 AM
3 replies to this topic
#1
Posted 15 December 2004 - 08:53 AM
#2
Posted 15 December 2004 - 09:35 AM
is_Sentence(Person,Verb):- proper_noun(Person), verb(Verb),!. is_Sentence(Person,Verb):- pronoun(Person),verb(Verb),!.
Tested in GNU Prolog.
#3
Posted 15 December 2004 - 09:39 AM
BTW, you'r really new to Prolog so check that cuts ("!" predicates) do, they are needed here in order to not to get ambiguous "yes, no" answer bnut may interfere if you expand your program further.
#4
Posted 15 December 2004 - 09:53 AM
Oops again. You do not really need those cuts:
with cuts:
Without cuts:
Second variant gives us complete answer, wich is better in this case.
So,
with cuts:
GNU Prolog 1.2.16 By Daniel Diaz Copyright (C) 1999-2002 Daniel Diaz | ?- [mary]. compiling H:\GNU-Prolog\bin\mary.pl for byte code... H:\GNU-Prolog\bin\mary.pl compiled, 15 lines read - 1380 bytes written, 20 ms yes | ?- is_Sentence(X,slept). X = mary yes | ?-
Without cuts:
[mary]. compiling H:\GNU-Prolog\bin\mary.pl for byte code... H:\GNU-Prolog\bin\mary.pl compiled, 15 lines read - 1265 bytes written, 10 ms yes | ?- is_Sentence(X,slept). X = mary ? a X = john X = she X = he yes | ?-
Second variant gives us complete answer, wich is better in this case.
So,
is_Sentence(Person,Verb):- proper_noun(Person), verb(Verb). is_Sentence(Person,Verb):- pronoun(Person),verb(Verb).
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











