33
A Principle Compiler for Extensible Dependency Grammar Bachelor Thesis Programming Systems Lab Jochen Setz, 24.05.2007 Betreuer: Ralph Debusmann A Principle Compiler for Extensible Dependency Grammar – p.1/14

A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

A Principle Compiler forExtensible Dependency

GrammarBachelor Thesis

Programming Systems Lab

Jochen Setz, 24.05.2007

Betreuer: Ralph Debusmann

A Principle Compiler for Extensible Dependency Grammar – p.1/14

Page 2: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Extensible Dependency Grammar

Grammatikformalismus fürDependenzgrammatik

A Principle Compiler for Extensible Dependency Grammar – p.2/14

Page 3: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Extensible Dependency Grammar

Grammatikformalismus fürDependenzgrammatik

Modell: Tupel von Dependenzgraphen

A Principle Compiler for Extensible Dependency Grammar – p.2/14

Page 4: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Extensible Dependency Grammar

Grammatikformalismus fürDependenzgrammatik

Modell: Tupel von Dependenzgraphen

Dependenzgraphen heißen Dimensionen

A Principle Compiler for Extensible Dependency Grammar – p.2/14

Page 5: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Extensible Dependency Grammar

Grammatikformalismus fürDependenzgrammatik

Modell: Tupel von Dependenzgraphen

Dependenzgraphen heißen Dimensionen

alle Dimensionen haben die gleicheKnotenmenge

A Principle Compiler for Extensible Dependency Grammar – p.2/14

Page 6: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Extensible Dependency Grammar

Grammatikformalismus fürDependenzgrammatik

Modell: Tupel von Dependenzgraphen

Dependenzgraphen heißen Dimensionen

alle Dimensionen haben die gleicheKnotenmenge

⇒ Modelle = Multigraphen

A Principle Compiler for Extensible Dependency Grammar – p.2/14

Page 7: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

XDG Beispiel

SYN:

1

Mary

2

wants

3

to

4

eat

5

spaghetti

6

today

advsubj vinf

objpart

SEM:

1

Mary

2

wants

3

to

4

eat

5

spaghetti

6

today

agth

ag pat

th

A Principle Compiler for Extensible Dependency Grammar – p.3/14

Page 8: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Prinzipien

Wohlgeformtheitbedingungen des Multigraphen

A Principle Compiler for Extensible Dependency Grammar – p.4/14

Page 9: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Prinzipien

Wohlgeformtheitbedingungen des Multigraphen

Beispiele:

Baumheit (eine Wurzel / keine Zyklen /keine oder eine Mutter pro Knoten)

A Principle Compiler for Extensible Dependency Grammar – p.4/14

Page 10: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Prinzipien

Wohlgeformtheitbedingungen des Multigraphen

Beispiele:

Baumheit (eine Wurzel / keine Zyklen /keine oder eine Mutter pro Knoten)

Valenz (Anzahl und Art der ein-/ausgehendenKanten)

A Principle Compiler for Extensible Dependency Grammar – p.4/14

Page 11: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Prinzipien

Wohlgeformtheitbedingungen des Multigraphen

Beispiele:

Baumheit (eine Wurzel / keine Zyklen /keine oder eine Mutter pro Knoten)

Valenz (Anzahl und Art der ein-/ausgehendenKanten)

Projektivität (keine kreuzenden Kanten)

A Principle Compiler for Extensible Dependency Grammar – p.4/14

Page 12: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Prinzipien in FOL

Prinzipien in First Order Logic (FOL)formalisiert

A Principle Compiler for Extensible Dependency Grammar – p.5/14

Page 13: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Prinzipien in FOL

Prinzipien in First Order Logic (FOL)formalisiert

Z.B. Baumheit auf Dimension d:

NoCycles = ∀v : ¬(v →+d v)

OneRoot = ∃1v : ¬∃v′ : v′ →d v

