View
30
Download
0
Category
Preview:
DESCRIPTION
Taaltheorie en Taalverwerking Week 4: Parseer-algoritmes. Gegeven: Sequentie woorden en CFG. Gevraagd:Wat zijn de structuren van deze sequentie volgens de CFG?. Parseer-algoritmes voor CFG's. Parsing as search. (1) Top-down: Toestandsruimte:Alle mogelijke bomen - PowerPoint PPT Presentation
Citation preview
Taaltheorie en Taalverwerking
Week 4: Parseer-algoritmes
Gegeven: Sequentie woorden en CFG.
Gevraagd:Wat zijn de structuren van deze sequentievolgens de CFG?
Parseer-algoritmes voor CFG's
Parsing as search.
(1) Top-down: Toestandsruimte: Alle mogelijke bomenDoel: Boom past op string
(2) Bottom-up:Toestandsruimte: Partiële analyses
van de stringDoel: Analyse is compleet
Parseer-algoritmes
Top-down search space
Bottom-up search space
Book that flight
Book that flight
Book that flightBook that flight
Book that flightBook that flight
Book that flightBook that flight
"Naïef top-down-algoritme": Toestandsruimte:Alle mogelijke bomenDoel: Boom past op string
Initialisering van de toestandenverzameling: {S}
Uitbreiding van de toestanden-verzameling(“successor-functie”):
Expandeer een non-terminale knoop m.b.v. een grammatica-regel
Goal-test: Is de yield van een van de bomen de gewenste string?
S
S NP VP
S
NP VP
article noun
S
NP VP
S NP VP
NP article noun
articlethe
noun
S
NP VP
S NP VP
NP article noun
articlethe
nounwumpus
S
NP VP
S NP VP
NP article noun
articlethe
nounwumpus
verbis
S
NP VP
adjectivedead
VP
"Naief" top-down: generate and test.
"Redelijk" top-down:
Toestand: analyse van linkerdeel v.d. zin+ current node+ volgende woord
Testen kan nu incrementeel.
Martin & Jurafsky (pp. 364-368):
"A Basic Top-Down Parser."
search state: partial tree + active node.input string + active word.
agenda: Stack of search states.
cs: current state
generatie van nieuwe search-states door:apply-rulesapply-lexical-rule
article
the
noun
S
NP VP
wumpus is dead
toestand (cs)
( , )
node to expand (nte)
current input (cip)
apply-rules (cs)
the
S
NP VP
article
the
noun
S
NPVP
wumpus is dead wumpus is dead
Voorbeeld: Actieve knoop: NP.Toepasbare regel: NP article noun
apply-lexical-rule (cs)
article
the
noun
S
NP VP
Voorbeeld: Actieve knoop: article. Actief woord: the.Toepasbare lexicale regel: article the
article
the
noun
S
NP VP
wumpus is dead wumpus is dead
agenda := [ (S, word1 word2 . . . wordn )]
cs := pop (agenda)
loopif success (cs) then return (cs)else
if cat (nte(cs)) POS thenif cat (nte(cs)) = pos (cip (cs))then push (apply-lexical-rule(cs), agenda)
else push (apply-rules (cs), agenda);if empty(agenda)
then return (reject) else cs := pop (agenda)
end
Martin & Jurafsky (pp. 364-368): "A Basic Top-Down Parser."
Intialisatie:
cs = ( S, Book that flight)agenda = [ ]
Intialisatie:
cs = ( S, Book that flight)agenda = [ ]
pop:
Na een aantal pop's:
cs = ( , Book that flight)
V
NP
Nu is “apply-lexical-rule” toepasbaar.
En zo verder.
Huiswerk: Implementeer top-down parser
Probleem bij top-down parseren: links-recursie.
Probleem bij top-down parseren: links-recursie.
B.v.: regels van de vorm:A A B.
Links-recursie in het Nederlands.
N N PP("kat", "kat op de mat")
VP VP PP("slaapt", "slaapt tot 10 uur")
S S en S("Kim slaapt", "Kim slaapt en Sandy werkt")
NP det NPdet NP 's
("Peter", "Peter's huis")
Links-recursie verwijderen
De regels:
N N PP | man | vrouw | huis | tafel | . . .PP Prep NP
Worden vervangen door:
N N-lex PP*N-lex man | vrouw | huis | tafel | . . .PP* PP PP*PP* PP Prep NP
Nadeel:
• Veranderde grammatica leidt tot andere boom-structuren! (Post-processing noodzakelijk.)
• Veranderde grammatica heeft (veel) meer regels
Lijkt de menselijke grammatica op een CFG?
Lijkt de menselijke grammatica op een CFG?
(1) Nee. Nederlands kan niet met een CFG beschreven worden: Cross-serial dependencies.
Lijkt de menselijke grammatica op een CFG?
(2) Nee. CFG genereert zinnen die voor een mens moeilijk zijn: "center-embedding".
J&M § 13.4: Center-embedding.
"The dog chased the cat that likes tuna fish"
"The cat the dog chased likes tuna fish."
J&M § 13.4: Center-embedding.
"The dog chased the cat that likes tuna fish"
"The cat the dog chased likes tuna fish."
"The cat [the dog chased] "
NP NP S'S' NP V2
NP NP NP V2
“center-embedding”
J&M § 13.4: Center-embedding.
"The dog chased the cat that likes tuna fish"
"The cat the dog chased likes tuna fish."
"The elephant admired the rat that bit the dog that chased the cat that likes tuna fish."
J&M § 13.4: Center-embedding.
"The dog chased the cat that likes tuna fish"
"The cat the dog chased likes tuna fish."
"The elephant admired the rat that bit the dog that chased the cat that likes tuna fish."
"The cat the dog the rat the elephant admired bit chased likes tuna fish."
J&M § 13.4: Center-embedding.
"The cat the dog the rat the elephant admired bit chased likes tuna fish."
Regels van de vormNP NP NP V2
kunnen de facto niet recursief toegepast worden.
Verklaring: beperkte stack-diepte.
Victor Yngve: Engels is wel een reguliere taal!
Chomsky-hierarchy revisited.
Cross-serial dependencies.
J&M § 13.3: Cross-serial dependencies.
Nederlands & Züüritüütsch.
J&M § 13.3: Cross-serial dependencies.
Engels:
"... that we let the children help Hans paint the house."
"... that [we let [the children help [Hans paint the house]]]."
J&M § 13.3: Cross-serial dependencies.
Duits:
"... dass wir die Kinder Hans das Haus anstreichen helfen liessen."
"... dass [wir [die Kinder [Hans das Haus anstreichen] helfen] liessen]."
J&M § 13.3: Cross-serial dependencies.
Nederlands: "... dat we de kinderen Hans het huis lieten helpen verven."
"... dat we de kinderen Hans het huis lieten helpen verven."
J&M § 13.3: Cross-serial dependencies.
Engels:"... that [we let [the children help [Hans paint the house]]]."
Duits:"... dass [wir [die Kinder [Hans das Haus anstreichen] helfen] liessen]."
Nederlands: "... dat we de kinderen Hans het huis lieten helpen verven."
J&M § 13.3: Cross-serial dependencies.
Nederlands: "... dat we de kinderen Hans het huis lieten helpen verven."
Kan niet contextvrij. (Bewijs m.b.v. Pompstelling voor conetxtvrije grammatica's.)
Recommended