next up previous contents
Next: Sources du module de Up: Application : Grammaires catégorielles Previous: Grammaire catégorielle généralisé de

Sources de la grammaire généralisée


/*****************************************************************************/
/*                                                                           */
/* Christophe DELORD                                                         */
/*                                                                           */
/* Stage 1997/98 : ENSEEIHT - Traitement du langage naturel                  */
/*                                                                           */
/*****************************************************************************/

/*****************************************************************************/
/*                                                                           */
/* Analyse de phrases : grammaire catégorielle généralisée de Lambek-Gentzen */
/*                                                                           */
/*****************************************************************************/

:-use_module(log_int).
:-use_module(parser).

/*****************************************************************************/
/*                                                                           */
/* Définition des catégories syntagmatiques                                  */
/*                                                                           */
/*****************************************************************************/

:-op(400,yfx,'/').
:-op(400,yfx,'\').

categorie(jean,sn).
categorie(marie,sn).
categorie(pierre,sn).
categorie(anne,sn).
categorie(est,(p\sn)/sa).
categorie(apparente,sa/sp).
categorie(a,sp/sn).
categorie(il,sn).
categorie(juge,(((p\sn)/sa)/sn)).
categorie(incompetente,sa).

lex(lex(MOT,MOT,CAT))-->[MOT],{categorie(MOT,CAT)}.

/*****************************************************************************/
/*                                                                           */
/*  R1  f: x/y, a: y -> f(a): x                                applicativité */
/*      a: y, f: x\y -> f(a): x                                              */
/*                                                                           */
/*****************************************************************************/

lex([F,A],VSF@VSA,X):=lex(F,VSF,X/Y),lex(A,VSA,Y).
lex([A,F],VSF@VSA,X):=lex(A,VSA,Y),lex(F,VSF,X\Y).

/*****************************************************************************/
/*                                                                           */
/*  R2  f: x/y, g: y/z -> lv[f(g(v))]: x/z                       composition */
/*      g: y\z, f: x\y -> lv[f(g(v))]: x\z                                   */
/*                                                                           */
/*****************************************************************************/

lex([F,G],V#VSF@(VSG@V),X/Z):=lex(F,VSF,X/Y),lex(G,VSG,Y/Z).
lex([G,F],V#VSF@(VSG@V),X\Z):=lex(G,VSG,Y\Z),lex(F,VSF,X\Y).

/*****************************************************************************/
/*                                                                           */
/*  R3  f: (x\z)/y -> lv[lw[f(w)(v)]]: (x/y)\z                 associativité */
/*      f: (x/y)\z -> lv[lw[f(w)(v)]]: (x\z)/y                               */
/*                                                                           */
/*****************************************************************************/

lex(F,V#W#VSF@W@V,(X/Y)\Z):=lex(F,VSF,(X\Z)/Y).
lex(F,V#W#VSF@W@V,(X\Z)/Y):=lex(F,VSF,(X/Y)\Z).

/*****************************************************************************/
/*                                                                           */
/*  R4  a: x, b: (y\x) -> lv[v(a)]: y/(y\x), b: (y\x)                 montée */
/*      b: (y/x), a: x -> b: (y/x), lv[v(a)]: y\(y/x)                        */
/*                                                                           */
/*****************************************************************************/

lex(A,V#V@VSA,Y/(Y\X)),lex(B,VSB,Y\X):=lex(A,VSA,X),lex(B,VSB,Y\X).
lex(B,VSB,Y/X),lex(A,V#V@VSA,Y\(Y/X)):=lex(B,VSB,Y/X),lex(A,VSA,X).

/*****************************************************************************/
/*                                                                           */
/*  R5  f: x/y, g: y/z -> lv[lw[f(v(w))]]: (x/z)/(y/z), g: y/z      division */
/*      g: y\z, f: x\y -> g: y\z, lv[lw[f(v(w))]]: (x\z)\(y\z)      foncteur */
/*                                                                 principal */
/*****************************************************************************/

lex(F,V#W#VSF@(V@W),(X/Z)/(Y/Z)),lex(G,VSG,Y/Z):=lex(F,VSF,X/Y),lex(G,VSG,Y/Z).
lex(G,VSG,Y\Z),lex(F,V#W#VSF@(V@W),(X\Z)\(Y\Z)):=lex(G,VSG,Y\Z),lex(F,VSF,X\Y).

/*****************************************************************************/
/*                                                                           */
/*  R6  g: z/x, f: x/y -> g: z/x, lv[lw[v(f(w))]]: (z/y)\(z/x)      division */
/*      f: x\y, g: z\x -> lv[lw[v(f(w))]]: (z\y)/(z\x), g: z\x      foncteur */
/*                                                                subordonné */
/*****************************************************************************/

lex(G,VSG,Z/X),lex(F,V#W#V@(VSF@W),(Z/Y)\(Z/X)):=lex(G,VSG,Z/X),lex(F,VSF,X/Y).
lex(F,V#W#V@(VSF@W),(Z\Y)/(Z\X)),lex(G,VSG,Z\X):=lex(F,VSF,X\Y),lex(G,VSG,Z\X).

/*****************************************************************************/
/*                                                                           */
/*  P   t: z/y, a: x, b: y -> t: z/y, b: y, a: x                 permutation */
/*      a: x, b: y, t: z\x -> b: y, a: x, t: z\x                             */
/*                                                                           */
/*****************************************************************************/

lex(T,VST,Z/Y),lex(B,VSB,Y),lex(A,VSA,X):=lex(T,VST,Z/Y),lex(A,VSA,X),
                                                         lex(B,VSB,Y).
lex(B,VSB,Y),lex(A,VSA,X),lex(T,VST,Z\X):=lex(A,VSA,X),lex(B,VSB,Y),
                                                       lex(T,VST,Z\X).

/*****************************************************************************/
/*                                                                           */
/*  C   a: x, b: x -> (a,b): x                                   contraction */
/*                                                                           */
/*****************************************************************************/

lex([A,B],contraction(VSA,VSB),X):=lex(A,VSA,X),lex(B,VSB,X).

/*****************************************************************************/
/*                                                                           */
/*  Analyse d'une phrase                                                     */
/*                                                                           */
/*****************************************************************************/
analyser(PH,VS_S):-
    parse(lex(NPH,VS,p),PH),
    writef("%t <=> \n\t%t\n",[NPH,VS]), 
    simplifier(VS,VS_S),
    writef("\t%t\n",[VS_S]).

test:-
    analyser([il,juge,incompetente,marie],_).



 

Christophe Delord
1998-09-02