Download presentation
Presentation is loading. Please wait.
Published byGriffin Gray Modified over 9 years ago
1
Natural Language Processing Chapter 4
2
323-670 Artificial IntelligenceChapter 42 NLP Language translation / multilingual translation Language understanding –Figure 14.5 p. 365 Interaction among component –Figure 14.6 p. 366 A speech Waveform
3
323-670 Artificial IntelligenceChapter 43 Figure14.5: More Interaction among Components S NP VJohn VP NPPP N boy sawDET the PP with a telescope in the park John saw the boy in the park with a telescope.
4
323-670 Artificial IntelligenceChapter 44 Figure14.5: More Interaction among Components S NP VJohn VP NP PP N boy sawDET the PP with a dogin the park John saw the boy in the park with a dog.
5
323-670 Artificial IntelligenceChapter 45 Figure14.5: More Interaction among Components John saw the boy in the park with a statue. S NP V John VP NP N boy sawDET the PP with a statue in the park
6
323-670 Artificial IntelligenceChapter 46 Figure14.6: Local Ambiguity in a Speech Problem The cat scares all the birds away. k a t s k a r s A cat’s caresare few.
7
323-670 Artificial IntelligenceChapter 47 The Problem: English sentences are incomplete descriptions of the information that they are intended to convey: Some dogs are outside. I called Lynda to ask her to the movies. She said she’ d love to go. Some dogs are on the lawn.She was home when I called. Three dogs are on the lawn.She answered the phone. Rover, Tripp, and Spot are I actually asked her. on the lawn. The Good Side: Language allows speakers to be as vague or precise as they like. It also allows speakers to leave out things they believe their hearers already know.
8
323-670 Artificial IntelligenceChapter 48 The Problem: The same expression means different things in different contexts: Where’s the water? (in a chemistry lab, it must be pure) Where’s the water? (when you are thirsty, it must be potable) Where’s the water? (dealing with a leaky roof, it can be filthy) The Good Side: Language lets us communicate about an infinite world using a finite (and thus earnable) number of symbols.
9
323-670 Artificial IntelligenceChapter 49 The Problem: No natural language program can be complete because new words, expressions, and meanings can be generated Quite freely: I’ll fax it to you. The Good Side: Language can evolve as the experiences that we want to communicate about evolve.
10
323-670 Artificial IntelligenceChapter 410 The problem: There are lots of ways to say the same thing: Mary was born on October 11. Mary’s birthday is October 11. The Good Side: When you know a lot, facts imply each other. Language is intended to be used by agents who know a lot. Figure 15.1: Features of Language That Mark It Both Difficult and Useful
11
323-670 Artificial IntelligenceChapter 411 NLP Problems Figure 15.1 P. 378 English sentences are incomplete descriptions of the information that are intended to convey. The same expression means different things in different context. No natural language program can be complete because of new words, expression, and meaning can be generated quite freely. There are lots of ways to say the same thing.
12
323-670 Artificial IntelligenceChapter 412 NLP Problems 1) Processing written text –using lexical, syntactic, and semantic knowledge of the language –require the real world information 2) Processing spoken language –using all information needed above plus additional knowledge about phonology –handle ambiguities in speech
13
323-670 Artificial IntelligenceChapter 413 Step in NLP 1) Morphological Analysis 2) Syntactic Analysis 3) Semantic Analysis 4) Discourse Integration 5) Pragmatic Analysis – boundaries between these five phrases are often fuzzy.
14
323-670 Artificial IntelligenceChapter 414 1. Morphological Analysis Individual words are analyzed into components Nonword tokens such as punctuation are separated from the words I want to print Bill ’ s.int file. proper noun possessive suffix file extension
15
323-670 Artificial IntelligenceChapter 415 2. Syntactic Analysis linear sequence of words are transformed into structures show how words relate to each other English syntactic analyzer If do not pass the syntactic analyzer reject e.g. (Boy the go to store the)
16
323-670 Artificial IntelligenceChapter 416 Example of syntactic analysis Figure 15.2 p. 382 RM2, RM5, RM5 A knowledge base Fragment Figure 15.3 p. 383 User073, F1, Printing, File_Structure, Waiting Mental Event/ Physical Event Animate/Event Partial meaning for a sentence Figure 15.4 p. 384 2. Syntactic Analysis
17
323-670 Artificial IntelligenceChapter 417 Syntax The dog bites the man.
18
323-670 Artificial IntelligenceChapter 418 Apply rule
19
323-670 Artificial IntelligenceChapter 419 Parse Tree The man bits the dog.
20
323-670 Artificial IntelligenceChapter 420 The dog likes a man. Parse Tree
21
323-670 Artificial IntelligenceChapter 421 Internal Representative
22
323-670 Artificial IntelligenceChapter 422 Syntactic Processing (2) Grammar declarative representation syntactic facts about the language Figure 15.6 p.387 Parser procedure compares the grammar against input sentences to produce parsed structure. –Figure 15.7 p.388 A parse tree for a sentence
23
323-670 Artificial IntelligenceChapter 423 Top-down Parsing –Begin with start symbol and apply the grammar rules forward until the symbols at the terminals of the tree correspond to the components of the sentence being parsed. Bottom-up Parsing –Begin with the sentence to be parsed and apply the grammar rules backward until a single tree whose terminals are the words of the sentence and whose top node is the start symbol has been produced. Syntactic Processing (2)
24
323-670 Artificial IntelligenceChapter 424 The man bits the dog. Transition Network
25
323-670 Artificial IntelligenceChapter 425 ATN : Augmented Transition Network similar to finite state machine Figure 15.8 p.392 An ATN network Figure 15.9 p.393 An ATN Grammar in List Form sentence “ The long file has printed. ” S NP Q1 AUX Q3 V Q4 (F) halt NP Det Q6 Adj Q6 N Q7 (F) (S DCL (NP (FILE (LONG) DEFINITE)) HAS (VP PRINTED)) p.394
26
323-670 Artificial IntelligenceChapter 426 Unification Grammar DAGs : Direct Acyclic Graph p.395 the graph corresponding to “ the ” and “ file ” are [CAT: DET[CAT: N [NP : [DET: the LEX:the]LEX : file HEAD: file NUMBER: SING] NUMBER: SING]]
27
323-670 Artificial IntelligenceChapter 427 3. Semantic Analysis the structures created by the syntactic analyzer are assign meanings mapping between the syntactic structure and objects in the task domain If no mapping reject (colorless green ideas sleep furiously) 1) It must map individual words into appropriate objects in the knowledge base or database. 2) It must create the correct structures to correspond to the meanings of the individual words combine with each other.
28
323-670 Artificial IntelligenceChapter 428 3. Semantic Processing Step 1. –Lexicon look up the individual words in a dictionary and extract their meaning. Step 2 –Lexicon disambiguity or Word sense disambiguity –words may have more than one meaning e.g. bank ( ธนาคาร หรือ ตลิ่ง ), diamond p.398 ( เพชร หรือ รูปเหลี่ยม ) –use semantic marker PHYSICAL OBJECT, ANIMATE OBJECT, ABSTRACT OBJECT e.g. I drop my diamond...
29
323-670 Artificial IntelligenceChapter 429 Semantic Processing (3) use semantic marker –PHYSICAL OBJECT –ANIMATE OBJECT –ABSTRACT OBJECT e.g. I drop my diamond... note that “ My lawn hates the cold ” is a correct semantic as well, although lawn can not act the verb hate..... but this sentence can be use in the good English sense.
30
323-670 Artificial IntelligenceChapter 430 Sentence Level Processing (3) 1) Semantic grammars 2) Case grammars 3) Conceptual parsing 4) Approximately compositional semantic interpretation
31
323-670 Artificial IntelligenceChapter 431 1) Semantic grammars - semantic action associate with the grammar rule - Figure 15.10 p. 401 e.g. “ I want to ” ACTION - Figure 15.11 p. 402 Parsing Result with semantic grammars Sentence Level Processing (3)
32
323-670 Artificial IntelligenceChapter 432 รูปแสดงผลการวิเคราะห์ทางวากยสัมพันธ์ ของประโยค “ I want to print Bill ’ s.init file. ”
33
323-670 Artificial IntelligenceChapter 433
34
323-670 Artificial IntelligenceChapter 434
35
323-670 Artificial IntelligenceChapter 435 ผลการวิเคราะห์ทางความหมายแสดง ดังรูป
36
323-670 Artificial IntelligenceChapter 436 ผลสุดท้ายที่จากการวิเคราะห์ทางปฏิบัติคือคำสั่งในยูนิกซ์ที่ ใช้สั่งยูนิกซ์พิมพ์ไฟล์ที่ต้องการ lpr /wsmith/stuff.init lpr /wsmith/stuff.init
37
323-670 Artificial IntelligenceChapter 437 2) Case grammars : passing process driven from the sentence ’ s main verb. - Figure 15.12 p. 404 Active and passive sentence : Susan printed a file. = The file was printed by Susan. - Figure 15.13 p. 404 Similar sentence : Mother baked for three hours. = The pie baked for three hours. - Word case p. 405 : (A) Agent, (I) Instrument, (F) Factitive, (L) Locatives, (S) Source, (G) Goal, (B) Beneficiary, (T) Time, (O) Object Sentence Level Processing (3)
38
323-670 Artificial IntelligenceChapter 438 2) Case grammars - Figure 15.14 p. 406 Some verb case frames : open [_ _ O (I) (A)] A : Instigator of the action D : Entity effect by the action : die [_ _ D] John die. : kill [_ _ D (I) (A)] Bill killed John. Bill killed John with a knife. : want [_ _A O] John wanted some ice cream. John wanted Marry to go to store. Sentence Level Processing (3)
39
323-670 Artificial IntelligenceChapter 439 3) Conceptual parsing strategy for finding both the structure and the meaning of the sentence in one step. use verb-ACT dictionary Figure 15.15 p. 407 e.g. “ want ” 1) stative (wanting something to happen) 2) transitive ATRANS (wanting an object) 3) intransitive PTRANS (wanting a person) Sentence Level Processing (3)
40
323-670 Artificial IntelligenceChapter 440 3) Conceptual parsing CD : Conceptual Dependency structure : passing process driven from the sentence ’ s main verb with more details in the lower level. Figure 15.16 p. 407 “ John wanted Mary to go to the store. ” (PTRANS) Sentence Level Processing (3)
41
323-670 Artificial IntelligenceChapter 441 4) Approximately compositional semantic interpretation - Semantic interpretation rules Figure 15.18 p. 411 - Combining Mapping Knowledge Figure 15.19 p. 412 wanting : agent : (animate), object : (state or event) Sentence Level Processing (3)
42
323-670 Artificial IntelligenceChapter 442 4. Discourse Integration the meaning of the individual sentence may depend on the sentences that precede it and may influence the meanings of the sentences that follow it. (Ex. John want it.) “ It ” depends on the previous sentence. Current user who type word “ I ” is –User068 = Susan_Black We get F1 with filename in /wsmith/ directory
43
323-670 Artificial IntelligenceChapter 443 5. Pragmatic Analysis The structure representing what was said is reinterpreted to determine what was actually meant. (Ex. Do you know what time it is?) we should understand what to do.... Understand to decide what to do as a result Representing the intended meaning –Figure 15.5 P. 385
44
323-670 Artificial IntelligenceChapter 444 Discourse (4) and Pragmatic Processing (5) use to understand a single sentence. p. 415 – 416 Relationship between discourse contexts Names of individuals Dave went to the movie. Parts of actions. 1) John went on a business trip to New York. 2) He left on an early morning flight. Causal chains.... Planning sequences....
45
323-670 Artificial IntelligenceChapter 445 knowledge to focus –the current focus on dialogue –a model of each participant’s current beliefs –the rule of conversation shared by all participants Modeling Individual beliefs p.419 –Model logic : Three belief spaces Figure 15.20 p.420 temporal logics –allow to talk about the truth of the set of proposition at current state of the real world, in the past, and in the future as well. conditional logic –allow to talk about the truth or falsehood under some circumstances Discourse (4) and Pragmatic Processing (5)
46
Turbo Prolog
47
323-670 Artificial IntelligenceChapter 447 ftp://172.28.80.6/older/DosProgram/TPROLOG Alt + Enter = Big Screen F1 : Help F2 : Save F3 : Load F6 : Next/Switch F8 : Previous Goal F9 : Compile F10 : Step (For trace) / End Alt + T : Trace ON/OFF Set up window size edit Use arrow key to adjust the size TURBO PROLOG
48
323-670 Artificial IntelligenceChapter 448 Use the example from the EXAMPLE directory to try to program. Start with EX03EX01.PRO predicates likes(symbol,symbol) clauses likes(ellen, tennis). likes(john, football). likes(tom, baseball). likes(eric, swimming) likes(mark, tennis). likes(bill, Activity) if likes(tom, Activity). likes(mark, Activity) :- likes(ellen, Activity). TURBO PROLOG FACTS RULES
49
323-670 Artificial IntelligenceChapter 449 ARITHMETIC Arithmetic operators: +, -, *, /, mod, div Relational operators: >, =,, >< Functions: sin, cos, tan, arctan, ln, log, exp, sqrt, round, trunc, abs EX: 1 + 2 = 2 + 1, X = 5/2, X = 5 mod 2, 5 <> 9 PROLOG.HELP
50
323-670 Artificial IntelligenceChapter 450 char1 byte characters integer2 byte integer numbers real8 byte floating point numbers symbolstrings inserted in the internal symbol table stringsequences of chars "hello world\n" PREDEFINED DOMAINS
51
323-670 Artificial IntelligenceChapter 451 CONSTANTS const1 = definition const2 = definition [GLOBAL] DOMAINS dom [,dom] = [reference] declaration1; declaration2 listdom = dom* dom = [GLOBAL] DATABASE [ - ] [determ] pred1(....) pred2(.....) GLOBAL PREDICATES [determ|nondeterm] pred1(.........) -(i,i,o,..)(i,o,i,..) [ language c|pascal|fortran ] [ as "name" ] pred2(........) PREDICATES [determ|nondeterm] pred1(.........) pred2(........) CLAUSES p(....):-p1(...), p2(.....),.... include "filename" Include a file during compilation. SUMMARY OF PROGRAM SECTIONS
52
323-670 Artificial IntelligenceChapter 452 random(RealVariable) (real) - (o) random(MaxValue,RandomInt) (integer,integer) - (i,o) sound(Duration,Frequency) (integer,integer) - (i,i) beep date(Year,Month,Day) (integer,integer,integer) - (o,o,o) (i,i,i) time(Hours,Minutes,Seconds,Hundredths) (integer,integer,integer,integer) - (o,o,o,o) (i,i,i,i) trace(on/off) (string) - (i) (o) MISCELLANEOUS
53
323-670 Artificial IntelligenceChapter 453 trap (PredicateCall,ExitCode,Predicate ToCallOnError) exit exit (ExitCode) (integer) - (i) if exit to DOS then the DOS errorlevel task processing variable will contain the value given to the exit predicate. break (on/off) (string) - (i) (o) ERROR & BREAK CONTROL
54
323-670 Artificial IntelligenceChapter 454 display(String) (string) - (i) edit(InputString,OutputString) (string,string) - (i,o) edit(InputString,OutputString,Headstr,Headstr2,Msg,Pos,He lpfilename, EditMode,Indent,Insert,TextMode,RetPos,RetStatus) (string,string,string,string,string,integer,string,int eger,integer,integer,integer,integer,integer) - (i,o,i,i,i,i,i,i,i,i,i,o,o) If the user saves the text from the editor, HeadStr2 will be used as the file name. editmsg(InputString,OutputString,Headstr,Headstr2,Msg,Pos,Helpfilename,RetStatus) (string,string,string,string,string,integer,string,int eger)- (i,o,i,i,i,i,i,o) EDITOR
55
323-670 Artificial IntelligenceChapter 455 makewindow(WindowNo,ScrAtt,FrameAtt,Framestr,Ro w,Column,Height,Width) (integer,integer,integer,string,integer,integ er,integer,integer) shiftwindow(WindowNo) (integer) - (i) (o) gotowindow(WindowNo) (integer) - (i) resizewindow(StartRow,NoOfRows,StartCol,NoOfCol s) (integer,integer,integer,integer) - (i,i,i,i) colorsetup(Main_Frame) (integer) - (i) WINDOW SYSTEM
56
323-670 Artificial IntelligenceChapter 456 readln(StringVariable) (string) - (o) readint(IntgVariable) (integer) - (o) readreal(RealVariable) (real) - (o) readchar(CharVariable) (char) - (o) keypressed unreadchar(CharToBePushedBack) (Char) - (i) readterm( Domain, Variable ) (DomainName,Domain) - (i,_) INPUT
57
323-670 Artificial IntelligenceChapter 457 write( Variable|Constant * ) nl writef( FormatString, Variable|Constant* ) In the format string the following options are known after a percentage sign: %d Normal decimal number. (chars and integers) %u As an unsigned integer. (chars and integers) %R As a database reference number. (database reference numbers) %X As a long hexadecimal number. (strings, database reference numb). %x As a hexadecimal number. (chars and integers). %s Strings. (symbols and strings). %c As a char. (chars and integers). %g Reals in shortest posible format (default for reals) %e Reals in exponetial notation %f Reals in fixed notation %lf Only for C compatibility (fixed reals) \n - newline \t - tabulator \nnn - character with code nnn OUTPUT
58
323-670 Artificial IntelligenceChapter 458 Natural Language Processing using prolog Sentence :- Noun_phrase, Verb_phrase. Noun_phrase :- Det, Noun. Noun_phrase :- Noun. Verb_phrase :- Verb, Noun_phrase. Verb_phrase :- verb. EX : The cat eats the fish. A man likes an apple.
59
323-670 Artificial IntelligenceChapter 459 EX13EX04.pro NLP.pro domains sentence = s(noun_phrase,verb_phrase) noun_phrase = noun(noun) ; noun_phrase(detrm,noun) noun = string verb_phrase = verb(verb) ; verb_phrase(verb,noun_phrase) verb = string detrm = string predicates s_sentence(string,sentence) s_noun_phrase(string,string,noun_phrase) s_verb_phrase(string,verb_phrase) d(string) n(string) v(string) start goal start. goal: Please enter the sentence > Bill eats apple
60
323-670 Artificial IntelligenceChapter 460 clauses start :- write("\n Please enter a sentence > "), readln(Str), s_sentence(Str,s(_,_)). s_sentence(Str, s(N_Phrase,V_Phrase) ):- s_noun_phrase(Str, Rest, N_Phrase), s_verb_phrase(Rest, V_Phrase). s_noun_phrase(Str, Rest, noun_phrase(Detr,Noun)):- fronttoken(Str,Detr,Rest1), d(Detr), fronttoken(Rest1,Noun,Rest), n(Noun). s_noun_phrase(Str,Rest,noun(Noun)):- fronttoken(STR,Noun,Rest), n(Noun). s_verb_phrase(Str, verb_phrase(Verb,N_Phrase)):- fronttoken(Str,Verb,Rest1), v(Verb), s_noun_phrase(Rest1,"",N_Phrase). s_verb_phrase(Str,verb(Verb)):- fronttoken(STR,Verb,""), v(Verb). EX13EX04.pro NLP.pro (cont)
61
323-670 Artificial IntelligenceChapter 461 EX13EX04.pro NLP.pro (cont) /* determiner */ d("the"). d("a"). d("an"). /* nouns */ n( “ Bill"). n("dog"). n("cat"). n("fish"). n("ant"). n("apple"). n("man"). n("bus"). /* verbs */ v("is"). v("eats"). v("likes"). v("takes"). The cat likes fish A man takes a bus
62
323-670 Artificial IntelligenceChapter 462 The End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.