Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

swi-prolog function check for list and logical operation

46 views
Skip to first unread message

swipro-learner

unread,
Apr 8, 2015, 7:39:11 AM4/8/15
to pys...@googlegroups.com
I want to check multiple condition like these into swi-prolog

           
if sub_link in links_list1:        
               
if ('Who').lower() in sent_split or 'Who' in sent_split:
                    result
= 'person'
                   
break
               
elif (('Where').lower() in sent_split or 'Where' in sent_split) and 'What' not in read_str and 'what' not in read_str:
                    result
= 'location'
                   
break
               
elif ('Why').lower() in sent_split or 'Why' in sent_split:
                    result
= 'reason'
                   
break



prolog code:

    member(SUBLINK, LINKSLIST),
   
(
        member
('Who', SENTSPLIT), member('who', SENTSPLIT),
       
(
            nb_linkval
(result , 'Person')
       
); # I guess if above condition satisfies then it automatically returns without checking further code
        member
('What', SENTSPLIT), notmember('what', SENTSPLIT), #notmember, is there cluase like notmember to check `not in list` then correct
       
(
            nb_linkval
(result , 'Thing')
       
);
        member
('Where', SENTSPLIT), notmember('where', SENTSPLIT),
       
(
            nb_linkval
(result , 'where')
       
)
   
).



I guess all above iteration behaves like `and` operation, how can I check `or` operation?

swipro-learner

unread,
Apr 8, 2015, 7:39:11 AM4/8/15
to pys...@googlegroups.com
I want to check multiple condition like these into swi-prolog

            if sub_link in links_list1:        
               
if ('Who').lower() in sent_split or 'Who' in sent_split:
                    result
= 'person'
                   
break
               
elif (('Where').lower() in sent_split or 'Where' in sent_split) and 'What' not in read_str and 'what' not in read_str:
                    result
= 'location'
                   
break
               
elif ('Why').lower() in sent_split or 'Why' in sent_split:
                    result
= 'reason'
                   
break



prolog code:

    member(SUBLINK, LINKSLIST),
   
(
        member
('Who', SENTSPLIT), member('who', SENTSPLIT),
       
(
            nb_linkval
(result , 'Person')
       
); # I guess if above condition satisfies then it automatically returns without checking further code
        member
('What', SENTSPLIT), notmember('what', SENTSPLIT), #notmember, is there cluase like notmember

       
(
            nb_linkval
(result , 'Thing')
       
);
        member
('Where', SENTSPLIT), notmember('where', SENTSPLIT),
       
(
            nb_linkval
(result , 'where')
       
)
   
).

Reply all
Reply to author
Forward
0 new messages