The DEFI matcher : Prolog code


 

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

%  TEXT-DICTIONARY MATCHER

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

 

%  @ Archibald Michiels and Nicolas Dufour

%  University of Liège 

%  DEFI project

%  Latest Update : 31 March 2000

 

 

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

%  Compiler Directives and Starting ...

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

 

:- public main/0.

:- public restart/0.

 

 

:- visible getlemw/5.

:- visible retrieveb/3.

:- visible append/3.

:- visible member/2.

:- visible itemsinlist/2.

 

% the above predicates need to be declared visible because embedded in

% a findall or setof clause

 

 

 

 

% in files UTIL.ARI and COLLOCT.ARI :

 

:- extrn istool/1.

:- extrn append/3.

:- extrn lastpost/2.

:- extrn gethandles/1.

:- extrn dividelist/2.

:- extrn removedot/2.

:- extrn member/2.

:- extrn mrest/3.

:- extrn checkmember/3.

:- extrn listl_no_or_or_cor/3.

:- extrn imprime/2.

:- extrn compute_average_time/3.

:- extrn set_default/0.

:- extrn customize/0.

:- extrn listl_no_or/2.

:- extrn neglect/1.

:- extrn accu/2.

:- extrn compute_processing_time/2.

:- extrn check_clwlist/2.

:- extrn writesettings/1.

:- extrn flatlist/2.

:- extrn wenvir/5.

 

 

:- extrn colloct/8.

 

:- extrn dans/2.

:- extrn wcoll/8.

:- extrn toolw/1.

:- extrn corr/2.

:- extrn intersection_colloc/3.

:- extrn intersection_roget/3.

:- extrn getrogetweight/5.

:- extrn flatten/2.

:- extrn flatten/3.

:- extrn flat/2.

:- extrn flat/3.

:- extrn remdup/2.

:- extrn len/2.

:- extrn listl/2.

:- extrn readin/2.

:- extrn mywrite/2.

:- extrn get_time_difference/3.

:- extrn custom/1.

:- extrn getvalue/2.

:- extrn writesettings/1.

:- extrn check_morph/4.

:- extrn metameet/3.

:- extrn rogetmeet/3.

:- extrn irogetmeet/3.

:- extrn wordnetmeet/3.

:- extrn rwn/3.

:- extrn max/2, maximum/3.

:- extrn lablink/3.

:- extrn assoc/2.

:- extrn keeplabel/1.

 

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

 

 

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

%% MAIN : restoring the idb and printing credits

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

 

 

main :-

        cls,

        restore('matcher.idb'),

        % the internal data base containing the DEFI binary trees

        nl,

        set_default,

        % setting default weights

        write($THE DEFI TEXT-DICTIONARY MATCHER$),

        nl,

        write($based on the English/French OH and RC dictionaries$),

        nl,

        write($and making use of the LingSoft CG Parser$),

        nl,

        write($----------------------------------------------------------$),

        nl,

        nl, 

        write($A. Michiels - N. Dufour, University of Liège$),nl,nl,

        go.

 

 

%%%%%%%%%%

% RESTART

%%%%%%%%%%

 

restart :- halt.

 

 

 

%%%%%%%%%%%

% GO step

%%%%%%%%%%%

 

go:-

        write($Textual clause file? No extension :  [filename] --> $),

        read_line(0,TempInput),

        nl,

        removedot(TempInput,Input),

        ifthen(Input == 'bof', halt),

        open(HandleIn,Input,r),

        write($Output file? No extension : [filename] --> $),

        read_line(0,TempOutput),

        nl,

        removedot(TempOutput,Output),

        recorded(stg,[current,Current],_),

        write('Current settings are: '),

        write(Current),

        write('. Modify ? (y/n) '),

        flush,

        get0_noecho(X),

        ifthenelse((X is 89;X is 121),

                    customize,(nl,nl)),

        ctr_set(0,1),

        concat(Output,$.lst$,Outlist),

        create(H2,Outlist),

        close(H2),

        open(ToFile,Outlist,w),

        write(ToFile,'Settings: '),

        writesettings(ToFile),

        time(Time),

        recorda(time,[initial,Time],_),

        recorda(time,[former,Time],_),

      

        repeat,

        read(HandleIn,Wlist),

        start(ToFile,Wlist,Status),

        check(Status),

        % repeat fail loop for a whole file

        % check(done) succeeds when file has been read in and

        % processed entirely

       

        compute_processing_time(initial,Processtime),

        nl,

        write('Total_processing_'),

        write(Processtime),

        nl,

        nl(ToFile),

        write(ToFile,'Total_processing_'),

        write(ToFile,Processtime),

        nl(ToFile),

        ctr_is(0,Counter),

        compute_average_time(Counter,Processtime,Average),

        write('Average_processing_'),

        write(Average),

        nl,

        write(ToFile,'Average_processing_'),

        write(ToFile,Average),

        nl(ToFile),

        close(ToFile),

        close(HandleIn),

        nl,

        write('Input file ['),

        write(Input),

        write('] has been fully processed.'),

        nl,

        write('Strike N to process another file, Q to quit.'),

        eraseall(time),

        nl,

       

        repeat,

        flush,

        get0_noecho(X2),

        ifthen((X2\=78,X2\=110,X2\=113,X2\=81),

                fail),

                % 78 and 110 are N/n

                % 113 and 81 are Q/q

                % otherwise we move back up to repeat

        ifthen((X2 = 113;X2 = 81),

                halt),

                % we quit by halting if Q/q

        cls,

        nl,

        go. % in case N is the answer - start processing a new file

 

 

 

/* Getting out of the repeat-fail loop for reading in a file */

 

check(done).

 

 

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

%% Starting the processing of an S

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

 

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

% MWU MATCHER

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

 

start(ToFile,

      txt(m,Clwlist,Wlist,Nplist,Collist,Polarity,Passivity,Structure,Sentence),

      notdone) :-

        

        ctr_inc(0,Counter),

       

        write('['),

        write(Counter),

        write('] '),

        write(Sentence),

        nl,

        write(ToFile,'['),

        write(ToFile,Counter),

        write(ToFile,'] '),

        write(ToFile,Sentence),

        nl(ToFile),

        write(ToFile,'Clwlist = '),

        write(ToFile,Clwlist),

        nl(ToFile),

        write('Looking up collocate references for textual syn rels...'),

        nl,

       

        lookuptxtcolls(Collist),

        % records all Roget info associated with each textual collocate

               

        check_clwlist(Clwlist,ToFile),

        % rejects toolwords as stand-alone clicked-on words

       

        !,     

       

        workon(Stop,txt(m,Clwlist,Wlist,Nplist,Collist,Polarity,Passivity,Structure),

                ToFile).

        /* workon will fail as long as matches can be found */       

 

        /* The variable Stop will be instantiated to stop,

           and the process will stop, when a solution with a weight

above the threshold is found : a threshold of 300 seems reasonable */

 

 

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

% SINGLE-WORD LEXEME MATCHER

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

 

start(FileOut,

      txt(s,[Clw|_],Wlist,Nplist,Collist,Polarity,Passivity,Structure,Sentence),

      notdone) :-

      eraseall(coll_in_dic),

      eraseall(coll_met),

      eraseall(metamet),

      eraseall(coll_in_roget),

      eraseall(rogetmet),

      eraseall(wnmet),

      expunge,

      gc,

                 

      ctr_inc(0,Counter),

      write('['),

      write(Counter),

      write('] '),

      write(Sentence),

      nl,

      write(FileOut,'['),

      write(FileOut,Counter),

      write(FileOut,'] '),

      write(FileOut,Sentence),

      nl(FileOut),

      string_lower(Clw,Lowerclw),

      findall(Lemclw,

              getlemw(Lowerclw,Lemclw,Wlist,Bidule,Bidon),

              TempListoflemclw),

      remdup(TempListoflemclw,Listoflemclw),

      write('Clw is lemmatized to: '),

      write(Listoflemclw), nl,

      write(FileOut,'Clw = '),

      write(FileOut,Clw),

      nl(FileOut),

      lookuptxtcolls_gen(Collist,Listoflemclw),

      /* records the Roget info for all txt colls */

      workon(txt(s,Clw,Wlist,Nplist,Collist,Polarity,Passivity,Structure),

             FileOut).

 

/* setting check status to 'done' on end-of-file condition: */

 

start(_,end_of_file,done).

 

 

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

%% Starting the matching procedure

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

 

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

%MWU MATCHER

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

 

/* note that all match args are uninstantiated except txt structure: */

 

workon(Stop,txt(m,Clwlist,Wlist,Nplist,Collist,Polarity,Passivity,Structure),ToFile) :-

       var(Stop),     

       match(Stop,txt(m,Clwlist,Wlist,Nplist,Collist,Polarity,Passivity,Structure),

Idnum,Clw,TStrings,DStrings,Trans,Match),

           [!

           register(Match)

           !],

       ifthenelse(var(Stop),

                  fail,   % get ALL matches

                  (workon(stop,txt(m,_,_,_,_,_,_,_),ToFile),!)).   

                 

% match instantiates Stop to stop, if a given threshold is reached

% if Stop is uninstantiated after the call to match, we go on

% otherwise we call on the workon clause which prints the results

% - stop is first arg - and we cut to ensure that backtracking 

% does not occur on the workon predicate

 

     

/* once we have all the matches: */      

workon(stop,txt(m,_,_,_,_,_,_,_),ToFile) :-

    

        recorded(sol,M,_),

        % at least one !

       

        eraseall(handles),      % handles for the clicked-on word(s)

        eraseall(wcoll),        % record of coll match success

        eraseall(coll_in_dic),  % collocates in dic clause

        eraseall(coll_in_roget),% roget info for the text

        eraseall(metamet),      % metameet success info

        eraseall(rogetmet),     % rogetmeet success info

        eraseall(wnmet),        % wordnetmeet success info

        eraseall(coll_met),     % collocate match success info

        expunge,

        gc,

 

        compute_processing_time(former,Processtime),

        write('Processing_'),

        write(Processtime),

        nl,

        write(ToFile,'Processing_'),

        write(ToFile,Processtime),

        nl(ToFile),

               

        recorded_terms(sol,_,L),

        eraseall(sol),

        % collect all solutions in list L

      

        sortremdup(L,[MaxWeight-Solution|Remainder]),

        % sort in descending order, removing duplicates

      

        [! imprimeles(ToFile,MaxWeight,[MaxWeight-Solution|Remainder])!],

        % printing all solutions to File and on screen

           

        write($------------------------------------------------------------$),

        write(ToFile,$-----------------------------------------------------$),

        nl,

        nl(ToFile),

        !.

 

 

 

/* no match found: */

 

workon(_,txt(m,_,_,_,_,_,_,_),ToFile) :-

        not(recorded(sol,M,_)),

        eraseall(handles),

        eraseall(wcoll),

        eraseall(coll_in_dic),

        eraseall(coll_in_roget),

        eraseall(metamet),

        eraseall(rogetmet),

        eraseall(wnmet),

        eraseall(coll_met),

        eraseall(sol),

        gc,

        compute_processing_time(former,Processtime),

        write('Processing_'),

        write(Processtime),

        nl,

        write(ToFile,'Processing_'),

        write(ToFile,Processtime),

        nl(ToFile),

        write($-------NO SOLUTION -----------------------------------------$),

        write(ToFile,$------NO SOLUTION------------------------------------$),

        nl,

        nl(ToFile),

        !.

 

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

% SINGLE-WORD LEXEME MATCHER

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

   

workon(txt(s,Clw,Wlist,Nplist,Collist,Polarity,Passivity,Structure),FileOut) :-

       simplematch(txt(s,Clw,Wlist,Nplist,Collist,Polarity,Passivity,Structure)

,Idnum,Clw,Match),

       [!

       sregister(Match)

       !],

       fail.

             

workon(txt(s,_,_,_,_,_,_,_),FileOut) :-

        sortkey(sol),

       

        % prioritizing the more frequent translations

        % when no translation is a clear winner:

       

        % check that it is not commented out !!!

        % it often is !!!

      

        getmax(Maxweight),

        getnext(Nextweight),

        % ifthen(Maxweight = Nextweight,computeratio),

      

        compute_processing_time(former,Processtime),

        write('Processing_'),

        write(Processtime),

        nl,

        write(FileOut,'Processing_'),

        write(FileOut,Processtime),

        nl(FileOut),

        [!  simprimeles(FileOut,Maxweight)!],

        eraseall(sol).

 

 

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

% Registering the match

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

 

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

% SINGLE-WORD LEXEME MATCHER

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

 

sregister([Weight,m(Idnum,Origin,Handleword,

                        Translation,Trfreq,Debug2)]) :-

        Otherweight is 10000 - Weight,

        recorded(sol,[Whateverweight,m(Idnum,Origin,Handleword,

                        Translation,Trfreq,Debug1)],Key),

        Otherweight < Whateverweight,

        replace(Key,[Otherweight,m(Idnum,Origin,Handleword,

                        Translation,Trfreq,Debug2)]),

        !.

 

sregister([Weight,m(Idnum,Origin,Handleword,Translation,Trfreq,Debug)]) :-

        not(recorded(sol,[_,m(Idnum,_,_,_,_,_)],Key)),

        Otherweight is 10000 - Weight,

        recorda(sol,[Otherweight,

                m(Idnum,Origin,Handleword,Translation,Trfreq,Debug)],_).

 

 

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

% Printing to File

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

     

simprimeles(FileOut,MaxWeight) :-

        recorded(sol,[Weight,m(Idnum,Origin,Handleword,

                        Translation,Trfreq,Debug)],_),

        TempWeight is 10000 - Weight,

        TempWeight > MaxWeight/5,

        FinalWeight is round(TempWeight,0),

        imprime(FileOut,[FinalWeight,m(Idnum,Origin,Handleword,

                        Translation,Trfreq,Debug)]),

        fail.

 

simprimeles(FileOut,_) :-

        write(FileOut,'-----------------------------------------------'),

        write('-------------------------------------------------------'),

        nl,

        nl(FileOut).

 

 

 

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

% recording the maximum weight

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

 

getmax(MaxWeight) :-

        recorded(sol,[MinWeight,_],_),!,

        MaxWeight is 10000 - MinWeight,

        !.

 

getmax(0).

 

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

% recording the next best weight

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

 

getnext(NextWeight) :-

       recorded_nth(sol,2,[NWeight,_],_),!,

       NextWeight is 10000 - NWeight,!.

 

getnext(0).

 

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

% Working out the weight to be assigned to translation frequency

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

 

/* a more frequent translation should be selected

in preference to the others only if no

match stands out */

 

computeratio :-

        recorded(sol,[Weight,m(Idnum,Origin,Handleword,

                Translation,Ratio,Debug)],Key),

        Bonus is Ratio*30,

        Trbonus is  round(Bonus,0),

        Newweight is Weight - Trbonus,

        % recall that Weight is less if heavier...

        replace(Key,[Newweight,m(Idnum,Origin,Handleword,

                        Translation,Ratio,Debug)]),

        fail.

 

computeratio :-

        sortkey(sol).

% resort after score modification by computeratio

 

 

 

 

 

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

/* recording matches and associated weights: */

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

 

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

% MWU MATCHER

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

 

register(M) :-

        recorded(sol,M,_),

        !.

 

register(W-Sol) :- var(W),!.

 

% register(W-Sol) :- W=err,!.

 

register(Otherweight-m(Idnum,DicOrigin,Clwlist,

                   DicLemma,DicTrans,

                   Debug)) :-

       

        recorded(sol,Whateverweight-m(Idnum,DicOrigin,Clwlist,

                        DicLemma,DicTrans,_),

                   Key),

       

        Otherweight >= Whateverweight,

        replace(Key,Otherweight-m(Idnum,DicOrigin,Clwlist,

                   DicLemma,DicTrans,

                   Debug)),

        % we keep the highest weight associated with the match

        !.

 

register(M) :-

        recorda(sol,M,_).

 

 

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

% Printing to file all solutions with a weight over threshold

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

 

 

imprimeles(F,M,[]) :- !.

 

imprimeles(ToFile,MaxWeight,[W-H|T]) :-

        imprimeune(ToFile,MaxWeight,W-H),

        imprimeles(ToFile,MaxWeight,T).

 

 

 

 

imprimeune(ToFile,MaxWeight,Weight-Solution) :-      

       Weight > MaxWeight/3,

       !,

        % we do not print solutions whose score is insufficient

        % as compared with the best       

       Finalweight is round(Weight,0),

       write(Finalweight-Solution),

       nl,

       mmywrite(ToFile,Finalweight-Solution),

       nl(ToFile).

 

% too light : we skip

imprimeune(A,B,C).

 

 

mmywrite(H,W-Sol)  :- 

        write(H,W),

        write(H,' - '),

        mmywrite(H,Sol).

 

mmywrite(H,m(A,B,C,D,E,F)) :-

        write(H,A),

        write(H,', '),

        write(H,B),

        write(H,', '),

        write(H,C),

        write(H,', '),

        write(H,D),

        write(H,', '),

        write(H,E),

        writedebug(H,F),

        !.

 

writedebug(H,Debug) :-

        recorded(stg,[debug,0],_).

       

 

writedebug(H,Debug) :-

        recorded(stg,[debug,1],_),

        write(H,', '),

        write(H,Debug).

 

 

 

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

%%  MATCHER  STRICTU SENSO

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

 

 

 

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

% MWU MATCHER

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

 

 

 

 

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

% MATCH : arity 8

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

 

/* args for match :

        Stop : instantiated to stop when a threshold is reached

               the matching process then stops

        txt(...) : as read in from the text chunk file where :

                Twlist : list of w-clauses for the input textual chunk;

                Clwlist: list of clicked-on words (simulated;

                        most of the time a single word)

                TNplist : list of np's in the textual chunk

                TCollocList : list of collocational relations

                TPolarity : clause polarity: either neg(1) or neg(0)

                Tvoice : clause voice: either passive(1) or passive(0)

                TType : nature of the chunk (phrasal or sentential)

        Idnum : identification number of the dic entry

        Twordlist: textual string matched

        Dwordlist: dictionary string matched (lemma's)

        DicTrans: translation

        m(_): results copied over to be displayed to the user

        DicOrigin : OH, RC or merged dic

        NewWeight: weight assigned to the match

 

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

Example of a dic-clause :

THAT NAME RINGS A BELL (Oxford-Hachette)

 

dic(

251141, % idnum

[[p_h,bell,bell],[p,name,name],[p,rings,ring]], % inh-clause:handles

[w(0,1,text('that',l), % w-clause for word1

       lem('that',l),morph([m(pos,det,2),m(type,central,0),

       m(type,dem,2),m(num,sg,2)]),

       syn([s(type,dn,0,r)])),

w(1,2,text('name',l),

      lem('name',l),morph([m(pos,n,5),

      m(case,nom,0),m(num,sg,2)]),

      syn([s(func,subj,5,_)])),

w(2,3,text('rings',l),

      lem('ring',l),morph([m(pos,v,5),m(tense,pres,1),

      m(num,sg3,1),m(type,finite,2)]),

      syn[s(type,main,3,f)])),

w(3,4,text('a',l),

      lem('a',l),morph([m(type,indef,3),

      m(pos,det,2),m(type,central,0),m(type,art,3),m(num,sg,2)]),

      syn([s(type,dn,0,r)])),

w(4,5,text('bell',l), % textual wordfoem

      lem('bell',l), % lemmatization

      morph([m(pos,n,5),m(case,nom,0),m(num,sg,2)]), % morph features

      syn([s(func,obj,5,_)])), % syntactic features

punct(5,6,unkn)], % punctuation at end of w-list

 

[np(0,2,c(1,2)),np(3,5,c(4,5))], % NP-list

 

[csubj('name','ring'), % syntactic relation box

cdobj('bell','ring')],

 

neg(0), % polarity

passive(0), % voice

s, % structural hypothesis

le($that name rings a bell$), % lemma

sc([nil]), % subject coll

oc([nil]), % object coll

env([nil]), % environment

pat(nil), % pattern

lab([nil]), % labels

sst([nil]), % source text style features

gt(nil), % cross ref

tr($ce nom me dit quelque chose$), % translation

rat(1,1), % translation frequency

gl(nil), % gloss

ohef). % origin

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

 

 

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

Example of a INH-clause : handle-list : all the mwu's reachable

from a given item, in casu BELL, marked as p_h (head):

the toolword wordforms are replaced by a category indicator

 

inh('bell',

     [

        [[p_h,answer,answer],[p,bell,bell]],

        [[p_h,bell,bell],[p,bottomed,bottom],[p,trousers,trouser]],

        [[p_h,bell,bell],[p,bottoms,bottom]],

        [[p_h,bell,bell],[p,cat,cat]],

        [[p_h,bell,bell],[p,door,door]],

        [[p_h,bell,bell],[p,first,first],[p,t_prep,for],[p,mass,mass],[p,ringing

                ,ring],[p,t_be,be]],

        [[p_h,bell,bell],[p,give,give]],

        [[p_h,bell,bell],[p,great,great]],

        [[p_h,bell,bell],[p,name,name],[p,rings,ring]],

        [[p_h,bell,bell],[p,number,number],[p,rings,ring]],

        [[p_h,bell,bell],[p,pull,pull]],

        [[p_h,bell,bell],[p,push,push]],

        [[p_h,bell,bell],[p,ring,ring]],       

        [[p_h,bell,bell],[p,ringer,ringer]],

        [[p_h,bell,bell],[p,rope,rope]],

        [[p_h,bell,bell],[p,shaped,shape]],

        [[p_h,bell,bell],[p,t_be,be],[p,there,there]],

        [[p_h,bell,bell],[p,t_mod,can],[p,hear,hear]],

        [[p_h,bell,bell],[p,tent,tent]],

        [[p_h,bell,bell],[p,tower,tower]],

        [[p_h,bells,bell],[p,ring,ring]],

        [[p_h,bells,bell],[p,sound,sound]],

        [[p_h,bells,bell]]

     ]

   ).

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

 

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

Example of a text-clause

DOES IT RING A BELL, MALCOLM?

 

txt(m, % mwu match requested

['bell'], % clicked-on word

[w(0,1, % first word of text w-list DOES

        text('does',u), % wordform

        lem('do',u), % lemma

        morph([m(pos,v,5),m(tense,pres,1),m(num,sg3,1),m(type,finite,2)]),

        syn([s(type,aux,3,f)])),

w(1,2, % IT

        text('it',l),

        lem('it',l),

        morph([m(type,nonmod,0),m(pos,pron,2),m(case,nom,0),m(num,sg3,1),

        m(func,subj,3)]),

        syn([s(func,subj,5,_)])),

w(2,3, % RING First lemmatization: a noun

        text('ring',l),

        lem('ring',l),

        morph([m(pos,n,5),m(case,nom,0),m(num,sg,2)]),

        syn([s(func,subj,5,_),s(func,obj,5,_),s(func,i_obj,5,_)])),

w(2,3, % RING second lemmatization : a verb

        text('ring',l),

        lem('ring',l),

        morph([m(pos,v,5),m(mood,inf,2)]),

        syn([s(type,main,3,nf)])),

w(3,4, % A

        text('a',l),

        lem('a',l),

        morph([m(type,indef,3),m(pos,det,2),m(type,central,0),

        m(type,art,3),m(num,sg,2)]),

        syn([s(type,dn,0,r)])),

w(4,5, % BELL

        text('bell',l),

        lem('bell',l),

        morph([m(pos,n,5),m(case,nom,0),m(num,sg,2)]),

        syn([s(func,subj,5,_),s(func,obj,5,_)])),

punct(5,6,comma),

w(6,7, % MALCOLM

        text('malcolm',u),

        lem('malcolm',u),

        morph([m(type,proper,3),m(pos,n,5),m(case,nom,0),m(num,sg,2)]),

        syn([s(func,obj,5,_),s(func,app,2,_)])),

punct(7,8,qmark)],

 

[np(1,2,c(1,2)),np(2,3,c(2,3)),np(3,5,c(4,5)),np(6,7,c(6,7)),

np(1,3,c(1,2)),np(2,5,c(2,3))],

% NP-list

 

[csubj('it','ring'),csubj('ring','ring'),cdobj('ring','ring'),

ciobj('ring','ring')],

% Syntactic relations box

% note that they are wrong, due to the wrong lemmatization of RING

 

neg(0),

% polarity

 

passive(0),

% voice

 

s,

% structural hypothesis

 

$Does it ring a bell, Malcolm ?$).

% text chunk

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

 

*/

 

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

match(Stop,txt(m,Clwlist,Twlist,TNplist,TCollocList,TPolarity,TVoice,TType),

      Idnum,

      Clwlist,

      Twordlist,

      Dwordlist,

      DicTrans,

      NewWeight-m(Idnum,DicOrigin,Clwlist,

                   DicLemma,DicTrans,

                   Debug)) :-

 

        % Collect the lemmas of the clicked-on words:

        getlemw(Clwlist,Twlist,Lemclwlist),

        first(Clwlist,First),

       

        % On backtracking produce new word lists,

        % each with one lemmatization only

        % for each word:

        dividelist(Twlist,NewTwlist),

       

        % Collect all the textual words and lemmas of the textual chunk:

        collectlemmas(NewTwlist,TWL,TextWordList),

       

        % Retrieve the handle list(s) they are members of

        % and write in handles db:

        write('Retrieving handles for '),

        write(Lemclwlist),

        write('... '),

        gethandles(Lemclwlist), % retrieves the Hlist, i.e. list

                                % of handles for the clicked-on word

        write('done'),

        nl,

        recorded(handles,[Lemclwlist,Hlist],_),

       

        % 'Plausibility check' of handle:

        enough(TWL,Hlist,p,Lemclwlist),

      

        % retrieving candidate dic-clause on basis of handle:

        retrieveb(dico,

                Hlist,

                dic(Idnum,

                        Hlist,

                        Dicwlist,

                        DicNplist,

                        DicCollocList,

                        DicPolarity,

                        DicVoice,

                        DicType,

                        le(DicLemma),

                        sc(DicScoll),

                        oc(DicOcoll),

                        env(DicEnvir),

                        DicPattern,

                        DicLab,

                        DicSst,

                        DicGothere,

                        DicTrans,

                        DicRat,

                        DicGloss,

                        DicOrigin)),

      

        % phrasal or sentential dic clause ?:

        translate(DicType,SorP),

 

        % Checking polarity:

        compatible(DicPolarity,TPolarity),

       

        % Checking voice (debatable!):

        compatible(DicVoice,TVoice),

       

        % Display candidate diclemma on screen:

        write(Idnum),

        tab(1),

        write(DicLemma),

        nl,

       

        % we have to go through the whole dictionary entry

        % and accept it against

        % the textual chunk w-clauses

        

        % we begin by recording the last position in the dictionary

        % wlist:

        lastpost(Dicwlist,Borne),

       

        accept(First,DicType,

        % phrasal or sentential

        Hlist,

        % handle list

        Dicwlist,

        % this is not the whole dicwlist, except right

        % at the start - it repeatedly gets beheaded by mrest

        RDicwlist,

        % remainder of dicwlist after success

        DicNplist,

        % Np list in the dic clause

        DicCollocList,

        % syntactic rel box in the dic clause

        DicPattern,

        % phrasal and prep verb patterns

        NewTwlist,

        % textual word list

        RTwlist,

        % what is left of it after success of accept

        TNplist,

        % np list in textual chunk

        TCollocList,

        % syntactic relations in textual chunk

        0,

        % position of pointer in dic w-list on entry

        Diconexit,

        % idem on exit

        Borne,

        % pointer to end of dic w-list

        Onenter,

        % position of pointer in text w-list on entry

        Onexit,

        % idem on exit

        PositionList,

        % list of positions in text w-list

        Twordlist,

        % textual wordlist as built by accept

        Dwordlist,

        % dic word list as built by acept

        Weights,

        % weights assigned to match

        DebugWlist,

        % Debug info

        0),

        % match quality rating

       

        % Assigning weights for environment match

        % and collocate match:

       

        % Envir

        % The environment is to the right of the last position

        % matched in the textual chunk:

        wenvir(Last,NewTwlist,DicEnvir,WeightEnvir,DebugEnvir),

       

        % Collocates

          colloct(Dicwlist,DicType,DicPattern,DicScoll,

               DicOcoll,TCollocList,Wcol,

               DebugCol),

        [! flatlist([DebugWlist,DebugEnvir,DebugCol],Debug)!],      

       

        % Compute final weight:

        [! accu([Wcol,WeightEnvir|Weights],Weight) !],

        divide(Weight,NewWeight,DicType),

        % weighting according to dictype, i.e phrasal or whole S

     

        ifthen(NewWeight>300,Stop=stop).

        % instantiates the Stop varaible if threshold is reached

 

 

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