ZeroOrOneMother =∀v : (¬∃v′ : v′ →d v)∨ (∃1v′ : v′ →d v)

A Principle Compiler for Extensible Dependency Grammar – p.5/14

Page 14: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

XDK

A Principle Compiler for Extensible Dependency Grammar – p.6/14

Page 15: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Parser (Grundidee)

Multigraphen kodiert durch endliche Mengenvon Integern

A Principle Compiler for Extensible Dependency Grammar – p.7/14

Page 16: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Parser (Grundidee)

Multigraphen kodiert durch endliche Mengenvon Integern

jeder Knoten v mit einem Index undverschiedenen Mengen assoziiert, z.B.:

mothers: Mutterknoten von v

daughters: Töchter von v

up: Vorfahren von v

daughtersL: Menge von Tupeln, jedes Tupel hat das

gleiche Label

A Principle Compiler for Extensible Dependency Grammar – p.7/14

Page 17: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Parser (Grundidee)

Multigraphen kodiert durch endliche Mengenvon Integern

jeder Knoten v mit einem Index undverschiedenen Mengen assoziiert, z.B.:

mothers: Mutterknoten von v

daughters: Töchter von v

up: Vorfahren von v

daughtersL: Menge von Tupeln, jedes Tupel hat das

gleiche Label

Prinzipien: Constraints auf diesen Mengen

A Principle Compiler for Extensible Dependency Grammar – p.7/14

Page 18: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Implementierung von Prinzipien

Prinzipien müssen von Hand alsMozart/Oz-Constraints implementiert werden

A Principle Compiler for Extensible Dependency Grammar – p.8/14

Page 19: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Implementierung von Prinzipien

Prinzipien müssen von Hand alsMozart/Oz-Constraints implementiert werden

⇒ nur Experten in Mozart/Oz und XDK könnenneue Prinzipien schreiben, nicht aber typischeAnwender wie z.B. Linguisten

A Principle Compiler for Extensible Dependency Grammar – p.8/14

Page 20: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Implementierung von Prinzipien

Prinzipien müssen von Hand alsMozart/Oz-Constraints implementiert werden

⇒ nur Experten in Mozart/Oz und XDK könnenneue Prinzipien schreiben, nicht aber typischeAnwender wie z.B. Linguisten

⇒ große Lücke zwischen Formalisierung undImplementierung

A Principle Compiler for Extensible Dependency Grammar – p.8/14

Page 21: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Implementierung von Prinzipien

Prinzipien müssen von Hand alsMozart/Oz-Constraints implementiert werden

⇒ nur Experten in Mozart/Oz und XDK könnenneue Prinzipien schreiben, nicht aber typischeAnwender wie z.B. Linguisten

⇒ große Lücke zwischen Formalisierung undImplementierung

provisorische Brücke: umfangreiche Bibliothekvon vorimplementierten Prinzipien

A Principle Compiler for Extensible Dependency Grammar – p.8/14

Page 22: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Idee meiner BA-Thesis

Lücke zwischen Formalisierung undImplementierung schließen

A Principle Compiler for Extensible Dependency Grammar – p.9/14

Page 23: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Idee meiner BA-Thesis

Lücke zwischen Formalisierung undImplementierung schließen

Ziel: Compiler (“PrincipleWriter”), der in FOLgeschriebene Prinzipien in Mozart/Oz-Constraints übersetzt, und ins XDK integriert

A Principle Compiler for Extensible Dependency Grammar – p.9/14

Page 24: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Idee meiner BA-Thesis

Lücke zwischen Formalisierung undImplementierung schließen

Ziel: Compiler (“PrincipleWriter”), der in FOLgeschriebene Prinzipien in Mozart/Oz-Constraints übersetzt, und ins XDK integriert

dadurch XDK attraktiver für typische Anwender,die neue Prinzipien schreiben wollen: nur nochKenntnisse in FOL benötigt

A Principle Compiler for Extensible Dependency Grammar – p.9/14

