Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE573 Autumn 1997 1 03/04/98 Natural Language Processing Administrative –Example code available in code\ps4\sample directory Last time –using features.

Similar presentations


Presentation on theme: "CSE573 Autumn 1997 1 03/04/98 Natural Language Processing Administrative –Example code available in code\ps4\sample directory Last time –using features."— Presentation transcript:

1 CSE573 Autumn 1997 1 03/04/98 Natural Language Processing Administrative –Example code available in code\ps4\sample directory Last time –using features to enforce context-sensitive syntactic rules make subsequent semantic analysis easier –building the grammar sentences objects This time –a little more about how the parser works –interpreting parser output –finish the grammar –semantic interpretation

2 CSE573 Autumn 1997 2 Basic Parser Operation ((S (TYPE (? X))) -> (VP (TYPE (? X))) (OBJ)) ((VP (TYPE LIFT)) -> (VERB (ROOT PICK-UP))) (GRAB (VERB (ROOT PICK-UP))) (LIFT (VERB (ROOT PICK-UP))) (PICK-UP (VERB (ROOT PICK-UP))) Grammar Lexicon (PARSE-SENTENCE ’(LIFT THE GREEN ROCK) :START-SYMBOL ’S) Invocation

3 CSE573 Autumn 1997 3 Parser Trace (failed sentence) (parse-sentence '(drop the sphere at location 3) :verbose t) ********** (Seen: (S (TYPE LIFT)) Seeking: ((VP (TYPE LIFT)) (OBJ))) Input: (DROP THE SPHERE AT LOCATION 3) ********** (Seen: (VP (TYPE LIFT)) Seeking: ((VERB (ROOT LIFT)))) (Seen: (S (TYPE LIFT)) Seeking: ((VP (TYPE LIFT)) (OBJ))) Input: (DROP THE SPHERE AT LOCATION 3) ********** (Seen: (VP (TYPE LIFT)) Seeking: ((VERB-H (ROOT PICK)) (PREP-H (ROOT UP)))) (Seen: (S (TYPE LIFT)) Seeking: ((VP (TYPE LIFT)) (OBJ))) Input: (DROP THE SPHERE AT LOCATION 3) ********** (Seen: (S (TYPE DROP)) Seeking: ((VP (TYPE DROP)) (OBJ))) Input: (DROP THE SPHERE AT LOCATION 3) ********** (Seen: (VP (TYPE DROP)) Seeking: ((VERB (ROOT DROP)))) (Seen: (S (TYPE DROP)) Seeking: ((VP (TYPE DROP)) (OBJ))) Input: (DROP THE SPHERE AT LOCATION 3) ********** (Seen: (VP (TYPE DROP) (1 (VERB (ROOT DROP)))) Seeking: NIL) (Seen: (S (TYPE DROP)) Seeking: ((VP (TYPE DROP)) (OBJ))) Input: (THE SPHERE AT LOCATION 3) **********

4 (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (THE SPHERE AT LOCATION 3) ********** (Seen: (OBJ (REF (? CNT156)) (COLOR (? COL157)) (SHAPE (? SHP158))) Seeking: ((ART (REF (? CNT156)) (VOWEL (? V159))) (ADJ (ROOT (? COL157)) (VOWEL (? V159))) (NOUN (ROOT (? SHP158))) (OPT- LOCATION (TYPE (? LOC160))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (THE SPHERE AT LOCATION 3) ********** (Seen: (OBJ (REF DEFINITE) (COLOR (? COL157)) (SHAPE (? SHP158)) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL)))) Seeking: ((ADJ (ROOT (? COL157)) (VOWEL NIL)) (NOUN (ROOT (? SHP158))) (OPT- LOCATION (TYPE (? LOC160))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (SPHERE AT LOCATION 3) ********** (Seen: (OBJ (REF DEFINITE) (COLOR (? COL157)) (SHAPE (? SHP158)) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL T)))) Seeking: ((ADJ (ROOT (? COL157)) (VOWEL T)) (NOUN (ROOT (? SHP158))) (OPT-LOCATION (TYPE (? LOC160))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (SPHERE AT LOCATION 3) ********** (Seen: (OBJ (REF (? CNT151)) (COLOR NIL) (SHAPE (? SHP152))) Seeking: ((ART (REF (? CNT151)) (VOWEL (? V153))) (NOUN (ROOT (? SHP152)) (VOWEL (? V153))) (OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (THE SPHERE AT LOCATION 3) ********** (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE (? SHP152)) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL)))) Seeking: ((NOUN (ROOT (? SHP152)) (VOWEL NIL)) (OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (SPHERE AT LOCATION 3) **********

5 (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) ********** (Seen: (OPT-LOCATION (TYPE ABSOLUTE)) Seeking: ((PREP (ROOT AT)) (POSITION (INDEX (? I171))))) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) ********** (Seen: (OPT-LOCATION (TYPE ABSOLUTE) (1 (PREP (ROOT AT)))) Seeking: ((POSITION (INDEX (? I171))))) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (LOCATION 3) ********** (Seen: (POSITION (INDEX (? X174))) Seeking: ((NOUN (ROOT POSITION)) (NUMBER (ROOT (? X174))))) (Seen: (OPT-LOCATION (TYPE ABSOLUTE) (1 (PREP (ROOT AT)))) Seeking: ((POSITION (INDEX (? I171))))) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (LOCATION 3) ********** (Seen: (OPT-LOCATION (TYPE RELATIVE)) Seeking: ((PROXIMITY))) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) **********

6 (Seen: (PROXIMITY (TYPE NEXT)) Seeking: ((PREP-H (ROOT NEXT)) (PREP-H (ROOT TO)) (OBJ))) (Seen: (OPT-LOCATION (TYPE RELATIVE)) Seeking: ((PROXIMITY))) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) ********** (Seen: (PROXIMITY (TYPE (? DIR178))) Seeking: ((PREP-H (ROOT TO)) (ART (ROOT THE)) (DIRECTION (TYPE (? DIR178))) (PREP-H (ROOT OF)) (OBJ))) (Seen: (OPT-LOCATION (TYPE RELATIVE)) Seeking: ((PROXIMITY))) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) ********** (Seen: (PROXIMITY (TYPE ABOVE)) Seeking: ((PREP (ROOT ABOVE)) (OBJ))) (Seen: (OPT-LOCATION (TYPE RELATIVE)) Seeking: ((PROXIMITY))) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) ********** (Seen: (PROXIMITY (TYPE TO)) Seeking: ((PREP-H (ROOT TO)) (OBJ))) (Seen: (OPT-LOCATION (TYPE RELATIVE)) Seeking: ((PROXIMITY))) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) ********** (Seen: (OPT-LOCATION (TYPE EMPTY)) Seeking: NIL) (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL)))) Seeking: ((OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) **********

7 (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL))) (3 (OPT-LOCATION (TYPE EMPTY)))) Seeking: NIL) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (AT LOCATION 3) ********** (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP))))) (2 (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL NIL))) (2 (NOUN (ROOT SPHERE) (VOWEL NIL))) (3 (OPT-LOCATION (TYPE EMPTY)))))) Seeking: NIL) Input: (AT LOCATION 3) ********** (Seen: (OBJ (REF DEFINITE) (COLOR NIL) (SHAPE (? SHP152)) (1 (ART (REF DEFINITE) (ROOT THE) (VOWEL T)))) Seeking: ((NOUN (ROOT (? SHP152)) (VOWEL T)) (OPT-LOCATION (TYPE (? LOC154))))) (Seen: (S (TYPE DROP) (1 (VP (TYPE DROP) (1 (VERB (ROOT DROP)))))) Seeking: ((OBJ))) Input: (SPHERE AT LOCATION 3) ********** (Seen: (VP (TYPE DROP)) Seeking: ((VERB-H (ROOT PUT)) (PREP-H (ROOT DOWN)))) (Seen: (S (TYPE DROP)) Seeking: ((VP (TYPE DROP)) (OBJ))) Input: (DROP THE SPHERE AT LOCATION 3) ********** (Seen: (S (TYPE MOVE)) Seeking: ((VP (TYPE MOVE)) (DESTINATION))) Input: (DROP THE SPHERE AT LOCATION 3) ********** (Seen: (VP (TYPE MOVE)) Seeking: ((VERB (ROOT MOVE)))) (Seen: (S (TYPE MOVE)) Seeking: ((VP (TYPE MOVE)) (DESTINATION))) Input: (DROP THE SPHERE AT LOCATION 3) ********** NIL

