/* Copyright (C) Wolfgang Menzel, Universität Hamburg, 2003-06-27 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ %%% a grammar for simple German sentences using %%% weak unification :- [unification]. :- nl. :- write_ln('parsing with weak unification'). :- write_ln('call: ?- s([der, männer, schläft],S,E).') :- nl. s(Sentence,Structure,Errors) :- s(Structure,Errors,Sentence,[ ]). s(s(NP,VP),ErrorsS) --> np(NP,_,SUBJagrNP,ErrorsNP), vp(VP,SUBJagrVP,ErrorsVP), {unify(SUBJagrVP,SUBJagrNP,_,ErrorsNew), append(ErrorsNP,ErrorsVP,E), append(ErrorsNew,E,ErrorsS)}. np(np(Det,Noun),NPagr,SUBJagr,ErrorsNP) --> det(Det,NPagrD), noun(Noun,NPagrN), {NPagr=npagr(_,Num,_), SUBJagr=subjagr(third,Num), unify(NPagrN,NPagrD,NPagr,ErrorsNP)}. vp(vp(V),SUBJagr,[]) --> v(V,SUBJagr). noun(mann,npagr(nom,sg,masc)) --> [mann]. noun(mann,npagr(acc,sg,masc)) --> [mann]. noun(mann,npagr(dat,sg,masc)) --> [mann]. noun(männer,npagr(nom,pl,masc)) --> [männer]. noun(männer,npagr(gen,pl,masc)) --> [männer]. noun(männer,npagr(acc,pl,masc)) --> [männer]. det(der,npagr(nom,sg,masc)) --> [der]. det(der,npagr(gen,sg,fem)) --> [der]. det(der,npagr(gen,pl,_)) --> [der]. det(die,npagr(nom,pl,_)) --> [die]. det(die,npagr(acc,pl,_)) --> [die]. det(die,npagr(nom,sg,fem)) --> [die]. det(die,npagr(acc,sg,fem)) --> [die]. v(schläft,subjagr(third,sg)) --> [schläft]. v(schlafen,subjagr(third,pl)) --> [schlafen].