Upload
tecla-rosa
View
213
Download
1
Embed Size (px)
Citation preview
Elaborazione del linguaggio naturaleCFG: esercizi
Maria Teresa PAZIENZAa.a. 2007-08
CFG
ESERCIZIO CFG 1
1. Scrivere una grammatica CFG, sul modello di quella precedentemente introdotta, in grado di riconoscere le seguenti frasi:
“Does America 487 have a first class section ? ”
“ Does America Airlines have a flight between 5 and 6 ?”
“ Is there an America airlines flight from Rome to London ?”
2. Produrre i parse-tree relativi alle frasi proposte
CFG: problemi
ESERCIZIO CFG 3
1. Aumentare la grammatica in modo da gestire i pronomi personali “he, she, her, him” nel caso corretto. Es:
- “He shot her” (corretto)- “Her shot he” (errato)
2. Aumentare la grammatica in modo da gestire i seguenti patterns di sottocategorizzazione:
• Verbi senza NP: disappear (“I disappear”)• Verbi con NP : find, leave, repeat (“I find the flight”)• Verbi con due NP: give, bring (“give me the book”)
Data la seguente grammatica:
S -> NP VPNP -> Pron | PropNoun | Det NomNom -> Noun Nom | NounVP -> Verb | Verb NP | Verb PP | Verb NP PPPP -> Prep NP
Parsing: ricerca
ESERCIZIO PARS 1
Data la grammatica presentata nella lezione, scrivere lo sviluppo dell’albero di parsing per le seguenti frasi:
“Book that flight”
“Does the TWA flight include a meal ?”
“Does the flight from Houston include a meal ?”
Utilizzando un parser top-down, depth-first, left-to-right
Parsing: left-corners
ESERCIZIO PARS 2
2. Data la frase “I shot a tiger”, scrivere gli stati prodotti da un parser :
1. Top-down, depth-first, left-to-right
2. Left Corner (ovvero con l’aggiunta del filtro bottom-up).
Quali miglioramenti ci sono ?
1. Determinare la tabella dei Left-Corners della seguente grammatica
S -> VP
S -> NP VP
NP -> Det Noun
NP -> Poss Noun
NP -> Pron
NP -> NP PP
PP -> Prep NP
VP -> Verb
VP -> Verb NP
VP -> Verb PP NP
Det -> an
Noun -> elephant|tiger |pajamas|
Pron -> I
Poss -> my
Verb -> shot
Prep -> in
Cong -> and
Parsing: ambiguità
ESERCIZIO PARS 3
1. Verificare se le seguenti frasi sono sintatticamente ambigue:
- “I shot an elephant in my pajamas”
- “I shot an elephant and a tiger”
2. In caso di ambiguità costruire i relativi parse-tree e dire qual è il tipo di ambiguità riscontrata
Data la seguente grammatica:
S -> NP VP
S -> VP
NP -> Det Noun
NP -> Poss Noun
NP -> NP Conj NP
NP -> Pron
NP -> NP PP
PP -> Prep NP
VP -> Verb
VP -> Verb NP
VP -> Verb NP PP
Det -> an
Noun -> elephant|tiger |pajamas|
Pron -> I
Poss -> my
Verb -> shot
Prep -> in
Cong -> and
3. Data la seguente grammatica:
S NP VPVP Verb NPVP VP PPVP VP Conj VPNP NP PPNP NP CONJ NPPP Prep NPPP PP Conj PP
NP SallyNP LondonNP ParisNP AprilVerb lovesP inConj and
verificare se la frase “Sally loves London and Paris in April” è ambigua. In caso positivo, scrivere tutti i possibili parse-tree corretti e indicare la tipologia di ambiguità.
Parsing: ambiguità
ESERCIZIO PARS 3
Parsing: Earley
ESERCIZIO PARS 4
Scrivere il processo di parsing completo secondo l’algoritmo di Earley, per la seguente frase:
“An elephant takes the flight”
Data la seguente grammatica:
S NP VPS VPNP Det NomNP PropNVP VerbVP Verb NPNom NounNom Noun Nom
Noun elephant | flightDet an |theVerb takes
Suggerimenti per esercizi
ESERCIZIO 6
Per la migliore comprensione degli argomenti svolti nelle presentazioni NLP 4,5 si suggerisce di cimentarsi anche con gli esercizi del libro
Speech and Language Processing, Prentice Hall, 2000,
autori: D.Jurafsky, J. H. Martin
In particolare:Capitolo 9, esercizi n. 9.1, 9.2, 9.3, 9.5, 9.9, 9.10, 9.11 facoltativo
Capitolo 10, esercizi n. 10.1, 10.3, 10.4, 10.5, 10.6