/* MWU'S */

/* an ndfa representation */

/**************************/

 

:- style_check(-singleton).

 

 

/* stepping down a word list in search of a multi-word unit */

 

 ndfa(Mwu_name,Word_List,[Mwu_name,initial(Initial_State)|Mwu]) :-

      initial(Mwu_name,Initial_State),

        traverse(Mwu_name,Initial_State,Word_List,Mwu).

 

 traverse(Mwu_name,

          State,

          [Word|Word_List],

          [transition(from(State),

                      to(Next_State),

                      reading(Word),

                      of_category(Lemma))|Lemma_List]) :-

         transition(Mwu_name,State,Next_State,Lemma),

         link(Word,Lemma),

         traverse(Mwu_name,Next_State,Word_List,Lemma_List).

 

 traverse(Mwu_name,Final_State,[],[final(Final_State)]) :-

         final(Mwu_name,Final_State).

 

 

/* bear_the_brunt : the transitions */

 

 transition(bear_the_brunt,q0,q0,any_Word).     

 transition(bear_the_brunt,q0,q1,bear).

 transition(bear_the_brunt,q0,q1,take).

 transition(bear_the_brunt,q0,q1,carry).

 transition(bear_the_brunt,q0,q1,catch).

 transition(bear_the_brunt,q0,q1,feel).

 transition(bear_the_brunt,q0,q1,face).

 transition(bear_the_brunt,q1,q2,the).

 transition(bear_the_brunt,q1, q2, a).

 transition(bear_the_brunt,q2,q2,bear_adj).

 transition(bear_the_brunt,q2,q4,brunt).

 transition(bear_the_brunt,q1,q4, brunt).

 transition(bear_the_brunt,q4,q5,of).

 transition(bear_the_brunt,q5,q6,any_Word).

 transition(bear_the_brunt,q6,q6,any_Word).

 

/* play_havoc_with : the transitions */

 

 transition(play_havoc_with,q0,q0,any_Word).

     

 transition(play_havoc_with,q0,q1,play).

 transition(play_havoc_with,q0,q1a,make).

 

 transition(play_havoc_with,q0,q1b,havoc_verb).

 

 transition(play_havoc_with,q1b,q1b,havoc_pre_adj).

 transition(play_havoc_with,q1b,q1b,havoc_adj).

 

 transition(play_havoc_with,q1,q2,havoc).

 transition(play_havoc_with,q1a,q2a,havoc).

 transition(play_havoc_with,q1b,q2b,havoc).

 

 transition(play_havoc_with,q2,q3,with).

 transition(play_havoc_with,q2a,q3,of).

 transition(play_havoc_with,q2b,q3,havoc_prep).

 

 transition(play_havoc_with,q3,q4,any_Word).

 transition(play_havoc_with,q4,q4,any_Word).

 

/* linking words and grammatical categories */

 

 link(Word,Lemma) :- morph(Word,Lemma).

  

 link(Word,Category) :- listof(Category,Category_List),

                        inlist(Lemma,Category_List),

                        morph(Word,Lemma).

 

 link(_,any_Word). % anything matches any_Word

 

 

/* morphological variants */

 

 morph(causing,cause).

 morph(causes, cause).

 morph(caused, cause).

 

 morph(creating,create).

 morph(creates, create).

 morph(created, create).

 

 morph(doing,do).

 morph(does,do).

 morph(did,do).

 morph(done,do).

 

 morph(making,make).

 morph(makes, make).

 morph(made, make).

 

 morph(wreaking,wreak).

 morph(wreaks, wreak).

 morph(wreaked, wreak).

 morph(wrought,wreak).

 

 morph(playing,play).

 morph(plays, play).

 morph(played, play).

 

 morph(bearing,bear).

 morph(bears, bear).

 morph(bore, bear).

 morph(borne,bear).

 

 morph(taking,take).

 morph(takes, take).

 morph(took, take).

 morph(taken,take).

 

 morph(carrying,carry).

 morph(carries, carry).

 morph(carried, carry).

 

 morph(catching,catch).

 morph(catches, catch).

 morph(caught,catch).

 

 morph(feeling,feel).

 morph(feels, feel).

 morph(felt,feel).

 

 morph(facing,face).

 morph(faces, face).

 morph(faced,face).

 

/* no morphological variation */

 

 morph(Lemma,Lemma).

 

 

 /* initial and final states */

 

 initial(bear_the_brunt,q0).

 

 initial(play_havoc_with,q0).

 

 final(bear_the_brunt,q4).

 final(bear_the_brunt,q6).

 

 final(play_havoc_with,q2).

 final(play_havoc_with,q2a).

 final(play_havoc_with,q2b).

 final(play_havoc_with,q4).

 

/* the category lists */

 

listof(havoc_verb,[cause,create,do,wreak]).

listof(havoc_pre_adj,[more,much,some,such]).

listof(havoc_adj,[horrible,financial,seasonal,untold]).

listof(bear_adj,[main,full,heaviest,real,considerable,financial]).

listof(havoc_prep,[against,among,around,at,for,in,on,to,with]).

 

/* membership of a list - identical to pre-defined member predicate */

 

inlist(First,[First|_]).

inlist(Element,[_|Tail_List]):- inlist(Element,Tail_List).

 

/* printing a list */

 

writelist([H|T]) :- write(H),nl,writelist(T).

writelist([]).

 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%