/* MWU'S */

/* an ndfa representation of the mwu bear the brunt of */

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

 

:- style_check(-singleton).

 

/* accepting a string of words or of categories */

 

 accepte(X,Y) :- initial(Q) , accepte1(Q,X,Y).

 

 accepte1(Q,[Word|Words],[Lemma|Lemmas]) :-

         t(Q,Q1,Lemma),assoc(Word,Lemma), accepte1(Q1,Words,Lemmas).

 

 accepte1(Q,[],[]) :- final(Q).

 

/* the transitions */

 t(q0,q0,any_Word).     

 t(q0,q1,bear).

 t(q0,q1,take).

 t(q0,q1,carry).

 t(q0,q1,catch).

 t(q0,q1,feel).

 t(q0,q1,face).

 t(q1,q2,the).

 t(q1, q2, a).

 t(q2,q2,Adjective) :- adjective(Adjective).

 t(q2,q4,brunt).

 t(q1,q4, brunt).

 t(q4,q5,of).

 t(q5,q6,any_Word).

 t(q6,q6,any_Word).

 

/* linking words and grammatical categories */

 

 assoc(bearing,bear).

 assoc(bears, bear).

 assoc(bore, bear).

 assoc(borne,bear).

 assoc(taking,take).

 assoc(takes, take).

 assoc(took, take).

 assoc(taken,take).

 assoc(carrying,carry).

 assoc(carries, carry).

 assoc(carried, carry).

 assoc(catching,catch).

 assoc(catches, catch).

 assoc(caught,catch).

 assoc(feeling,feel).

 assoc(feels, feel).

 assoc(felt,feel).

 assoc(facing,face).

 assoc(faces, face).

 assoc(faced,face).

 

 assoc(X,X) :- lemma(X).

 assoc(_,any_Word).

 

/* the lemmas */

 

lemma(bear).

lemma(take).

lemma(carry).

lemma(catch).

lemma(feel).

lemma(face).

lemma(the).

lemma(a).

lemma(main).

lemma(full).

lemma(heaviest).

lemma(real).

lemma(considerable).

lemma(financial).

lemma(brunt).

lemma(of).

 

/* adjectives */

 

adjective(main).

adjective(full).

adjective(heaviest).

adjective(real).

adjective(considerable).

adjective(financial).

 

/* initial and final states */

 

 initial(q0).

 final(q4).

 final(q6).


 

/* MWU'S */

/* an ndfa representation of the mwu play havoc with */

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

 

:- style_check(-singleton).

 

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

 

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

            initial(Initial_State),

        traverse(Initial_State,Word_List,Mwu).

 

 traverse(State,

          [Word|Word_List],

          [transition(from(State),

                      to(Next_State),

                      reading(Word),

                      of_category(Lemma))|Lemma_List]) :-

         transition(State,Next_State,Lemma),

         link(Word,Lemma),

         traverse(Next_State,Word_List,Lemma_List).

 

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

         final(Final_State).

 

 

/* the transitions */

 

 transition(q0,q0,any_Word).

     

 transition(q0,q1,play).

 transition(q0,q1a,make).

 

 transition(q0,q1b,havoc_verb).

 

 transition(q1b,q1b,havoc_pre_adj).

 transition(q1b,q1b,havoc_adj).

 

 transition(q1,q2,havoc).

 transition(q1a,q2a,havoc).

 transition(q1b,q2b,havoc).

 

 transition(q2,q3,with).

 transition(q2a,q3,of).

 transition(q2b,q3,havoc_prep).

 

 transition(q3,q4,any_Word).

 transition(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

 

 

 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(Word,Word).

 

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

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

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

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

 

/* initial and final states */

 

 initial(q0).

 final(q2).

 final(q2a).

 final(q2b).

 final(q4).

 

/* 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([]).