1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding...

23
1 Understanding 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. Winston’s AI textbook, Addison Wesley, 1993.
  • date post

    18-Dec-2015
  • Category

    Documents

  • view

    219
  • download

    0

Transcript of 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding...

Page 1: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

1

Understanding Natural Language13 13.0 Role of Knowledge in

LanguageUnderstanding

13.1 Deconstructing Language: A SymbolicAnalysis

13.2 Syntax

13.3 Syntax and Knowledgewith ATN parsers

13.4 Stochastic Tools forLanguage Analysis

13.5 Natural LanguageApplications

13.6 Epilogue and References

13.7 Exercises

Additional sources used in preparing the slides:Patrick H. Winston’s AI textbook, Addison Wesley, 1993.

Page 2: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

2

Chapter Objective

• Give a brief introduction to the techniques used in understanding natural language

Page 3: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

3

An early natural language understanding system: SHRDLU (Winograd, 1972)

Page 4: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

4

It 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?

Page 5: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

5

Stages 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.

Page 6: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

6

The result of parsing would be:

Page 7: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

7

The result of semantic interpretation

Page 8: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

8

The result of contextual/world knowledge interpretation

Page 9: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

9

Can also represent questions:Who loves Jane?

Page 10: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

10

Parsing 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

These are the nonterminalsThese are the terminals

These are the symbols of the grammar

Page 11: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

11

Parsing

• 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.

Page 12: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

12

The parse tree

Page 13: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

13

Transition networks

Page 14: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

14

The 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

Page 15: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

15

Parsing the sentence “Dog bites.”

Page 16: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

16

Notes

• 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.”

Page 17: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

17

The 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.

Page 18: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

18

The algorithm (cont’d)

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.

Page 19: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

19

The algorithm (cont’d)

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.

Page 20: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

20

Grammars might be ambiguous

Page 21: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

21

A different parse tree for the same sentence

Page 22: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

22

The network may contain “loops”

si si si

article noun

adjective

Traverse “adjective” twice to parse the noun phrase:

“the cute little puppy”

Noun-phrase:

Page 23: 1 Understanding Natural Language 13 13.0Role of Knowledge in Language Understanding 13.1Deconstructing Language: A Symbolic Analysis 13.2Syntax 13.3Syntax.

23

Comments 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 “doesn’t 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”