<div class="notebook open-fullscreen"> <div class="nb-cell markdown" name="md1"> # Materialien zu Kapitel 2 </div> <div class="nb-cell markdown" name="md5"> ### Task 1: Specify a reasonable syntax for the language fragment </div> <div class="nb-cell program" name="p13"> % Toy grammar %%%%%%%%%%%%%%%%% s --> np,vp. np --> pn. np --> det, noun. pn --> [vincent]. pn --> [mia]. det --> [a]. det --> [every]. noun --> [woman]. noun --> [foot,massage]. vp --> iv. vp --> tv,np. iv --> [snorts]. iv --> [walks]. tv --> [loves]. tv --> [likes]. </div> <div class="nb-cell query" name="q1"> s([mia,loves,vincent],[]). </div> <div class="nb-cell markdown" name="md3"> **Exercise** How many sentences are accepted by this grammar? How many noun phrases? How many verb phrases? (1) Use the Prolog built-in predicate `findall/3` to generate the relevant items. (2) Use the predicate `length/2` to check the length of these generated lists. </div> <div class="nb-cell markdown" name="md4"> ### Task 2: Specify semantic representations for the lexical items </div> <div class="nb-cell markdown" name="md6"> To build lexical items, we need to associate _Vincent_ with the constant VINCENT, _Mia_ with the constant MIA, _walks_ with the unary relation symbol WALK, _loves_ with the binary relation symbol LOVE and determiners ( _a_, _every_) with the quantified formulas. We are not dealing with the definite article _the_ in the course. Prolog solution: </div> <div class="nb-cell program" data-background="true" name="p14"> % Lexicon %%%%%%%%%%%%%%%%% % Proper Names pn(mia)--> [mia]. pn(vincent)--> [vincent]. % Transitive Verbs tv(love(_,_))--> [loves]. % Intransitive Verbs iv(snort(_))--> [snorts]. % Nouns noun(woman(_))--> [woman]. % Determiners det(some(_,and(_,_)))--> [a]. det(all(_,imp(_,_)))--> [every]. </div> <div class="nb-cell markdown" name="md7"> **Übung:** * Erkläre die Klauseln für _a_ und _every_. Tipp: Überlege dir, welche Repräsentationen _a woman snorts_ und _every woman snorts_ haben sollen. </div> <div class="nb-cell markdown" name="md8"> ### Task 3: Specify the translation compositionally Wir brauchen Verkleberegeln, die die lexikalischen semantischen Repräsentationen zu Repräsentationen von NPs, VPs oder ganzen Sätzen verkleben. Die erste Idee ist es, die DCG um einen zusätzlichen Parameter für die semantische Repräsentation zu erweitern. </div> <div class="nb-cell markdown" name="md15"> #### Experiment 1 </div> <div class="nb-cell markdown" name="md9"> Zunächst die Regeln für die quantorenfreien Fragmente der Sprache: </div> <div class="nb-cell program" data-background="true" name="p15"> % Syntax-Semantics Rules %%%%%%%%%%%%%%%%% % quantifier free sentences :- discontiguous([s/3,np/3,vp/3]). s(Sem)--> np(SemNP), vp(Sem), { arg(1,Sem,SemNP) }. np(Sem)--> pn(Sem). vp(Sem)--> tv(Sem), np(SemNP), { arg(2,Sem,SemNP) }. </div> <div class="nb-cell query" name="q2"> arg(2,schenk(mia,vincent,buch),X). </div> <div class="nb-cell markdown" name="md11"> Zur Erinnerung `arg/3` ist ein eingebautes Prädikat. `arg(N,Formula,Arg)` gelingt, wenn `Arg` das `N`-te Argument von `Formula` ist. </div> <div class="nb-cell markdown" name="md10"> **Übung:** * Betrachten sie den Trace zu dem Satz _Mia loves Vincent_. </div> <div class="nb-cell markdown" name="md12"> Es folgen die Regeln für die Verarbeitung von quantifizierten NPs: </div> <div class="nb-cell program" data-background="true" name="p16"> % quantifier sentences %%%%%%%%%%%%%%%%% s(Sem)--> np(Sem), vp(SemVP), { arg(1,SemVP,X), arg(1,Sem,X), arg(2,Sem,Matrix), arg(2,Matrix,SemVP) }. np(Sem)--> det(Sem), noun(SemNoun), { arg(1,SemNoun,X), arg(1,Sem,X), arg(2,Sem,Matrix), arg(1,Matrix,SemNoun) }. vp(Sem)--> tv(SemTV), np(Sem), { arg(2,SemTV,X), arg(1,Sem,X), arg(2,Sem,Matrix), arg(2,Matrix,SemTV) }. vp(Sem)--> iv(Sem). </div> <div class="nb-cell query" name="q3"> s(Sem,[a,woman,loves,a,woman],[]). </div> <div class="nb-cell markdown" name="md13"> **Übung:** * Erklären Sie, wie die semantische Information in den syntaktischen Regeln verarbeitet wird. * Warum führen die zwei NP-Regeln zu Problemen? * Welche Repräsentationen werden für den Satz_a woman loves a woman_ generiert? Welche sind erwünscht? Testen sie auch die Sätze _Mia loves a woman_ und _a woman loves Mia_, was fällt auf? * Generiert diese Grammatik alle gewünschten Sätze mit ihren semantischen Repräsentationen? Generiert sie nur die gewünschten Repräsentationen? </div> <div class="nb-cell markdown" name="md14"> Den obenstehenden Code finden sie auch in der Datei `experiment1.pl` Weiter geht es hier: [Experiment 2](CompSem_Petersen_Material_Kapitel_2b.swinb) </div> <div class="nb-cell html" name="htm1"> </div> </div>