2:- module(miniFrameNet,[axiomsFN/2]).    3
    4:- use_module(library(lists),[member/2,append/3]).    5:- use_module(semlib(options),[option/2]).    6
    7
    8/* ------------------------------------------------------------------------
    9   Main Predicate
   10------------------------------------------------------------------------ */
   11
   12axiomsFN(DRS,Axioms):- 
   13   option('--roles',framenet),
   14   framenetfile(File),
   15   exists_file(File), !,
   16   findFrames(DRS,[]-Frames), 
   17   selectAxioms(Frames,Axioms).
   18
   19axiomsFN(_,[]).
   20
   21
   22/* ------------------------------------------------------------------------
   23   File with Framenet Axioms
   24------------------------------------------------------------------------ */
   25
   26framenetfile('working/framenet/framenet.pl').
   27
   28
   29/* ------------------------------------------------------------------------
   30   Find Frames in DRS
   31------------------------------------------------------------------------ */
   32
   33findFrames(drs(_,C),F1-F2):- !, findFrames(C,F1-F2).
   34findFrames(smerge(A,B),F1-F3):- !, findFrames(A,F1-F2), findFrames(B,F2-F3).
   35findFrames(merge(A,B),F1-F3):- !, findFrames(A,F1-F2), findFrames(B,F2-F3).
   36findFrames(alfa(_,A,B),F1-F3):- !, findFrames(A,F1-F2), findFrames(B,F2-F3).
   37
   38findFrames([],F-F):- !.
   39findFrames([_:pos(A)|C],F1-F3):- !, findFrames(A,F1-F2), findFrames(C,F2-F3).
   40findFrames([_:nec(A)|C],F1-F3):- !, findFrames(A,F1-F2), findFrames(C,F2-F3).
   41findFrames([_:not(A)|C],F1-F3):- !, findFrames(A,F1-F2), findFrames(C,F2-F3).
   42findFrames([_:prop(_,A)|C],F1-F3):- !, findFrames(A,F1-F2), findFrames(C,F2-F3).
   43findFrames([_:imp(A,B)|C],F1-F4):- !, findFrames(A,F1-F2), findFrames(B,F2-F3), findFrames(C,F3-F4).
   44findFrames([_:or(A,B)|C],F1-F4):- !, findFrames(A,F1-F2), findFrames(B,F2-F3), findFrames(C,F3-F4).
   45findFrames([_:whq(A,B)|C],F1-F4):- !, findFrames(A,F1-F2), findFrames(B,F2-F3), findFrames(C,F3-F4).
   46findFrames([_:whq(_,A,_,B)|C],F1-F4):- !, findFrames(A,F1-F2), findFrames(B,F2-F3), findFrames(C,F3-F4).
   47findFrames([_:pred(_,F,f,1)|C],F1-F2):- \+ member(F,F1), !, findFrames(C,[F|F1]-F2).
   48findFrames([_|C],F1-F2):- findFrames(C,F1-F2).
   49
   50
   51/* ------------------------------------------------------------------------
   52   Select Axioms
   53------------------------------------------------------------------------ */
   54
   55selectAxioms([],[]).
   56
   57selectAxioms([F|L],Axioms):-
   58   findall(A,axiom(F,_,A),Axioms1),
   59   atom_concat(f1,F,Frame), functor(Sym,Frame,1), arg(1,Sym,X),
   60   Extra = all(X,imp(Sym,n1event(X))),
   61   append([Extra|Axioms1],Axioms2,Axioms),
   62   selectAxioms(L,Axioms2).
   63
   64
   65/* ------------------------------------------------------------------------
   66   Load FrameNet
   67------------------------------------------------------------------------ */
   68
   69loadFN:-
   70   framenetfile(File),
   71   exists_file(File),   
   72   [File].
   73
   74loadFN.
   75
   76:- loadFN.