;;; Simple Script Applier                                   Chris Mellish
;;; For MSc course

understand(Sentences,Summary,Sequence) :-
   script(Summary,Sequence),
   find_seq(Sentences,Sequence).

find_seq([],_).
find_seq([S|Rest],[S|RestSeq]) :-
   find_seq(Rest,RestSeq).
find_seq([S|Sents],[_|RestSeq]) :-
   find_seq([S|Sents],RestSeq).

;;; example script

script(restaurant(Cust,Waiter,Food),
    [
        enters(Cust,Restaurant),
        calls(Cust,Waiter),
        brings(Waiter,Food),
        eats(Cust,Food),
        pays(Cust,Teller),
        leaves(Cust,Restaurant)
    ]).

;;; Example of use
;;;
;;;?- understand([
;;;    enters(john,harrods),
;;;    brings(frodo,sausages),
;;;    pays(X,Y)],Summary,Seq).                  
