Vous êtes sur la page 1sur 6

Natural Language Processing

Understanding nature language is a mundane task. Mundane tasks Humans can do easily but very difficult to automate by computers. Natural Language Processing (NLP): 1. Natural Language Understanding 2. Natural Language Generation

Natural Language Processing

Spoken/typed sentence

Natural Language Understanding

The sentences meanings

Formal representations

Natural Language Generation

English expressions

159.302, Isaac Fung, IIST, 2005

159.302, Isaac Fung, IIST, 2005

Natural Language Systems


To explore general theories of human language processing. To do practical tasks such as providing natural language interfaces or front ends to application systems. User speaking typing System

Natural Language Systems


4 stages in natural language processing - speech recognition, syntactic analysis, semantic analysis and pragmatics.
Frequencies of different sounds Frequency Spectrogram Grammar of Language Word sequence He loves Mary

Speech Recognition

Syntactic Analysis
Sentence structure

Understanding spoken language is much harder as the input is just the raw speech signals taken from a microphone.
159.302, Isaac Fung, IIST, 2005
3

Speech Recognition

Context of utterance Sentence Meaning loves(john,mary)

He

loves

Mary Meanings of words

Pragmatics

Partial Meaning x loves(x,mary)

Semantic Analysis

159.302, Isaac Fung, IIST, 2005

Syntactic Analysis
To understand how words are grouped together to make complex sentences. A starting point for working out the meaning of the whole sentence. Consider the following two sentences: 1. The dog ate the bone. 2. The bone was eaten by the dog.

Syntactic Analysis
Understanding the structure (via the syntax rules) of the sentences help us work out that its the bone that gets eaten and not the dog. Simple rule such as its the 2nd noun that gets eaten wouldnt work. Syntactic analysis determines possible groupings of words in a sentence.

159.302, Isaac Fung, IIST, 2005

159.302, Isaac Fung, IIST, 2005

Syntactic Analysis
Consider the following sentence: The rabbit with long ears enjoyed a large green lettuce. Noun phrase Noun phrase

Syntactic Analysis
In other cases there may be many possible groupings of words. Consider the sentence John saw Mary with a telescope. Two different readings based on the groupings:

meaning of individual word group


meaning of the whole sentence

1. 2.

John saw (Mary with a telescope). John (saw Mary with a telescope).

A sentence is syntactically ambiguous if there are two or more possible groupings.


7

159.302, Isaac Fung, IIST, 2005

159.302, Isaac Fung, IIST, 2005

Syntactic Analysis
The use of general knowledge can sometimes help working out which is the intended grouping. For example, consider the sentence I saw the bridge flying into Auckland This sentence is unambiguous if we bring to bear general knowledge about bridge.

Syntactic Analysis
Syntactic analysis helps determining the meaning of a sentence by working out possible word structures. Rules of syntax are specified by writing a grammar for the language. A parser 1. will check if a sentence is correct according to the grammar. 2. returns a representation of the sentences structure. Parse tree

159.302, Isaac Fung, IIST, 2005

159.302, Isaac Fung, IIST, 2005

10

Syntactic Analysis
A grammar specifies allowable sentence structures in terms of basic categories such as nouns and verbs. A given grammar, however, is unlikely to cover all possible grammatical sentences. Parsing sentences is to help determining their meanings, not just to check that they are correct. A good starting point is a simple context free grammar.

Syntactic Analysis
Suppose we want a grammar that recognises sentences like the following: 1. John ate the biscuit. 2. The lion ate the zebra. 3. The lion kissed John. but reject incorrect sentences such as: 1. Ate John biscuit the. 2. Zebra the lion the ate. 3. Biscuit lion kissed.

159.302, Isaac Fung, IIST, 2005

11

159.302, Isaac Fung, IIST, 2005

12

Syntactic Analysis
A simple grammar that deals with this is given below:
sentence --> noun_phase, verb phrase. noun_phrase --> proper_noun. noun_phrase --> determiner, noun. verb_phrase --> verb, noun_phrase. proper_noun --> [mary]. proper_noun --> [john]. noun --> [zebra]. noun --> [biscuit]. verb --> [ate]. verb --> [kissed]. determiner --> [the].
159.302, Isaac Fung, IIST, 2005
13

Syntactic Analysis
The grammar rule John ate the biscuit

sentence --> noun_phase, verb_phrase. says that a sentence consists of a noun phrase and a verb phrase. Subject the thing that does something Predicate the thing that was done

159.302, Isaac Fung, IIST, 2005

14

Syntactic Analysis
A simple grammar:
sentence --> noun_phase, verb phrase. noun_phrase --> proper_noun. or noun_phrase --> determiner, noun. verb_phrase --> verb, noun_phrase.

Syntactic Analysis
John ate the biscuit.
np vp

v det

np n

and Incorrect sentences such as biscuit lion kissed will be excluded by the grammar. However, some odd sentences are still allowed such as The biscuit kissed John.
159.302, Isaac Fung, IIST, 2005

proper_noun --> [mary]. proper_noun --> [john]. noun --> [zebra]. noun --> [biscuit]. verb --> [ate]. verb --> [kissed]. determiner --> [the].
159.302, Isaac Fung, IIST, 2005

like dictionary entries.

15

16

Syntactic Analysis
A parse trees illustrates the syntactic structure of the sentence.
sentence noun_phrase proper_noun verb verb_phrase noun_phrase determiner noun

Syntactic Analysis
The grammar given above is very limited. It either 1. fails to handle complex sentences; or 2. recognize some sentences that are ungrammatical such as
Subject verb agreement

Mary eat the lion. Mary eats the ferocious lion.


No mentioning of adjectives

John

ate

the

lion

More comprehensive grammar is needed for non-trival applications.


