Natural Language Processing Eliza? - Computer Science

scarfpocketAI and Robotics

Oct 24, 2013 (4 years and 6 months ago)


NLP involves reasoning with themeaning of language, not the earliest and perhaps the best known AI program.. although
just manipulating surface text. it’s not really an AI program
so, for instance, Eliza is NOT an NLP system done in the ’60 at MIT to replicate a conversation between a
psychoanalist and a patient
S: Hi. What brings you to see me?
U: I’m feeling a bit depressed.
it works simply on pattern matching:
S: Are you depressed often?
user says: IfeelX→ Eliza saysI’msorryyoufeelX
this is obtained by simple string searching and replacing, but
user says: xxxmotheryyy→ Eliza saysTellmemore
has no sophisticated reasoning:
U: I’m feeling a bit XyZZYhjla222 today.
S: Why do you say you are feeling a bit XyZZYhjla222 today?
there is basically no knowledge about the language
but natural language is much more complex, as it involves
reasoning about meaning
COMP106-lecture9–p.1/18 COMP106-lecture9–p.2/18
Reasoningaboutmeaning NLUnderstanding
by reasoning about the meaning of the text, the applications to understand language it is necessary to determine how words
can be made much moreflexible: are grouped together in meaningful ways.
questions can be expressed in unusual ways (“France has
we need:
what city as its capital?”)
1. rules concerning how the language is organized:
cooperative answers can be given for implicit questions
lexicon: checking that the words in the sentence do
(“the nextflight is completely booked, but there’s still
room on the 8:04flight”)
syntax: checking that the sequence of words has a
conciseness (“When is the next train to London?”, “4.40”, "valid" structure and extracting that structure to
“which platform is it?”) determine the meaning
semantics: obtaining a representation of what the
a problem of two halves: understanding and generation
sentence means:
John gave the book to Mary. give-action:
agent: john
The book was given to Mary
object: book
by John.
receiver: mary
COMP106-lecture9–p.3/18 COMP106-lecture9–p.4/18
but we also need: You may have a simple grammar (syntax) like:
2. an algorithm using these rule to parse a sentence
S = NP(number) + VP (number) a sentence is formed by a nominal phrase and
it is a bit like parsing computer languages
a verbal phrase, with accordance on number
that is, determining that
(both plural or both singular)
if (rs == null) { columns = 5; } else { columns =
NP(number) = N(number) a nominal phrase can be either a name...
NP(number) = P(number) ... or a pronoun
is a Java sentence, while
VP(number) = TV(number) + N(-) a verbal phrase can be either a transitive verb,
if (rs == null) otherwise 5; with an object, which is a name (no matter
whether the object is plural or singular)..
is not
VP(number) = IV(number) or an intransitive verb
but more complex, mainly because natural language is
ambiguous and not context free
programming language sentences have always the same
meaning no matter where they are in the code
COMP106-lecture9–p.5/18 COMP106-lecture9–p.6/18a parsing algorithm will "recognise" sentences in the given
grammar and lexicon:
You need to add to your grammar a lexicon such as:
lecturerslovecats is a correct sentence, because:
love is a TV(plural)
N(singular) = {Floriana, The cat} N(plural) = {lecturers, cats}
cats is a N(plural)
P(singular) = {she} P(plural) = {they}
thereforelovecats is a VP(plural) as its a TV(plural) +
TV(plural) = {love,hate} TV(singular) = {loves,hates}
IV(plural) = {jump,travel} IV(singular) = {jumps,travels}
lecturers is a N(plural)
thereforelecturerslovecats is a S as it’s a N(plural) +
whilelecturerlovecats is not correct because it would be
parsed as a N(singular) + VP (plural) which is not a S
then you need a way to transform sentences into facts that can
be managed automatically, such as:
lecturerslovecats→ love(lecturers,cats)
COMP106-lecture9–p.7/18 COMP106-lecture9–p.8/18
Butyouneedmore! NaturalLanguageAmbiguity
apart fromsyntax (rules about the structure of language)
andsemantics (rules about the meaning of words and
you needpragmatics, that is rules about how language is used
The man hits the boy with the stick
in context
Canyoupassmethesalt? is not meant to be a yes/no
So for instance:
Ionlyeatsfruit is syntactically wrong
Noun Attribute
Ionlyeatmyfreedom is semantically wrong
IonlyeatinItaly is pragmatically wrong (as I leave in
The man hits the boy with the stick
In most of the cases,context helps disambiguating.
COMP106-lecture9–p.9/18 COMP106-lecture9–p.10/18
Sourcesofambiguity Sourcesofambiguity
structural ambiguity referential ambiguity
the one in the example before MarytoldJaneshelikedherhat
Youcanhavepeasandbeansorcarrots ... whose hat does Mary like?
I’mtryingtohelpoutmyfriends. It’stheleastIcando
word sense ambiguity
... what doesit refer to?
fuzzy concepts
Londonishugeandexpensive. Edinburghtoo.
... how many books is several books? More than 5? More
than 10? More than 100?
what about: thereareseveralgirlsinmyson’sclass
interpretation depends on context
COMP106-lecture9–p.11/18 COMP106-lecture9–p.12/18Interpretingforacting Application?AdatabaseNLquerysystem
Courses Lectures
Course Semester CourseDep. Course Day Time Theatre
U: howmuchisatickettoLondon?
COMP507 1 Comp. Science COMP352 Monday 11am RB6
S: 40pounds COMP352 2 Comp. Science COMP352 Tuesday 11am RB8
COMP552 2 Comp. Science COMP552 Thursday 10am C
U: whenisthenext flight? COMP102 2 Comp. Science COMP102 Monday 12pm B
MATH103 1 Mathematics MATH103 Tuesday 15pm B
S: thenext flightiscompletelybooked,butthere’sstillroom
Lecturers TeachingDuties
onthe8:04 flight.
StaffNo 1stName 2ndName Office Department StaffNo Course
5235234 Floriana Grasso 2.08 Comp. Science 5235234 COMP507
the system should interpret the second question as:
5235234 COMP352
9759212 Paul Dunne 6.03 Comp. Science
5235234 COMP552
you need totake the nextflight to London 4626737 Dean Jones 2.06 Comp. Science
5235234 COMP102
4626737 COMP507
you haven’t booked yet, so you need both information
9759212 COMP102
Department Address
about the timetable and to buy your ticket 4626737 MATH103
Comp. Science Peach Street
your main goal is to get to London with thefirst available English Chatham Street
flight, rather than to take the particularflight that happens
to be the nextflight to London
suppose you have the above database of lecturers, departments they
this can be done only with a user model, and by reasoning on
work for, and their teaching duties
the domain
COMP106-lecture9–p.13/18 COMP106-lecture9–p.14/18
Queries ARealWWWExample
WHERE 1stName = ‘‘Floriana’’;
WHERE LECTURERS.1stName = ‘‘Floriana’’
COMP106-lecture9–p.15/18 COMP106-lecture9–p.16/18
The system has four components: NL understanding has gone a long way, but lots of research is
still needed
1. Question Processing Engine: matches the input query to a
“question template” involving both semantics and syntax an example: a chat withJabberwock, last year winner of the
Loebner prize
so you can ask any of the following:
wherecanIfindcheap flightstoLondon? a competition where entrants are challenged to create a
Ineedacheap flighttoLondon conversational system that can foul you to think it’s a
cheap flightsLondon human (
Jabb: ...Greetings! Jabberwock is at the keyboard. Please
and it will even correct your spelling mistakes (Loondon
just sit back, relax and tell me your desires
→ London)
user: ...I’dliketotalkabouttheweatherinSpain.
Jabb: ...Who or what is obstructing you?
2. Answer Processing Engine
user: ...DidIsaysomethingwasobstructingme?
3. Knowledge Base, including a semantic and a syntactic network
Jabb: ...How do people usually respond to that?
user ...Canwestartagainplease. Yourenotmakinganysense.
4. MetaSearch (using 5 search engines)
Jabb: ...I started without you
COMP106-lecture9–p.17/18 COMP106-lecture9–p.18/18