Laste ned presentasjonen
Presentasjon lastes. Vennligst vent
1
INF2820 Datalingvistikk – V2011
Jan Tore Lønning & Stephan Oepen
2
TabellParsing 29. april 2019
3
I dag Oppsummering fra sist: Tabellparsing: Chartparsing:
Recursive-descent og Shift-reduce parser Svakheter med disse Tabellparsing: Dynamisk programmering CKY-algoritmen Chartparsing: Dotted items Fundamentalregel Bottom-up strategi Neste gang: alternative strategier 29. april 2019
4
Recursive descent parser
Lager en venstreavledning Bygger et tre: Fra toppen (”top-down”) Fra venstre mot høyre Tilstrekkelig å bare se på venstreavledninger fordi de svarer til trær Streber mot tidligst mulig å sjekke mot input-data Et trinn er ikke-deterministisk: Velg en regel! Dette gir et søkerom å holde orden på 29. april 2019
5
Speech and Language Processing - Jurafsky and Martin
Top Down Space 4/29/2019 Speech and Language Processing - Jurafsky and Martin
6
Problem for RD-parser:
Consider A flight from Indianapolis to Houston on TWA NP Det Nominal Nominal Noun Nominal Nominal PP Kan vi finne G’ uten Venstrerekursjon s.a. L(G’) = L(G)? 4/29/2019 Speech and Language Processing - Jurafsky and Martin
7
Bottom-up: Shift reduce parser
| Kim saw the girl with the telescope … NP V Det | girl with the telescope NP V Det girl| with the telescope (SHIFT) NP V Det N| with the telescope (REDUCE) NP V NP| with the telescope (REDUCE) 29. april 2019
8
Bottom-up: Shift-Reduce parser
Tilsvarer en reversert høyreavledning: Til hver høyreavledning svarer nøyaktig en SR-parse. To plasser for valg/ikke-determinisme: Skal vi flytte eller redusere? Hva skal vi velge når vi har flere valg for reduksjon ? Vi kan gjøre den mer effektiv hvis grammatikken er på CNF: Når vi flytter, gjør vi samtidig en unær reduksjon. Svarer til regel på formen B t Bare se på de to siste symbolene når vi reduserer Svarer til regel på formen A BC 29. april 2019
9
Problem for både RD og SR
Ineffektivitet Så på eksempler sist RD: Eksempel: S NP VP Noen valg under NP Noen valg under VP Vi foretar valgene for VP på nytt for hvert alternativ under NP Tilsvarende for SR For hvert valg vi foretar må vi se på alle muligheter for resten av strengen på nytt 29. april 2019
10
I dag Oppsummering fra sist: Tabellparsing: Chartparsing:
Recursive-descent og Shift-reduce parser Svakheter med disse Tabellparsing: Dynamisk programmering CKY-algoritmen Chartparsing: Dotted items Fundamentalregel Bottom-up strategi Neste gang: alternative strategier 29. april 2019
11
Speech and Language Processing - Jurafsky and Martin
Dynamic Programming DP search methods fill tables with partial results and thereby Avoid doing avoidable repeated work Solve exponential problems in polynomial time (well, no not really) Efficiently store ambiguous structures with shared sub-parts. Vi skal se på: CKY Chartparsing (Earleys algoritme svarer til en variant av chartparsing) 4/29/2019 Speech and Language Processing - Jurafsky and Martin
12
Speech and Language Processing - Jurafsky and Martin
CKY Parsing First we’ll limit our grammar to CNF Consider the rule A BC If there is an A somewhere in the input then there must be a B followed by a C in the input. If the A spans from i to j in the input then there must be some k st. i<k<j Ie. The B splits from the C someplace. 4/29/2019 Speech and Language Processing - Jurafsky and Martin
13
Speech and Language Processing - Jurafsky and Martin
Sample L1 Grammar 4/29/2019 Speech and Language Processing - Jurafsky and Martin
14
Speech and Language Processing - Jurafsky and Martin
CNF Conversion 4/29/2019 Speech and Language Processing - Jurafsky and Martin
15
Speech and Language Processing - Jurafsky and Martin
CKY So let’s build a table so that an A spanning from i to j in the input is placed in cell [i,j] in the table. So a non-terminal spanning an entire string will sit in cell [0, n] Hopefully an S If we build the table bottom-up, we’ll know that the parts of the A must go from i to k and from k to j, for some k. 4/29/2019 Speech and Language Processing - Jurafsky and Martin
16
Speech and Language Processing - Jurafsky and Martin
CKY Meaning that for a rule like A B C we should look for a B in [i,k] and a C in [k,j]. In other words, if we think there might be an A spanning i,j in the input… AND A B C is a rule in the grammar THEN There must be a B in [i,k] and a C in [k,j] for some i<k<j 4/29/2019 Speech and Language Processing - Jurafsky and Martin
17
Speech and Language Processing - Jurafsky and Martin
CKY So to fill the table loop over the cell[i,j] values in some systematic way What constraint should we put on that systematic search? For each cell, loop over the appropriate k values to search for things to add. 4/29/2019 Speech and Language Processing - Jurafsky and Martin
18
Speech and Language Processing - Jurafsky and Martin
Example 4/29/2019 Speech and Language Processing - Jurafsky and Martin
19
Speech and Language Processing - Jurafsky and Martin
Example 4/29/2019 Speech and Language Processing - Jurafsky and Martin
20
Speech and Language Processing - Jurafsky and Martin
Example Filling column 5 4/29/2019 Speech and Language Processing - Jurafsky and Martin
21
Speech and Language Processing - Jurafsky and Martin
Example 4/29/2019 Speech and Language Processing - Jurafsky and Martin
22
Speech and Language Processing - Jurafsky and Martin
Example 4/29/2019 Speech and Language Processing - Jurafsky and Martin
23
Speech and Language Processing - Jurafsky and Martin
Example 4/29/2019 Speech and Language Processing - Jurafsky and Martin
24
Speech and Language Processing - Jurafsky and Martin
Example 4/29/2019 Speech and Language Processing - Jurafsky and Martin
25
Speech and Language Processing - Jurafsky and Martin
CKY Algorithm 4/29/2019 Speech and Language Processing - Jurafsky and Martin
26
Speech and Language Processing - Jurafsky and Martin
CKY Parsing Is that really a parser? 4/29/2019 Speech and Language Processing - Jurafsky and Martin
27
I dag Oppsummering fra sist: Tabellparsing: Chartparsing:
Recursive-descent og Shift-reduce parser Svakheter med disse Tabellparsing: Dynamisk programmering CKY-algoritmen Chartparsing: Dotted items Fundamentalregel Bottom-up strategi Neste gang: alternative strategier 29. april 2019
28
Chart – alternativ datastruktur
(VP, [0,1]) … (Det, [1,2]) (Nom, [2,3]) (N, [2,3]) (NP, [1, 3]) (S, [0,5]) S, VP, X2 NP S, VP, X2 Nom NP PP S, VP, V, Nom, N Det Nom, N P NP, PN 1 2 3 4 5 book the flight through Houston 29. april 2019
29
Chart – alternativ datastruktur
(VP, [0,1]) … (Det, [1,2]) (Nom, [2,3]) (N, [2,3]) (NP, [1, 3]) (S, [0,5]) S, VP, X2 NP S, VP, X2 Nom NP PP S, VP, V, Nom, N Det Nom, N P NP, PN 1 2 3 4 5 book the flight through Houston 29. april 2019
30
Begrensninger i CKY Grammatikken må være på CNF
Det foreslås strukturer som holder lokalt, men ikke globalt: Løsninger baserer seg på å kombinere TD og BU Hjelp for begge problemene å innføre ”dotted items” 29. april 2019
31
Speech and Language Processing - Jurafsky and Martin
States The table-entries are called states and are represented with dotted-rules. S VP - A VP is predicted NP Det Nominal - An NP is in progress VP V NP - A VP has been found 4/29/2019 Speech and Language Processing - Jurafsky and Martin
32
Speech and Language Processing - Jurafsky and Martin
States/Locations S VP [0,0] NP Det Nominal [1,2] VP V NP [0,3] . A VP is predicted at the start of the sentence An NP is in progress; the Det goes from 1 to 2 A VP has been found starting at 0 and ending at 3 4/29/2019 Speech and Language Processing - Jurafsky and Martin
33
Chart – alternativ datastruktur
NP Det Nom Nom Nom PP PP P NP NP Det Nom, N P NP, PN 1 2 3 4 5 book the flight through Houston NP Det Nom NP Det Nom Nom Nom PP Nom Nom PP PP P NP PP P NP Partielt snapshot 29. april 2019
34
Fundamentalregelen Fra (A B , [i,k] ) + (B , [k, i] )
NP Det Nom Nom Nom PP 1 2 3 4 5 book the flight through Houston NP Det Nom Fra (A B , [i,k] ) + (B , [k, i] ) Kan vi lage (A B , [i,j] ) 29. april 2019
35
Chart-parsing To datastrukturer: I tillegg må vi tenke på:
Agenda Hovedstruktur: Fjern en kant k fra agenda Hvis k ikke alt finnes i chartet: Legg k til chartet For alle aktuelle kanter m i chartet: Prøv å matche k mot m m/fundamentalregelen: Hvis de matcher, legg resultatet i agenda Gjenta til agenda er tom I tillegg må vi tenke på: Initialisering: for w ordet på plass n og alle leksikalske regler B w, for en B, skal (B w , [n-1,n] ) legges til agenda (/chart) Innfør aktive kanter: Legg de nødvendige aktive kanter på formen (B , [k,i]) til agenda (/chart) Hold styring på rekkefølge Ulike strategier for Rekkefølge Og dermed hvilke aktive kanter som er nødvendige for å få fullstendig parse. 29. april 2019
36
Bottom-up ”Legg de nødvendige aktive kanter på formen (B , [k,i]) til agenda (/chart)”: Når inaktiv/ukomplett kant (B , [m, n] ) flyttes til chartet: Finn alle A, s.a. A B er en regel, og Legg kanten (A B , [m, m]) til agenda 29. april 2019
37
Make-predictions, fig 29. april 2019
38
Chart-algoritme, fig 29. april 2019
Liknende presentasjoner
© 2024 SlidePlayer.no Inc.
All rights reserved.