17

159.302, Isaac Fung, IIST, 2005

159.302, Isaac Fung, IIST, 2005

18

Semantic Analysis
The stages of semantic and pragmatic analysis are concerned with getting the meaning of a sentence. Semantics a partial representation of the meaning is obtained based on the possible syntactic structure(s) of the sentence, and on the meanings of the words. Pragmatics the meaning is elaborated based on contextual and world knowledge.

Semantic Analysis
Compositional Semantics - the meaning of the whole sentence can be put together from the meaning of the parts of the sentence. The division of the sentence into meaningful parts was done by syntactic analysis. In general the meaning of a sentence may be represented using any of the knowledge representation schemes.

159.302, Isaac Fung, IIST, 2005

19

159.302, Isaac Fung, IIST, 2005

20

Semantic Analysis
Using predicate logic, for example, one can represent sentences like John likes Mary The man likes Mary A man likes Mary likes(john,mary) man(m1)likes(m1,mary) X(man(X)likes(X,mary))

Semantic Analysis
Using semantic net, one can represent sentence Tarzan kissed Jane as
person: tarzan person: jane

agent

kiss

object

A tall bearded man likes Mary X(man(X)tall(X)bearded(X)likes(X,mary)

past

tense

instrument

lips

159.302, Isaac Fung, IIST, 2005

21

159.302, Isaac Fung, IIST, 2005

22

Pragmatics
John likes Mary Speech recognition // sound Syntactic analysis // structure Semantic analysis // meaning likes(john,mary) Context of the utterance where it was said, by whom and why, and what was said before.
159.302, Isaac Fung, IIST, 2005
23

Pragmatics Language as Action


Language plays role in both communication and action. Some examples: 1. Where is the coffee? 2. Can you close the window? 3. Do you have the time? 4. When will you be home? 5. Youre late Language is used here to achieve something.
159.302, Isaac Fung, IIST, 2005
24

Pragmatics Language as Action


Speech act the actions that can be achieved through language. Example speech acts: informing, requesting & promising. S Speaker; H - Hearer. 1. 2. 3. 4. 5. S wants H to inform him where the coffee is. S wants H to shut the window. S wants H to tell him the time. S wants H to tell him when she will be home. S wants H to know that she is annoyed that he is late.

Pragmatics Handling Pronouns


Handling pronouns such as he, she and it is not always straight forward. Peter kisses Mary. He loves her loves(peter, mary). He refers to male entity and she refers to female entity.
159.302, Isaac Fung, IIST, 2005

159.302, Isaac Fung, IIST, 2005

25

26

Pragmatics Handling Pronouns


John buys a new telescope. He sees Mary in the distance. He gets out his telescope. He looks at her through it. her refers to Mary who was not mentioned at all in the previous sentence. Johns telescope was referred to as a new telescope, his telescope and it.

Pragmatics Handling Pronouns


John saw a blue Nissan Micra and a red Ford Fiesta in the garage. He decided to buy the blue car. the blue care refers to the Nissan Micra. When is the next flight to Sydney? Does it have any seat left? it refers to a particular flight to Sydney, not Sydney itself.

159.302, Isaac Fung, IIST, 2005

27

159.302, Isaac Fung, IIST, 2005

28

Pragmatics Ambiguity in Language


Most utterances have more than one possible interpretation. Ambiguity in Speech Recognition. Homophones sound the same such as bear and bare. Syntactic ambiguity. There are two problems: 1. A word may have more than one possible syntactic category, e.g. bat can both be a noun or a verb. 2. A sentence may have more than one structure such as John saw Mary on the hill with a telescope.
159.302, Isaac Fung, IIST, 2005

Pragmatics Ambiguity in Language


Semantic ambiguity. Many words (even with the same syntactic category) may have more than one meaning. Bank, for example, can be a river bank or a financial institution. Pragmatic ambiguity. It is sometimes unclear which object a pronoun refers to (referential ambiguity). The utternance Do you know what time it is? may be a criticism or a genuine question.

29

159.302, Isaac Fung, IIST, 2005

30

Pragmatics Ambiguity in Language


Pragmatic ambiguity. (contd) He read the book He red the book Fruit flies like a banana
// General knowledge says that fruit tends not to fly; rejected.

Natural Language Generation


Natural language communication = Understanding + Responding An idea on what to communicate a sequence of words of expression. An utterance from a phone-based database query system on flights from Auckland to Sydney: There are two flights that might suit you. The first is with AirNZ, costs $180, and leaves at 11am. The second one is with Quantas, costs $175, and leaves at 1pm. There are other flights available, but they are all more expensive.
31

speech recognisable ungrammatical; rejected.

Richard went to the bank to ask about a mortgage


// refers to a financial institute, not river bank.
159.302, Isaac Fung, IIST, 2005

159.302, Isaac Fung, IIST, 2005

32

Natural Language Generation


First stage of NL generation is deciding on what to say. Text planning start with a goal and find a sequence of utterances that will achieve the goal. Second stage how to say it, i.e. the actual sequence of words to express the material.
cost(flight1,180)leavetime(flight1,1100)airline(flight,anz).

Natural Language Generation


Each sentence must be produced from splitted information. The sentence should be grammatical, use appropriate pronouns, and understandable words. Template-base system such as: There is a flight with X which costs Y and leaves at Z Template systems work like mail-merge systems. More flexibility in NL generation requires more complex methods.

The first is with Air New Zealand, costs $180, and leaves at 11am.

159.302, Isaac Fung, IIST, 2005

33

159.302, Isaac Fung, IIST, 2005

34

Readings
Textbook: Section 13.0 13.3 & 13.5 Supplementary notes.

159.302, Isaac Fung, IIST, 2005

35

Vous aimerez peut-être aussi