8 CSE573 Autumn 1997 8 The Grammar So Far (S (TYPE LIFT)) -> (VP (TYPE LIFT)) (OBJ...) (S (TYPE DROP)) -> (VP (TYPE DROP)) (OBJ...) (S (TYPE MOVE)) -> (VP (TYPE MOVE)) (DESTINATION...) (OBJ (SHAPE (? S)) (COLOR (? C)) (REF (? REF)))) -> (DET (REF (? REF)) (VOWEL (? V))) (COLOR (ROOT (? C)) (VOWEL (? V))) (SHAPE (ROOT (? S))) (LOCATION (TYPE (? LOC-TYPE))) (OBJ (SHAPE (? S)) (COLOR NIL) (REF (? REF)))) -> (DET (REF (? REF)) (VOWEL (? V))) (SHAPE (ROOT (? S))) (LOCATION (TYPE (? LOC-TYPE)))

9 CSE573 Autumn 1997 9 A Quick Cut at LOCATIONs and DESTINATIONs

10 CSE573 Autumn 1997 10 “Semantic Interpretation” ( interpret.lsp ) The basic idea: extract the command name and object attributes from the parse tree to facilitate precondition verification and action execution (defstruct command action object destination) (defstruct location (abs-position NIL) (rel-direction NIL) (rel-object NIL)) (defstruct object ref color shape place) Parse the SENTENCE subtree Parse the LOCATION subtree Parse the OBJECT subtree