%%% divide(Accumulated_weight(+),Final_Weight(-),Dictype(+))

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

 

% we decrease a Weight that has been computed on the basis of a

% clausal match to make sure that canonical phrases gather more weight than

% example sentences.

% BUT we cannot be too strict:

% That name rings a bell (example S in dic)  vs. to ring the

% bell (expected phrase, not registered in dic as a phrase)

% We find in text (ldg): does that ring a bell, Malcolm ?

 

divide(X,Y,s) :- Y is integer(X/1.3),!.

 

divide(X,X,D) :- D \= s.

% keep as is for phrasal dictype

 

 

 

%%%%%%%%%%

% ACCEPT

%%%%%%%%%%

 

/* P1 and Pn point to positions in the w-clauses

corresponding to the textual chunk ; progression in the

dictionary clause is ensured by the list processing strategy

it is important to realize that the gothrough predicate allows

the traversal of nodes in the textual chunk, not in the

w-clauses belonging to the dictionary, which are all dealt with

by smatch */

 

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

% recursive clause : double match

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

  

accept(First,Dictype,

       Hlist,           % handle list

       Dicwlist,        % Dictionary w-list

       RDicwlist,       % what remains of it after success

       DicNplist,       % Np-list in the dic clause

       DicCollocList,   % Collocate list of the dic clause

       pat(nil),        % NOT a phrasal of prep verb

       Twlist,          % Textual w-list

       RTwlist,         % what remains of it after success

       TNplist,         % Np-list in text       

       TCollocList,     % Collocate list in text

       Dp1,             % Starting position in dic w-list

       Dpn,             % End position in dic w-list after success

       Borne,           % END of dic w-list

       P1,              % Starting position in text w-list

       Pn,              % Position reached in text w-list after success

       [P1|Otherps],    % List of textual positions, built up as

                        % we go along

       [Twordlist|Ts],  % Text w-list as built by accept

       [Dicword|Ds],    % Dictionary w-list as built by accept

       [Sweight|Weights], % weights

       [Debug|Debugs], % debug info

       OldQuality) :-     % match quality weighting

 

        doublematch(First,Dictype,

                    Hlist,

                    Dicwlist,

                    RDicwlist,

                    DicNplist,

                    Twlist,

                    RTwlist,

                    TNplist,

                    Idnum,

                    Dp1,

                    Dp2,

                    P1,

                    P2,

                    Twordlist,

                    Dicword,

                    Debug,

                    Sweight),

        % we match the 2 head clauses in the w-clause list of the

        % dictionary entry : 'do something', 'doing something' or 'to be'

 

        gothrough(P2,P3,RTwlist,TNplist),

        % we move on in text if need be

       

        % we recursively accept the remainder of the dic w-list

        accept(First,Dictype,

            Hlist,

            RDicwlist,

            NewRDicwlist,

            DicNplist,

            DicCollocList,

            pat(nil),

            RTwlist,

            NewRTwlist,

            TNplist,

            TCollocList,

            Dp2,

            Dpn,

            Borne,

            P3,

            Pn,

            Otherps,

            Ts,

            Ds,

            Weights,

            Debugs,

            OldQuality).

  

  

  

  

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

% recursive clause : single match

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

 

accept(First,Dictype,

       Hlist,

       Dicwlist,

       RDicwlist,

       DicNplist,

       DicCollocList,

       pat(nil),

       Twlist,

       RTwlist,

       TNplist,

       TCollocList,

       Dp1,

       Dpn,

       Borne,

       P1,

       Pn,

       [P1|Otherps],

       [Twordlist|Ts],

       [Dicword|Ds],

       [Sweight|Weights],

       [Debug|Debugs],

       OldQuality):- % we start with quality 0

 

        smatch(First,Dictype,

                Hlist,

                Dicwlist,

                RDicwlist,

                DicNplist,

                Twlist,

                RTwlist,

                TNplist,

                Idnum,

                Dp1,

                Dp2,

                P1,

                P2,

                Twordlist,

                Dicword,

                TempSweight, % weight returned by smatch

                Debug,

                Quality),

 

        TempFactor is OldQuality/8,

        Factor is TempFactor+1,

        Distance is Dp2 - Dp1,

        ifthenelse(Distance =< 1,                       % condition

                   Sweight is TempSweight * Factor,     % Then action

                   % we increase weight if we find the words we need

                   % in the order specified and in strict adjacency

                   Sweight is TempSweight),             % Else action

        /* we assign weight in function of the distance we have

travelled in the dic clause, too; NPs are sometimes traversed

here as well, not only in the textual wordlist (for which see

gothrough below) */

 

        gothrough(P2,P3,RTwlist,TNplist),

        /* we traverse nodes in the w-clauses belonging to the

        textual chunk; such nodes need to be marked as traversable, i.e

        auxiliaries, adverbs, pps, ... */

 

        % we recursively accept the remainder of the dic-clause, from P3,

        % the point we have reached at the end of the gothrough walk:

        accept(First,Dictype,

               Hlist,

               RDicwlist,

               NewRDicwlist,

               DicNplist,

               DicCollocList,

               pat(nil),

               RTwlist,

               NewRTwlist,

               TNplist,

               TCollocList,

               Dp2,

               Dpn,

               Borne,

               P3,

               Pn,

               Otherps,

               Ts,

               Ds,

               Weights,

               Debugs,

               Quality).

 

 

 

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

% end of recursion:

% dictionary pointer has reached end of dicwclause

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

 

accept(_,_,_,_,_,_,_,_,_,_,_,_,Dx,Dx,Borne,Px,Px,[],[],[],[0],[],_):-

        Dx >= Borne.

 

 

 

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

% ACCEPT: dealing with phrasal and prepositional verbs.

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

 

accept(_,_,_,

       [w(0,1,_,lem(Verb,_),_,_)|RDicwlist],

                        % the verb is in first position

                        % if pattern is not nil

       _,_,_,

       pat(DicPattern),

       Twlist,

       RTwlist,

       TNplist,

       TCollocList,

       Dp1,

       Dpn,

       Borne,

       EnterVerb,

       ExitPart,

       [Enterverb,ExitPart],

       [Twordlist|Ts],

       [Dicword|Ds],

       [Weight],

       [m(pattern(DicPattern),Verb,100)],

       OldQuality):-

 

        DicPattern \= 'nil',            % phrasal or prepositional

        member(w(EnterVerb,ExitVerb,_,lem(Verb,_),_,_),Twlist),

        findpart(RDicwlist,Twlist,EnterVerb,EnterPart,ExitPart),

        np_all_right(TNplist,DicPattern,ExitVerb,EnterPart,ExitPart),

        Weight is 100.

 

 

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

%%% Finding the prep or part

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

 

findpart([w(1,2,_,lem(Part1,_),_,_),w(2,3,_,lem(Part2),_,_)|Tail],

        % Part1 and Part2 are the parts of a two-word particle

        % of prep e.g. GET verb ALONG Part1 With Part2

         Twlist,

         EnterVerb,

         Enter,

         Exit) :-

        member(w(Enter,Next,_,lem(Part1,_),_,_),Twlist),

        Enter > Enterverb,

        member(w(Next,Exit,_,lem(Part2),_,_),Twlist),

        Exit > EnterVerb,

        % find them in strict adjacency, after the verb

        !.

 

findpart([w(1,2,_,lem(Part,_),_,_)|Tail], % a single prep or particle

         Twlist,

         EnterVerb,

         Enter,

         Exit) :-

        member(w(Enter,Exit,_,lem(Part,_),_,_),Twlist),

        Enter > EnterVerb.

 

 

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

% checking the NP object in phrasal and prep verbs

% and allowing room for one adverb between verb and

% particle or prep: go right down...

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

 

% no np allowed because fused pat

% room for one adverb :

 

np_all_right(TNplist,Pattern,ExitVerb,EnterPart,ExitPart) :-

        fus(Pattern),

        not(member(np(ExitVerb,ExitNp,c(_,_)),TNplist)),

        Border is EnterPart-1,

        ExitVerb >= Border,

        !.

 

 

% no np found after the verb

% room for one adverb between verb and particle, nothing more :

 

np_all_right(TNplist,Pattern,ExitVerb,EnterPart,ExitPart) :-

        not(member(np(ExitVerb,ExitNp,c(_,_)),TNplist)),

        Border is EnterPart-1,

        ExitVerb >= Border.

 

 

 

% room for an np:

 

np_all_right(TNplist,Pattern,ExitVerb,EnterPart,ExitPart) :-

        member(np(ExitVerb,ExitNp,c(_,_)),TNplist),

        Border is EnterPart-1,

        ExitNp >= Border.

 

 

/* get_trans_bonus : REMMED */

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

 

 

%%%%%   get_trans_bonus(TColloclist,Verb,DicPattern,30) :-

%%%%%   DicPattern \= '4',

%%%%%   member(cdobj(_,Verb),TColloclist),

%%%%%   !.

 

%%%%%   get_trans_bonus(_,_,DicPattern,0).

 

 

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

/* Phrasal and prepositonal patterns */

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

 

/* 1 to 4 do not admit of an intervening np between verb and

   particle */

 

fus('1').

fus('2').

fus('3').

fus('4').

 

 

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

% GOTHROUGH: traversing nodes in list of textual w-clauses

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

 

% staying put; end of recursion:

 

gothrough(Node,Node,_,_).

 

 

% Punctuation : jumpable

 

gothrough(Node1,Nodex,Twlist,TNplist) :-

        member(punct(Node1,Nodetemp,_),Twlist),

        gothrough(Nodetemp,Nodex,Twlist,TNplist).

 

 

 

% a sequence - including a seq of one - of crossable POS or TYPES

% Warning : LAX !

 

gothrough(Node1,Nodex,Twlist,TNplist) :-

        member(w(Node1,Nodetemp,T,L,morph(Lmorph),S),Twlist),

        member(m(pos,Pos,W),Lmorph),

        crossable(Pos),

        gothrough(Nodetemp,Nodex,Twlist,TNplist).

    

gothrough(Node1,Nodex,Twlist,TNplist) :-

        member(w(Node1,Nodetemp,T,L,morph(Lmorph),S),Twlist),

        member(m(type,Type,W),Lmorph),

        crossable(Type),

        gothrough(Nodetemp,Nodex,Twlist,TNplist).

 

 

% a whole phrase (PP)

% Warning : LAX !

 

gothrough(Node1,Nodex,Twlist,TNplist) :-

        member(w(Node1,Node1Plus1,T,L,morph(Lmorph),S),Twlist),

        member(m(pos,prep,_),Lmorph),

        member(np(Node1Plus1,Nodetemp,Head),TNplist),

        gothrough(Nodetemp,Nodex,Twlist,TNplist).

 

 

% a whole phrase (NP)

% Warning : LAX !

 

gothrough(Node1,Nodex,Twlist,TNplist) :-

        member(np(Node1,Nodetemp,Head),TNplist),

        gothrough(Nodetemp,Nodex,Twlist,TNplist).

 

/* The above two clauses allows nps and pps to be traversed;

a pp is a prep followed by an np;

the nps belonging to the textual chunk are recorded in

the TNplist, a list of np structures: np(Start,End,Head) */

 

 

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

% crossable POS and TYPES

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

 

crossable(adv).

crossable(inf_part).

crossable(modaux).

crossable(neg).

crossable(aux).

crossable(num).

crossable(pron).

crossable(det).

crossable(adj).

crossable(excl).

crossable(ingform).

crossable(edform).

 

 

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

% Crossable pos in dic-clauses

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

dic_cross(adv,Word) :-

        not(isprep(Word)).

 

dic_cross(cconj,Word).

dic_cross(sconj,Word).

dic_cross(det,Word).

 

isprep(at).

isprep(in).

isprep(into).

isprep(on).

isprep(upon).

isprep(through).

isprep(for).

isprep(with).

isprep(by).

isprep(from).

isprep(up).

isprep(out).

isprep(about).

isprep(into).

isprep(of).

isprep(back).

isprep(down).

isprep(over).

isprep(after).

isprep(off).

 

 

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

% SMATCH: match of a single item in the dic clause against txt-clause item

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

 

/*

We distinguish:

 

a) match in both textual word and lemma :

we reap marks for both, and

collect marks in the morph and syn features

 

b) match in lemma only :

we reap marks for lemma, and

collect marks for morph and syn

 

c) matching a placeholder :

we look for the corresponding structure in the w clause,

and advance pointers accordingly;

we reap marks for the match

 

Placeholders:

 

something : any np

somebody : any np

somebody's : an np whose head is marked as [+GEN] or of+NP or a member

             of the list matching *** one's ***

one's: [my,your,his,her,its,our,their]

 

Two placeholders seem to need a double match clause, i.e two dic nodes

at one and the same go:

 

do something

doing something

 

But it might be enough to match them by a verb of the correct

inflectional type (TO-inf or Ving) if the placeholder couple is

at the end of the lemma (reluctant to do sth= reluctant to V)

 

Note that we must match the TO opening a vp dic type vacuously.

 

Note also that we must match depleted verbs according to an

equivalence table (cf. R/C front matter). We have two sets,

intransitive and transitive depleted verbs.

 

d) coordinated elements

        open area for RESEARCH

 

e) no match and no penalty: a toolword in the dic-clause ?

        open area for RESEARCH

 

f) no match and penalty: we assign a negative weight

        open area for RESEARCH

 

Points e and f will have to be dealt with according to the type

of the dictionary entry, phrasal or clausal (sentential). We need

to insist on a stricter match in the case of phrasal entries

than in that of example sentences (Dictype = s).

 

Progression in the textual w-clause list: do we simply require moving

forward (Onenter to be further along in the clause than the

previous Onexit), allowing for jumped elements to be anything;

or do we specify which elements are jumpable ?

 

We begin by following the latter strategy.

 

*/

 

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

%% VACUOUS MATCHES

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

 

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

% TO starting a VP node in a dictionary entry

% no weight assigned

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

 

% CASE 1

 

smatch(_,vp,

           Hlist,

           [w(0,1,text(to,T1),L,M,S)|RDicwlist],

           RDicwlist,

           DicNplist,

           Twlist,

           Twlist,

           TNplist,

           Idnum,

           0,

           1,

           Onenter,

           Onenter,

           [],

           to,

           [0],

           m(c1,vac,to,0),

           0) :-!.

 

 

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

% 'of' ending a dic-clause

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

 

% CASE 2

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,

        RDicwlist,

        DicNplist,

        Twlist,

        Twlist,

        TNplist,

        Idnum,

        Dicstart,

        Dicend,

        Onenter,

        Onenter,

        Othertext,

        Text,

        [-5],

        m(c2,vac,of,-5),

        0) :-

 

mrest(w(Dicstart,Dicend,text(of,T1),lem(Lemma,T2),morph(M),syn(S)),

      Dicwlist,

      RDicwlist),

not(member(w(_,_,_,_,_,_),RDicwlist)), % it is the last element

not(mrest(w(Onenter,Onexit,text(of,T11),lem(Lemma,T22),morph(M2),syn(S2)),

          Twlist,

          RTwlist)).

% no match in the text

 

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

% A Whole NP matched vacuously in the dic clause !!!

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

 

/* very lax but unavoidable because some mwu's are dealt with in the

dictionary by means of example sentences only, not phrasal squeletons

- not "to ring a bell" but "the number rings a bell"

in that case, the NP "the number" ought to be crossed vacuously, and the

match should begin at "rings"

- a deplorable situation, due to the need on the lexicographer's part

to translate more naturally - full S's easier to translate naturally than

skeletal phrases; "I miss you" translates more easily than "to miss someone"

*/

 

% CASE 3

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,

        RDicwlist,

        [np(A,B,C)|Tail], % Dic Np-list is not empty

        Twlist,

        Twlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onenter,

        np,np,

        [0],

        m(c3,vac,np(A,B,C),0),

        0) :-

 

        % find jumpable np with right position in dic NP-list:

        member(np(Dicstart,Dicend,c(_,_)),[np(A,B,C)|Tail]),

 

        % make sure np is not the whole mwu (words are found before start

        % or after end) :

        (member(w(Dicend,_,_,_,_,_),Dicwlist)

         ;

         member(w(_,Dicstart,_,_,_,_),Dicwlist)),

 

        % make sure there is an np in the text, too :

        member(np(Onenter,Onexit,c(_,_)),TNplist),

 

        mrest(w(_,Dicend,_,_,_,_),

              Dicwlist,

              RDicwlist).

 

 

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

% punctuation within or at the end of a dictionary entry

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%/

 

% CASE 4

 

smatch(_,_,_,

       [punct(Distart,Dicend,_)|RDicwlist],

       RDicwlist,

       _,X,X,_,_,

       Dicstart,Dicend,

       Onenter,Onenter,

       [],

       [punct],

       [0],

       m(c4,vac,punct,0),

       0).

 

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

%% REGULAR, NON-VACUOUS MATCHES

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

 

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

% match both textual wordform and lemma

% weight is heavier if the item is not a toolword, i.e.

% belongs to the handlelist

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

 

% CASE 5

   

