Inteligenta Artificiala
Universitatea Politehnica Bucuresti
Anul universitar 2005-2006
Adina Magda Florea
http://turing.cs.pub.ro/ia_06
1
Curs nr. 13
Prelucrarea limbajului natural
2
2
Comunicare
Definite
mesaj, limbaj, protocol
Componentele comunicarii
– intentie
– generare
– sinteza
–
–
–
–
perceptie
analiza
desambiguare
incorporare
3
Acte de comunicare
Teoria actelor de comunicare
locutie
ilocutie
prelocutie
Tipuri de agenti care comunica
–
–
–
–
–
–
–
asertive
directive
comisive
permisive
prohibitive
declarative
expresive
4
Definire limbaj
Lexicon
Analiza lexicala
Gramatici
Analiza (pars oratoris)
Terminale, neterminale, reguli de rescriere
simbol de inceput
LHS RHS
Analza semantica
Analiza pragmatica
5
Lexicon
Noun breeze | wumpus | ball
Verb is | see | smell | hit
Adjective right | left | smelly …
Adverb here | there | ahead …
Pronoun me | you | I | it
RelPronoun that | who
Name John | Mary
Article the | a | an
Preposition to | in | on
Conjunction and | or | but
6
Gramatica
Neterminale – diferite categorii din
propozitie
– sentence S
– noun phrase NP
– verb phrase VP
– prepositional phrase PP
– relative clause RelClause
7
Exemplu
S NP VP | S Conjunction S
NP Pronoun | Noun | Article Noun |
NP PP | NP RelClause
VP Verb | VP NP | VP Adjective |
VP PP | VP Adverb
PP Preposition NP
RelClause RelPronoun VP
8
Analiza sintactica
– top-down parsing
– bottom-up parsing
– in adancime
– pe nivel
9
Top-Down Parsing
"John hit the ball"
1. S
2. S NP, VP
3. S Noun, VP
4. S John, Verb, NP
5. S John, hit, NP
6. S John, hit, Article, Noun
7. S John, hit, the, Noun
8. S John, hit, the, ball
10
Bottom-Up Parsing
1. John, hit, the, ball
2. Noun, hit, the, ball
3. Noun, Verb, the, ball
4. Noun, Verb, Article, ball
5. Noun, Verb, Article, Noun
6. NP, Verb, Article, Noun
7. NP, Verb, NP
8. NP, VP
9. S
11
Definite Clause Grammar (DCG)
Gramatici BNF - probleme
Utilizare LP
Gramatici cu clauze definite
DCG – gramatica; propozitie = clauza
definita
neterminal = predicat de 1 argument
12
In BNF
S NP VP
In LP
NP(s1) VP(s2) S(Append(s1, s2))
NF
Noun ball | book
In LP
(s = “ball” s = “book”) Noun(s)
13
BNF, DCG, Prolog
BNF
FOPL
PROLOG
S NP VP
NP Noun
Noun stench
Noun wumpus
VP Verb
Verb smells
Verb kills
NP(s1) VP(s2) S(append(s1,s2))
Noun(s) NP(s)
Verb(s) VP(s)
(s = “stench” s = “wumpus”)
Noun(s)
(v = “smells” v = “kills”)
Verb(v)
sentence([S1, S2]) :np(S1), vp(S2).
np(S):- noun(S).
vp(S):- verb(S).
noun(stench).
noun(wumpus).
verb(smells).
verb(kills).
?- sentence([wumpus,
smells]).
?-sentence([S1, S2]).
Imbogatire DCG
Imbogatesc neterminale cu argumente
suplimentare
Verifica corectitudinea gramaticala
Ataseseaza semantica
Adauga expresii / functii care se
testeaza
15
Argument pt semantica
DCG
FOPL
PROLOG
S(sem) NP(sem1) VP(sem2)
{compose(sem1, sem2, sem)}
NP(s1, sem1) VP(s2, sem2)
S(append(s1, s2)),
compose(sem1, sem2, sem)
slide urmator
semantica compozitionala
16
The dog has legs.
The ball is yellow.
The ball is red.
The dog bites.
(dog parts legs)
(ball property yellow)
(ball property red)
(dog action bytes)
sentence(S, Sem) :- np(S1, Sem1), vp(S2, Sem2), append(S1, S2, S),
Sem = [Sem1 | Sem2].
np([S1, S2], Sem) :- article(S1), noun(S2, Sem).
vp([S], Sem) :- verb(S, Sem1), Sem = [action, Sem1].
vp([S1, S2], Sem) :- verb(S1,_), adjective(S2, Sem1), Sem = [property, Sem1].
vp([S1, S2], Sem) :- verb(S1,_), noun(S2, Sem1), Sem = [parts, Sem1].
noun(dog,dog).
noun(ball,ball).
verb(bytes,bytes).
verb(is,is).
verb(has,has).
adjective(yellow,yellow).
adjective(red,red).
Verificare corectitudine gramaticala
cazuri
subcategorii verbe: compleentul pe care
il poate accepta un verb
acord subiect predicat
etc.
Parametrizarea neterminalelor
18
Cazuri
Nominativ (subjective)
I take the bus
You take the bus
He takes the bus
Eu iau autobuzul
Tu iei autobuzul
El ia autobuzul
Acuzativ (objective)
He gives me the book
Imi da cartea
S NP(Subjective) VP
NP(case) Pronoun (case) | Noun | Article Noun
//
I
VP VP NP(Objective)
//
believe him
VP VP PP
// turn to the right
VP VP Adjective
VP Verb
PP Preposition NP(Objective)
Pronoun(Subjective) I | you | he | she
Pronoun(Objective) me | you | him | her
sentence(S) :- np(S1,subjective), vp(S2),
append(S1, S2, S).
np([S], Case) :- pronoun(S, Case).
np([S], _ ) :- noun(S).
np([S1, S2], _ ) :- article(S1), noun(S2).
pronoun(i, subjective).
pronoun(you, _ ).
pronoun(he, subjective).
pronoun(she, subjective).
pronoun(me, objective).
pronoun(him, objective).
pronoun(her, objective).
noun(ball).
noun(stick).
article(a).
article(the).
20
Subcategorii verbe
Lista de subcategorii: ce complemente
accepta verbul
depinde de verb
S NP(Subjective) VP(subcat)
dar cazuri in care nu depinde
VP(subcat) VP(subcat) PP
| VP(subcat) Adverb
I smell the wumpus now
21
VP(subcat) {subcat = np} VP(np) NP(Objective)
| {subcat = adj} VP(adj) Adjective
| {subcat = pp} VP (pp) PP
| Verb
smell
[NP]
[Adjective]
[PP]
smell a wumpus
smell awfull
smell like a wumpus
is
[Adjective]
[PP]
[NP]
is smelly
is in box
is a pit
give
[NP, PP] give the gold in box to me
[NP, NP] give me the gold
died
[]
died
S NP(Subjective) VP(subcat)
NP(case) Pronoun (case) | Noun | Article Noun
Pronoun(Subjective) I | you | he | she
Pronoun(Objective) me | you | him | her
VP(subcat) {subcat = np} VP(np) NP(Objective)
| {subcat = adj} VP(adj) Adjective
| {subcat = pp} VP (pp) PP
| Verb
| VP(subcat) PP
| VP(subcat) Adverb
sentence(S) :- np(S1,subjective), vp(S2),
append(S1, S2, S).
np([S], Case) :- pronoun(S, Case).
np([S], _ ) :- noun(S).
np([S1, S2], _ ) :- article(S1), noun(S2).
VP(subcat) VP(subcat) … !!!
vp(S, Subcat) :- Subcat = np, vp1(S1, np),np(S2, objective),
append(S1, S2, S).
vp1([S],np):-verb(S).
verb(give).
verb(make).
vp(S,Subcat) :- vp1(S1, Subcat), pp(S2), append(S1, S2, S).
Analiza pragmatica
Analiza semantica
Desambiguare
Interpretare pragmatica – utilizare si
efect asupra ascultatorului
Indexical - situatia curenta
Anafora – deja mentionate
25
Ambiguitate
Lexicala
Sintactica
Referentiala
Pragmatica
26
© Copyright 2026 Paperzz