Page 25: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Idee meiner BA-Thesis

Lücke zwischen Formalisierung undImplementierung schließen

Ziel: Compiler (“PrincipleWriter”), der in FOLgeschriebene Prinzipien in Mozart/Oz-Constraints übersetzt, und ins XDK integriert

dadurch XDK attraktiver für typische Anwender,die neue Prinzipien schreiben wollen: nur nochKenntnisse in FOL benötigt

Nebeneffekt: Formalisierung undImplementierung rücken näher zusammen

A Principle Compiler for Extensible Dependency Grammar – p.9/14

Page 26: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Arbeitspakete

konkrete Eingabesyntax definieren (fertig)

A Principle Compiler for Extensible Dependency Grammar – p.10/14

Page 27: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Arbeitspakete

konkrete Eingabesyntax definieren (fertig)

Mozart/Oz-Constraints für FOL finden(1. Version)

A Principle Compiler for Extensible Dependency Grammar – p.10/14

Page 28: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Arbeitspakete

konkrete Eingabesyntax definieren (fertig)

Mozart/Oz-Constraints für FOL finden(1. Version)

Compiler bauen, der Eingabesyntax inMozart/Oz-Constraints überführt, mit

Typ-Checker,Typ-Inferenz

A Principle Compiler for Extensible Dependency Grammar – p.10/14

Page 29: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Arbeitspakete

konkrete Eingabesyntax definieren (fertig)

Mozart/Oz-Constraints für FOL finden(1. Version)

Compiler bauen, der Eingabesyntax inMozart/Oz-Constraints überführt, mit

Typ-Checker,Typ-Inferenz

Wie gut kann der PrincipleWriteroptimieren, verglichen mit einemExperten?

A Principle Compiler for Extensible Dependency Grammar – p.10/14

Page 30: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Literatur

Ralph Debusmann (2006). ExtensibleDependency Grammar: A Modular GrammarFormalism Based On Multigraph Description.PhD thesis (revised version)

Ralph Debusmann (2007). Scrambling as theIntersection of Relaxed Context-FreeGrammars in a Model-Theoretic GrammarFormalism. ESSLLI 2007 Workshop ModelTheoretic Syntax at 10, Dublin

A Principle Compiler for Extensible Dependency Grammar – p.11/14

Page 31: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Optimierung - ZeroOrOneMother

FOL: ∀v : (¬∃v′ : v′ →d v)∨ (∃1v′ : v′ →d v)

UL:forall V::node:(exists V1::node: edge(V1 V D))|(existsone V1::node: edge(V1 V D))

A Principle Compiler for Extensible Dependency Grammar – p.12/14

Page 32: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Optimierung - ZeroOrOneMother

proc {ZeroOrOneIncomingEdges NodeRecs}{ForAllNodes NodeRecs

fun {$ NodeRec}{Disj{ExistsOneNodes NodeRecs

fun {$ NodeRec1} {Edge NodeRec1 NodeRec d} end}{Nega{ExistsNodes NodeRecs

fun {$ NodeRec1} {Edge NodeRec1 NodeRec d} end}}}end 1}

end

Komplexität: O(n2)

A Principle Compiler for Extensible Dependency Grammar – p.13/14

Page 33: A Principle Compiler for Extensible Dependency Grammar · 3 to 4 eat 5 spaghetti 6 today j f v t j SEM: 1 Mary 2 wants 3 to 4 eat 5 spaghetti 6 today g h g t h A Principle Compiler

Optimierung - ZeroOrOneMother

FOL: ∀v : (¬∃v′ : v′ →d v)︸ ︷︷ ︸

|mothers(v)| = 0

∨(∃1v′ : v′ →d v)︸ ︷︷ ︸

|mothers(v)| = 1

Optimiert: ∀v : |mothers(v)| ≤ 1

Komplexität: O(n)

A Principle Compiler for Extensible Dependency Grammar – p.14/14