1 / 37

Syntactic Parsing

Syntactic Parsing. Obiettivo. Richiamo: Discussione della derivazione nelle grammatiche context -free e relazione con gli alberi Obiettivo di un parser : Costruire alberi a partire da frasi. Outline. Parsing Algorithms Top down Bottom Up CYK Early Algorithm / Chart Parsing.

vernon
Télécharger la présentation

Syntactic Parsing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SyntacticParsing

  2. Obiettivo • Richiamo: Discussione della derivazione nelle grammatiche context-free e relazione con gli alberi • Obiettivo di un parser: Costruire alberi a partire da frasi

  3. Outline • ParsingAlgorithms • Top down • Bottom Up • CYK • EarlyAlgorithm / Chart Parsing

  4. FMZ Parsing CF with Cocke-Younger-Kasami (CYK) algorithm Grammar in CNF* S→AB|BC A→BC|a B→BB|CC|b C→a *CNF Chomsky Normal Form

  5. FMZ Parsing CF with Cocke-Younger-Kasami (CYK) algorithm Grammar in CNF S→AB|BC A→BC|a B→BB|CC|b C→a

  6. FMZ Parsing CF with Cocke-Younger-Kasami (CYK) algorithm input: a1 ... an. Pn,n is the matrix of sets of symbols initially Pn,n = For each i = 1 to n For each unit production Rj → ai, set P1,j = {Rj} For each i = 2 to n For each j = 1 to n-i+1 For each k = 1 to i-1 For each production RA → RB RC If RBPj,k and RC Pj+k,i-k then Pj,i = Pj,i {RA} If R1 P[1,n] Then string is member of language Else string is not member of language

  7. FMZ Parsing CF with Cocke-Younger-Kasami (CYK) Limits • CYK relies on Chomsky Normal Form hence • there is no freedom on the final structure • a CYK parser has to be coupled with a tree transformer CYK is a very interesting theoretical result but let us find a more flexible parser!!!

  8. EarlyAlgorithm

  9. FMZ Natural Language and its Models • Formal Languages Languages are artificially designed. The Chomsky Level is choosen Structural ambiguity is controlled and semantic is made “clear” • Natural Languages • It is a social phenomenon... as such has to be studied • It exists and evolves • People use differently natural language (performance) according to their language competence

  10. FMZ Observing natural language .... La rivoluzione è la voce che corre sul web. ... ... Netto recupero anche per Iberia, mentre si riprende del 4,1% anche British Airways. ... Nella tabella la chiusura degli indici dei titoli guida delle principali piazze finanziarie del Vecchio Continente ... ... Mentre il professore spiega il modello climatico, Roberto e i colleghi sperimentano l'influenza di diversi parametri sulle previsioni meteorologiche. ...

  11. FMZ A sample Grammar (introspectively produced) S  NP VP | S SBAR | SBAR S SBAR  CongSub S S  S CongCoord S | S, S CongCoord S NP  NP SBAR VP  Verb NP VP  Verb NP PP NP  Art Noun | Art Adj Noun | Noun | NP PP PP  Prep NP

  12. FMZ Observing natural language Telefonia, la rivoluzione è la voce che corre sul web Si chiama Voip, è una rivoluzione perché abbatte i costi delle telefonate ma arriverà solo quando sarà chiaro come si potrà evitare che distrugga i bilanci delle telecom Finisce così con l'avere un impatto contenuto il brusco tonfo segnato dalla fiducia degli investitori tedeschi, con una flessione inattesa dell'indice Zew a marzo da 69,9 punti a quota 57,6. Il rimbalzo più deciso viene messo a segno da Madrid (+1,45%), maggiormente penalizzata nelle scorse sessioni, dopo che anche le banche d'affari consigliano di acquistarne i titoli. Hsbc, in particolare, ha ribadito l'indicazione di sovrappesare le azioni spagnole giudicando improbabili grandi cambiamenti alle politiche economiche da parte del nuovo governo socialista.Tra i bancari, in progresso Credit Suisse (+1,7%). Mentre corre la spagnola Santander Central Hispano (+1,8%). Nel comparto aereo, netto recupero anche per Iberia (+7,5%), mentre si riprende del 4,1% anche British Airways. Virgin Express, la compagnia low cost di Richard Branson, termina invariata dopo la formalizzazione con una lettera di intenti delle trattative di fusione con Sn Brussels Airlines (ex Sabena). Il comparto non registra però nessuna fiammata sulle attese di consolidamento e Ryanair termina in calo del 2,39%, Klm avanza di un modesto 0,49%. Dopo le vendite delle ultime sedute, Air France rimbalza dell'1,20%. Nel comparto petrolifero, è la spagnola Repsol (+1,42%) la blue chip più vivace, mentre Bp segna un progresso dello 0,22%. Invariata Shell, giù dello 0,36% Royal Dutch. La francese Total cede lo 0,14%.

  13. FMZ Observations • The sample grammar is insufficient!! • NL is not completely captured! • However, it is possible to think to a camprehensive model? An NL model can cover all natural language phenomena?

  14. FMZ Model Coverage • A complete model can be hardly achieved • Augmenting the coverage may imply also augmenting the induced ambiguity of the model • The model can cover partially a sentence. • Partial analysis are also relevant

  15. FMZ Partial Analysis may be relevant... ... sai: questa cosa che è cosata all'improvviso, non so se è una cosa che coserà, ma coso di sì, anche se, cosando le solite cose, coso a cosare che le cose si cosino cosabilmente e che le cose non cosino per sempre, che siano cosabili, cosibili, soprattutto cosubili. Queste cose si stracosano all'inizio, poi si cosano, si discosano, si supercosano, fino a cosarsi di nuovo, e noi, in tutto questo, non ci possiamo cosare nessuna cosa, anche se adesso io ti coso cose e tu mi cosi cose, e tutti cosiamo le cose che ci cosiamo fino a scosarci e ricosarci all'infinito...

  16. FMZ Model Ambiguity • Genuine ambiguity Time flies like an arrow Flying planes can be dangerous La vecchia porta la sbarra • Model-induced Ambiguity NP  Art Noun | Art Adj Noun | Noun | NP PP Nella tabella la chiusura degli indici dei titoli guida delle principali piazze finanziarie del Vecchio Continente

  17. FMZ Aim • Build a formalism/model able to give the possibility of reducing the unnecessary interpretations • Build a formalism (and an associated algorithm) able to represent partial analysis • We want the freedom to adopt bottom-up or top-down algorithms

  18. FMZ What we have done? • CNF grammars and CYK: • a bottom-up algorithm • it stores partial analyses • CFG and prolog: • a top-down algorithm • it does not store partial analysis • many subtrees are recomputed in the different analyses

  19. FMZ Parsing CF with Cocke-Younger-Kasami (CYK) algorithm Grammar in CNF S→AB|BC A→BC|a B→BB|CC|b C→a

  20. FMZ Chart Parsing and Early Algorithm

  21. FMZ Chart parsing: la struttura dati • Well Formed Substring Table WFST • La struttura dati è un grafo i cui • Nodi sono i connettori • Archi sono le ragioni per cui i connettori sono connessi tra loro

  22. FMZ Un esempio di WFST SNP VP VP  VP NP VP  VP NP PP NP  NP PP PP  Prep NP NP  Art Noun NP VP NP Noun Verb Noun Art Noun Prep Art Mario guarda l’ uomo con il microscopio

  23. FMZ Chart Parsing • Making the chart WFST active: representing a state of the analysis S  NP VP | S SBAR | SBAR S SBAR  CongSub S S  S CongCoord S | S, S CongCoord S NP  NP SBAR VP  Verb NP VP  Verb NP PP NP  Art Noun | Art Adj Noun | Noun | NP PP PP  Prep NP NPNP•PP PPPrep•NP NP  Art Noun NP VP NP Noun Verb Noun Art Art Noun Prep Mario guarda l’ uomo con il microscopio

  24. FMZ Chart parsing • Estende l’idea del WFST per permettere di rappresentare goal e ipotesi. La struttura risultante è quella degli active chart • Il concetto principale è quello delle Dotted Rules A B.C I simboli a destra del punto sono quelli che sono stati confermati mentre quelli a sinistra sono quelli da confermare.

  25. FMZ Chart Parsing • Gli archi dell’active chart sono delle dotted rules. • E’ quindi possibile implementare strategie di parsing: • Bottom-up • Top-down • Ibride

  26. FMZ Chart Parsing: introduzione • Definizione del formalismo • Definizione della struttura dati in prolog • Implementazione di una strategia di parsing

  27. FMZ Chart Parsing • Dotted rule in prolog: edge(V0,V1,Category,TOBEFOUND,FOUND_STRUCTURED) • Rule: rule(Mother,List_of_daughters) • Lexicon: word(Category,Word). Un parser bottom-up • esempio

  28. FMZ Bottom-up Chart Parsing (a) parse(V0,Vn,String) :- start_chart(V0,Vn,String). % defined in chrtlib1.pl start_chart(V0,V0,[]). start_chart(V0,Vn,[Word|Words]) :- V1 is V0+1, foreach(word(Category,Word), add_edge(V0,V1,Category,[],[Word,Category])), start_chart(V1,Vn,Words).% add_edge(V0,V1,Category,Categories,Parse) :- edge(V0,V1,Category,Categories,Parse),!.

  29. FMZ Bottom-up Chart Parsing (b) add_edge(V1,V2,Category1,[],Parse) :- assert_edge(V1,V2,Category1,[],Parse), foreach(rule(Category2,[Category1|Categories]), add_edge(V1,V1,Category2,[Category1|Categories],[Category2])), foreach(edge(V0,V1,Category2,[Category1|Categories],Parses), add_edge(V0,V2,Category2,Categories,[Parse|Parses])).

  30. FMZ BU Chart in action add_edge(V1,V2,Category1,[],Parse) :- assert_edge(V1,V2,Category1,[],Parse), foreach(rule(Category2,[Category1|Categories]), add_edge(V1,V1,Category2,[Category1|Categories],[Category2])), foreach(edge(V0,V1,Category2,[Category1|Categories],Parses), add_edge(V0,V2,Category2,Categories,[Parse|Parses])). in black real edges in red add_edge NP • Noun Noun Mario guarda l’ uomo con il ....

  31. FMZ Bottom-up Chart Parsing (c) add_edge(V0,V1,Category1,[Category2|Categories],Parses) :- assert_edge(V0,V1,Category1,[Category2|Categories],Parses), foreach(edge(V1,V2,Category2,[],Parse), add_edge(V0,V2,Category1,Categories,[Parse|Parses])).

  32. FMZ BU Chart in action add_edge(V0,V1,Category1,[Category2|Categories],Parses) :- assert_edge(V0,V1,Category1,[Category2|Categories],Parses), foreach(edge(V1,V2,Category2,[],Parse), add_edge(V0,V2,Category1,Categories,[Parse|Parses])). in black real edges in red add_edge NP Noun • NP • Noun Noun Mario guarda l’ uomo con il ....

  33. FMZ BU Chart in action in black real edges in red add_edge SNP • VP NP Noun• Noun Mario guarda l’ uomo con il ....

  34. FMZ BU Chart in action add_edge(V1,V2,Category1,[],Parse) :- assert_edge(V1,V2,Category1,[],Parse), foreach(rule(Category2,[Category1|Categories]), add_edge(V1,V1,Category2,[Category1|Categories],[Category2])), foreach(edge(V0,V1,Category2,[Category1|Categories],Parses), add_edge(V0,V2,Category2,Categories,[Parse|Parses])). in black real edges in red add_edge SNP • VP VP  VP NP • NP Noun• VPVerb Noun Verb Mario guarda l’ uomo con il ....

  35. FMZ Bottom-up Chart Parsing (d)foreach’s mistery % % foreach - for each X do Y % foreach(X,Y) :- X, do(Y), fail. foreach(X,Y) :- true. do(Y) :- Y,!.

  36. FMZ Where are we? • NL is a phenomenon to be studied: • building a model implies understanding how it behaves • Performance makes things difficult • A compentence model hardly explain all the possible produced sentences • Partial analyses are needed • Charts are proposed as a good for storing partial and competing analysis

  37. FMZ What’s next? • The eternal struggle between coverage and ambiguity. • Feacture structures to empower the language of representig grammatical rules

More Related