smatch(_,Dictype,

        Hlist,

        Dicwlist,

        RDicwlist,

        DicNplist,

        Twlist,

        RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Txt,Txt,

        Sweight,

        m(c5,dictxt(Txt),morph(Mark1),syn(Mark2),Lemweight),

        2) :- % Quality

 

        mrest(w(Dicstart,Dicend,text(Txt,T1),lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

        mrest(w(Onenter,Onexit,text(Txt,T11),lem(Lemma,T22),morph(M2),syn(S2)),

                    Twlist,RTwlist),

        /* we find the textual word form, and it is

           lemmatized the same way */

           

        checkmember([_,_,Lemma],Hlist,Val),

        /* Val is 2 if the pair is part of the handlelist, 1 otherwise */

       

        reapmarks_morph(M,M2,Marks1),

        reapmarks_syn(S,S2,Marks2),

        /* we assign marks according to the weight argument

        of each morph and syn feature that matches */

       

        accu(Marks1,Mark1),

        accu(Marks2,Mark2),

        /* we add up the two lists */

       

        Lemweight is 25 * Val,

        /* Val is 2, i.e. Lemweight is 50, if the item is not

        a toolword, i.e. IS part of the handle list, where toolwords

        (except the headword) are not included as p(Text,Lemma) , but

        as p(Class, Lemma) */

       

        Sweight is Lemweight+Mark1+Mark2.

 

 

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

% match in lemma only

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

 

% CASE 6

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,

        RDicwlist,

        DicNplist,

        Twlist,

        RTwlist,

        TNplist,

        Idnum,

        Dicstart,

        Dicend,

        Onenter,

        Onexit,

        OT,

        T,

        Sweight,

        m(c6,dic(T),txt(OT),morph(Mark1),syn(Mark2),Lemweight),

        1) :-

 

mrest(w(Dicstart,Dicend,text(T,T1),lem(Lemma,T2),morph(M),syn(S)),

      Dicwlist,

      RDicwlist),

 

mrest(w(Onenter,Onexit,text(OT,T11),lem(Lemma,T22),morph(M2),syn(S2)),

      Twlist,

      RTwlist),

 

T \= OT, % the match excludes a textual variant match - see above

 

checkmember([_,_,Lemma],Hlist,Val),

reapmarks_morph(M,M2,Marks1),

reapmarks_syn(S,S2,Marks2),

accu(Marks1,Mark1),

accu(Marks2,Mark2),

Lemweight is 15 * Val,

Sweight is Lemweight+Mark1+Mark2.

 

 

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

% word correspondences: on/upon, on/onto, in/into

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

% REMMED

 

% CASE 7

 

/*

smatch(_,Dictype, Hlist,

           Dicwlist,RDicwlist,DicNplist,

           Twlist,RTwlist,TNplist,

           Idnum,

           Dicstart,Dicend,

           Onenter,Onexit,

           Othertext,Text,

           Sweight,

           m(c7,dic(Txt),txt(OtherText),morph(Mark1),syn(Mark2),Lemweight),

           0) :-

 

           mrest(w(Dicstart,Dicend,text(Text,T1),

             lem(Lemma,T2),morph(M),syn(S)),Dicwlist,RDicwlist]),

 

           mrest(w(Onenter,Onexit,text(OtherText,Typ1),

                    lem(TextLemma,Typ2),morph(Morpht),syn(Synt)),

                    Twlist,RTwlist),

 

           OtherText \= Text,

           TextLemma \= Text,

 

           corrword(Lemma,TextLemma),

 

           checkmember([_,_,Lemma],Hlist,Val),

           reapmarks_morph(M,Morpht,Marks1),

           reapmarks_syn(S,Synt,Marks2),

           accu(Marks1,Mark1),

           accu(Marks2,Mark2),

           Lemweight is 15 * Val,

           Sweight is Lemweight+Mark1+Mark2.

*/

 

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

% CORRWORD: synonymy or near synonymy between closed-class words

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

 

corrword(on,upon).

corrword(upon,on).

corrword(on,onto).

corrword(onto,on).

corrword(in,into).

corrword(into,in).

 

 

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

% matching a semantically depleted lemma 

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

 

% CASE 8

   

smatch(_,Dictype,

        Hlist,

        Dicwlist,

        RDicwlist,

        DicNplist,

        Twlist,

        RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Othertext,Text,

        Sweight,

        m(c8,dic(Text),txt(OtherText),morph(Mark1),syn(Mark2),20),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(Text,T1),

                                     lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

        mrest(w(Onenter,Onexit,text(OtherText,Typ1),

                              lem(TextLemma,Typ2),morph(Morpht),syn(Synt)),

              Twlist,

              RTwlist),

        OtherText \= Text,

        TextLemma \= Lemma,

        /* we need these two clauses to distinguish this case

        from the cases where text and lemma match, both or lemma only */

       

        member(m(pos,v,W),M),

        member(m(pos,v,W),Morpht),

        /* both the item in the text and the item in the

        dictionary are verbs */

       

        equaldepleted(Lemma,TextLemma),        

        /* they belong to the same class of semantically

        depleted verbs */

       

        reapmarks_morph(M,Morpht,Marks1),

        reapmarks_syn(S,Synt,Marks2),

        accu(Marks1,Mark1),

        accu(Marks2,Mark2),

        Sweight is 12+Mark1+Mark2.   

 

 

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

% Matching placeholders

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

 

 

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

% placeholder for single words (one's)

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

 

% CASE 9

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Othertext,oneßs,

        12,

        m(c9,dic(ones),txt(Text),12),

        0) :-        

 

        mrest(w(Dicstart,Dicend,text(oneßs,T1),

                                     lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        mrest(w(Onenter,Onexit,text(Text,Typ1),

                           lem(TextLemma,Typ2),morph(Morpht),syn(Synt)),

              Twlist,

              RTwlist),

 

        correspond(oneßs,Text).

        /* we match the textual form, which is unique : one's */

        /* the correspond predicate lists the possessive adjectives */

 

 

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

%% placeholder for single words (oneself)

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

 

% CASE 10

   

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Text,oneself,

        12,

        m(c10,dic(oneself),txt(Text),12),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(oneself,T1),

                        lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        mrest(w(Onenter,Onexit,text(Text,Typ1),

                      lem(TextLemma,Typ2),morph(Morpht),syn(Synt)),

              Twlist,

              RTwlist),

 

        correspond(oneself,Text).

        /* we match the textual form, which is unique : oneself */

        /* the correspond predicate lists the -self/-selves forms */

 

 

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

% placeholder for single words (somebody's)

% can be matched by my, your, his,her, ...

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

 

% CASE 11

 

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,RTwlist,

        TNplist,

        Idnum,

        Dicstart,

        Dicend,

        Onenter,

        Onexit,

        Text,

        somebodyßs,

        12,

        m(c11,dic(somebodys),txt(Text),12),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(somebodyßs,T1),

                              lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        mrest(w(Onenter,Onexit,text(Text,Typ1),

                            lem(TextLemma,Typ2),morph(Morpht),syn(Synt)),

              Twlist,

              RTwlist),

 

        correspond(oneßs,Text).

 

 

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

/* placeholder for NPs (someone/something) */

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

 

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

/* someone or somebody */   

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

 

% CASE 12

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Othertext,someone,

        12,

        m(c12,dic(sb),txt(Othertext),12),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(Someone,T1),

                        lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

        issomebody(Someone),

        member(np(Onenter,Onexit,c(St,E)),

               TNplist),

        mrest(w(St,E,text(Othertext,T),_,_,_),

              Twlist,

              RTwlist).

 

 

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

/* something */

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

 

% CASE 13

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Text,something,

        12,

        m(c13,dic(sth),txt(Text),12),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(something,T1),

                          lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        member(np(Onenter,Onexit,c(St,E)),

               TNplist),

        mrest(w(St,E,text(Text,T),_,_,_),

              Twlist,

              RTwlist).

          

           

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

/* jumpable negative words (polarity is accounted for globally, rather

than by matching negative words) */

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

 

% CASE 14

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,Twlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onenter,

        [],'NEG',

        3,

        m(c14,dic(NegWord),jmpd,3),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(NegWord,T1),

                     lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        isneg(NegWord).

      

 

          

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

/* jumpable toolwords (very lax - too lax!!!) */

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

 

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

% REMMED !!!!!!!

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

 

 

/*

 

% CASE 14bis

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,Twlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onenter,

        [],'toolw',

        0,

        m(c14,dic(ToolWordform),jmpd,0),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(ToolWordform,_),

                     lem(ToolWord,_),_,_),

              Dicwlist,

              RDicwlist),

 

        istool(ToolWord).

 

*/

 

 

 

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

/* placeholder for VP's : *** do *** and *** doing ***

   (by the side of do something and doing something,

   which require a doublematch */

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

 

% CASE 15

 

smatch(_,Dictype, Hlist,

           Dicwlist,RDicwlist,DicNplist,

           Twlist,RTwlist,TNplist,

           Idnum,

           Dicstart,Dicend,

           Onenter,Onexit,

           Othertext,do,

           12,

           m(c15,dic(do),txt(T),12),

           0) :-

 

        mrest(w(Dicstart,Dicend,text(do,T1),

                  lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        member(m(mood,inf,_),M),

        % placeholder do is infinitive

 

        % we read a word in the text that can match, i.e. is an infinitive:

        mrest(w(Onenter,Onexit,text(T,Case),L,morph(Morpht),Synt),

              Twlist,

              RTwlist),

        member(m(mood,inf,_),Morpht).        

       

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

%%%% ING form

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

 

% CASE 16

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Othertext,doing,

        12,

        m(c16,dic(doing),txt(T),12),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(doing,T1),

                     lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        /* we find a word form, lemmatized as an ing form */

        mrest(w(Onenter,Onexit,text(T,Case),L,morph(Morpht),Synt),

              Twlist,

              RTwlist),

        member(m(pos,ingform,_),Morpht).

 

 

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

%  Matching types

%  (By the light of THE moon > by the light of A full moon)

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

 

% CASE 17

 

smatch(_,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Text,Othertext,

        Sweight,

        m(c17,dic(Text),txt(OtherText),morph(Mark1),syn(Mark2),5),

        0) :-

                                 

        mrest(w(Dicstart,Dicend,text(Text,T1),

                     lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        mrest(w(Onenter,Onexit,text(OtherText,Typ1),

                     lem(TextLemma,Typ2),morph(Morpht),syn(Synt)),

              Twlist,

              RTwlist),

 

        OtherText \= Text,

        TextLemma \= Lemma,

          

        member(Dtype,M),

        member(Ttype,Morpht),

 

        corrtype(Dtype,Ttype),

 

        reapmarks_morph(M,Morpht,Marks1),

        reapmarks_syn(S,Synt,Marks2),

        accu(Marks1,Mark1),

        accu(Marks2,Mark2),

        Sweight is 4+Mark1+Mark2.   

 

                                                            

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

% Matching POS with equivalence classes in dic-clauses

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

 

% CASE 18

 

smatch(First,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,RTwlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onexit,

        Othertext,Text,

        Sweight,

        m(c18,dic(Text),txt(OtherText),morph(Mark1),syn(Mark2),5),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(Text,T1),

             lem(Lemma,T2),morph(M),syn(S)),Dicwlist,RDicwlist),

                                                              

        mrest(w(Onenter,Onexit,text(OtherText,Typ1),

                    lem(TextLemma,Typ2),morph(Morpht),syn(Synt)),

                    Twlist,RTwlist),

 

        OtherText \= Text,

        TextLemma \= Lemma,

       

        Text \= First,

        % not the clicked-on word

                      

        member(m(pos,Dpos,_),M),

        member(m(pos,Tpos,_),Morpht),

 

        corr_dicpos(Dpos,Tpos,Lemma),

 

        reapmarks_morph(M,Morpht,Marks1),

        reapmarks_syn(S,Synt,Marks2),

        accu(Marks1,Mark1),

        accu(Marks2,Mark2),

        Sweight is 3+Mark1+Mark2.   

 

 

 

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

% Crossable POS in dic-clauses

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

 

% CASE 19

 

smatch(First,Dictype,

        Hlist,

        Dicwlist,RDicwlist,

        DicNplist,

        Twlist,Twlist,

        TNplist,

        Idnum,

        Dicstart,Dicend,

        Onenter,Onenter,

        Othertext,Text,

        0,

        m(c19,dic(Text),crossdicpos,0),

        0) :-

 

        mrest(w(Dicstart,Dicend,text(Text,T1),

                 lem(Lemma,T2),morph(M),syn(S)),

              Dicwlist,

              RDicwlist),

 

        member(m(pos,Dpos,_),M),

        Text \= First,

        dic_cross(Dpos,Lemma).

 

 

 

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

%  filler-word  correspondences

%  used for one's, someone's and somebody's

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

 

correspond(oneßs,my).

correspond(oneßs,your).

correspond(oneßs,his).

correspond(oneßs,her).

correspond(oneßs,its).

correspond(oneßs,our).

correspond(oneßs,their).

 

 

correspond(oneself,myself).

correspond(oneself,yourself).

correspond(oneself,yourselves).

correspond(oneself,himself).

correspond(oneself,herself).

correspond(oneself,itself).

correspond(oneself,ourselves).

correspond(oneself,themselves).

 

issomebody(someone).

issomebody(somebody).

 

isneg(no).

isneg(noone).

isneg(nobody).

isneg(nothing).

isneg(nowhere).

isneg(not).

isneg(never).

isneg(nor).

isneg(neither).

isneg(none).

 

 

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

% classes of depleted verbs

% from the Robert/Collins prefatory matter

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

 

equaldepleted(X,Y) :-

        member(X,[be,become,come,get,go,look,seem,sound,turn]),

        member(Y,[be,become,come,get,go,look,seem,sound,turn]).

/* intransitives */

 

equaldepleted(X,Y) :-

        member(X,[do,get,give,have,lay,make,put,set,take]),

        member(Y,[do,get,give,have,lay,make,put,set,take]).

/* transitives */

 

 

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

%  matching two dic clauses : do something / doing something    

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

 

/* the strategy developed here depends on pps and nps being

crossable by 'gothrough'; otherwise, if the 'do something/doing

something' placeholder is not final in the mwu, the match will

fail because only the verb will be matched, not its args or

(pp or np) modifiers

 

NOTE: do sth and doing sth can also be jumped, with no weight assigned.

*/

 

 

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

% do sth

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

 

% CASE 20

 

doublematch(_,vp, Hlist,

           [w(Dicstart,End,text(do,T1),

             lem(do,T2),morph(M),syn(S)),

            w(End,Dicnewend,text(something,T1),

             lem(something,T2),morph(M1),syn(S1))|RDicwlist],

           RDicwlist,DicNplist,

           Twlist,RTwlist,TNplist,

           Idnum,

           Dicstart,Dicnewend,

           Onenter,Onexit,

           Text,[do,something],

           m(c20,dic(dosth),txt(Text),15),

           15) :-                      

 

           mrest(w(Onenter,Onexit,text(Text,Typ1),

                    lem(Lemma,Typ2),morph(Morpht),syn(Synt)),

                    Twlist,RTwlist),

           /* we find a word form, lemmatized as an infinitive (verb) */

           /* member(m(pos,v,_),Morpht), */

           member(m(mood,inf,_),Morpht),

           !.

 

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

% doing sth

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

 

% CASE 21

 

doublematch(_,vp, Hlist,

           [w(Dicstart,End,text(doing,T1),

             lem(do,T2),morph(M),syn(S)),

            w(End,Dicnewend,text(something,T1),

             lem(something,T2),morph(M1),syn(S1))|RDicwlist],

           RDicwlist,DicNplist,

           Twlist,RTwlist,TNplist,

           Idnum,

           Dicstart,Dicnewend,

           Onenter,Onexit,

           Text,[doing,something],

            m(c20,dic(doingsth),txt(Text),15),

           15) :-

         

           mrest(w(Onenter,Onexit,text(Text,Typ1),

                    lem(Lemma,Typ2),morph(Morpht),syn(Synt)),

                    Twlist,RTwlist),

           /* we find a word form, lemmatized as an ing form */

           member(m(pos,ingform,_),Morpht),

           !.

          

          

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

% do sth JUMPED

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

 

% CASE 22

 

doublematch(_,vp, Hlist,

           [w(Dicstart,End,text(do,T1),

             lem(do,T2),morph(M),syn(S)),

            w(End,Dicnewend,text(something,T1),

             lem(something,T2),morph(M1),syn(S1))|RDicwlist],

           RDicwlist,DicNplist,

           Twlist,Twlist,TNplist,

           Idnum,

           Dicstart,Dicnewend,

           Onenter,Onenter,

           Text,[],

           m(c22,dic(dosth),jmpd,0),

           0).

          

           

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

% doing sth JUMPED

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

 

% CASE 23

 

doublematch(_,vp, Hlist,

           [w(Dicstart,End,text(doing,T1),

             lem(do,T2),morph(M),syn(S)),

            w(End,Dicnewend,text(something,T1),

             lem(something,T2),morph(M1),syn(S1))|RDicwlist],

           RDicwlist,DicNplist,

           Twlist,Twlist,TNplist,

           Idnum,

           Dicstart,Dicnewend,

           Onenter,Onenter,

           Text,[],

           m(c22,dic(doingsth),jmpd,0),

           0).

 

 

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

% Opening 'to be' is jumpable in DIC clause

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

 

% CASE 24

 

doublematch(_,_,Hlist,

           [w(0,1,text(to,_),L,M,S),

            w(1,2,T,lem(be,_),M1,S1)|RDicwlist],

           RDicwlist,DicNplist,

           Twlist,Twlist,TNplist,

           Idnum,

           0,2,

           Onenter,Onenter,

           Text,[],

           m(c24,dic(tobe),jmpd,0),

           0) :- !.

 

 

 

 

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

% Opening Pron + be is jumpable in dic clause

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

 

% CASE 25

 

doublematch(_,s, Hlist,

           [w(0,1,text(DicText,_),_,morph(M),_),

            w(1,2,text(DicText2,_),lem(be,_),_,_)|

              RDicwlist],

           RDicwlist,DicNplist,

           Twlist,Twlist,TNplist,

           Idnum,

           0,2,

           Onenter,Onenter,

           Text,[],

           m(c25,dic(DicText,DicText2),jmpd,0),

           0) :-

 

           member(m(_,pron,_),M).

 

 

 

 

 

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

% Opening There + be is jumpable in dic clause

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

 

% CASE 25

 

doublematch(_,s, Hlist,

           [w(0,1,text(there,_),lem(there,_),_,_),

            w(1,2,_,lem(be,T2),_,_)|

             RDicwlist],

           RDicwlist,DicNplist,

           Twlist,Twlist,TNplist,

           Idnum,

           0,2,

           Onenter,Onenter,

           Text,[],

           m(c25,dic(there,be),jmpd,0),

           0).

 

 

 

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

% Opening Pron + have is jumpable in dic clause

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

 

% CASE 25

 

doublematch(_,s, Hlist,

           [w(0,1,text(DicText,_),_,morph(M),_),

            w(1,2,text(DicText2,_),lem(have,_),_,_)|

                RDicwlist],

           RDicwlist,DicNplist,

           Twlist,Twlist,TNplist,

           Idnum,

           0,2,

           Onenter,Onenter,

           Text,[],

           m(c25,dic(DicText,DicText2),jmpd,0),

           0) :-

 

           member(m(_,pron,_),M).

 

 

 

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

% Opening Pron + modaux is jumpable in dic clause

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

 

% CASE 25

 

doublematch(_,s, Hlist,

           [w(0,1,text(DicText,_),_,morph(M),_),

            w(1,2,text(DicText2,_),_,morph(M1),_)|

                RDicwlist],

           RDicwlist,DicNplist,

           Twlist,Twlist,TNplist,

           Idnum,

           0,2,

           Onenter,Onenter,

           Text,[],

           m(c25,dic(DicText,DicText2),jmpd,0),

           0) :-

 

           member(m(_,pron,_),M),

           member(m(_,modaux,_),M1).

          

 

 

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

%  somebody's displeasure ---> the displeasure of NP

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

 

% CASE 26

 

doublematch(_,Dictype, Hlist,

           [w(Dicstart,End,text(somebodyßs,T1),

             lem(Lemma,T2),morph(M),syn(S)),

            w(End,Dicnewend,text(TNindic,T1),

             lem(LNindic,T2),morph(M1),syn(S1))|RDicwlist],

           RDicwlist,DicNplist,

           Twlist,RTwlist,TNplist,

           Idnum,Dicstart,Dicnewend,

           Onenter,Onexit,

           [the,TNintext,of,Text],[somebodyßs,TNindic],

           m(c26,dic(somebodys,TNindic),txt(the,TNindic,of),20),

           20) :-

 

           /* issomebodygen(Somebodyßs),*/

           mrest(w(Onenter,Ontemp,text(the,Typ1),

                    lem(the,_),morph(Morpht),syn(Synt)),

                    Twlist,RTwlist),

           /* we find the definite article */

         

           mrest(w(Ontemp,Ontemp1,text(TNintext,Typ1),

                    lem(LNindic,_),morph(Morpht1),syn(Synt1)),

                    Twlist,RTwlist),

           member(m(pos,n,_),Morpht1),

           /* followed by the noun specified in the mwu */

          

           mrest(w(Ontemp1,Ontemp2,text(of,Typ1),

                    lem(of,_),_,_),

                    Twlist,RTwlist),    

           /* followed by *** of *** */

         

           member(np(Ontemp2,Onexit,c(S,E)),TNplist),

           /* followed by an np */          

           mrest(w(S,E,text(Text,T),_,_,_),Twlist,RTwlist).

 

 

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

% somebody's displeasure --->  NP's displeasure 

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

 

% CASE 27

 

doublematch(_,Dictype, Hlist,

           [w(Dicstart,End,text(somebodyßs,T1),

             lem(Lemma,T2),morph(M),syn(S)),

            w(End,Dicnewend,text(TNindic,T1),

             lem(LNindic,T2),morph(M1),syn(S1))|RDicwlist],

           RDicwlist,

           DicNplist,

           Twlist,RTwlist,

           TNplist,

           Idnum,Dicstart,Dicnewend,

           Onenter,Onexit,

           TNinT,[somebodyßs,TNindic],

           m(c27,dic(somebodys,TNindic),txt(TNinT),20),

           20) :-

 

                                 

        member(np(Onenter,Onexit,c(StHead,EndHead)),TNplist),

        /*  an np */          

       

        mrest(w(Sthead,Endhead,text(TNinT,Typ),

                     lem(LNindic,Typ),_,_),

              Twlist,

              RTwlist).

           /* whose head is the head noun in the mwu genitive

construction */ 

 

 

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

%  Ambiguity in dic w-clauses

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

 

/* we also need a double match when we have two dic w-clauses

for the same item; we match either one or the other, not both

(mark assignment would be wrong) */

 

% CASE 28

 

doublematch(First,Dictype,

            Hlist,

            Dicwlist,

            RDicwlist,

            DicNplist,

            Twlist,

            RTwlist,

            TNplist,

            Idnum,

            Start,End,

            Onenter,Onexit,

            Text,Lemma,

            Debug,

            Weight) :-

 

 

        mrest(w(Start,End,T,L,M,S), % first lemmatization

                Dicwlist,

                [w(Start,End,T,L1,M1,S1)|RDicwlist]),

                % second lemmatization

 

        ( smatch(First,Dictype,

                 Hlist,

                 [w(Start,End,T,L,M,S)],

                 RDicwlist,

                 DicNplist,

                 Twlist,RTwlist,

                 TNplist,

                 Idnum,

                 Start,End,

                 Onenter,

                 Onexit,

                 Text,

                 Lemma,

                 Weight,

                 Debug,

                 _)

             

          ; 

          smatch(First,Dictype,

                 Hlist,

                 [w(Start,End,T,L1,M1,S1)],

                 RDicwlist,

                 DicNplist,

                 Twlist,

                 RTwlist,

                 TNplist,

                 Idnum,

                 Start,End,

                 Onenter,

                 Onexit,

                 Text,

                 Lemma,

                 Weight,

                 Debug,

                 _)

          ).

 

 

          

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

% BONUSES FOR BETTER MATCHING                                   

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

 

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

% WENVIR : computing weight for matched environments

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

 

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

% COLLECTLEMMAS: collecting wordforms and lemmas in the textual chunk

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

 

/* collectlemmas(TextualChunk,Lemmalist,WordList) */

/* Lemmalist is a list of t-structures:

   t(Word,Lemma) */

/* WordList is a list of textual wordforms */

  

% end of recursion:

collectlemmas([],[],[]).

 

% general case:

collectlemmas([w(StPos,EndPos,text(TextWord,Typ1),

                        lem(Lemma,Typ),Morph,Syn)|Remainder],

              [t(TextWord, Lemma)|Others],

              [TextWord|More]) :-

        collectlemmas(Remainder,Others,More).

 

% punctuation :

collectlemmas([punct(_,_,_)|Remainder],Others,More) :-

        collectlemmas(Remainder,Others,More).

 

 

 

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

% GETLEMW : retrieving the lemmas of the clicked-on words

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

 

getlemw([],_,[]).

 

getlemw([[Clw1,Clw2]|Tail],Twlist,[Lemclw|Tail2]) :-

        (sub_getlemw(Clw1,Twlist,Lemclw)

        ;

        sub_getlemw(Clw2,Twlist,Lemclw)),

        getlemw(Tail,Twlist,Tail2).

 

getlemw([Clw|Tail],Twlist,[Lemclw|Tail2]) :-

        sub_getlemw(Clw,Twlist,Lemclw),

        getlemw(Tail,Twlist,Tail2).

 

sub_getlemw(Clw,Twlist,Lemclw) :-

        string_lower(Clw,Lowerclw),

        member(w(_,_,text(Lowerclw,_),lem(Lemclw,_),_,_),Twlist).

 

 

 

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

% ENOUGH : 'plausibility check' of handle

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

 

/*

enough(TWL,Hlist,Type,Lemmalist) fails or succeeds.

All args are +.

'Enough' succeeds if the intersection of the lemma list associated

with the textual chunk, and the handlelist associated with the

candidate mwu entry, is large enough

*/

                 

enough(TWL,Hlist,Type,Clwlist) :-

        % Clwlist is Lemmalist

        listl_no_or(Hlist,GlobalNhandles),

        listl_no_or_or_cor(Clwlist,Hlist,CleanNhandles),

        checkratio(GlobalNhandles,CleanNhandles,Nhandles),

        ifthenelse(GlobalNhandles>2,

                   Hdwd_weight is 2,

                   Hdwd_weight is 1),

        myintersection(Hlist,TWL,Clwlist,Hdwd_weight,Nlemmas),

       

        % ok checks whether the acceptance level is reached:

        ok(Nhandles,Minimum,Type),

       

        Nlemmas >= Minimum.

 

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

% Checkratio: prevents the handlelist from too severe a reduction

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

 

% can't reduce 1 :

checkratio(1,B,1) :- !.

 

% New number B accepted if at least 2:

checkratio(A,B,B) :-

  B >= 2,

  !.

 

% 2 and 1 yields 1:

checkratio(2,1,1) :- !.

 

% otherwise don't get lower than 2:

checkratio(A,B,2).

 

 

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

% MYINTERSECTION

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

 

/* this predicate is less general than intersection, because

the call on init is more specific than a call on member - see

intersection below */

/* Hdwd_weight is the special weight assigned to the headword in

the lemmalist */

 

%%%%%%%%%%%% success on head:

 

% normal word:       

myintersection([[p,W,L]|Others],TWL,Clwlist,Hdwd_weight,Commonnumber) :-

        init([p,W,L],TWL),

        (not(neglect(W)) ; member(L,Clwlist)),

        !,

        myintersection(Others,TWL,Clwlist,Hdwd_weight,Newnumber),

        Commonnumber is Newnumber + 1.

 

 

% member of an OR-pair:                            

myintersection([[or,W,L]|Others],TWL,Clwlist,Hdwd_weight,Commonnumber) :-

        init([or,W,L],TWL),

        (not(neglect(W)) ; member(L,Clwlist)),

        !,

        myintersection(Others,TWL,Clwlist,Hdwd_weight,Newnumber),

        Commonnumber is Newnumber + 1.

 

       

% the headword ipse:

% Double value if element is headword:

myintersection([[p_h,W,L]|Others],TWL,Clwlist,Hdwd_weight,Commonnumber) :-

        init([p_h,W,L],TWL),

        (not(neglect(W)) ; member(L,Clwlist)),

        !,

        myintersection(Others,TWL,Clwlist,Hdwd_weight,Newnumber),

        Commonnumber is Newnumber + Hdwd_weight.

 

 

% the headword in an OR-pair:                            

myintersection([[or_h,W,L]|Others],TWL,Clwlist,Hdwd_weight,Commonnumber) :-

        init([or_h,W,L],TWL),

        (not(neglect(W)) ; member(L,Clwlist)),

        !,

        myintersection(Others,TWL,Clwlist,Hdwd_weight,Newnumber),

        Commonnumber is Newnumber + Hdwd_weight.

 

 

%%%%%%%%%%%% failure on head:

 

myintersection([First|Others],TWL,Clwlist,Hdwd_weight,R) :-

        % not(init(First,TWL)),

        myintersection(Others,TWL,Clwlist,Hdwd_weight,R).

 

 

        %  end of recursion :                     

myintersection([],_,_,_,0).    

 

 

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

% INTERSECTION

% General predicate for building the intersection of 2 lists

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

 

% success on head

intersection([X|Xs], Second,[X|Rest]) :-

        member(X,Second),!,

        intersection(Xs,Second,Rest).

       

% failure on head        

intersection([X|Xs],Second,Rest) :-

     /*   not( member(X,Second) ),*/

        intersection(Xs,Second,Rest).

       

% end of recursion

intersection([],_,[]).    

 

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

% REAPMARKS_morph/syn : reaps marks for the parsing tags of individual words

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

 

% disabled (morphology tags):

reapmarks_morph(M1,M2,[0]) :-

        recorded(stg,[reapmarks_m,0],_),!.

 

% reaping:

reapmarks_morph(M1,M2,Marks) :-

        intersection(M1,M2,L),

        gothroughlistm(L,Marks).

 

 

 

% disabled (syntactical tags):

reapmarks_syn(S1,S2,[0]) :- recorded(stg,[reapmarks_s,0],_),!.

 

% reaping: 

reapmarks_syn(S1,S2,Marks) :-

        intersection(S1,S2,L),

        gothroughlists(L,Marks).

 

 

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

%  gothroughlistm(L,Marks)

% the Weight is third arg of m(Type,Value,Weight) structures

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

 

gothroughlistm([m(_,_,W)|R],[W|Others]) :-

        gothroughlistm(R,Others).

 

gothroughlistm([],[]).

 

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

%  gothroughlists(L,Marks)

%  the Weight is third arg of s(Type,Value,Weight,Direction) structures

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

 

gothroughlists([s(_,_,W,_)|R],[W|Others]) :-

        gothroughlists(R,Others).

 

gothroughlists([],[]).

 

 

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

% INIT: membership of a lemma in the handlelist for the mwu

%       or correspondence between lemma and toolword class (TWClass)

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

 

init([_,_,Lemma],[t(_,Lemma)|Rest]) :- !.

 

init(Pair,[X|Rest]) :-

       init(Pair,Rest).

 

 

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

% CORRTYPE : correspondence between types (for smatch)

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

 

corrtype(m(type,X,_),m(type,X,_)) :-

        nonvar(X),

        X \= finite.

 

corrtype(m(type,indef,_),m(type,def,_)).

corrtype(m(type,def,_),m(type,indef,_)).

 

corrtype(m(case,gen,_),m(case,gen,_)).

                    

corrtype(m(case,gen,_),m(type,art,_)).

corrtype(m(case,gen,_),m(type,indef,_)).

corrtype(m(case,gen,_),m(type,def,_)).

 

corrtype(m(type,art,_),m(case,gen,_)).

corrtype(m(type,def,_),m(case,gen,_)).

corrtype(m(type,indef,_),m(case,gen,_)).

 

 

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

% CORR_DICPOS : correspondence between POS

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

 

corr_dicpos(X,X,Word) :- nonvar(X), licitpos(X,Word).

corr_dicpos(det,num,_).

corr_dicpos(num,det,_).

 

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

% LICITPOS : matchable pos

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

 

licitpos(adv,Word) :- not(isprep(Word)).

licitpos(cconj,_).

licitpos(sconj,_).

licitpos(det,_).

licitpos(excl,_).

licitpos(num,_).

licitpos(pron,_).

 

      

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

% OK

%  ok(Length_of_handlelist,

%      Minimum_number_of_items_in_textual_chunk,

%      Type) */

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

 

% Type is either p: phrasal or s: sentential

 

% phrasal

 

% no margin

ok(1,1,p).

ok(2,2,p).

ok(3,3,p).

ok(4,4,p).

 

% margin of 1

ok(5,4,p).

 

% margin of 2

ok(6,4,p).

ok(7,5,p).

ok(8,6,p).

 

% margin of 3

ok(9,6,p).

ok(10,7,p).

 

% margin of 4

ok(11,7,p).

ok(12,8,p).

ok(13,9,p).

 

 

/* clausal */

 

ok(1,1,s).

ok(2,2,s).

ok(3,3,s).

ok(4,4,s).

ok(5,5,s).

 

ok(6,5,s).

 

ok(7,5,s).

 

ok(8,5,s).

ok(9,6,s).

ok(10,7,s).

ok(11,8,s).

ok(12,9,s).

 

ok(13,9,s).

ok(14,10,s).

 

ok(15,10,s).

 

 

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

% TRANSLATE :  translates all types to p(phrasal) except s

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

 

translate(s,s) :- !.

translate(_,p).

 

 

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

% phrasal versus clausal dictypes

% only s is clausal

% NOT used now

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

 

phrasal(p).

phrasal(np).

phrasal(vp).

phrasal(pp).

phrasal(adjp).

phrasal(advp).

          

clausal(s).

 

 

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

% COMPATIBLE: compatibility of voice or polarity

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

 

/* compatible(DicPo,TextPo) */

/* works out compatibility in polarity between the dic entry and

the textual chunk */

/* if the dic clause is neg, the textual chunk must be neg too */

 

compatible(neg(1),neg(1)).

compatible(neg(0),neg(1)).

compatible(neg(0),neg(0)).

 

/* compatible(DicVoice,TextVoice) */

/* works out compatibility in voice between the dic entry and

the textual chunk */

/* if the dic clause is pass, the textual chunk must be pass too */

 

compatible(passive(1),passive(1)).

compatible(passive(0),passive(1)).

compatible(passive(0),passive(0)).

 

 

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

% LOOKUPTXTCOLLS pred :

% records all Roget-related idnums for all txt collocates

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

 

lookuptxtcolls([]) :- !.

 

lookuptxtcolls([Coll|Tail]) :-

        lookup(Coll),

        lookuptxtcolls(Tail).

 

/* the Item is the collocate in text, i.e. the subject, object,

etc. of the clicked-on word, as recorded in the syntactic

relation box associated with the textual w-list - its distance

from a dictionary-specified collocate is to be measured by

various means, among which checking whether the two items share

a category in Roget */

 

lookup(csubj(Item,_)) :- look_in_roget(Item),!.

lookup(cdobj(Item,_)) :- look_in_roget(Item),!.

lookup(ciobj(Item,_)) :- look_in_roget(Item),!.

lookup(cadj(_,Item)) :-  look_in_roget(Item),!.

lookup(cnn(_,Item)) :-   look_in_roget(Item),!.

lookup(cnn(Item,_)) :-   look_in_roget(Item),!.

lookup(cadva(_,Item)) :- look_in_roget(Item),!.

lookup(cadvv(_,Item)) :- look_in_roget(Item),!.

lookup(ccplt(Item,_)) :- look_in_roget(Item),!.

 

lookup(_).

 

 

look_in_roget(Item) :-

        not(recorded(coll_in_roget,[Item|_],_)),

        retrieveb(roget,Item,r(Item,Listofidnums)),

        recorda(coll_in_roget,[Item,Listofidnums],_),

        !.

 

look_in_roget(_).

 

 

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

% assessing whether two matches are 'identical'

% we disregard debug info

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

 

same(m(Idnum,DicOrigin,_,DicLemma,DicTrans,Debug),

     m(Idnum,DicOrigin,_,DicLemma,DicTrans,_)).

                  

 

 

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

% ordering matches and checking for identity

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

 

% we do not keep an identical match 

order(W-H,W1-H1,del) :-

        W=W1,

        same(H,H1),

        !.

       

% we keep a match with identical weight if it differs

% from the one we have in sth else than just debug info 

order(W-H,W1-H1,keep) :-

        W=W1.

 

order(W-H,W1-H1,smaller) :-

        W<W1.

   

order(W-H,W1-H1,bigger) :-

        W>W1.

 

 

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

% adapted splitting for a quisort that also

% removes duplicate solutions

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

% we do not keep identical solutions

 

split(W-H,[W1-H1|X],Y,Z):-

        order(W-H,W1-H1,del) ,

        split(W-H,X,Y,Z).

 

 

% we keep solutions with the same weight,

% provided they differ from each other

% somewhere else than just in debug info slot

 

split(W-H,[W1-H1|X],Y,[W1-H1|Z]):-

        order(W-H,W1-H1,keep) ,

        split(W-H,X,Y,Z).

 

 

% we put the heavy solutions in front

 

split(W-H,[W1-H1|X],[W1-H1|Y],Z):-

        order(W-H,W1-H1,bigger) ,

        split(W-H,X,Y,Z).

 

 

% we put the lighter solutions behind the heavier ones

 

split(W-H,[W1-H1|X],Y,[W1-H1|Z]):-

        order(W-H,W1-H1,smaller) ,

        split(W-H,X,Y,Z).

 

                           

% getting out of recursion

split(_,[],[],[]).

 

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

% quisort and removal of duplicate solutions

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

 

sortremdup([W-H|T],S) :-

        split(W-H,T,A,B),

        sortremdup(A,A1),

        sortremdup(B,B1),

        append(B1,[W-H|A1],S),!.

         

sortremdup([],[]) :- !.

sortremdup([W-H],[W-H]) :- !.

 

       

first([H|T],H).

 

 

 

 

 

 

 

 

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

% THE SINGLE WORD-UNIT MATCHER

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

 

 

 

 

 

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

% SIMPLEMATCH : arity 4

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

 

/* args for simplematch :

txt(...): as read in from the text chunk file where :

        Twlist: list of w-clauses for the input textual chunk;

        Clw: clicked-on word (simulated)

        TNplist: list of np's in the textual chunk

        TCollocList: list of syntactic relations in the textual chunk

        TPolarity: clause polarity: either neg(1) or neg(0)

        TType: nature of the chunk (phrasal or sentential)

 

Idnum: identification number of the sdic entry

m(_): results copied over to be displayed to the user

Weight: weight assigned to the match

 

Example of a txt term : see mm.ari

 

Example of an sdic-clause:

second sdic-clause for the item ADVANCE

 

sdic(

        29801, % Idnum

        'advance', % DicLem

        'vtr', % DicPos

        sc(['work','civilization','mankind','person',

                society','knowledge', technique']), % subject coll

        oc([nil]), % object coll

        ind(['progress']), % indicator

        lab([nil]), % labels

        env([nil]), % environment

        sst([nil]), % NOT USED source text style

        head([nil]),% head

        sf([nil]),  % NOT USED semantic features

        st(nil),    % NOT USED countability status

        xr([nil]),  % NOT USED cross ref

        gt(nil),    % NOT USED cross ref

        tr($progresser, faire des progres$), % translation

        rat(2,41),  % translation freqency: this tr/all tr

        gl(nil),  % gloss

        efm).     % origin

        

*/

 

 

simplematch(txt(s,Clw,Twlist,TNplist,TCollocList,TPolarity,TVoice,TType),

            Idnum,

            Clw,

            [Weight,m(Idnum,Origin,DicLem,Translation,Ratio,Debug)]) :-

 

        string_lower(Clw,LowerClw),

        getlemw(LowerClw,Lemclw,Twlist,TempTextPos,Case),

        translatecase(Lemclw,Case,TempHandleword),

        check_morph(TempHandleword,Handleword,TempTextPos,TextPos),

        getlemmas(Twlist,Lemclw,LemmaList),

        write([Handleword,TextPos]), nl,

 

        (retrieveb(sdico,

                   Handleword,

                   sdic(Idnum,

                   DicLem, % Handleword and DicLem are identical

                   DicPos,

                   sc(Precollist),

                   oc(Postcollist),

                   ind(Indicator),

                   lab(Label),

                   env(Envir),

                   sst(Sstyle),

                   head(Head),

                   sf(SemFeat),

                   st(Status),

                   xr(Xref),

                   Gothere,

                   tr(Translation),

                   rat(Trfreq,Trtotal),

                   gl(Gloss),

                   Origin))            

 

;

 

        Clw \= Handleword,

         retrieveb(sdico,

                   Clw,

                   sdic(Idnum,

                   DicLem, % Clw and DicLem are identical

                   DicPos,

                   sc(Precollist),

                   oc(Postcollist),

                   ind(Indicator),

                   lab(Label),

                   env(Envir),

                   sst(Sstyle),

                   head(Head),

                   sf(SemFeat),

                   st(Status),

                   xr(Xref),

                   Gothere,

                   tr(Translation),

                   rat(Trfreq,Trtotal),

                   gl(Gloss),

                   Origin))

                   ), 

    /* retrieving a candidate sdic clause on the basis of either

the textual variant or the lemma of the selected word */

 

        write(Translation),

        nl,

        weigh(LowerClw,

              DicLem,

              Twlist,

              LemmaList,

              TNplist,

              TCollocList,

              TPolarity,

              TVoice,

              Idnum,

              Lemclw,

              TextPos,

              DicPos,

              Translation,

              Gloss,

              Precollist,

              Postcollist,

              Label,

              Envir,

              Indicator,

              Sstyle,

              Head,

              Xref,

              Weight,

              Debug),

         freqbonus(Trfreq,Trtotal,Ratio).

 

        

 

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

% WEIGH : arity  24

% notice that all predicates must succeed

% failure is converted to 0 weight:

% basicpos, wpos, whead, wcol, wlabel, windic

% so that the weighting flow is not interrupted

% by unsuccessful candidates

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

     

weigh(LowerClw,

      DicLem,

          Twlist,

          LemmaList,

          TNplist,

          TCollocList,

          TPolarity,

          TVoice,

          Idnum,

          Lemclw,

          TextPos,

          DicPos,

          Translation,

          Gloss,

          Precollist,

          Postcollist,

          Labels,

          Envir,

          Indicator,

          Sstyle,

          Head,

          Xref,

          Weight,

          Debug) :-

       

        identitybonus(DicLem,LowerClw,IdentityBonus), 

 

        % we prioritize a dictionary entry whose headword

        % is identical to the lower-cased clicked-on word

        % -spellbound- is preferred to -bind-

        % (spellbound is lemmatized as bind by the parser)

        % the bonus is minimal (10) in so far as the wordform

        % - an ing-form for instance -

        % sometimes does need to be associated with the corresponding

        % verb, even if the ingform is a headword

        % ---they were backing the wrong horse---

        % versus ---in need of financial backing---

 

 

        basicpos(TextPos,ColPos),

       

        % ColPos is the POS in the syntactic rel box in text clause          

        

 

        wpos(TextPos,DicPos,TCollocList,Lemclw,W1,PosDebug),

       

    [!  wcoll(pre,Lemclw,_,ColPos,Precollist,TCollocList,W2,CPreDeb),

        wcoll(post,Lemclw,_,ColPos,Postcollist,TCollocList,W3,CPostDeb),

       

        wenvir(Lemclw,Twlist,Envir,W4,EnvirDebug),

       

        whead(Clw,Lemclw,Twlist,Head,W6,HeadDebug),

       

        wlabel(Lemclw,Labels,CleanLabList,

               TNplist,Twlist,LemmaList,W7,LabelDebug),

        case([W7>100 -> W7n is 15,

               W7>50 -> W7n is 12,

               W7>30 -> W7n is 10,

               W7>20 -> W7n is 8,

               W7>10 -> W7n is 6,

               W7>4 -> W7n is 5|

               W7n = W7]), 

 

                       

        % windic cannot be backtracked into (gets bogged down) - better to use

        % the set-of predicate to collect info from the dics

        % in the clauses for windic itself

 

         windic(CleanLabList,DicLem,TCollocList,LemmaList,

               Indicator,W8acc,IndicDebug)  ,

 

 

         flat(W8acc,Wflat),

                  accu(Wflat,W8) ,       

         case([W8>100 -> W8n is 22,

               W8>50 -> W8n is 18,

               W8>30 -> W8n is 16,

               W8>20 -> W8n is 15,

               W8>12 -> W8n is 13|

               W8n = W8]), 

      

            

        flatlist(CPreDeb,C1),

        flatlist(CPostDeb,C2),

        flatlist(LabelDebug,Ldbg)  ,

        flatlist(IndicDebug,Idbg),

              

        Weight is W1+W2+W3+W4+W6+W7n+W8n+IdentityBonus,

        flatlist([PosDebug,C1,C2,EnvirDebug,HeadDebug,Ldbg,Idbg],Debug) !].

       

 

 

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

%  POS

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

 

wpos(TextPos,DicPos,TCollocList,Lemclw,Weight,

                [pos(Weight1),vb(Weight2)]) :-

        corrpos(TextPos,DicPos,Weight1),

        getverbbonus(DicPos,TCollocList,Lemclw,Weight2),

        Weight is Weight1 + Weight2,

        !.

 

/* avoid failure */

wpos(_,_,_,_,1,[]).

 

 

 

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

% HEAD

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

 

 

% head ponderation is disabled

whead(_,_,_,_,0,[]) :-

        recorded(stg,[head_hmatch,0],_), !.

 

% no head in sdic clause: return 0

whead(_,_,_,[nil],0,[]) :- !.

 

% Text head is found in Headlist

 

whead(Clw,Lemma,Twlist,Headlist,W,hdf(Nextword,W)) :-

        member(w(Start,Next,_,lem(Lemma,_),morph(Morphlist),_),Twlist),

        member(m(pos,n,_),Morphlist),

        member(w(Next,N2,_,lem(Nextword,_),_,_),Twlist),

        member(Nextword,Headlist),

        recorded(stg,[head_hmatch,W],_),

        !.

 

% Text head metameets/rogetmeets/wordnetmeets with a member of Headlist

% (cf. abortion law/bill)

 

whead(Clw,Lemma,Twlist,Headlist,Weight,

      hd(DicHead,Nextword,

           mt(Weight1),rg(Weight2),

           wn(Weight3),bonus(Weight4),tot(Weight))) :-

        member(w(Start,Next,_,lem(Lemma,_),morph(Morphlist),_),Twlist),

        member(m(pos,n,_),Morphlist),

        member(w(Next,N2,_,lem(Nextword,_),morph(Morphlist),_),Twlist),

        member(m(pos,n,_),Morphlist),

        member(Dichead,Headlist),

        ifthenelse(recorded(stg,[head_meta,1],_),

                   metameet(Dichead,Nextword,Weight1),

                   Weight1 is 0),

        ifthenelse(recorded(stg,[head_roget,1],_),

                   rogetmeet(Dichead,Nextword,Weight2),

                   Weight2 is 0),

        ifthenelse(recorded(stg,[head_wn,1],_),

                   wordnetmeet(item(Dichead,Pos,_),

                                item(Nextword,Pos,_),Weight3),

                   Weight3 is 0),

        recorded(stg,[head_bonus,Weight4],_),

        Weight is Weight1 + Weight2 + Weight3 + Weight4,

        Weight \= Weight4,

        !.

 

% Bonus is granted if clw had a head in the text (N1N2 combination),

% even if no link can be established with the dictionary head.

 

whead(Clw,Lemma,Twlist,Headlist,W,hd(Nextword,W)) :-

        member(w(Start,Next,_,lem(Lemma,_),morph(Morphlist),_),Twlist),

        member(m(pos,n,_),Morphlist),

        member(w(Next,N2,_,lem(Nextword,_),morph(Morphlist),_),Twlist),

        member(m(pos,n,_),Morphlist),

        recorded(stg,[head_bonus,W],_),

        !.

 

% avoid failure, but with penalty if sdic requires a head and Clw has

% none

 

whead(_,_,_,_,W,hd(penalty,W)) :-

        recorded(stg,[head_penalty,W],_),!.

   

whead(_,_,_,_,0,[]).

 

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

% Dealing with labels

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

%  pattern :  wlabel(Lemclw,Labels,

%  CleanLabels,TNplist,Textwlist,W7,LabelDebug)

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

 

% Matched item has no label:

 

wlabel(Lemclw,[nil],[],_,_,_,0,[]) :- !.

 

wlabel(Lemclw,[],[],_,_,_,0,[]) :- !.

 

 

% Matched item has a lablist, but it does not contain

% a single significant label:

 

wlabel(Lemclw,Lablist,[],NPlist,Textwlist,Lemmalist,0,[]) :-

        cleanlabs(Lablist,Clean),

        Clean=[],

        !.

 

 

% 'standard' case:

 

wlabel(Lemclw,Lablist,Clean,NPlist,Textwlist,LemmaList,

       Weight,Debug) :-

      

        cleanlabs(Lablist,Clean),

        getnpheads(Lemclw,NPlist,Textwlist,Headlist1),

        remdup(Headlist1,Headlist),

        getlabels(Headlist,ToMatchList),

        getgrouplabels(Textwlist,Grouplabels),

        append(ToMatchList,Grouplabels,Matchall),

        [! flatlist(Matchall,TMflat),

           cleanlabs(TMflat,TMclean) !],

        connected(Clean,TMclean,Weights1,Debug),

        [! flat(Weights1,Wflat1),

        accu(Wflat1,Weight) !].

       

   

/* avoid failure */

 

wlabel(_,_,[],_,_,_,0,[]).

       

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

% Getting heads of NPs in TextNPList

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

% Pattern: getnpheads(NPlist,Textwlist,Headlist)

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

 

getnpheads(_,[],_,[]).

 

getnpheads(Head,[np(S,E,c(Sc,Ec))|Othernps],Textwlist,

            OtherHeads) :-

        member(w(Sc,Ec,T,lem(Head,Type),_,_),Textwlist),

        getnpheads(Head,Othernps,Textwlist,OtherHeads).

 

 

getnpheads(Lemclw,[np(S,E,c(Sc,Ec))|Othernps],Textwlist,

            [Head|OtherHeads]) :-

        member(w(Sc,Ec,T,lem(Head,Type),_,_),Textwlist),

        Lemclw \= Head,

        getnpheads(Lemclw,Othernps,Textwlist,OtherHeads).

 

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

% Getting labels of NP-headList

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

% pattern: getlabels(Headlist,LabelsToMatch)

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

 

 

getlabels([Head|Otherheads],[Labellist|OtherLabLists]) :-

        findall(Label,

              retrieveb(

                             sdico,Head,

                             sdic(A,Head,n,B,C,D,lab(Label),E,F,G,H,

                                   I,J,K,L,M,N,O)

                             ),

              Labellist),

        getlabels(Otherheads,OtherLabLists).                 

 

getlabels([],[]).       

 

 

 

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

% getting labels of mwu's

% restricted to adj-n, n-n, and v-part units

% getgrouplabels(Textwlist,Grouplabels)

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

 

getgrouplabels(Twlist,Flatlab) :-

        adjn(Twlist,Adjns),

        nn(Twlist,Nns),

        vpart(Twlist,Vparts),

        append(Adjns,Nns,L1),

        append(L1,Vparts,Groups),

        getgrlabels(Groups,Labels),

        [! flatlist(Labels,Flatlab) !].

       

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

% adjn(Twlist,LabelsofAdjn)

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

 

% end of recursion:

adjn([],[]).

 

% standard case:

adjn(Twlist,[Adjnstring|Others]) :-

        gradjn(Twlist,Adjnstring,RTwlist),

        adjn(RTwlist,Others),!.

 

% avoid failure:       

adjn(_,[]).       

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

 

gradjn(Twlist,Adjnstring,RTwlist) :-

         mrest(w(St,Temp,T1,

                     lem(Adj,_),morph(M1),_),

               Twlist,

               Reste1), 

         mrest(w(Temp,End,T2,

                     lem(N,_),morph(M2),_),   

              Reste1,

              RTwlist),             

         member(m(pos,adj,_),M1),

         member(m(pos,n,_),M2),

         concat([Adj,' ',N],Adjnstring).                   

 

       

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

% nn(Twlist,Labelsofnn)

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

 

% end of recursion:

nn([],[]).

 

% standard case:

nn(Twlist,[Nnstring|Others]) :-

        grnn(Twlist,Nnstring,RTwlist),

        nn(RTwlist,Others),!.

 

% avoid failure:       

nn(_,[]).       

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

 

grnn(Twlist,Nnstring,RTwlist) :-

         mrest(w(St,Temp,T1,

                     lem(N1,_),morph(M1),_),

               Twlist,

                   Reste1),

         mrest(w(Temp,End,T2,

                     lem(N2,_),morph(M2),_),   

              Reste1,

              RTwlist),             

         member(m(pos,n,_),M1),

         member(m(pos,n,_),M2),

         concat([N1,' ',N2],Nnstring).                   

 

       

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

% vpart(Twlist,Labelsofvpart)

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

 

% end of recursion:

vpart([],[]).

 

% standard case:

vpart(Twlist,[Vpartstring|Others]) :-

        grvp(Twlist,Vpartstring,RTwlist),

        vpart(RTwlist,Others),!.

 

% avoid failure:       

vpart(_,[]).       

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

 

grvp(Twlist,Vpartstring,RTwlist) :-

         mrest(w(St,Temp,T1,

                     lem(V,_),morph(M1),_),

               Twlist,

               Reste1),

         mrest(w(Temp,End,T2,

                     lem(Part,_),morph(M2),_),   

              Reste1,

              RTwlist),             

         member(m(pos,v,_),M1),

         member(m(type,adv_part,_),M2),

         concat([V,' ',Part],Vpartstring).                   

 

 

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

% getgrlabels(Groups,Labels)

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

% getting labellists for the list of

% potential mwu's of the types

% adj-n, n-n, v-part

% in textual chunk w-list

% presupposes the existence of a dico

% where mwu's are indexed on the diclemma

% the I field in

% dic(A,B,C,D,E,F,G,H,I,etc.)

% in which the index is provided by the

% variable inside the le(Mwu) structure,

% i.e. Mwu

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

 

% empty clause to be used until dic is indexed on

% lemma as well as inh clause:

% getgrlabels(_,[]).

 

 

% end of recursion:

getgrlabels([],[]).

 

 

getgrlabels([Mwu|Mwus],[Lablist|Lablists]) :-

        findall(Labs,

                retrieveb(mwutree,Mwu,

                        dic(A,B,C,D,E,F,G,H,le(Mwu),I,J,K,L,

                            lab(Labs),M,N,O,P,Q,R)),

                Lablist),!,           

        getgrlabels(Mwus,Lablists).

 

 

% avoid failure:

getgrlabels([_|Tail],Others) :-

        getgrlabels(Tail,Others).

 

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

% assessing connectedness between labellists

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

 

connected([Lab|OtherLabs],MatchedList,[W|Ws],[Dbg|Dbgs]) :-

        connect(Lab,MatchedList,W,Dbg),

        connected(OtherLabs,MatchedList,Ws,Dbgs).

       

       

connected([],_,[0],[]).       

 

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

% assessing connectedness between labels

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

 

connect(Lab,[Labm|OtherLabms],[W1|Weights],[Dbg|Dbgs]) :-

        lablinkweight(Lab,Labm,W1,Dbg),

        connect(Lab,OtherLabms,Weights,Dbgs).

       

       

      

connect(_,[],0,[]).      

 

 

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

% retrieving connectedness between labels

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

 

% data: lablink(LabelOne,LabelTwo,LinkWeight)

% where 0<Linkweight<1

 

 

% same label on either side:

lablinkweight(L,L,4,label(L,4)) :-

        nonvar(L),

        !.

 

% get weight from a list of lablink facts:       

 

lablinkweight(L1,L2,Weight,label(L1,L2,Weight)) :-

        lablink(L1,L2,W),

        !,

        W1 is  W/3,

        W2 is round(W1,0),

        ifthenelse(W2=0,Wnew is 1,Wnew is W2),

        ifthenelse(Wnew>3,Weight is 3, Weight is Wnew).

        

 

 

% no link:

% does duty as 'avoid failure'

 

lablinkweight(L1,L2,0,[]).

 

 

 

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

% Cleaning labellist

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

 

cleanlabs([],[]) :- !.

 

cleanlabs([Significant|Others],[Significant|Clean]) :-

        keeplabel(Significant),

        !,

        cleanlabs(Others,Clean).

 

cleanlabs([_|Others],Clean) :-

        cleanlabs(Others,Clean),

        !.

 

 

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

% CLEANING INDICATOR FIELD

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

 

 

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

% we return the last word of the indicator (retindic)

% and check that it is not a toolw (throwaway)

% this procedure can be used if a full parsing scheme for

% the whole indic field proves unnecessary

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

 

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

% Returning the core of the indicator string

% i.e simply its last element

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

 

% no space in string - return the whole string:

 

 

retindic(Str,Str) :-

        not(string_search(' ',Str,Loc)),!.

 

 

 

% return the last element

% if cut is removed, will return more string, from the end up to

% the next space backwards:

%  applied to $a and b and c$ it will return successively,

% on backtracking:

% c -- and c -- b and c -- and b and c -- FAIL

 

 

retindic(Str,Indic) :-

        list_text(List,Str),

        reverse(List,Reverse),

        list_text(Reverse,Rstr),

        string_search(' ',Rstr,Loc),

        string_length(Str,Length),

        Start is Length - Loc,

        substring(Str,Start,Loc,Indic),

        !.

 

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

%% throwaway if toolword or high frequency word

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

 

throwaway(X) :- toolw(X),!.

 

 

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

% Dealing with Indicator

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

 

% pattern:

% windic(Labs,DicLem,TCollocList,

%        LemmaList,Indicator,Weight,Debug)

 

% Labs is the clean Label List associated with the

% clicked-on word

 

% DicLem is the lemmatized clicked-on word

 

% TCollocList is the list of SYN REL in the textual chunk

 

% LemmaList is the list of all non-toolwords in textual

% w-list

 

% for both TCollocList and LemmaList

% we should exclude, not only toolwords, but very high frequency

% items as well

 

% After paring the indicator down to its putative head

% we work with a

 

% Two-pronged match:

 

% 1 within the text

 

% INDIC and TEXT

% we match the indicator against all textual lemmas

% the match is either identity or roget-meet of the

% finest two levels

 

 

% 2 calling on the dics

 

% |A|

% INDIC and BI and TEXT

% we go through the TCollocList looking for the clicked-on word

% in the position of collocate with respect to a collocate-bearer (e.g.

% clicked-on word in object position)

% we retrieve from the ***bilingual dic*** (sdic) the collocate bearer

% we match the relevant collocate list of the collocate bearer

% as against the indicator

% the match is the usual type of indicmatch described above

 

% |B|

% INDIC and MONO and TEXT

% we start from the couples Indicator-Lemma

% to retrieve the right reading of the Lemma in the mono

% we explore the DEFlexlist and EXlexlist of the Lemma in the monolingual

% dictionary and we match it as against the collocate bearers and collocate lists

% retrieved from the textual syn rel slot and dictionanry look-up of |A|

 

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

 

% no indic

 

windic(Labs,DicLem,TCollocList,LemmaList,[nil],0,[]) :- !.

 

 

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

% exploration types 1 and 2A-B:

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

 

windic(Labs,DicLem,TCollocList,LemmaList,[Indicator|Others],

                 [Weight|OtherWeights],[Debug1,Debug2|Debugs]) :-

 

        retindic(Indicator,CleanIndic),

        ifthenelse(throwaway(CleanIndic), % Condition

       

                    (Weight=0,Debug1=[],Debug2=[]), % Then Action : discard

               

                    (look_in_rgt(CleanIndic,Rogindic), % Else Action

                   

                    % Type 1:

                     indicmatch1(Rogindic,CleanIndic,LemmaList,

                             Weights1,Debug1),

                     [! flat(Weights1,Wflat1),

                     accu(Wflat1,Weight1) !] ,

                    

                   % Type 2AB

                   indicmatch2(Labs,Rogindic,CleanIndic,DicLem,

                            TCollocList,Weights2,Debug2),

                    [! flat(Weights2,Wflat2),

                    accu(Wflat2,Weight2) !],

                    Weight is Weight1+Weight2)

                   ),

                 

        windic(Labs,DicLem,TCollocList,LemmaList,

              Others,OtherWeights,Debugs).

 

 

/* end of recursion */

 

windic(Labs,DicLem,TCollocList,Lemmalist,[],0,[]).

 

/* avoid failure */

 

% windic(_,_,_,_,[],0,[]).        

 

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

% Matching Indicator against list of lemmas

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

 

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

% Pattern : indicmatch1(Rogindic,Indic,LemmaList,Weight,Debug)

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

 

 

indicmatch1(Rogindic,Indic,[L|Ls],[Weight|Weights],[Debug|Debugs]) :-

     imatch1(Rogindic,Indic,L,Weight,Debug),

     indicmatch1(Rogindic,Indic,Ls,Weights,Debugs).

 

indicmatch1(_,_,[],0,[]).

 

 

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

% Matching Indicator against lemma

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

 

% imatch1 and imatch2 are identical except for debug info

% having two preds is a way of recording where the imatch predicate

% was called

 

imatch1(_,Indicator,Indicator,10,i1(Indicator,10)) :- !.

 

imatch1(R1,Indicator,Lemma,Weight,Debug) :-

         look_in_rgt(Lemma,R2),       

         irogetmeet(R1,R2,W),

         metameet(Indicator,Lemma,W1),

        Wmeta is W1//2, % metameet weight reduced in this type of match

        rwn(item(Indicator,Pos,S1),item(Lemma,Pos,S2),W2),

        Weight is W+Wmeta+W2,

        ifthenelse(Weight=0,Debug=[],Debug=i1(Indicator,Lemma,rg(W),mt(Wmeta),wn(W2))),

        !.

               

imatch1(_,_,_,0,[]).    

 

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

 

imatch2(_,Indicator,Indicator,10,i2(Indicator,10)) :- !.

 

imatch2(R1,Indicator,Lemma,Weight,Debug) :-

         look_in_rgt(Lemma,R2),       

         irogetmeet(R1,R2,W),

         metameet(Indicator,Lemma,W1),

        Wmeta is W1//2, % metameet weight reduced in this type of match

        rwn(item(Indicator,Pos,S1),item(Lemma,Pos,S2),W2),

        Weight is W+Wmeta+W2,

        ifthenelse(Weight=0,Debug=[],Debug=i2(Indicator,Lemma,rg(W),mt(Wmeta),wn(W2))),

        !.

               

imatch2(_,_,_,0,[]).    

 

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

% Exploration Type 2:

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

 

% Part One : as against the lemmas contained in the box

% of textual relations, i.e. TCollocList

 

% A & B

        

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

% Matching Indicator against list of collocates

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

 

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

% Pattern : indicmatch2(Lab,Rogindic,CleanIndic,

%              DicLem,TCollocList,Weight,Debug)

 

% we find the lemma in the textual chunk syn rel list

% in the position of a collocate

% we retrieve the collocates to match by looking up

% the collocate bearer in the bilingual

% we match against the indic

 

% we then go on to look up the collocate-BEARERS in the mono

% and we attempt to match the indicator and def and ex lexlists

% of the clicked-on word against the collocate lists and

% def and exlist of the collocate bearer

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

 

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

% Note that LkpList is a list of t-structures:

% t(Collocate-Bearer, Part-of-Speech, Pre-or-Post-Collocate-List-Position)

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

 

indicmatch2(Lab,Rogindic,CleanIndic,

            DicLem,TCollocList,[Weight1,Weight2],[Debug1,Debug2]) :-

       

        % find the collocate bearers

        findlem(DicLem,TCollocList,LkpList),

        [! flatlist(LkpList,Flat) !],

 

        % find the relevant collocate lists

        lkp(Flat,ItemsToMatch),

        [! flatlist(ItemsToMatch,Flat2) !],                   

       

        % A:

        matchem(Rogindic,CleanIndic,Flat2,Weight1,Debug1),

        % indic against collocates

       

        % B:

        matchinmono(Lab,DicLem,Rogindic,CleanIndic,Flat,Flat2,Weight2,Debug2).

        % items in the deflex of the clicked-on word as against collocates and

        % collocate bearer's defexlexlist

 

 

 indicmatch2(_,_,_,_,_,0,[]).

 

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

 

 

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

% findlem(DicLem,TCollocList,LkpList)

% we find the Lemma in the textual syn rel box

% we keep track of collocate bearer, pos and

% position (pre or post) (a triplet)

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

 

findlem(Lemma,[SynRel|OtherSynRels],

        [T3|OtherT3s]) :-

       

        lkpinlist(Lemma,SynRel,T3),

        findlem(Lemma,OtherSynRels,OtherT3s).

       

 

findlem(Lemma,[],[]).       

 

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

% lkpinlist(Lemma,SynRel,TripletToLookUpInSdic)

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

 

lkpinlist(Lemma,_,nil) :- toolw(Lemma),!.

 

lkpinlist(Lemma,csubj(Lemma,Verb),t3(Verb,v,pre)) :- !.

lkpinlist(Lemma,cdobj(Lemma,Verb),t3(Verb,vtr,post)) :- !.

lkpinlist(Lemma,ciobj(Lemma,Verb),t3(Verb,vtr,post)) :- !.

lkpinlist(Lemma,cadvv(Adverb,Lemma),t3(Adverb,adv,pre)) :- !.

lkpinlist(Lemma,cnn(Lemma,Noun),t3(Noun,n,pre)) :- !.

lkpinlist(Lemma,ccplt(Lemma,Noun),t3(Noun,n,pre)) :- !.

lkpinlist(Lemma,cadj(Adjective,Lemma),t3(Adjective,adj,pre)) :- !.

lkpinlist(Lemma,cadva(Adverb,Lemma),t3(Adverb,adv,pre)) :- !.

 

 

/* avoid failure */

 

lkpinlist(Lemma,_,nil).

 

 

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

% lkp(Lkplist,ItemsToMatch)

% we lookup in sdic on the basis of the triplets

% retrieved by findlem:

% item to be looked up (lemma)

% pos (vtr,vi,n,adj,adv)

% pre or postcoll list, which we collect in ItemsToMatch

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

 

 

lkp([],[]).

 

lkp(nil,[]).

 

lkp([t3(Lemma,Pos,PreOrPost)|OtherT3s],[List|OtherLists]) :-

        insdic(t3(Lemma,Pos,PreOrPost), List),

        lkp(OtherT3s,OtherLists).

       

lkp([nil|Others], OtherLists) :- lkp(Others,OtherLists).       

 

 

/* keeping the lemmas  -- presently NOT USED */

 

lkpitems([],[]).

lkpitems(nil,[]).

lkpitems([t3(L,_,_)|OtherT3s],[L|OtherLs]) :-

         lkpitems(OtherT3s,OtherLs).

 

lkpitems([nil|Others],Ls) :- lkpitems(Others,Ls).

  

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

% insdic(Triplet,CollocateList)

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

 

insdic(t3(Lemma,v,PreOrPost),List) :-

       insdic(t3(Lemma,vi,PreOrPost),List).

      

insdic(t3(Lemma,v,PreOrPost),List) :-      

        insdic(t3(Lemma,vtr,PreOrPost),List).  

 

insdic(t3(Lemma,Pos,pre),L) :-

        setof(List,

              (Lemma,Pos)^retrieveb(sdico,

                   Lemma,

                   sdic(A,Lemma,Pos,sc(List),

                   B,C,D,E,F,G,H,I,J,K,M,N,O,P)),

             L).

 

insdic(t3(Lemma,Pos,post),L) :-

        setof(List,

              (Lemma,Pos)^retrieveb(sdico,

                   Lemma,

                   sdic(A,Lemma,Pos,B,oc(List),

                   C,D,E,F,G,H,I,J,K,M,N,O,P)),

             L).

 

 

/* avoid failure */

insdic(_,[]).

 

 

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

%% matchem(Rogindic,CleanIndic,ItemsToMatch,Weight,Debug)

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

 

 

 

% fuller form: standard indicator matching

 

matchem(Rogindic,CleanIndic,

        [L|Ls],[Weight,Weights],[Debug,Debugs]) :-

 

    imatch2(Rogindic,CleanIndic,L,Weight,Debug),

    matchem(Rogindic,CleanIndic,Ls,Weights,Debugs).

 

 

 

 

% simpler form : testing for membership only

 

% matchem(_,Indic,List,[Weight],Debug) :-

%     membre(Indic,List,Weight,Debug).

 

 

   matchem(_,_,[],0,[]).

 

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

 

 

 

 

 

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

%% matchinmono(Lab,DicLem,Rogindic,CleanIndic,

%% ItemsToLookup,Weight,Debug)

%% made up of:

%% lkpmono1 :

 

%% lkpmono1a(DicLem,Rogindic,CleanIndic,DicLemList)

%% 1a :retrieving DicLem in mono on the basis of a match

%%    between Indicator and GuideWord in mono

%%    in case of success, we house the Deflexlist

%%    of the matching item in DicLemList

 

 

%% lkpmonot3 :

%% lkpmonot3(DicLemList,Lkplist,ItemsToMatch)

%% collecting the deflexlist of the collocate bearer

 

%% membre and matchmono :

%%    matching the indicator and the words in the

%%    deflexlist of the item retrieved in the mono

%%    on the basis of a match with the indicator or label

%% with : the collocates and the defexlexlist of the collocate bearer

 

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

 

matchinmono(Lab,DicLem,Rogindic,CleanIndic,T3list,Llist,

            [Weight1|Weight2],[Debug1|Debug2]) :-

       

        % look up the clicked-on word in the relevant reading

        % and collect its defexlist   

        lkpmono1a(DicLem,Rogindic,CleanIndic,DicLemList),

        [! flatlist(DicLemList,DDL) !],

 

        % look up the collocate bearers' defexlists

        lkpmonot3(DDL,T3list,ItemsToMatch),

        [! flatlist(ItemsToMatch, Flat) !],

 

        % append the collocate lists to the defexlists of the collocate bearers

        append(Flat, Llist, ITM),

 

        % match (simple intersection match)

        % the indicator against the collocate bearers' defexlists

        membre(CleanIndic,Flat,Weight1,Debug1),

 

        % intermatch (simple intersection match)

        %  the defexlist of the clicked-on word in the relevant reading

        %  and the list of collocates appended to the defexlists of the collocate

        % bearers

        matchmono(DDL,ITM,Weight2,Debug2).

 

 

 

%% Membership with weighting and debug info

 

membre(CleanIndic,Items,3,i2(CleanIndic,3,dfexcb)) :-

        member(CleanIndic,Items),!.

 

membre(CleanIndic,Items,0,[]).

 

 

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

%% matchmono(DicLemList,ItemsToMatch,Weight,Debug)

%% the match is simple identity here

%% the weight is the number of matching items

%% debug is the list of matching items

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

 

matchmono([Lem|Others],List,Weight,[Lem|OtherLems]) :-

        member(Lem,List),

        matchmono(Others,List,PreviousWeight,OtherLems),

        Weight is PreviousWeight + 3.

 

 

matchmono([Lem|Others],List,Weight,OtherLems) :-

        not(member(Lem,List)),

        matchmono(Others,List,Weight,OtherLems).

 

matchmono([],List,0,[]).

 

 

 

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

%% lkpmono1a(DicLem,Rogindic,CleanIndic,DicLemList)

%% retrieving on the basis of a match between indicator

%% and a member of the guideword list or of the definition and

%% example wordlist

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

 

lkpmono1a(Lemma,Rogindic,Indic,BBL) :-

        findall(DicLemList,

              (retrieveb(monotree,

                   Lemma,

                   mono(lem(Lemma),

                   A,

                   B,

                   C,

                   gw(Gwlist),

                   deflex(List1),

                   exlex(List2))),

       

        append(List1,List2,List),

        itemsinlist(List,DicLemList),

        append(DicLemList,Gwlist,BigList),

        member(Indic,BigList)),

        DDL),

        remdup(DDL,BBL).

 

 

/* avoid failure */

% lkpmono1a(_,_,_,[]).

 

 

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

% on the basis of the label list of the bi

% matched by assoc with the label list of the mono (ldoce items)

%%%%%%%%%%%

% NOT USED

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

 

lkpmono1b(Lemma,BiLab,DicLemList) :-

        retrieveb(monotree,

                   Lemma,

                   mono(lem(Lemma),

                   _,

                   _,

                   lab(MonoLab),

                   _,

                   deflex(List),

                   Exlex)),

        itemsinlist(List,DicLemList),                  

        assoclists(BiLab,MonoLab,Weights,Debugs),

        accu(Weights,Weight),

        Weight \= 0.

 

 

/* avoid failure */       

 

lkpmono1b(_,_,[]).

 

 

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

%% lkpmono1c(Indic,DicLemList)

%% looking up the indicator itself in the mono

%%%%%%%%%%%

%% NOT USED

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

 

lkpmono1c(Indic,DicLemList) :-

        retrieveb(monotree,

                   Indic,

                   mono(lem(Indic),

                   _,

                   _,

                   _,

                   _,

                   deflex(List),

                   Exlex)),

        itemsinlist(List,DicLemList).                  

      

/* avoid failure */

lkpmono1c(_,[]).

 

 

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

% assoclists(Bi,Mono,Weights,Debugs)

% association of DEFI label codings

% with Merriam-Webster/Ldoce codings

% we have lists of codes in either case

% NOT USED

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

 

assoclists([],_,0,[]).

 

 

assoclists([Bilab1|Otherbis],Mono,

          Weight,[assoc(Bilab1,Monocode)|OtherDebugs]) :-

       

        assoc(Bilab1,Monocode),

        member(Monocode,Mono),

        assoclists(Otherbis,Mono,PreviousWeight,OtherDebugs),

        Weight is PreviousWeight+1.         

 

 

assoclists([Bilab1|Otherbis],Mono,

          Weight,Debugs) :-

       

        assoc(Bilab1,Monocode),

        not(member(Monocode,Mono)),

        assoclists(Otherbis,Mono,Weight,Debugs).

         

 

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

% lkpmonot3(_,Lkplist,ItemsToMatch)

% we lookup in mono on the basis of the first two elements of

% the triplets retrieved by findlem:

% item to be looked up (lemma) and  pos (vtr,vi,n,adj,adv)

% we collect the deflex and exlex items of the elements in one big list

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

 

 

lkpmonot3(_,[],[]).

 

lkpmonot3(_,nil,[]).

 

lkpmonot3(_,[t3(Lemma,Pos,_)|OtherT3s],[Items|OtherLists]) :-

        insmono2(t3(Lemma,Pos,_), List),

        [! flatlist(List,Flat) !],

        itemsinlist(Flat,Items),

        lkpmonot3(_,OtherT3s,OtherLists).

       

lkpmonot3(_,[nil|OtherT3s],OtherLists) :- lkpmonot3(_,OtherT3s,OtherLists).

 

/* avoid failure */        

 

lkpmonot3(_,_,[]).  

 

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

% insmono(Triplet,DeflexList)

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

 

insmono2(t3(Lemma,Pos,_),L) :-

        backtov(Pos,NewPos),

        setof(List,

              (Lemma,NewPos,List1,List2)^(retrieveb(monotree,

                   Lemma,

                   mono(lem(Lemma),

                   A,

                   pos(NewPos),

                   B,

                   C,

                   deflex(List1),

                   exlex(List2))),

         append(List1,List2,List)),

         L).

 

 

 

/* avoid failure */

 insmono2(_,[]).

 

 

 

% pos is v in monodic, not vtr or vi

 

backtov(vtr,v) :- !.

backtov(vi,v) :- !.

backtov(Pos,Pos).

 

 

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

% itemsinlist(DeflexList,Items)

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

 

itemsinlist([],[]).

itemsinlist(nil,[]).

 

itemsinlist([w(Pos,W)|RemainderList],[W|OtherWs]) :-   

        itemsinlist(RemainderList,OtherWs).

 

itemsinlist([nil|Others],OtherWs) :- itemsinlist(Others, OtherWs).

       

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

 

 

 

 

 

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

% Getting at the lemma

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

 

/* retrieve from Twlist the lemma (Lemclw),

   Pos and case of the clicked-on word (Clw) */

 

getlemw([_,Clw],Lemclw,Twlist,Pos,Case) :-

        member(w(_,_,text(Clw,_),lem(Lemclw,Case),morph(Morph),_),Twlist),

        member(m(pos,Pos,_),Morph).

 

getlemw(Clw,Lemclw,Twlist,Pos,Case) :-

        member(w(_,_,text(Clw,_),lem(Lemclw,Case),morph(Morph),_),Twlist),

        member(m(pos,Pos,_),Morph).

 

 

% sniper's --> sniper

% get at the lemmatized form directly, without looking at the textual variant

 

getlemw(Lemclw,Lemclw,Twlist,Pos,Case) :-

        member(w(_,_,text(_,_),lem(Lemclw,Case),morph(Morph),_),Twlist),

        member(m(pos,Pos,_),Morph).

 

 

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

% Getting at the lemmas of all non toolwords in the

% textual wordlist

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

 

% end of recursion:

getlemmas([],_,[]) :- !.

 

% throw away toolwords:

getlemmas([w(_,_,_,lem(Lemma,C),_,_)|RTwlist],Clw,OtherLemmas) :-

         toolw(Lemma),!,

         getlemmas(RTwlist,Clw,OtherLemmas).

 

% throw away the clicked-on word ipse:

getlemmas([w(_,_,_,lem(Clw,C),_,_)|RTwlist],Clw,OtherLemmas) :-

         !,

         getlemmas(RTwlist,Clw,OtherLemmas).

 

% throw away punctuation: 

getlemmas([punct(_,_,_)|RTwlist],Clw,OtherLemmas) :-

        !,

        getlemmas(RTwlist,Clw,OtherLemmas).

 

% collect all other lemmas:

getlemmas([w(_,_,text(Text,_),lem(Lemma,C),_,_)|RTwlist],

        Clw,[Lemma|OtherLemmas]) :-

           !,

           getlemmas(RTwlist,Clw,OtherLemmas).

 

/*

getlemmas([w(_,_,text(Text,_),lem(Lemma,C),_,_)|RTwlist],

        Clw,[Text,Lemma|OtherLemmas]) :-

           Text \= Lemma,

           getlemmas(RTwlist,Clw,OtherLemmas).

 

*/

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

% TRANSLATECASE : given a lemmatized clickedonword and its case,

% create a lemmatized form respecting case

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

 

translatecase(Word,l,Word) :- !.

 

translatecase(Word,au,Newword) :- string_upper(Word,Newword).

 

translatecase(Word,au,Word).

 

translatecase(Word,u,Newword) :-

        string_length(Word,Length),

        Length2 is Length-1,

        substring(Word,1,Length2,Ending),

        substring(Word,0,1,Start),

        string_upper(Start,Upperstart),

        concat(Upperstart,Ending,Newword).

 

translatecase(Word,u,Word).

 

 

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

% LOOKUPTXTCOLLS_GEN pred : records all Roget info

% for all txt collocates

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

 

lookuptxtcolls_gen(_,[]) :-!.

 

lookuptxtcolls_gen(Collist,[Lemma|Tail]) :-

        lookuptxtcolls(Collist,Lemma),

        lookuptxtcolls_gen(Collist,Tail).

 

lookuptxtcolls([],Lemma) :- !.

 

lookuptxtcolls([Coll|Tail],Lemma) :-

        lookup(Coll,Lemma),

        lookuptxtcolls(Tail,Lemma).

 

lookup(csubj(Item,Lemma),Lemma) :-

        look_in_roget(Item),

        !.

 

lookup(cdobj(Item,Lemma),Lemma) :-

        look_in_roget(Item),

        !.

 

lookup(ciobj(Item,Lemma),Lemma) :-

        look_in_roget(Item),

        !.

 

lookup(cadj(Lemma,Item),Lemma) :- 

        look_in_roget(Item),

        !.

 

lookup(cnn(Lemma,Item),Lemma) :-  

        look_in_roget(Item),

        !.

 

lookup(cnn(Item,Lemma),Lemma) :-  

        look_in_roget(Item),

        !.

 

lookup(cadva(Lemma,Item),Lemma) :-

        look_in_roget(Item),

        !.

 

lookup(cadvv(Lemma,Item),Lemma) :-

        look_in_roget(Item),

        !.

 

lookup(ccplt(Item,Lemma),Lemma) :-

        look_in_roget(Item),

        !.

 

lookup(_,_).

 

 

look_in_roget(Item) :-

        not(recorded(coll_in_roget,[Item|_],_)),

        retrieveb(roget,Item,r(Item,Listofidnums)),

        recorda(coll_in_roget,[Item,Listofidnums],_),

        !.

 

look_in_roget(_).

 

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

% used in windic:

% getting a roget list-of-idnums for a lemma

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

 

look_in_rgt(Item,[Item,Listofidnums]) :-

        retrieveb(roget,Item,r(Item,Listofidnums)),

        !.

 

look_in_rgt(_,[]).

 

 

 

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

% correspondences between TextPos (engcg related)

% and DicPos (in Defidic)

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

 

corrpos(X,Y,W) :-

        nonvar(X),

        nonvar(Y),

        X=Y,

        recorded(stg,[pos_1,W],_).

 

corrpos(edform,'p adj',W) :- recorded(stg,[pos_2,W],_).

corrpos(edform,adj,W) :- recorded(stg,[pos_2,W],_).

corrpos(edform,vb,W) :- recorded(stg,[pos_2,W],_).

corrpos(edform,vtr,W) :- recorded(stg,[pos_2,W],_).

corrpos(edform,vtri,W) :- recorded(stg,[pos_2,W],_).

corrpos(edform,vi,W) :- recorded(stg,[pos_2,W],_).

corrpos(edform,'refl vb',W) :- recorded(stg,[pos_2,W],_).

 

corrpos(ingform,'p adj',W) :- recorded(stg,[pos_2,W],_).

corrpos(ingform,adj,W) :- recorded(stg,[pos_2,W],_).

corrpos(ingform,n,W) :- recorded(stg,[pos_2,W],_).

corrpos(ingform,vb,W) :- recorded(stg,[pos_2,W],_).

corrpos(ingform,vtr,W) :- recorded(stg,[pos_2,W],_).

corrpos(ingform,vtri,W) :- recorded(stg,[pos_2,W],_).

corrpos(ingform,vi,W) :- recorded(stg,[pos_2,W],_).

corrpos(ingform,'refl vb',W) :- recorded(stg,[pos_2,W],_).

 

corrpos(erform,vb,W) :- recorded(stg,[pos_2,W],_).

corrpos(erform,vtr,W) :- recorded(stg,[pos_2,W],_).

corrpos(erform,vtri,W) :- recorded(stg,[pos_2,W],_).

corrpos(erform,vi,W) :- recorded(stg,[pos_2,W],_).

corrpos(erform,'refl vb',W) :- recorded(stg,[pos_2,W],_).

 

corrpos(abbr,n,W)  :- recorded(stg,[pos_2,W],_).

 

corrpos(neg,adv,W) :- recorded(stg,[pos_1,W],_).

 

corrpos(num,det,W) :- recorded(stg,[pos_1,W],_).

corrpos(num,pron,W) :- recorded(stg,[pos_1,W],_).

 

corrpos(v,vtr,W) :- recorded(stg,[pos_1,W],_).

corrpos(v,vb,W) :- recorded(stg,[pos_1,W],_).

corrpos(v,vi,W) :- recorded(stg,[pos_1,W],_).

corrpos(v,vtri,W) :- recorded(stg,[pos_1,W],_).

corrpos(v,comp,W) :- recorded(stg,[pos_3,W],_).

corrpos(v,'refl vb',W) :- recorded(stg,[pos_1,W],_).

 

corrpos(n,'pr n',W) :- recorded(stg,[pos_1,W],_).

corrpos(n,npl,W) :- recorded(stg,[pos_1,W],_).

corrpos(n,modif,W) :- recorded(stg,[pos_1,W],_).

corrpos(n,comp,W) :- recorded(stg,[pos_3,W],_).

 

corrpos(sconj,conj,W) :- recorded(stg,[pos_1,W],_).

corrpos(cconj,conj,W) :- recorded(stg,[pos_1,W],_).

 

 

/* corrpos(adj,modif,W). */

 

corrpos(adj,comp,W) :- recorded(stg,[pos_3,W],_).

 

 

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

% prioritizing verbs

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

 

getverbbonus(vtri,List,Lemclw,W) :-

        member(ciobj(_,Lemclw),List),

        recorded(stg,[pos_vbonus,W],_),

        !.

 

getverbbonus(vtr,List,Lemclw,W) :-

        member(cdobj(_,Lemclw),List),

        recorded(stg,[pos_vbonus,W],_),

        !.

 

% getverbbonus(vi,List,Lemclw,5) :- !.

 

getverbbonus(_,_,_,0).

 

 

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

% correspondences between TextPos (engcg related) and ColPos

% (n, adj or v)

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

 

 

basicpos(abbr,n).

 

basicpos(edform,v).

basicpos(edform,adj).

 

basicpos(ingform,v).

basicpos(ingform,adj).

basicpos(ingform,n).

 

basicpos(X,X).

 

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

% Working out the frequency bonus

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

 

freqbonus(Trfreq,Trtotal,Ratio) :-

        nonvar(Trfreq),

        nonvar(Trtotal),

        R is Trfreq/Trtotal,

        Ratio is round(R,5).

      

 

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

% Reverse with Accumulator - from Sterling and Shapiro

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

 

reverse(Xs,Ys) :-

        reverse(Xs,[],Ys).

 

reverse([X|Xs],Acc,Ys) :-

        reverse(Xs,[X|Acc],Ys).

       

reverse([],Ys,Ys).       

               

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

% Identity Bonus : bonus for identity between

% DicLem and lower-cased clicked-on word

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

 

identitybonus(X,X,10) :- nonvar(X),!.

identitybonus(_,_,0).       

 

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

% THE END

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

 

 

 

 

 

 

 

 

 

% UTIL.ARI

 

 

%%%%%%%%%%%

% UTIL.ARI

%%%%%%%%%%%

 

 

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

% THE DEFI MATCHERS : AUXILIARY PREDICATES

% Defi Project

% A. Michiels and Nicolas Dufour

% Ulg

% Last update : 25 Feb 2000

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

 

 

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

% Declarations and compiler directives

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

 

:- public dans/2.

:- public istool/1.

:- public corr/2.

:- public lastpost/2.

:- public dividelist/2.

:- public gethandles/1.

:- public intersection_colloc/3.

:- public intersection_roget/3.

:- public i_roget/3.

:- public getrogetweight/5.

:- public flatten/2, flatten/3.

:- public flat/2, flat/3.

:- public flatlist/2.

:- public remdup/2.

:- public removedot/2.

:- public len/2.

:- public append/3.

:- public member/2.

:- public mrest/3.

:- public checkmember/3.

:- public listl/2.

:- public listl_no_or/2.

:- public listl_no_or_or_cor/3.

:- public neglect/1.

:- public accu/2.

:- public readin/3.

:- public imprime/2.

:- public mywrite/2.

:- public compute_processing_time/2.

:- public get_time_difference/3.

:- public compute_average_time/3.

:- public check_clwlist/2.

:- public reject_clw/1.

:- public set_default/0.

:- public customize/0.

:- public custom/1.

:- public getvalue/1.

:- public writesettings/1.

:- public check_morph/4.

:- public max/2, maximum/3.

:- public lablink/3, keeplabel/1,assoc/2.

:- public wenvir/5.

      

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

% Tool word list

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

 

istool(yes).

istool(no).

 

istool(i).

istool(you).

istool(we).

istool(they).

istool(it).

istool(he).

istool(she).

 

istool(one).

istool(two).

istool(three).

istool(four).

istool(five).

istool(ten).

 

istool(lot).

istool(few).

istool(a).

istool(the).

istool(some).

istool(any).

istool(much).

istool(many).

istool(more).

istool(most).

istool(both).

istool(either).

istool(each).

istool(every).

istool(all).

 

istool(shall).

istool(will).

istool(can).

istool(may).

istool(would).

istool(could).

istool(should).

istool(ought).

istool(might).

istool(be).

istool(have).

istool(do).

 

istool(there).

istool(here).

istool(now).

 

istool(how).

istool(when).

istool(why).

istool(where).

istool(what).

istool(who).

istool(which).

istool(whose).

 

istool(or).

istool(and).

istool(but).

istool(though).

istool(although).

istool(however).

istool(if).

istool(as).

istool(like).

 

istool(about).

istool(after).

istool(by).

istool(for).

istool(from).

istool(down).

istool(back).

istool(up).

istool(out).

istool(of).

istool(off).

istool(to).

istool(on).

istool(with).

istool(over).

 

istool(my).

istool(your).

istool(his).

istool(her).

istool(our).

istool(their).

 

istool(than).

istool(that).

istool(this).

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

% Checking occurrence of clicked-on word

% textual syn rel list

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

 

dans(Lemma,List) :-

   member(cadj(Lemma,_),List),!.

 

dans(Lemma,List) :-

   member(cnn(Lemma,_),List),!.

 

dans(Lemma,List) :-

   member(cnn(_,Lemma),List),!.

 

dans(Lemma,List) :-

   member(cadva(Lemma,_),List),!.

 

dans(Lemma,List) :-

   member(cadvv(Lemma,_),List),!.

 

dans(Lemma,List) :-

   member(cdobj(_,Lemma),List),!.

 

dans(Lemma,List) :-

   member(csubj(_,Lemma),List),!.

 

dans(Lemma,List) :-

   member(ciobj(_,Lemma),List),!.

 

dans(Lemma,List) :-

   member(ccplt(_,Lemma),List),!.

 

 

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

% CORR : correspondence between lemmas and toolword classes

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

 

/* the toolword classes are used in the p-structures of the

handlelist items */

 

corr(any,t_dq).

corr(some,t_dq).

corr(no,t_dq).

corr(none,t_dq).

corr(neither,t_dq).

corr(either,t_dq).

corr(other,t_dq).

corr(another,t_dq).

corr(both,t_dq).

corr(several,t_dq).

corr(each,t_dq).

corr(all,t_dq).

corr(few,t_dq).

corr(this,t_dq).

corr(these,t_dq).

corr(those,t_dq).

corr(such,t_dq).

corr(one,t_dq).

corr(much,t_dq).

corr(many,t_dq).

corr(most,t_dq).

corr(more,t_dq).

 

corr(two,t_dig).

corr(three,t_dig).

corr(four,t_dig).

corr(five,t_dig).

corr(six,t_dig).

corr(seven,t_dig).

corr(eight,t_dig).

corr(nine,t_dig).

corr(ten,t_dig).

 

corr(can,t_mod).

corr(could,t_mod).

corr("can't",t_mod).

corr(cannot,t_mod).

corr("couldn't",t_mod).

corr(must,t_mod).

corr("mustn't",t_mod).

corr(would,t_mod).

corr(will,t_mod).

corr(ought,t_mod).

corr("oughtn't",t_mod).

corr("won't",t_mod).

corr("wouldn't",t_mod).

corr(shall,t_mod).

corr(should,t_mod).

corr("shouldn't",t_mod).

corr(may,t_mod).

corr("mightn't",t_mod).

corr(might,t_mod).

 

corr(have,t_have).

corr(has,t_have).

corr(had,t_have).

corr("haven't",t_have).

corr(having,t_have).

corr("hasn't",t_have).

corr("hadn't",t_have).

 

corr(is,t_be).

corr(being,t_be).

corr(are,t_be).

corr(been,t_be).

corr(was,t_be).

corr(were,t_be).

corr(be,t_be).

corr("isn't",t_be).

corr("aren't",t_be).

corr("wasn't",t_be).

corr("weren't",t_be).

 

corr(which,t_intrel).

corr(who,t_intrel).

corr(what,t_intrel).

corr(whom,t_intrel).

corr(how,t_intrel).

corr(when,t_intrel).

corr(why,t_intrel).

corr(where,t_intrel).

 

 

/* we exclude prep because of phrasal and prep verbs */

 

/*

corr(at,t_prep).

corr(in,t_prep).

corr(on,t_prep).

corr(upon,t_prep).

corr(through,t_prep).

corr(for,t_prep).

corr(with,t_prep).

corr(by,t_prep).

corr(from,t_prep).

corr(up,t_prep).

corr(out,t_prep).

corr(about,t_prep).

corr(into,t_prep).

corr(of,t_prep).

corr(back,t_prep).

corr(down,t_prep).

corr(over,t_prep).

corr(after,t_prep).

corr(off,t_prep).

*/

 

corr("I",t_pro).

corr(i,t_pro).

corr(you,t_pro).

corr(he,t_pro).

corr(me,t_pro).

corr(him,t_pro).

corr(my,t_pro).

corr(she,t_pro).

corr(it,t_pro).

corr(her,t_pro).

corr(its,t_pro).

corr(his,t_pro).

corr(we,t_pro).

corr(us,t_pro).

corr(our,t_pro).

corr(your,t_pro).

corr(they,t_pro).

corr(their,t_pro).

corr(them,t_pro).

 

corr(myself,t_self).

corr(yourself,t_self).

corr(oneself,t_self).

corr(himself,t_self).

corr(herself,t_self).

corr(itself,t_self).

corr(ourselves,t_self).

corr(yourselves,t_self).

corr(themselves,t_self).

 

 

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

% LASTPOST : returns position of last element in w-list

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

 

lastpost(Wlist,Borne) :-

        last(Wlist,punct(Borne,_,_)).

 

 

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

% DIVIDELIST

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

 

/* we produce two textual word lists in case of ambiguity

detected by the LingSoft Parser by removing the first

or the second lemmatization; on backtracking the process

is repeatedly carried through, since there may be more than one

case of double lemmatization in the parsing of a single textual chunk */

 

dividelist(Twlist,NewTwlist) :-

        pick(w(A,B,C,L1,M1,S1),w(A,B,C,L2,M2,S2),Twlist,Temp),

        dividelist(Temp,NewTwlist),

        !.

 

dividelist(X,X).        

           

 

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

% ENVIR

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

 

% envir weighing is disabled

wenvir(_,_,_,0,[]) :-

        recorded(stg,[envir,0],_), !.

 

% no envir

wenvir(_,_,[nil],0,[]) :- !.

 

 

/* a prep */

 

wenvir(Lemma,Twlist,Envir,W,[env(Source,W)]) :-

        member(e(Source,_),Envir),

        member(w(N,N2,text(Source,_),lem(Source,_),morph(Morph),_),Twlist),

        member(m(pos,prep,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        recorded(stg,[envir,W],_),

        N >= Next.

       

       

/* to do */

 

wenvir(Lemma,Twlist,Envir,W,[env(todo,W)]) :-

        member(e('to do',_),Envir),

        member(w(N,N2,text(to,_),lem(to,_),morph(Morph),_),Twlist),

        member(m(pos,inf_part,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

      

             

/* to sth */

 

wenvir(Lemma,Twlist,Envir,W,[env(to,W)]) :-

        member(e('to sth',_),Envir),

        member(w(N,N2,text(to,_),lem(to,_),morph(Morph),_),Twlist),

        member(m(pos,prep,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

       

/* to sb */

 

wenvir(Lemma,Twlist,Envir,W,[env(to,W)]) :-

        member(e('to sb',_),Envir),

        member(w(N,N2,text(to,_),lem(to,_),morph(Morph),_),Twlist),

        member(m(pos,prep,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

 

 

/* with sb */

 

wenvir(Lemma,Twlist,Envir,W,[env(with,W)]) :-

        member(e('with sb',_),Envir),

        member(w(N,N2,text(with,_),lem(with,_),morph(Morph),_),Twlist),

        member(m(pos,prep,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

         

 

/* for sth */

 

wenvir(Lemma,Twlist,Envir,W,[env(for,W)]) :-

        member(e('for sth',_),Envir),

        member(w(N,N2,text(for,_),lem(for,_),morph(Morph),_),Twlist),

        member(m(pos,prep,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

 

 

/* for sb */

 

wenvir(Lemma,Twlist,Envir,W,[env(for,W)]) :-

        member(e('for sb',_),Envir),

        member(w(N,N2,text(for,_),lem(for,_),morph(Morph),_),Twlist),

        member(m(pos,prep,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

 

/* from sb */

 

wenvir(Lemma,Twlist,Envir,W,[env(from,W)]) :-

        member(e('from sb',_),Envir),

        member(w(N,N2,text(from,_),lem(from,_),morph(Morph),_),Twlist),

        member(m(pos,prep,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

 

/* conjunction that */

 

wenvir(Lemma,Twlist,Envir,W,[env(that,W)]) :-

        member(e(that,_),Envir),

        member(w(Next,N2,text(that,_),lem(that,_),morph(Morph),_),Twlist),

        member(m(pos,sconj,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        recorded(stg,[envir,W],_).

       

       

 

/* by doing, for doing, of doing */

 

wenvir(Lemma,Twlist,Envir,W,[env(bydoing,W)]) :-

        member(e('by doing',_),Envir),

        member(w(N,N2,text(by,_),lem(by,_),morph(Morph),_),Twlist),

        member(w(N2,_,_,_,morph(Morph2),_),Twlist),

        member(m(pos,ingform,_),Morph2),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

 

wenvir(Lemma,Twlist,Envir,W,[env(ofdoing,W)]) :-

        member(e('of doing',_),Envir),

        member(w(N,N2,text(of,_),lem(of,_),morph(Morph),_),Twlist),

        member(w(N2,_,_,_,morph(Morph2),_),Twlist),

        member(m(pos,ingform,_),Morph2),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

 

wenvir(Lemma,Twlist,Envir,W,[env(fordoing,W)]) :-

        member(e('for doing',_),Envir),

        member(w(N,N2,text(for,_),lem(for,_),morph(Morph),_),Twlist),

        member(w(N2,_,_,_,morph(Morph2),_),Twlist),

        member(m(pos,ingform,_),Morph2),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        N >= Next,

        recorded(stg,[envir,W],_).

       

 

/* doing */

 

wenvir(Lemma,Twlist,Envir,W,[env(doing,W)]) :-

        member(e('doing',_),Envir),

        member(w(Next,_,_,_,morph(Morph),_),Twlist),

        member(m(pos,ingform,_),Morph),

        member(w(Start,Next,_,lem(Lemma,_),_,_),Twlist),

        recorded(stg,[envir,W],_).

       

 

 

/* avoid failure */

 

wenvir(_,_,_,0,[]).

     

 

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

% GETHANDLES : stores all handles featuring all the clicked-on words into

% a 'handles' database

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

 

gethandles(Lemclwlist) :-

        recorded(handles,[Lemclwlist,_],_),

        !.

 

gethandles([Head|Tail]) :-

        eraseall(temp),

        getfirsthandles(Head,[Head|Tail],Tail).

 

 

getfirsthandles(Word,Lemclwlist,Tail) :-

        retrieveb(hl,Word,inh(Word,Listofhandles)),

        store_to_handles(Listofhandles,Lemclwlist,Tail),

        fail.

 

getfirsthandles(_,_,_).

 

 

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

store_to_handles([],_,_) :- !.

 

store_to_handles([A|B],Lemclwlist,Tail) :-

        ifthen(contains(A,Tail),

              (recorda(handles,[Lemclwlist,A],_))),

        store_to_handles(B,Lemclwlist,Tail).

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

 

 

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

contains(Hlist,[]) :- !.

 

contains(Hlist,[A|B]) :-

        member([_,_,A],Hlist),

        contains(Hlist,B).

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

 

 

 

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

% INTERSECTION_COLLOC: computes the intersection

% of two list of collocate idnums

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

 

intersection_colloc([],_,0).

 

intersection_colloc([Idnum|Tail],Otherlist,Length1) :-

        member(Idnum,Otherlist),

        intersection_colloc(Tail,Otherlist,Length),

        Length1 is Length + 1.

        !.

 

intersection_colloc([Idnum|Tail],Otherlist,Tail2) :-

        intersection_colloc(Tail,Otherlist,Tail2).

 

 

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

% INTERSECTION_ROGET: computes the intersection of two lists of Roget

%  references 

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

 

intersection_roget([],_,[]).

 

intersection_roget([[Pos,Cat,Sub1,Sub2]|Tail],Otherlist,[Weight|Tail2]) :-

        member([Pos,Cat,Othersub1,Othersub2],Otherlist),!,

        getrogetweight(Sub1,Sub2,Othersub1,Othersub2,Weight),

        intersection_roget(Tail,Otherlist,Tail2).

 

intersection_roget([A|Tail],Otherlist,Tail2) :-

        intersection_roget(Tail,Otherlist,Tail2).

                               

getrogetweight(A,B,A,B,W) :-

        recorded(stg,[rogetmeet_33,W],_),!.

getrogetweight(A,_,A,_,W) :-

        recorded(stg,[rogetmeet_23,W],_),!.

getrogetweight(_,_,_,_,W) :-

        recorded(stg,[rogetmeet_13,W],_),!.

 

 

% for indicator match against lemmalist

 

i_roget([],_,[]).

 

i_roget([[Pos,Cat,Sub1,Sub2]|Tail],Otherlist,[Weight|Tail2]) :-

        member([Pos,Cat,Othersub1,Othersub2],Otherlist),!,

        irogetweight(Sub1,Sub2,Othersub1,Othersub2,Weight),

        i_roget(Tail,Otherlist,Tail2).

 

i_roget([A|Tail],Otherlist,Tail2) :-

        i_roget(Tail,Otherlist,Tail2).

                               

irogetweight(A,B,A,B,3) :-   !.

irogetweight(A,_,A,_,2) :-   !.

irogetweight(_,_,_,_,1) :-   !.

 

 

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

% list flattening : adapted from Sterling and Shapiro, The Art

% of Prolog, MIT Press, first ed., p.243

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

 

% 2 args

 

flatten([],[]).

 

flatten(Xs,Ys) :-

        Xs \= [],

        flatten(Xs,[],Ys).

 

 

 

% 3 args

 

flatten([X|Xs],Zs,Ys) :-

        flatten(Xs,Zs,Ys1),

        flatten(X,Ys1,Ys).

 

flatten(X,Xs,[X|Xs]) :-

        X=item(A,B,C),

        X \= [].

 

flatten([],Xs,Xs).

 

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

/* standard flatten for integer lists */

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

 

% 2 args

 

flat([],[]).

 

flat(Xs,Ys) :-

        Xs \= [],

        flat(Xs,[],Ys).

 

 

% 3 args

 

flat([X|Xs],Zs,Ys) :-

        flat(Xs,Zs,Ys1),

        flat(X,Ys1,Ys).

 

flat(X,Xs,[X|Xs]) :-

        integer(X), X \= [].

 

flat([],Xs,Xs).

      

/* LIST FLATTEN : standard flatten for lists of atoms */

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

 

 

flatlist([],[]) :- !.

flatlist(X,[]) :- var(X),!.

flatlist([n],[]) :- !.

flatlist(n,[]) :- !.

 

flatlist([X|Xs],Ys) :-

        flatlist(X,Ys1),

        flatlist(Xs,Ys2),

        append(Ys1,Ys2,Ys).

 

 

 

% standard:

 

flatlist(X,[X]) :-

        not(islist(X)).

 

 

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

% Type predicate ISLIST

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

 

islist([]).

islist([A|B]).

 

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

% removing duplicates from a list

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

        

remdup([X|Y],L) :-

        member(X,Y),

        remdup(Y,L),

        !.

   

remdup([],[]).

 

remdup([X|Y],[X|Y1]) :-

        not(member(X,Y)) ,

        remdup(Y,Y1),

        !.

 

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

% REMOVEDOT: removes final dot from keyed-in data

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

 

removedot(File,Newfile) :-

        string_length(File,Length),

        End is Length-1,

        substring(File,End,1,Finalchar),

        Finalchar = '.',

        substring(File,0,End,Newfile),

        !.

 

removedot(File,File).

 

 

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

% computing length and weight on the basis of length

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

 

/* used in metalinguistic slot sharing assessment */

 

len([],0).

 

len([H|T],Weight) :-

        len(T,Weight1),

        Weight is Weight1 + 4.

 

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

% list append

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

 

append([],X,X).

 

append([H|Q],L,[H|Q2]) :-

        append(Q,L,Q2).

 

 

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

% list membership

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

 

%%%%%%%%%

% Member

%%%%%%%%%                          

 

member(X,[X|_]).

 

member(X,[_|Y]) :-

        member(X,Y).

 

 

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

% mrest: cf. member + returns rest of list

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

 

mrest(A,[A|Rest],Rest).

 

mrest(A,[B|C],Rest) :-

        mrest(A,C,Rest).

 

 

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

% Pick

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

 

/* picking a pair of adjacent members out of a list, returning

either member + the remainder */

 

/* does not succeed if first two args

   not members of third arg */

 

pick(A,B,[A,B|C],[B|C]).

 

pick(A,B,[A,B|C],[A|C]).

 

pick(A,B,[X|Y],[X|Z]) :-

        pick(A,B,Y,Z).

 

 

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

% getting the last element of a list

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

 

last([X],X).

 

last([_|Z],X) :-

        last(Z,X).

 

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

% getting the second element of a list

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

 

second([First,Second|_], Second).

 

 

 

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

/* checking membership with value assignment: value is 1 if not

in, 2 if in : used for distinguishing members of the Hlist from

others */

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

 

checkmember(X,Y,2) :-

        member(X,Y),

        !.

 

checkmember(X,Y,1).

 

 

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

% list length

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

 

 

listl([],0).

 

listl([X|Y],Length) :-

        listl(Y,L1),

        Length is L1+1.

 

 

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

% accumulating weights

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

 

accu([],0) :- !.

accu([0],0) :- !.

accu([X],X) :- integer(X),!.

 

accu([H|T],Weight) :-

        nonvar(H),

        !,

        accu(T,W),

        Weight is H+W.

 

accu([H|T],Weight) :-

        var(H),

        !,

        accu(T,Weight).

 

 

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

% INLIST: non-deterministic member

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

 

inlist(X,[X|_]) :- !.

 

inlist(X,[_|Remainder]) :-

        inlist(X,Remainder).

 

 

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

% INPUT / OUTPUT

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

 

 

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

% reading in or stopping ...

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

 

 

readin(Hlist,HandleIn,X) :-

        read(HandleIn,X),

        X \= end_of_file.

    

readin(Hlist,HandleIn,X) :-

        read(HandleIn,X),

        X=end_of_file,

        close(Hlist),

        close(HandleIn),

        fail.

                            

 

            

/* printing results in file and on screen */

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

 

imprime(Handle,ToPrint):-

        write(ToPrint),

        nl, 

        mywrite(Handle,ToPrint),

        nl(Handle).

 

 

mywrite(H,[]):- !.

 

mywrite(H,[X,Xs])  :- 

        write(H,X),

        write(H,' - '),

        mywrite(H,Xs),

        !.

 

mywrite(H,m(A,B,C,D,E,F)) :-

        write(H,A),

        write(H,', '),

        write(H,B),

        write(H,', '),

        write(H,C),

        write(H,', '),

        write(H,D),

        % write(H,', '),

        % write(H,E),

        writedebug(H,F),

        !.

 

mywrite(H,[A|B]) :-

        mywrite(H,A),

        tab(H,1),

        mywrite(H,B),

        !.               

 

mywrite(H,X) :-

        write(H,X).                     

 

writedebug(H,Debug) :-

        recorded(stg,[debug,0],_).

       

 

writedebug(H,Debug) :-

        recorded(stg,[debug,1],_),

        write(H,', '),

        write(H,Debug).

       

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

% COMPUTE_PROCESSING_TIME : processing time for each sentence

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

 

compute_processing_time(Startingpoint,Processtime) :-

        recorded(time,[Startingpoint,Former],Keyformer),

        time(Current),

        replace(Keyformer,[former,Current]),

        get_time_difference(Current,Former,Processtime).

 

get_time_difference(time(H2,M2,S2,C2),time(H1,M1,S1,C1),time(Hd,Md,Sd,Cd)) :-

        Total2 is H2*3600 + M2*60 + S2 + C2/100,

        Total1 is H1*3600 + M1*60 + S1 + C1/100,

        Tdif is Total2 - Total1,

        Hd is integer(Tdif/3600),

        Rest1 is Tdif mod 3600,

        Md is integer(Rest1/60),

        Rest2 is Rest1 mod 60,

        Sd is integer(Rest2),

        Cd is integer(100*(Rest2-Sd)+0.5).

 

 

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

% COMPUTE_AVERAGE_TIME

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

 

compute_average_time(Counter,time(Ht,Mt,St,Ct),time(Ha,Ma,Sa,Ca)) :-

        Total is Ht*3600 + Mt*60 + St + Ct/100,

        Averseconds is Total / (Counter-1),

        Ha is integer(Averseconds/3600),

        Rest1 is Averseconds mod 3600,

        Ma is integer(Rest1/60),

        Rest2 is Rest1 mod 60,

        Sa is integer(Rest2),

        Ca is integer(100*(Rest2-Sa)+0.5).

 

 

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

% SET_DEFAULT: activates default settings

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

 

set_default :-

        eraseall(stg),

        recorda(stg,[current,'DEFAULT'],_),

        recorda(stg,[debug,1],_),

        recorda(stg,[pos_1,20],_),

        recorda(stg,[pos_2,15],_),

        recorda(stg,[pos_3,10],_),

        recorda(stg,[pos_vbonus,5],_),

        recorda(stg,[coll_hmatch,200],_),

        recorda(stg,[coll_meta,1],_),

        recorda(stg,[coll_roget,1],_),

        recorda(stg,[coll_wn,1],_),

        recorda(stg,[head_hmatch,200],_),

        recorda(stg,[head_meta,1],_),

        recorda(stg,[head_roget,1],_),

        recorda(stg,[head_wn,1],_),

        recorda(stg,[head_bonus,20],_),

        recorda(stg,[head_penalty,-20],_),

        recorda(stg,[envir,15],_),

        recorda(stg,[ratio,2],_),

        recorda(stg,[wn_syn,100],_),

        recorda(stg,[wn_ant,40],_),

        recorda(stg,[wn_dic_is_txt_1_up,16],_),

        recorda(stg,[wn_dic_is_txt_2_up,10],_),

        recorda(stg,[wn_dic_is_txt_3_up,6],_),

        recorda(stg,[wn_txt_is_dic_1_up,8],_),

        recorda(stg,[wn_txt_is_dic_2_up,4],_),

        recorda(stg,[wn_txt_is_dic_3_up,1],_),

        recorda(stg,[wn_hypermeet,2],_),

        recorda(stg,[metameet,4],_),

        recorda(stg,[rogetmeet_33,30],_),

        recorda(stg,[rogetmeet_23,20],_),

        recorda(stg,[rogetmeet_13,10],_).

 

 

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

%  CUSTOMIZE : user's choice of settings

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

 

customize :-

        cls,

        nl,

        recorded(stg,[current,Current],Key),

        write(' Customizing settings (current is '),

        write(Current),

        write('): choose one the following items...'),

        nl,

        nl,

        write(' 0 - Debug Info'), nl,

        write(' 1 - Pos'), nl,

        write(' 2 - Collocates'), nl,

        write(' 3 - Head'), nl,

        write(' 4 - Environment'), nl,

        write(' 5 - Translation frequency (ratio)'), nl,

        write(' 6 - WordNet search'), nl,

        write(' 7 - Metalinguistic slot sharing'), nl,

        write(' 8 - Roget category sharing'), nl,

        write(' 9 - Back to default'), nl,nl,

        write(' Strike X to quit this screen'), nl, nl,

        flush,

        get0_noecho(X),

        custom(X),

        ifthen(X \=57,

               replace(Key,[current,'CUSTOM'])),

        customize.

 

customize :- cls.

 

custom(X)  :-

        (X is 88;X is 120),

        fail.

 

custom(48) :-

        write('Customizing debug info value '), nl,

        write('Enter 0 to hide debug info, 1 to show it: '),

        getvalue(debug).

 

 

custom(49) :-

        write('Customizing part-of-speech computation '), nl,

        write('Enter value for direct pos match: '), getvalue(pos_1),

        write('Enter value for second-level pos match: '), getvalue(pos_2),

        write('Enter value for third-level pos match: '), getvalue(pos_3),

        write('Enter value for transitive/intransitive bonus '),

        getvalue(pos_vbonus).

       

custom(50) :-

        write('Customizing collocates weighing '), nl,

        write('Enter value for collocate head match '), getvalue(coll_hmatch),

        write('Enter value for coll_metameet (0/1) '), getvalue(coll_meta),

        write('Enter value for coll_rogetmeet (0/1) '), getvalue(coll_roget),

        write('Enter value for coll_wordnetmeet (0/1) '), getvalue(coll_wn).

       

custom(51) :-

        write('Customizing head weighing '), nl,

        write('Enter value for head head match '),  getvalue(head_hmatch),

        write('Enter value for head bonus '), getvalue(head_bonus),

        write('Enter value for head penalty '), getvalue(head_penalty),

        write('Enter value for head_metameet (0/1) '), getvalue(head_meta),

        write('Enter value for head_rogetmeet (0/1) '), getvalue(head_roget),

        write('Enter value for head_wordnetmeet (0/1) '), getvalue(head_wn).

 

custom(52) :-

        write('Customizing environment weighing: value for envir match? '),

        getvalue(envir).

 

custom(53) :-

        write('Customizing frequency weighing: weight per occurrence? '),

        getvalue(ratio).

 

custom(54) :-

        write('Customizing WordNet search '), nl,

        write('Synonymy? '),

        getvalue(wn_syn),

        write('Antonymy? '),

        getvalue(wn_ant),

        write('Dic is txt 1 up -> '),

        getvalue(wn_dic_is_txt_1_up),

        write('Dic is txt 2 up -> '),

        getvalue(wn_dic_is_txt_2_up),

        write('Dic is txt 3 up -> '),

        getvalue(wn_dic_is_txt_3_up),

        write('Txt is dic 1 up -> '),

        getvalue(wn_txt_is_dic_1_up),

        write('Txt is dic 2 up -> '),

        getvalue(wn_txt_is_dic_2_up),

        write('Txt is dic 3 up -> '),

        getvalue(wn_txt_is_dic_3_up),

        write('Hypermeet -> '),

        getvalue(wn_hypermeet).

 

custom(55) :-

        write('Customizing metameet: weight per list shared? '),

        getvalue(metameet).

 

custom(56) :-

        write('Customizing rogetmeet '), nl,

        write('Value for 1st-level (= closest) co-occurrence? '),

        getvalue(rogetmeet_33),

        write('Value for 2nd-level co-occurrence? '),

        getvalue(rogetmeet_23),

        write('Value for 3rd-level co-occurrence? '),

        getvalue(rogetmeet_13).

 

custom(57) :-

        set_default.

 

custom(X) :-

        X \= 88,

        X \= 120.

 

getvalue(X) :-

        read_line(0,Tempvalue),

        removedot(Tempvalue,Value),

        string_term(Value,Newvalue),

        recorded(stg,[X,_],Key),

        replace(Key,[X,Newvalue]).

 

writesettings(Hout) :-

        recorded(stg,X,_),

        write(Hout,X), tab(Hout,1),

        fail.

 

writesettings(Hout) :-

        nl(Hout),

        nl(Hout).

 

 

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

%  CHECK_MORPH/4. : morphological analysis and customized lemmatization

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

 

check_morph(X,X,Y,Y).

 

check_morph(X,Go,Y,Y) :-

        retrieveb(sdico,X,

                  sdic(_,_,_,_,_,_,_,_,_,_,_,_,_,gt(Gothere),_,_,_,_)),

         Gothere \= nil,

         retgothere(Gothere,Go).

 

check_morph(Variant,Lemma,OldPos,NewPos) :-

        not(retrieveb(sdico,Variant,_)),

        string_length(Variant,L),

        lemmatize(Variant,L,Lemma,NewPos),

        retrieveb(sdico,Lemma,_),

        !.

 

% -ing, no double consonant

lemmatize(V,L,Lem,ingform) :-

        NewL is L-3,

        string_search(ing,V,NewL),

        Sublength is L-3,

        substring(V,0,Sublength,Lem).

 

% -ing, double consonant

        lemmatize(V,L,Lem,ingform) :-

        NewL is L-3,

        string_search(ing,V,NewL),

        Sublength is L-4,

        substring(V,0,Sublength,Lem).

 

% -ing, add an -e (uniting > unite)

        lemmatize(V,L,Lem,ingform) :-

        NewL is L-3,

        string_search(ing,V,NewL),

        Sublength is L-3,

        substring(V,0,Sublength,TempLem),

        concat(TempLem,'e',Lem).

 

% -er, no double consonant

lemmatize(V,L,Lem,erform) :-

        NewL is L-2,

        string_search(er,V,NewL),

        Sublength is L-2,

        substring(V,0,Sublength,Lem).

 

% -er, double consonant

lemmatize(V,L,Lem,ly_form) :-

        NewL is L-2,

        string_search(er,V,NewL),

        Sublength is L-3,

        substring(V,0,Sublength,Lem).

 

% -ical -> ic

lemmatize(V,L,Lem,adj) :-

        NewL is L-4,

        string_search(ical,V,NewL),

        Sublength is L-2,

        substring(V,0,Sublength,Lem).

 

% -ily -> y

lemmatize(V,L,Lem,adj) :-

        NewL is L-3,

        string_search(ily,V,NewL),

        Sublength is L-3,

        substring(V,0,Sublength,TempLem),

        concat(TempLem,'y',Lem).

 

% -ly, no -ily, no double consonant

lemmatize(V,L,Lem,adj) :-

        NewL is L-2,

        string_search(ly,V,NewL),

        Sublength is L-2,

        substring(V,0,Sublength,Lem).

       

% -ness

lemmatize(V,L,Lem,adj) :-

        NewL is L-4,

        string_search(ness,V,NewL),

        Sublength is L-4,

        substring(V,0,Sublength,Lem).

 

% -iness -> y

lemmatize(V,L,Lem,adj) :-

        NewL is L-5,

        string_search(iness,V,NewL),

        Sublength is L-5,

        substring(V,0,Sublength,TempLem),

        concat(TempLem,'y',Lem).

       

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

 

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

% LISTL_NO_OR

% handle length without taking or-structures into account

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

 

% end of recursion:

 

listl_no_or([],0).

 

 

% neglect an or-structure, i.e. alternate lemmatization

 

listl_no_or([[or,_,_]|Y],Length) :-

        listl_no_or(Y,Length).

 

 

% ????????????????????????

 

listl_no_or([a|Y],Length) :-

        listl_no_or(Y,Length).

 

       

% p-structures are OK and need to be counted

 

listl_no_or([[p,_,_]|Y],Length) :-

        listl_no_or(Y,L1),

        Length is L1+1.

 

 

% alternate lemmatization for the headword : or_h-structure

 

listl_no_or([[or_h,_,_]|Y],Length) :-

        listl_no_or(Y,Length).

 

 

% p-structure for the headword : counted in

 

listl_no_or([[p_h,_,_]|Y],Length) :-

        listl_no_or(Y,L1),

        Length is L1+1.

 

 

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

% LISTL_NO_OR_OR_COR

% handle length taking neither or-structures nor correspondence classes

% into account

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

 

listl_no_or_or_cor(_,[],0) :- !.

 

listl_no_or_or_cor(_,[a|Y],Length) :-

        listl_no_or_or_cor(_,Y,Length).

 

listl_no_or_or_cor(Clwlist,[[p,Class,Lem]|Y],Length) :-

        neglect(Class),

        not(member(Lem,Clwlist)),

        !,

        listl_no_or_or_cor(Clwlist,Y,Length).

 

listl_no_or_or_cor(Clwlist,[[p_h,Class,Lem]|Y],Length) :-

        neglect(Class),

        not(member(Lem,Clwlist)),

        !,

        listl_no_or_or_cor(Clwlist,Y,Length).

 

listl_no_or_or_cor(Clwlist,[[p,_,_]|Y],Length) :-

        listl_no_or_or_cor(Clwlist,Y,L1),

        Length is L1+1.

 

listl_no_or_or_cor(Clwlist,[[p_h,_,_]|Y],Length) :-

        listl_no_or_or_cor(Clwlist,Y,L1),

        Length is L1+1.

 

listl_no_or_or_cor(Clwlist,[[or,_,_]|Y],Length) :-

        listl_no_or_or_cor(Clwlist,Y,Length),

        !.

 

listl_no_or_or_cor(Clwlist,[[or_h,_,_]|Y],Length) :-

        listl_no_or_or_cor(Clwlist,Y,Length),!.

 

 

neglect(t_dq).

neglect(t_dig).

neglect(t_mod).

neglect(t_have).

neglect(t_be).

neglect(t_intrel).

neglect(t_pro).

neglect(t_self).

 

 

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

% CHECK_CLWLIST : rejects words that cannot be clicked-on alone.

%     If the selected word is non-clickable, we move directly to

%     the next sentence.

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

 

check_clwlist([A,B|Tail],Hout) :-  !.

 

check_clwlist([Clw],Hout) :-

        not(reject_clw(Clw)),

        !.

 

check_clwlist([Clw],Hout) :-

        % i.e. reject_clw(Clw),

        write($Sorry, '$),

        write(Clw),

        write($' cannot be selected alone.$),

        nl,

        write(Hout,$Sorry, '$),

        write(Hout,Clw),

        write(Hout,$' cannot be selected alone.$),

        nl(Hout),

        write($--------------------------------------------------------$),

        nl,

        write(Hout,$----------------------------------------------------$),

        nl(Hout),

        fail.

 

 

% reject member of a correspondence pair, i.e. semantically light:

 

reject_clw(Clw) :-

        corr(Clw,_).

 

 

% reject prep and particles:

 

reject_clw(at).

reject_clw(in).

reject_clw(on).

reject_clw(upon).

reject_clw(through).

reject_clw(for).

reject_clw(with).

reject_clw(by).

reject_clw(from).

reject_clw(up).

reject_clw(out).

reject_clw(about).

reject_clw(into).

reject_clw(of).

reject_clw(back).

reject_clw(down).

reject_clw(over).

reject_clw(after).

reject_clw(off).

 

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

% Computing the maxvalue of a list of integers

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

 

max([X|Rest],M) :- maximum(Rest,X,M).

 

maximum([X|Xs],Y,M) :- X =< Y, maximum(Xs,Y,M).

maximum([X|Xs],Y,M) :- X>Y, maximum(Xs,X,M).

maximum([],M,M).

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

 

 

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

% Links table:

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

 

% lablink(L1,L2,W).

 

 

lablink($accounting$,$advert$,9.1694814815).

lablink($accounting$,$comm$,4.6211105926).

lablink($admin$,$comm$,2.700205154).

lablink($advert$,$comm$,2.7812239678).

lablink($advert$,$press$,11.908417508).

lablink($advert$,$tv$,7.953701409).

lablink($aerosp$,$naut$,2.0671297842).

lablink($agr$,$ecol$,2.8509442653).

lablink($agr$,$ind$,3.7524110657).

lablink($airforce$,$mil$,11.41394148).

lablink($anat$,$med$,1.1703535274).

lablink($antiquity$,$admin$,2.0346482577).

lablink($antiquity$,$theat$,1.8667511159).

lablink($archit$,$cards$,1.2296169739).

lablink($archit$,$mus$,1.0387804196).

lablink($archit$,$rel$,2.3231739359).

lablink($army$,$mil$,8.1946246525).

lablink($army$,$naut$,6.9964392698).

lablink($art$,$cine$,3.9407085527).

lablink($art$,$mus$,3.1180856423).

lablink($art$,$theat$,1.8620489721).

lablink($athletics$,$sport$,11.440665434).

lablink($audio$,$cine$,2.4142921226).

lablink($audio$,$rad$,3.8462590107).

lablink($audio$,$tv$,3.7874768614).

lablink($audiorecording$,$cine$,9.7778830964).

lablink($audiorecording$,$tv$,7.6696406444).

lablink($aviat$,$aut$,3.4660170755).

lablink($aviat$,$mil$,1.7672820913).

lablink($aviat$,$naut$,6.8776725538).

lablink($banking$,$comm$,1.6662658387).

lablink($banking$,$press$,2.5763403263).

lablink($baseball$,$sport$,5.1482994455).

lablink($basketball$,$sport$,8.5804990758).

lablink($billiards$,$sport$,1.7876039741).

lablink($bio$,$anat$,5.6202311614).

lablink($bio$,$ecol$,11.246638401).

lablink($bio$,$med$,1.6315066069).

lablink($biochem$,$med$,29.600191296).

lablink($bot$,$anat$,6.7264621396).

lablink($bot$,$culin$,4.9404533844).

lablink($bowling$,$sport$,5.7203327172).

lablink($bowls$,$sport$,28.601663586).

lablink($boxing$,$sport$,3.6814022437).

lablink($bridge$,$cards$,25.119318182).

lablink($business$,$ind$,5.0741105099).

lablink($business$,$scol$,2.8675871016).

lablink($chem$,$culin$,1.9361236236).

lablink($chem$,$ind$,2.3450618843).

lablink($cine$,$rad$,6.2342207661).

lablink($cine$,$theat$,18.366707662).

lablink($cine$,$tv$,21.445914598).

lablink($climbing$,$sport$,1.3365263358).

lablink($constr$,$admin$,3.0862642112).

lablink($constr$,$comm$,1.4603228699).

lablink($constr$,$ind$,2.4372834191).

lablink($cricket$,$sport$,6.6396719039).

lablink($croquet$,$sport$,9.533887862).

lablink($dancing$,$mus$,4.7157333333).

lablink($dancing$,$sport$,3.4049599507).

lablink($dancing$,$theat$,3.2001447702).

lablink($darts$,$sport$,28.601663586).

lablink($dentistry$,$anat$,1.8882787235).

lablink($dentistry$,$med$,3.8370618347).

lablink($dice$,$cards$,351.67045455).

lablink($diplomacy$,$press$,16.746212121).

lablink($dominoes$,$cards$,87.917613636).

lablink($dress$,$anat$,3.186470346).

lablink($dress$,$theat$,1.0500475027).

lablink($econ$,$admin$,1.5393485943).

lablink($econ$,$banking$,2.0845345548).

lablink($econ$,$comm$,2.2761599898).

lablink($econ$,$ind$,2.7014528809).

lablink($educ$,$scol$,3.2527853689).

lablink($elec$,$rad$,2.3336852424).

lablink($electron$,$mus$,1.9044307692).

lablink($electron$,$tv$,1.9665745242).

lablink($equitation$,$sport$,2.252099495).

lablink($fashion$,$anat$,3.6634868648).

lablink($fashion$,$sport$,2.0552093595).

lablink($fencing$,$mil$,2.3158721844).

lablink($fencing$,$sport$,6.2177529535).

lablink($fin$,$advert$,1.7760478796).

lablink($fin$,$banking$,3.9521944575).

lablink($fin$,$comm$,4.5073090313).

lablink($games$,$cards$,38.908220503).

lablink($games$,$sport$,5.8420419239).

lablink($genetics$,$ecol$,317.40512821).

lablink($geom$,$anat$,7.0322104187).

lablink($golf$,$sport$,5.5614345862).

lablink($govt$,$admin$,36.623668639).

lablink($gym$,$sport$,3.7306517721).

lablink($hist$,$mil$,1.276212036).

lablink($hist$,$rel$,1.2245733987).

lablink($hockey$,$sport$,11.917359827).

lablink($horseracing$,$sport$,1.5889813103).

lablink($hort$,$culin$,1.9664941903).

lablink($hotel$,$comm$,3.2608643295).

lablink($hypnosis$,$rel$,51.10982659).

lablink($ind$,$admin$,3.1945879187).

lablink($ind$,$comm$,3.4190459992).

lablink($ind$,$ecol$,2.9664030673).

lablink($insurance$,$admin$,1.3996306486).

lablink($jur$,$admin$,2.9951611826).

lablink($literat$,$advert$,3.0667162145).

lablink($literat$,$cine$,7.5214485357).

lablink($literat$,$mus$,5.4648882943).

lablink($literat$,$press$,4.9286510591).

lablink($literat$,$rad$,1.7366052389).

lablink($literat$,$theat$,4.270427302).

lablink($literat$,$tv$,5.3867041315).

lablink($marketing$,$comm$,5.7763882408).

lablink($meas$,$naut$,1.0454449484).

lablink($mech$,$aut$,8.7847942564).

lablink($metal$,$ind$,11.568971963).

lablink($mgmt$,$admin$,14.0860264).

lablink($mgmt$,$comm$,2.2216877849).

lablink($mgmt$,$jur$,2.9057533861).

lablink($mgmt$,$sport$,6.6003839045).

lablink($military_sl$,$mil$,6.1459684893).

lablink($motor_racing$,$aut$,3.9265368267).

lablink($motor_racing$,$sport$,2.6001512351).

lablink($mus$,$cine$,1.016899842).

lablink($mus$,$theat$,2.5268343105).

lablink($myth$,$rel$,1.4465045261).

lablink($naut$,$mil$,1.4871949222).

lablink($navy$,$mil$,2.4967996988).

lablink($navy$,$naut$,5.6846069067).

lablink($nucl_phys$,$ecol$,25.058299595).

lablink($nucl_phys$,$ind$,5.0741105099).

lablink($nucl_phys$,$med$,5.4526668177).

lablink($nucl_phys$,$mil$,2.8034242232).

lablink($opt$,$med$,3.1158096101).

lablink($opt$,$mil$,1.4017121116).

lablink($opt$,$naut$,2.3935186976).

lablink($painting$,$mus$,12.3788).

lablink($parl$,$admin$,3.1335759263).

lablink($pharm$,$culin$,2.2212891186).

lablink($pharm$,$med$,7.2279536886).

lablink($philo$,$rel$,4.7544024735).

lablink($phon$,$anat$,3.1214403389).

lablink($phon$,$mus$,2.0210285714).

lablink($phot$,$cine$,8.2243876511).

lablink($phot$,$tv$,5.0175219169).

lablink($phys$,$mus$,1.2761649485).

lablink($phys$,$rad$,1.6059122673).

lablink($physiol$,$anat$,7.5133616579).

lablink($physiol$,$med$,3.4273905711).

lablink($poetry$,$rad$,2.8067295483).

lablink($pol$,$admin$,2.9349978352).

lablink($pol$,$ecol$,2.7648530331).

lablink($pol$,$ind$,1.287680774).

lablink($pol$,$press$,1.0113856333).

lablink($police$,$mil$,2.5608202039).

lablink($printing$,$advert$,14.26363786).

lablink($printing$,$press$,3.5725252525).

lablink($psych$,$ecol$,2.5460304401).

lablink($psych$,$med$,3.4032305501).

lablink($racing$,$sport$,2.993197352).

lablink($rad$,$theat$,1.804108461).

lablink($radar$,$tv$,38.348203222).

lablink($rail$,$aut$,2.1833270707).

lablink($rail$,$naut$,1.5991861188).

lablink($recording$,$cine$,32.592943655).

lablink($recording$,$rad$,34.616331096).

lablink($recording$,$tv$,25.565468815).

lablink($rowing$,$sport$,9.533887862).

lablink($rugby$,$sport$,6.6515496712).

lablink($sailing$,$naut$,45.476855253).

lablink($sci$,$anat$,1.6994508512).

lablink($sci$,$cine$,1.6296471827).

lablink($sci$,$comm$,1.9254627469).

lablink($sci$,$med$,4.933365216).

lablink($sci$,$naut$,1.5158951751).

lablink($sci$,$rad$,1.7308165548).

lablink($sci$,$tv$,1.2782734407).

lablink($scol$,$admin$,1.6119572464).

lablink($scouting$,$mil$,5.3265060241).

lablink($snooker$,$sport$,6.6003839045).

lablink($soccer$,$sport$,8.6911132444).

lablink($space$,$mil$,1.8580834968).

lablink($space$,$naut$,2.1152025699).

lablink($spec$,$med$,29.600191296).

lablink($surgery$,$med$,14.800095648).

lablink($tax$,$admin$,1.09324384).

lablink($tax$,$comm$,1.2932212479).

lablink($tax$,$jur$,1.4095072395).

lablink($tech$,$aut$,2.9358553002).

lablink($tech$,$ind$,3.7763541353).

lablink($telec$,$rad$,9.3634338211).

lablink($telec$,$tv$,2.3050832538).

lablink($tennis$,$cards$,2.344469697).

lablink($tennis$,$sport$,5.52965496).

lablink($tex$,$ind$,1.1409242567).

lablink($tourism$,$sport$,2.8287359591).

lablink($transp$,$aut$,1.5829494014).

lablink($turf$,$athletics$,104.90508475).

lablink($turf$,$betting$,21.855225989).

lablink($turf$,$darts$,524.52542373).

lablink($turf$,$equitation$,8.2602428934).

lablink($turf$,$games$,6.6960692391).

lablink($turf$,$horseracing$,29.140301318).

lablink($turf$,$racing$,24.396531336).

lablink($turf$,$sport$,6.7868354272).

lablink($tv$,$press$,8.9645150389).

lablink($tv$,$rad$,54.562544181).

lablink($tv$,$theat$,5.6627097048).

lablink($typ$,$mus$,1.8338962963).

lablink($typ$,$press$,2.835337502).

lablink($univ$,$admin$,1.0693041938).

lablink($univ$,$scol$,14.032936671).

lablink($vet$,$med$,5.1682873691).

lablink($video$,$cine$,53.77835703).

lablink($video$,$mus$,4.95152).

lablink($video$,$tv$,15.339281289).

lablink($volleyball$,$sport$,14.300831793).

lablink($wine$,$culin$,4.0935185185).

lablink($wrestling$,$sport$,3.3649015983).

lablink($zool$,$anat$,3.6240308943).

lablink($zool$,$culin$,1.6973663216).

lablink($zool$,$ecol$,3.0766248291).

 

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

%%% assoc (DEFIcode,Merriam-Webster/Longmancode)

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

 

assoc(accounting,ecza).

assoc(admin,pl).

assoc(advert,bzza).

assoc(aerosp,ao).

assoc(agr,ag).

assoc(anat,mdza).

assoc(antiquity,hi).

assoc(archeol,ar).

assoc(archit,ac).

assoc(art,af).

assoc(astrol,oczs).

assoc(astron,as).

assoc(audio,re).

assoc(aut,au).

assoc(aviat,ae).

assoc(banking,eczb).

assoc(baseball,bb).

assoc(betting,gb).

assoc(bible,bl).

assoc(bio,mdzb).

assoc(bot,bo).

assoc(boxing,gyzb).

assoc(bridge,cdzb).

assoc(cards,cd).

assoc(chem,sizc).

assoc(chess,gazc).

assoc(cine,mp).

assoc(climbing,spzh).

assoc(comm,bz).

assoc(comput,dp).

assoc(constr,bd).

assoc(cosmetics,bezc).

assoc(cricket,ck).

assoc(culin,fozc).

assoc(dancing,da).

assoc(dentistry,de).

assoc(dress,cl).

assoc(drugs,dg).

assoc(drug_sl,dg).

assoc(ecol,mdze).

assoc(econ,ec).

assoc(educ,ed).

assoc(elec,egze).

assoc(electron,egzt).

assoc(equitation,eq).

assoc(fashion,cl).

assoc(fin,ec).

assoc(fishing,hfza).

assoc(games,ga).

assoc(geog,gozg).

assoc(geol,go).

assoc(geom,mhzg).

assoc(golf,gf).

assoc(gram,ln).

assoc(gym,gy).

assoc(herald,he).

assoc(hist,hi).

assoc(hort,agzh).

assoc(hunting,hfzh).

assoc(ind,eg).

assoc(insurance,in).

assoc(jur,lw).

assoc(ling,ln).

assoc(literat,lt).

assoc(math,mh).

assoc(meas,ms).

assoc(mech,egzm).

assoc(med,md).

assoc(metal,mt).

assoc(meteo,ml).

assoc(mil,mi).

assoc(min,mg).

assoc(miner,mn).

assoc(mus,mu).

assoc(myth,my).

assoc(naut,na).

assoc(nucl_phys,sizp).

assoc(opt,sizo).

assoc(orn,ozzo).

assoc(parl,pl).

assoc(pharm,rx).

assoc(philo,ph).

assoc(phon,lnzp).

assoc(phot,pg).

assoc(phys,sizp).

assoc(physiol,mdzp).

assoc(poetry,lt).

assoc(pol,pl).

assoc(police,sozc).

assoc(post,stzp).

assoc(press,ptzj).

assoc(printing,pt).

assoc(psych,ps).

assoc(racing,spzm).

assoc(rad,ra).

assoc(rail,rr).

assoc(rel,rl).

assoc(rel,rn).

assoc(rugby,fbzr).

assoc(sci,si).

assoc(scol,ed).

assoc(sewing,kszs).

assoc(ski,wi).

assoc(soc,so).

assoc(soccer,fbzs).

assoc(sociol,so).

assoc(space,ao).

assoc(sport,sp).

assoc(statistics,mhzs).

assoc(stex,eczs).

assoc(surg,mdzs).

assoc(surv,egzs).

assoc(tax,eczt).

assoc(telec,cm).

assoc(tennis,ntzt).

assoc(tex,te).

assoc(theat,th).

assoc(transport,tn).

assoc(turf,gbzg).

assoc(tv,razt).

assoc(typ,ptzy).

assoc(univ,ed).

assoc(vet,mdzv).

assoc(zool,oz).

 

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

 

 

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

% Significant labels (10 occur. upwards in DEFIDIC)

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

 

keeplabel(accounting).

keeplabel(admin).

keeplabel(advert).

keeplabel(aerosp).

keeplabel(agr).

keeplabel(airforce).

keeplabel(anat).

keeplabel(anthrop).

keeplabel(antiquity).

keeplabel(archeol).

keeplabel(archit).

keeplabel(army).

keeplabel(art).

keeplabel(astrol).

keeplabel(astron).

keeplabel(athletics).

keeplabel(audio).

keeplabel(audiorecording).

keeplabel(aut).

keeplabel(aviat).

keeplabel(banking).

keeplabel(baseball).

keeplabel(basketball).

keeplabel(betting).

keeplabel(bible).

keeplabel(billiards).

keeplabel(bio).

keeplabel(bookkeeping).

keeplabel(bot).

keeplabel(boxing).

keeplabel(bridge).

keeplabel(business).

keeplabel(cards).

keeplabel(carpentry).

keeplabel(chem).

keeplabel(chess).

keeplabel(cine).

keeplabel(climbing).

keeplabel(comm).

keeplabel(comput).

keeplabel(constr).

keeplabel(cosmetics).

keeplabel(cricket).

keeplabel(culin).

keeplabel(customs).

keeplabel(dancing).

keeplabel(dentistry).

keeplabel(diplomacy).

keeplabel(dress).

keeplabel(drugs).

keeplabel(drug_sl).

keeplabel(ecol).

keeplabel(econ).

keeplabel(educ).

keeplabel(elec).

keeplabel(electron).

keeplabel(engineering).

keeplabel(equitation).

keeplabel(fashion).

keeplabel(fencing).

keeplabel(fin).

keeplabel(fishing).

keeplabel(games).

keeplabel(geog).

keeplabel(geol).

keeplabel(geom).

keeplabel(golf).

keeplabel(gram).

keeplabel(gym).

keeplabel(hairdressing).

keeplabel(herald).

keeplabel(hist).

keeplabel(hockey).

keeplabel(horseracing).

keeplabel(hort).

keeplabel(hotel).

keeplabel(hunting).

keeplabel(ind).

keeplabel(insurance).

keeplabel(job).

keeplabel(jur).

keeplabel(knitting).

keeplabel(ling).

keeplabel(literat).

keeplabel(localgovt).

keeplabel(math).

keeplabel(meas).

keeplabel(mech).

keeplabel(med).

keeplabel(metal).

keeplabel(meteo).

keeplabel(mgmt).

keeplabel(mil).

keeplabel(military_sl).

keeplabel(min).

keeplabel(miner).

keeplabel(motor_racing).

keeplabel(mus).

keeplabel(myth).

keeplabel(naut).

keeplabel(navy).

keeplabel(nucl_phys).

keeplabel(opt).

keeplabel(orn).

keeplabel(parl).

keeplabel(pharm).

keeplabel(philo).

keeplabel(phon).

keeplabel(phot).

keeplabel(phys).

keeplabel(physiol).

keeplabel(poetry).

keeplabel(poker).

keeplabel(pol).

keeplabel(police).

keeplabel(post).

keeplabel(press).

keeplabel(printing).

keeplabel(prison).

keeplabel(prov).

keeplabel(psych).

keeplabel(publishing).

keeplabel(r).

keeplabel(racing).

keeplabel(rad).

keeplabel(rail).

keeplabel(rel).

keeplabel(rowing).

keeplabel(rugby).

keeplabel(sci).

keeplabel(scol).

keeplabel(sewing).

keeplabel(ski).

keeplabel(snooker).

keeplabel(soc).

keeplabel(soccer).

keeplabel(sociol).

keeplabel(space).

keeplabel(sport).

keeplabel(statistics).

keeplabel(stex).

keeplabel(surveying).

keeplabel(swimming).

keeplabel(tax).

keeplabel(tech).

keeplabel(telec).

keeplabel(tennis).

keeplabel(tex).

keeplabel(theat).

keeplabel(tourism).

keeplabel(transp).

keeplabel(turf).

keeplabel(tv).

keeplabel(typ).

keeplabel(univ).

keeplabel(vet).

keeplabel(video).

keeplabel(wine).

keeplabel(wrestling).

keeplabel(zool).

 

 

 

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

% Returning the core of the gothere string

% i.e simply its first element

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

 

% no space in string - return the whole string:

 

retgothere(Str,Str) :-

        not(string_search(' ',Str,Loc)),!.

 

 

 

% return the first element

 

 

retgothere(Str,Gothere) :-

        string_search(' ',Str,Loc),

        substring(Str,0,Loc,Gothere),

        !.

 

 

 

 

 

 

 

 

% COLLOCT.ARI

 

 

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

% COLLOCT.ARI

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

 

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

% Collocation list treatment in the DEFI Matchers

% Defi Project

% A.Michiels and Nicolas Dufour

% Ulg

% Last update: 29 March 2000

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

 

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

% COLLOCT : weighing collocations

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

 

 

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

% Compiler Directives and Declarations

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

 

:- visible word/6.

:- visible synset_words/2.

:- visible synset/6.

 

% from util.ari:

 

:- extrn i_roget/3.

:- extrn intersection_roget/3.

:- extrn flatten/2, flat/2, flatlist/2.

:- extrn append/3, member/2.

:- extrn accu/2.

:- extrn max/2, maximum/3.

:- extrn dans/2.

 

% used by mm.ari

 

:- public colloct/8.

 

% used by sm.ari:

 

:- public metameet/3.

:- public rogetmeet/3.

:- public wordnetmeet/3.

:- public irogetmeet/3.

:- public rwn/3.

:- public toolw/1.

 

:- public wcoll/8.

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

% Colloct : main predicate

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

 

colloct(_,_,_,[nil],[nil],_,0,[]):- !.

 

    

colloct(Dicwlist,DicType,DicPattern,DicScoll,DicOcoll,

        TCollocList,Wcol,ListColl):-

 

        getfirstlemma(Dicwlist,DicType,Lemmafirst),

 

/* this lemma is supposed to give the part of speech of the

item governing the collocate */

 

 

        getlastlemma(Dicwlist,Lemmalast,Poslast,DicType,Lemmafirst),

 

/* permits the retrieval of the prep for those mwu's ending

in a prep as BEAR THE BRUNT OF - a frequent pattern ;

otherwise retrieves the verb in prepositional and phrasal verbs ;

or, if the latter two fail, retrieves the lemma and pos of the

last element of the mwu */

 

        basicpos(DicType,ColPos),

 

/* dealing with collocates presupposes that we know the POS

of the governor; we translate from the Dictype to a POS */

 

       wcoll(pre,Lemmafirst,_,ColPos,DicScoll,TCollocList,

              Wcol1,Lcolpre),   

/* pre-head coll */

 

        wcoll(post,Lemmalast,Last,Poslast,DicOcoll,TCollocList,

              Wcol2,Lcolpost),

/* post-head coll */

 

      [!   flatlist([Lcolpre|Lcolpost],ListColl),

        accu([Wcol1,Wcol2],Wcol) !].

/* adding up */

 

 

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

% BASICPOS(DicType,ColPos)

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

 

basicpos(np,n):- !.

basicpos(vp,v):- !.

basicpos(adjp,adj) :- !.

basicpos(advp,adv) :- !.

basicpos(s,v):- !.

 

 

/* avoiding failure */

 

basicpos(unkn,v).

basicpos(X,X).

 

 

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

% GETFIRSTLEMMA:  gets first appropriate lemma of dicwlist

% on the basis of structural hypothesis.

% getfirstlemma(Dicwlist,Pos,Lemmafirst)

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

 

% get at first main verb

 

getfirstlemma([First|Dicwlist],vp,Lemmafirst) :-

        member(w(_,_,_,lem(Lemmafirst,_),morph(M),syn(S)), Dicwlist),

        member(m(pos,v,_),M),

        member(s(type,main,_,_),S),!.

 

getfirstlemma(Dicwlist,unkn,Lemmafirst) :-

        member(w(_,_,_,lem(Lemmafirst,_),morph(M),syn(S)), Dicwlist),

        member(m(pos,v,_),M),

        member(s(type,main,_,_),S),!.

 

getfirstlemma(Dicwlist,s,Lemmafirst) :-

        member(w(_,_,_,lem(Lemmafirst,_),morph(M),syn(S)), Dicwlist),

        member(m(pos,v,_),M),

        member(s(type,main,_,_),S),!.

 

% other pos

 

getfirstlemma(Dicwlist,StrucHyp,Lemmafirst) :-

        member(w(_,_,_,lem(Lemmafirst,_),morph(M),syn(S)), Dicwlist),

        member(m(pos,ParserPos,_),M),

        corpos(ParserPos,StrucHyp),!.

 

 

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

% corpos(ParserPos, StrucHyp)

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

 

corpos(n,np):- !.

corpos(v,vp):- !.

corpos(adj,adjp):- !.

corpos(adv,advp):- !.

corpos(edform,adjp).

corpos(edform,vp) :- !.

corpos(ingform,adjp).

corpos(ingform,vp) :- !.

corpos(abbr,np):- !.

 

 

% avoiding failure

 

corpos(v,unkn):- !.

corpos(v,s):- !.

corpos(_,_).

 

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

% GETLASTLEMMA

% the last lemma is the last member of the dicwlist but one

% (the last element is always a punct sign)

% getlastlemma(Dicwlist,Lemmalast,Poslast,Dictype,Lemmafirst)

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

  

getlastlemma(Dicwlist,Lemmalast,n,Dictype,Lemmafirst) :-

        lasttwobutone(Dicwlist,w(_,_,_,lem(Lemmalast,_),morph(M1),_),

                        w(_,_,_,lem(of,_),morph(M2),_)

                        ),

        member(m(pos,n,_),M1),!.

  

getlastlemma(_,Lemmalast,v,vp,Lemmalast) :- !.

 

getlastlemma(_,Lemmalast,v,unkn,Lemmalast) :- !.

 

getlastlemma(_,Lemmalast,v,s,Lemmalast) :- !.

  

getlastlemma(Dicwlist,Lemmalast,Poslast,Dictype,Lemmafirst) :-

        lastbutone(Dicwlist,w(_,_,_,lem(Lemmalast,_),morph(M),_)),

        member(m(pos,Poslast,_),M).

 

 

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

% lastbutone(List,Penult)

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

 

lastbutone([X,Y],X) :- !.

 

lastbutone([_|Z],X) :-

        lastbutone(Z,X).

 

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

% lasttwobutone(List,Antepenult, Penult)

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

 

lasttwobutone([X,Y,Z],X,Y) :- !.

 

lasttwobutone([_|Z],X,Y) :-

        lasttwobutone(Z,X,Y).

 

 

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

% WCOLL : Weighting the collocate lists

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

 

wcoll(_,_,_,_,_,_,0,[]) :- recorded(stg,[coll_hmatch,0],_), !.

 

 

 

% no collocates in dic

 

wcoll(_,_,_,_,[nil],_,0,[]) :- !.

wcoll(_,_,_,_,nil,_,0,[]) :- !.

 

 

% no occurrence of lemma in textual collocate list

 

wcoll(_,Lemma,_,_,_,List,0,[]) :-

     not(dans(Lemma,List)),!.

    

 

wcoll(Dir,Lemma,Position,Pos,[Collocate|Others],TCollocList,W,[Lcol,Lcols]) :-

        prc(Dir,Lemma,Position,Pos,Collocate,TCollocList,Weight,Lcol),

        prclist(Dir,Lemma,Position,Pos,Others,TCollocList,Weights,Lcols),

        [! flat([Weight|Weights],Wflat),

           max(Wflat,W) !],!.

 

% avoiding failure and assigning zero weight

 wcoll(_,_,_,_,_,_,0,[]).

 

% going through a list of collocates specified by the dic

       

prclist(_,_,_,_,[],_,0,[]).

 

prclist(Dir,Lemma,Position,Pos,[Head|Remainder],

                TCollocList,[Weight|Weights],[Lcol|Lcols]) :-

        prc(Dir,Lemma,Position,Pos,Head,TCollocList,Weight,Lcol),

        prclist(Dir,Lemma,Position,Pos,Remainder,TCollocList,Weights,Lcols).

 

 

% dealing with one collocate and matching it against the list

% of syntactic rel in the clause

       

prc(Dir,Lemma,Position,Pos,Collocate,[Relation|Otherrelations],

                [Oneweight|Otherweights],[Col1|Nextcols]) :-

        prc1(Dir,Lemma,Position,Pos,Collocate,Relation,Oneweight,Col1),

        prcrest(Dir,Lemma,Position,Pos,Collocate,Otherrelations,

                Otherweights,Nextcols).

 

 

% matching a collocate against all the other textual syn rel

 

prcrest(_,_,_,_,_,[],0,[]).  

 

prcrest(Dir,Lemma,Position,Pos,Collocate,[H|T],[W|Ws],[C1|NxtC]) :-

       prc1(Dir,Lemma,Position,Pos,Collocate,H,W,C1),

       prcrest(Dir,Lemma,Position,Pos,Collocate,T,Ws,NxtC).       

       

 

% matching a dic collocate against a textual syn rel

 

prc1(pre,Lemma,_,v,Collocate,csubj(Intext,Lemma),Weight,Col) :-

      cm(Collocate,Intext,n,Weight,Col).

 

prc1(pre,Lemma,_,adj,Collocate,cadj(Lemma,Intext),Weight,Col) :-

      cm(Collocate,Intext,n,Weight,Col).

 

prc1(pre,Lemma,_,n,Collocate,cnn(Lemma,Intext),Weight,Col) :-

      cm(Collocate,Intext,n,Weight,Col).

 

prc1(post,Lemma,_,n,Collocate,cnn(Intext,Lemma),Weight,Col) :-

      cm(Collocate,Intext,n,Weight,Col).

 

prc1(pre,Lemma,_,adv,Collocate,cadva(Lemma,Intext),Weight,D) :-

      cm(Collocate,Intext,a,Weight,D).

 

prc1(pre,Lemma,_,adv,Collocate,cadvv(Lemma,Intext),Weight,Col) :-

      cm(Collocate,Intext,v,Weight,Col).

                                             

prc1(post,Lemma,Position,v,Collocate,cdobj(Intext,Lemma),Weight,Col) :-

      cm(Collocate,Intext,n,Weight,Col).

 

prc1(post,Lemma,Position,v,Collocate,ciobj(Intext,Lemma),Weight,Col) :-

      cm(Collocate,Intext,n,Weight,Col).

 

prc1(post,Lemma,Position,n,Collocate,ccplt(Intext,Lemma),Weight,Col) :-

      cm(Collocate,Intext,n,Weight,Col).

/*

prc1(post,Lemma,Position,prep,Collocate,

     cprep(Posintxt,Lemma,Intext),Weight,Col) :-

     Newpos is Position - 1,

     Newpos >= Posintxt,

     cm(Collocate,Intext,n,Weight,Col).

*/

 

prc1(_,_,_,_,_,_,0,[]).

 

  

/* COMPUTING A PRIORITY RATING IN COLLOC  */

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

 

/* DIRECT HEAD MATCH */

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

 

/* match between the head of the arg and the metalinguistic

slot in dic */

 

cm(C,C,_,W,coll(hm,C,W)) :-

        nonvar(C),

        recorded(stg,[coll_hmatch,W],_),

        !.

 

 

% matching gender-marked personal pronouns

 

cm(person,she,_,10,coll(pr,person,she,10)) :-

        !.

cm(girl,she,_,10,coll(pr,girl,she,10)) :-

        !.

cm(woman,she,_,10,coll(pr,woman,she,10)) :-

        !.

 

       

cm(person,he,_,10,coll(pr,person,he,10)) :-

        !.

cm(man,he,_,10,coll(pr,man,he,10)) :-

        !.

cm(boy,he,_,10,coll(pr,boy,he,10)) :-

        !.

       

       

% matching they against people : dubious

cm(people,they,_,10,coll(pr,people,they,10)) :-

        !.

 

                                 

/* INDIRECT MATCH: metameet, rogetmeet,wordnetmeet */

 

cm(Diccoll,Txtcoll,Pos,Weight,Debug) :-

        recorded(coll_met,[Diccoll,Txtcoll,Pos,Weight],_),

        ifthenelse(Weight=0,

                    Debug=[],

                     Debug=cmet(Diccoll,Txtcoll,Weight) ),

        !.

 

cm(Diccoll,Txtcoll,Pos,Weight,Debug) :-

        ifthenelse(recorded(stg,[coll_meta,1],_),

                   metameet(Diccoll,Txtcoll,Weight1),

                   Weight1 is 0),

        ifthenelse(recorded(stg,[coll_roget,1],_),

                   rogetmeet(Diccoll,Txtcoll,Weight2),

                   Weight2 is 0),

        ifthenelse(recorded(stg,[coll_wn,1],_),

                   wordnetmeet(item(Diccoll,Pos,_),

                               item(Txtcoll,Pos,_),Weight3),

                   Weight3 is 0),

        Weight is Weight1 + Weight2 + Weight3,

        ifthenelse(Weight=0,

                     Debug=[],

                     Debug=coll(Diccoll,Txtcoll,mt(Weight1),

                        rg(Weight2),wn(Weight3),tot(Weight))),

        recorda(coll_met,[Diccoll,Txtcoll,Pos,Weight],_).

 

 

/* METALINGUISTIC SLOT SHARING */

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

 

/* match between the head of the arg and the metalinguistic

slot of the OH sdic through the sharing of metalinguistic slots

elsewhere in Defidic */

 

metameet(W1,W2,Weight) :-

        nonvar(W1),

        nonvar(W2),

        W1 @< W2,

        retrieveb(colloc,W1,mt(W1,List)),

        member([W2,TempWeight],List),

        ifthenelse( (W1=person;W2=person;W1=object;W2=object),

                     Weight is TempWeight // 4,

                     Weight is TempWeight * 4),

        !.

 

metameet(W1,W2,Weight) :-

        nonvar(W1),

        nonvar(W2),

        W1 @> W2,

        retrieveb(colloc,W2,mt(W2,List)),

        member([W1,TempWeight],List),

        ifthenelse( (W1=person;W2=person;W1=object;W2=object),

                     Weight is TempWeight // 4,

                     Weight is TempWeight * 4),

        !.

 

metameet(_,_,0).

 

 

/* CO-OCCURRENCE IN ROGET'S THESAURUS */

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

 

rogetmeet(_,_,0) :-

        recorded(stg,[rogetmeet,0],_),!.

 

rogetmeet(Collocate,Text,Weight) :-

        recorded(rogetmet,[Text,Collocate,Weight],_),

        !.

 

rogetmeet(Collocate,Text,Weight) :-

        recorded(coll_in_roget,[Text|[Tcollist]],_),

        retrieveb(roget,Collocate,r(Collocate,Dcollist)),

        intersection_roget(Tcollist,Dcollist,Commonlist),

        [! accu(Commonlist,Weight) !],

        recorda(rogetmet,[Text,Collocate,Weight],_),

        !.

 

rogetmeet(_,_,0).

 

 

 

irogetmeet(A,B,W) :-

        i_roget(A,B,Commonlist),

        [! accu(Commonlist,W) !],

        !.

 

irogetmeet(_,_,0).

 

 

%%

% WORDNETMEET

%%

 

/* WordNet Prolog Queries for Arity/Prolog 32 bit version

   adapted from the public domain WordNet prolog package 

   distributed by Princeton University */

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

 

/* The wordnet predicates are stored in various binary trees with

   the search key acting as index :

  

   BTREE NAME           INDEXED ON              CLAUSE

  

   synset               A(synset)               s(A,B,C,D,E,F)

   wordset              C(word)                 w(C,D,E,F,A,B)

  

   hypo                 A(source)               hyp(A,B)

   hyper                B(dest)                 hyp(A,B)

  

   member               A                       mm(A,B)

   set                  B                       mm(A,B)

  

   subst                A                       ms(A,B)

   whole                B                       ms(A,B)

  

   part                 A                       mp(A,B)

   whole                B                       mp(A,B)

  

   ant                  A                       ant(A,B,C,D)

  

   sim                  A                       sim(A,B)

  

*/  

  

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

 

% restricted wordnet for use on indicators - only synonyms

% and antonyms

 

rwn(item(W1,Pos1,S1),item(W2,Pos1,S2),5) :-

    qsyns(W1,Pos1,S1,L1),

    member(item(W2,Pos1,S2),L1),

    !.

  

rwn(item(W1,Pos1,S1),item(W2,Pos1,S2),5) :-

    qants(W1,Pos1,S1,L1),

    member(item(W2,Pos1,S2),L1),

    !.

 

rwn(_,_,0).

 

% wordnetmeet(item(Word,Pos,Sense),item(Word,Pos,Sense),Weight) :

% the two items are connected and the connection is assigned

% a given weight on the basis of the strength of the link

 

% Wordnetmeet is disabled

wordnetmeet(_,_,0) :- recorded(stg,[wn_syn,0],_),!.

 

% Wordnetmeet has already been performed for the pair.

wordnetmeet(item(W1,Pos1,S1),item(W2,Pos1,S2),W) :-

  recorded(wnmet,[W1,W2,Pos1,W],_),

  !.

 

% they are synonyms

 

wordnetmeet(item(W1,Pos1,S1),item(W2,Pos1,S2),W) :-

    qsyns(W1,Pos1,S1,L1),

    member(item(W2,Pos1,S2),L1),

    recorded(stg,[wn_syn,W],_),

    recorda(wnmet,[W1,W2,Pos1,W],_),

    !.

 

 

% they are antonyms in the broader sense, i.e. item a belongs to

% to a synset at least one of whose members has an antonym in the

% synset that item b belongs to

 

wordnetmeet(item(W1,Pos1,S1),item(W2,Pos1,S2),W) :-

    qants(W1,Pos1,S1,L1),

    member(item(W2,Pos1,S2),L1),

    recorded(stg,[wn_ant,W],_),

    recorda(wnmet,[W1,W2,Pos1,W],_),

    !.

 

% Y is a parent of X one up

 

wordnetmeet(item(W1,Pos1,S1), item(W2,Pos1,S2),W) :-

   explore(W1,Pos1,S1,genhyp,up,2,Wlist),

   member(item(W2,Pos1,S2),Wlist),

   recorded(stg,[wn_dic_is_txt_1_up,W],_),

   recorda(wnmet,[W1,W2,Pos1,W],_),

   !.

 

% X is a parent of Y one up

 

wordnetmeet(item(W1,Pos1,S1), item(W2,Pos1,S2),W) :-

   explore(W2,Pos1,S2,genhyp,up,2,Wlist),

   member(item(W1,Pos1,S1),Wlist),

    recorded(stg,[wn_txt_is_dic_1_up,W],_),

   recorda(wnmet,[W1,W2,Pos1,W],_),

   !.

 

% Y is a parent of X two up

 

wordnetmeet(item(W1,Pos1,S1), item(W2,Pos1,S2),W) :-

   explore(W1,Pos1,S1,genhyp,up,3,Wlist),

   member(item(W2,Pos1,S2),Wlist),

   recorded(stg,[wn_dic_is_txt_2_up,W],_),

   recorda(wnmet,[W1,W2,Pos1,W],_),

   !.

 

% X is a parent of Y two up

 

wordnetmeet(item(W1,Pos1,S1), item(W2,Pos1,S2),W) :-

   explore(W2,Pos1,S2,genhyp,up,3,Wlist),

   member(item(W1,Pos1,S1),Wlist),

   recorded(stg,[wn_txt_is_dic_2_up,W],_),

   recorda(wnmet,[W1,W2,Pos1,W],_),

   !.

 

% We rem three-up and common-hypernym treatment if too expensive

 

% START REM HERE IF NEEDED---------------------------------------------------

 

% Y is a parent of X three up

 

wordnetmeet(item(W1,Pos1,S1), item(W2,Pos1,S2),W) :-

   explore(W1,Pos1,S1,genhyp,up,4,Wlist),

   member(item(W2,Pos1,S2),Wlist),

   recorded(stg,[wn_dic_is_txt_3_up,W],_),

   recorda(wnmet,[W1,W2,Pos1,W],_),

   !.

 

%  X is a parent of Y three up

 

wordnetmeet(item(W1,Pos1,S1), item(W2,Pos1,S2),W) :-

   explore(W2,Pos1,S2,genhyp,up,4,Wlist),

   member(item(W1,Pos1,S1),Wlist),

   recorded(stg,[wn_txt_is_dic_3_up,W],_),

   recorda(wnmet,[W1,W2,Pos1,W],_),

   !.

                                        

% they are related through a common parent one up

 

 wordnetmeet(item(W1,Pos1,S1),item(W2,Pos1,S2),W) :-

     hypermeet(item(W1,Pos1,S1),item(W2,Pos1,S2),_),

     recorded(stg,[wn_hypermeet,W],_),

     recorda(wnmet,[W1,W2,Pos1,W],_),

     !.

 

% STOP REM HERE --------------------------------------------                 

 

% Avoid failure

wordnetmeet(item(W1,Pos1,S1),item(W2,Pos1,S2),0) :-

        recorda(wnmet,[W1,W2,Pos1,0],_),

        !.

 

/* they have a common hypernym 1 up */

/* not called if too expensive - see remmed predicates above */

 

hypermeet(item(W1,Pos1,S1),item(W2,Pos1,S2), 2) :-

    explore(W1,Pos1,S1,hyp,up,2,L1),

    explore(W1,Pos1,S1,part,up,2,L2),

    explore(W1,Pos1,S1,subst,up,2,L3),

    explore(W1,Pos1,S1,member,up,2,L4),

    explore(W2,Pos1,S2,member,up,2,LL1),

    explore(W2,Pos1,S2,subst,up,2,LL2),

    explore(W2,Pos1,S2,part,up,2,LL3),

    explore(W2,Pos1,S2,hyp,up,2,LL4),

  ( member(X,L1); member(X,L2) ; member(X,L3); member(X,L4) ) ,

  ( member(X,LL1); member(X,LL2) ; member(X,LL3) ;member(X,LL4) ).  

 

 

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

 

/*  qsyns/qants(Word,Pos,Sense,Wordlist) list the synonyms/antonyms

    of Word with part-of-speech Pos and sense number Sense. */

 

 

qsyns(Word,Pos,Sense,Wordlist1) :-

      findall(Words,

              ( word(Word,Pos,Sense,Synset,_,_), synset_words(Synset,Words) ),

              Wordlist),

      [! flatten(Wordlist,Wordlist1) !].

 

 

 

qants(Word,Pos,Sense,Wordlist1) :-

      findall(Words,

              ( word(Word,Pos,Sense,Source,_,_),

                retrieveb(ant,Source,ant(Source,_,Dest,_)),

                synset_words(Dest,Words) ),

              Wordlist),

     [! flatten(Wordlist,Wordlist1)!].

              

 

 

qsims(Word,Pos,Sense,Wordlist1) :-

      findall(Words,

              ( word(Word,Pos,Sense,Source,_,_),

                retrieveb(sim,Source,sim(Source,Dest)),

                synset_words(Dest,Words) ),

              Wordlist),

     [! flatten(Wordlist,Wordlist1)!].

              

 

 

synset_words(Synset,Words1) :-

           findall(item(Syn,P,Sns),

                    synset(Synset,_,Syn,P,Sns,_),

                    Words),

           [! flatten(Words,Words1) !].

 

 

 

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

 

/* explore walks up and down hierarchies based on:

 

   hyponym-hypernym : hyp

   member-set :  member

   substance-whole : subst

   part-whole : part

  

*/

  

  

explore(Word,Pos,Sense,genhyp,Dir,Levels,Wlist) :-

           word(Word,Pos,Sense,Synset,_,_),

           explore1(Synset,hyp,Dir,Levels,Wlist).

 

  

explore(Word,Pos,Sense,genhyp,Dir,Levels,Wlist) :-

           word(Word,Pos,Sense,Synset,_,_),

           explore1(Synset,part,Dir,Levels,Wlist).

  

explore(Word,Pos,Sense,genhyp,Dir,Levels,Wlist) :-

           word(Word,Pos,Sense,Synset,_,_),

           explore1(Synset,member,Dir,Levels,Wlist).

  

explore(Word,Pos,Sense,genhyp,Dir,Levels,Wlist) :-

           word(Word,Pos,Sense,Synset,_,_),

           explore1(Synset,subst,Dir,Levels,Wlist).

 

 

explore(Word,Pos,Sense,Relation,Dir,Levels,Wlist) :-

           word(Word,Pos,Sense,Synset,_,_),

           explore1(Synset,Relation,Dir,Levels,Wlist).

 

 

explore1(_,_,_,Levels,[]) :- nonvar(Levels), Levels = 0, !.

 

 

/* hyponymy */

 

explore1(Synset,hyp,down,Levels,WWlist1) :-

           synset_words(Synset,Words),

           findall(Quid,

                   retrieveb(hyper,Synset,hyp(Quid,Synset)),

                   L),

           (var(Levels); (nonvar(Levels), Levels1 is Levels - 1) ),

           explore2(L,hyp,down,Levels1,Wlist),

           append(Words,Wlist,WWlist),

           [! flatten(WWlist,WWlist1) !].

 

explore1(Synset,hyp,up,Levels,WWlist1) :-

           synset_words(Synset,Words),

           findall(Quid,

                   retrieveb(hypo,Synset,hyp(Synset,Quid)),

                   L),

           (var(Levels); (nonvar(Levels), Levels1 is Levels - 1) ),

           explore2(L,hyp,up,Levels1,Wlist),

           append(Words,Wlist,WWlist),

           [! flatten(WWlist,WWlist1)!].

 

 

/* member - set */

 

explore1(Synset,member,down,Levels,WWlist1) :-

           synset_words(Synset,Words),

           findall(Quid,

                   retrieveb(set,Synset,mm(Quid,Synset)),

                   L),

           (var(Levels); (nonvar(Levels), Levels1 is Levels - 1) ),

           explore2(L,member,down,Levels1,Wlist),

           append(Words,Wlist,WWlist),

           [! flatten(WWlist,WWlist1)!].

 

explore1(Synset,member,up,Levels,WWlist1) :-

           synset_words(Synset,Words),

           findall(Quid,

                   retrieveb(member,Synset,mm(Synset,Quid)),

                   L),

           (var(Levels); (nonvar(Levels), Levels1 is Levels - 1) ),

           explore2(L,member,up,Levels1,Wlist),

           append(Words,Wlist,WWlist),

           [! flatten(WWlist,WWlist1)!].

 

 

/* substance - whole */

 

explore1(Synset,subst,down,Levels,WWlist1) :-

           synset_words(Synset,Words),

           findall(Quid,

                   retrieveb(whole,Synset,ms(Quid,Synset)),

                   L),

           (var(Levels); (nonvar(Levels), Levels1 is Levels - 1) ),

           explore2(L,subst,down,Levels1,Wlist),

           append(Words,Wlist,WWlist),

           [! flatten(WWlist,WWlist1)!].

 

explore1(Synset,subst,up,Levels,WWlist1) :-

           synset_words(Synset,Words),

           findall(Quid,

                   retrieveb(subst,Synset,ms(Synset,Quid)),

                   L),

           (var(Levels); (nonvar(Levels), Levels1 is Levels - 1) ),

           explore2(L,subst,up,Levels1,Wlist),

           append(Words,Wlist,WWlist),

           [! flatten(WWlist,WWlist1) !].

 

 

/* part - whole */

 

explore1(Synset,part,down,Levels,WWlist1) :-

           synset_words(Synset,Words),

           findall(Quid,

                   retrieveb(whole,Synset,mp(Quid,Synset)),

                   L),

           (var(Levels); (nonvar(Levels), Levels1 is Levels - 1) ),

           explore2(L,part,down,Levels1,Wlist),

           append(Words,Wlist,WWlist),

           [! flatten(WWlist,WWlist1)!].

 

explore1(Synset,part,up,Levels,WWlist1) :-

           synset_words(Synset,Words),

           findall(Quid,

                   retrieveb(part,Synset,mp(Synset,Quid)),

                   L),

           (var(Levels); (nonvar(Levels), Levels1 is Levels - 1) ),

           explore2(L,part,up,Levels1,Wlist),

           append(Words,Wlist,WWlist),

           [! flatten(WWlist,WWlist1) !].

 

 

/* recursion in explore */

 

explore2(_,_,_,Levels,[]) :- nonvar(Levels), Levels = 0, !.

explore2([],_,_,_,[]).

explore2([H|T],Relation,Dir,Levels,Wlist1) :-

           explore1(H,Relation,Dir,Levels,Hlist),

           explore2(T,Relation,Dir,Levels,Tlist),

           append(Hlist,Tlist,Wlist),

           [! flatten(Wlist,Wlist1) !].

 

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

/* basic Wordnet data base queries */

 

synset(A,B,C,D,E,F) :- retrieveb(synset,A,s(A,B,C,D,E,F)).

word(A,B,C,D,E,F) :- retrieveb(wordset,A,w(A,B,C,D,E,F)).

 

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

 

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

% Toolword list

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

toolw(a).

toolw(few).

toolw(lot).

toolw(abbreviation).

toolw(about).

toolw(across).

toolw(adj).

toolw(adv).

toolw(after).

toolw(again).

toolw(against).

toolw(all).

toolw(almost).

toolw(along).

toolw(also).

toolw(always).

toolw(am).

toolw(ame).

toolw(american).

toolw(among).

toolw(an).

toolw(and).

toolw(another).

toolw(any).

toolw(anyone).

toolw(anything).

toolw(are).

toolw(around).

toolw(as).

toolw(at).

toolw(aus).

toolw(away).

toolw(back).

toolw(be).

toolw(because).

toolw(become).

toolw(becomes).

toolw(been).

toolw(before).

toolw(behind).

toolw(being).

toolw(between).

toolw(bit).

toolw(both).

toolw(br).

toolw(bre).

toolw(britain).

toolw(british).

toolw(but).

toolw(by).

toolw(can).

toolw(cannot).

toolw(cant).

toolw(cause).

toolw(certain).

toolw(clauses).

toolw(come).

toolw(comes).

toolw(coming).

toolw(comparative).

toolw(comps).

toolw(concerning).

toolw(consists).

toolw(contexts).

toolw(could).

toolw(derog).

toolw(did).

toolw(do).

toolw(does).

toolw(doing).

toolw(done).

toolw(dont).

toolw(down).

toolw(during).

toolw(each).

toolw(either).

toolw(else).

toolw(emphatic).

toolw(emphasis).

toolw(enough).

toolw(esp).

toolw(especial).

toolw(etc).

toolw(even).

toolw(every).

toolw(excl).

toolw(expressing).

toolw(far).

toolw(fig).

toolw(first).

toolw(five).

toolw(fixed).

toolw(fml).

toolw(for).

toolw(formally).

toolw(four).

toolw(french).

toolw(from).

toolw(gen).

toolw(general).

toolw(geog).

toolw(get).

toolw(getting).

toolw(give).

toolw(giving).

toolw(go).

toolw(goes).

toolw(going).

toolw(gone).

toolw(got).

toolw(group).

toolw(groups).

toolw(had).

toolw(has).

toolw(have).

toolw(having).

toolw(he).

toolw(her).

toolw(here).

toolw(hes).

toolw(him).

toolw(his).

toolw(how).

toolw(i).

toolw(if).

toolw(im).

toolw(impers).

toolw(in).

toolw(indefinite).

toolw(indicating).

toolw(infin).

toolw(infml).

toolw(informal).

toolw(intensifier).

toolw(interrog).

toolw(into).

toolw(is).

toolw(it).

toolw(its).

toolw(ive).

toolw(john).

toolw(just).

toolw(keep).

toolw(kept).

toolw(kind).

toolw(l).

toolw(le).

toolw(less).

toolw(like).

toolw(lit).

toolw(literary).

toolw(little).

toolw(loc).

toolw(london).

toolw(long).

toolw(lot).

toolw(made).

toolw(main).

toolw(mainly).

toolw(make).

toolw(makes).

toolw(making).

toolw(many).

toolw(mark).

toolw(matter).

toolw(may).

toolw(me).

toolw(mean).

toolw(means).

toolw(mentioned).

toolw(might).

toolw(more).

toolw(most).

toolw(mr).

toolw(much).

toolw(must).

toolw(my).

toolw(n).

toolw(names).

toolw(need).

toolw(neg).

toolw(never).

toolw(next).

toolw(no).

toolw(not).

toolw(nothing).

toolw(nouns).

toolw(now).

toolw(number).

toolw(of).

toolw(off).

toolw(often).

toolw(oldfashioned).

toolw(on).

toolw(one).

toolw(ones).

toolw(oneself).

toolw(only).

toolw(onto).

toolw(or).

toolw(order).

toolw(other).

toolw(others).

toolw(our).

toolw(out).

toolw(over).

toolw(part).

toolw(particular).

toolw(parts).

toolw(party).

toolw(pass).

toolw(passive).

toolw(past).

toolw(people).

toolw(person).

toolw(persons).

toolw(phr).

toolw(phrase).

toolw(phrs).

toolw(phrases).

toolw(piece).

toolw(pieces).

toolw(pl).

toolw(place).

toolw(prep).

toolw(present).

toolw(previously).

toolw(ptp).

toolw(put).

toolw(quite).

toolw(rare).

toolw(rather).

toolw(real).

toolw(really).

toolw(refer).

toolw(rel).

toolw(related).

toolw(round).

toolw(run).

toolw(said).

toolw(same).

toolw(sb).

toolw(sbs).

toolw(seem).

toolw(seen).

toolw(sense).

toolw(senses).

toolw(set).

toolw(several).

toolw(she).

toolw(shes).

toolw(should).

toolw(show).

toolw(showing).

toolw(since).

toolw(sl).

toolw(so).

toolw(some).

toolw(someone).

toolw(something).

toolw(sometimes).

toolw(soon).

toolw(sort).

toolw(special).

toolw(specific).

toolw(st).

toolw(stated).

toolw(sth).

toolw(still).

toolw(such).

toolw(take).

toolw(taken).

toolw(takes).

toolw(taking).

toolw(tech).

toolw(technical).

toolw(tell).

toolw(tense).

toolw(th).

toolw(than).

toolw(that).

toolw(thats).

toolw(the).

toolw(their).

toolw(them).

toolw(themselves).

toolw(then).

toolw(there).

toolw(therefore).

toolw(theres).

toolw(these).

toolw(they).

toolw(thing).

toolw(things).

toolw(this).

toolw(those).

toolw(three).

toolw(through).

toolw(time).

toolw(times).

toolw(to).

toolw(today).

toolw(together).

toolw(too).

toolw(towards).

toolw(two).

toolw(type).

toolw(types).

toolw(under).

toolw(unstressed).

toolw(until).

toolw(up).

toolw(upon).

toolw(us).

toolw(use).

toolw(used).

toolw(uses).

toolw(using).

toolw(usu).

toolw(usual).

toolw(usually).

toolw(various).

toolw(vb).

toolw(verbal).

toolw(verbally).

toolw(very).

toolw(was).

toolw(way).

toolw(ways).

toolw(we).

toolw(well).

toolw(went).

toolw(were).

toolw(what).

toolw(when).

toolw(where).

toolw(whether).

toolw(which).

toolw(while).

toolw(who).

toolw(whose).

toolw(why).

toolw(will).

toolw(with).

toolw(within).

toolw(without).

toolw(word).

toolw(words).

toolw(would).

toolw(yet).

toolw(you).

toolw(your).

toolw(youre).

toolw(yourself).

 


Back to the DEFI Home Page