Title: Understanding Natural Language
1Understanding Natural Language
13
13.0 Role of Knowledge in Language Understanding
13.1 Deconstructing Language A
Symbolic Analysis 13.2 Syntax 13.3 Syntax and
Knowledge with ATN parsers
13.4 Stochastic Tools for Language
Analysis 13.5 Natural Language Applications 13.6
Epilogue and References 13.7 Exercises
Additional sources used in preparing the
slides Patrick H. Winstons AI textbook, Addison
Wesley, 1993.
2Chapter Objective
- Give a brief introduction to the techniques used
in understanding natural language
3An early natural language understanding system
SHRDLU (Winograd, 1972)
4It could converse about a blocks world
- What is sitting on the red block?
- What shape is the blue block on the table?
- Place the green cylinder on the red brick.
- What color is the block on the red block? Shape?
5Stages of language analysis
- 1. Parsing analyze the syntactic structure of a
sentence - 2. Semantic interpretation analyze the meaning
of a sentence - 3. Contextual/world knowledge representation
Analyze the expanded meaning of a sentence - For instance, consider the sentence
- Tarzan kissed Jane.
6The result of parsing would be
7The result of semantic interpretation
8The result of contextual/world knowledge
interpretation
9Can also represent questionsWho loves Jane?
10Parsing using Context-Free Grammars
- A bunch of rewrite rules
- 1. sentence ? noun_phrase verb_phrase 2.
noun_phrase ? noun 3. noun_phrase ? article
noun 4. verb_phrase ? verb 5. verb_phrase ?
verb noun_phrase 6. article ? a 7. article ?
the 8. noun ? man 9. noun ? dog10. verb ?
likes11. verb ? bites
11Parsing
- It is the search for a legal derivation of the
sentence in hand starting with the nonterminal
sentence. - Sentence is the starting nonterminal.
- The result is a parse tree. A parse tree is a
structure where each node is a symbol from the
grammar. The root node is the starting
nonterminal, the intermediate nodes are
nonterminals, the leaf nodes are terminals.
12The parse tree
13Transition networks
14The main idea
- Represent the rules in the grammar in the form
of transition networks - Then parsing a sentence is a matter of
traversing the network - If the label of the transition (arc) is a
terminal, it must match the input, and the input
pointer advances - If the label of the transition (arc) is a
nonterminal, the corresponding transition network
is invoked recursively - If several alternative paths are possible, each
must be tried (backtracking)---very much like
nondeterministic finite automaton---until a
successful path is found
15Parsing the sentence Dog bites.
16Notes
- A successful parse is the complete traversal
of the net for the starting nonterminal from
sinitial to sfinal . - If no path works, the parse fails. It is not a
valid sentence. - The following algorithm would be called using
parse(sinitial ) - It would start with the net for sentence.
17The algorithm
- Function parse(grammar_symbol)
- begin save pointer to current location in input
stream case grammar_symbol is a terminal
if grammar_symbol matches the next word in
the input stream then return(success)
else begin reset input stream
return(failure) end
grammar_symbol is a nonterminal begin
retrieve the transition network labeled by
grammar_symbol state start state of
network if transition(state) returns
success then return(success)
else begin reset input stream
return (failure) end endend.
18The algorithm (contd)
- Function parse(grammar_symbol)
- begin save pointer to current location in input
stream case grammar_symbol is a terminal
if grammar_symbol matches the next word in
the input stream then return(success)
else begin reset input stream
return(failure) end
grammar_symbol is a nonterminal begin
retrieve the transition network labeled by
grammar_symbol state start state of
network if transition(state) returns
success then return(success)
else begin reset input stream
return (failure) end endend.
19The algorithm (contd)
- Function transition(current_state)begin case
current_state is a final state return
(success) current_state is not a final
state while there are unexamined
transitions out of current_state do
begin grammar_symbol the label on
the next unexamined transition if
parse(grammar_symbol) returns (success)
then begin next_state state at
the end of the transition if
transition(next_state) returns (success)
then return(success) end
end return(failure) endend.
20Grammars might be ambiguous
21A different parse tree for the same sentence
22The network may contain loops
adjective
Noun-phrase
noun
article
si
si
si
Traverse adjective twice to parse the noun
phrase the cute little puppy
23Comments of transition networks
- They capture the regularity in the sentence
structure - They exploit the fact that only a small
vocabulary is needed in a specific domain - If a sentence doesnt make sense, it might be
caught by the domain information. For instance,
the answer to both of the following questions is
there is none - Pick up the blue cylinder
- Pick up the red blue cylinder