11 CSE573 Autumn 1997 11 Extraction Primitives (defun extract-feature (tree feature) (second (assoc feature (cdr tree)))) (defun extract-subtree (tree nonterminal) (let ((subtrees (mapcar 'second (remove-if-not #'(lambda (comp) (numberp (first comp))) (cdr tree))))) (find nonterminal subtrees :key 'car))) (S (TYPE LIFT) (1 (VP (TYPE LIFT) (1 (VERB-H (ROOT PICK))) (2 (PREP-H (ROOT UP))))) (2 (OBJ (REF DEFINITE) (COLOR GREEN) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (NUM S))) (2 (OPT-ADJ (ROOT GREEN) (1 (ADJ (ROOT GREEN))))) (3 (NOUN (ROOT SPHERE) (NUM S))) (4 (OPT-LOCATION (TYPE ABSOLUTE) (1 (PREP (ROOT AT))) (2 (POSITION (INDEX 3) (1 (NOUN (ROOT POSITION))) (2 (NUMBER (ROOT 3))))))))))

12 CSE573 Autumn 1997 12 Constructing a command structure (S (TYPE LIFT) (1 (VP (TYPE LIFT) (1 (VERB-H (ROOT PICK))) (2 (PREP-H (ROOT UP))))) (2 (OBJ (REF DEFINITE) (COLOR GREEN) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (NUM S))) (2 (OPT-ADJ (ROOT GREEN) (1 (ADJ (ROOT GREEN))))) (3 (NOUN (ROOT SPHERE) (NUM S))) (4 (OPT-LOCATION (TYPE ABSOLUTE) (1 (PREP (ROOT AT))) (2 (POSITION (INDEX 3) (1 (NOUN (ROOT POSITION))) (2 (NUMBER (ROOT 3)))))))))) (defstruct command action object destination) NIL

13 CSE573 Autumn 1997 13 Constructing an object structure (OBJ (REF DEFINITE) (COLOR GREEN) (SHAPE SPHERE) (1 (ART (REF DEFINITE) (ROOT THE) (NUM S))) (2 (OPT-ADJ (ROOT GREEN) (1 (ADJ (ROOT GREEN))))) (3 (NOUN (ROOT SPHERE) (NUM S))) (4 (OPT-LOCATION (TYPE ABSOLUTE) (1 (PREP (ROOT AT))) (2 (POSITION (INDEX 3) (1 (NOUN (ROOT POSITION))) (2 (NUMBER (ROOT 3)))))))))) (defstruct object ref color shape place)

14 CSE573 Autumn 1997 14 Constructing a location structure (OPT-LOCATION (TYPE ABSOLUTE) (1 (PREP (ROOT AT))) (2 (POSITION (INDEX 3) (1 (NOUN (ROOT POSITION))) (2 (NUMBER (ROOT 3)))))))))) (defstruct location (abs-position NIL) (rel-direction NIL) (rel-object NIL))


Download ppt "CSE573 Autumn 1997 1 03/04/98 Natural Language Processing Administrative –Example code available in code\ps4\sample directory Last time –using features."

Similar presentations


Ads by Google