ITCS 6010 GSL Grammars What is a Grammar

  • Slides: 34
Download presentation
ITCS 6010 GSL Grammars

ITCS 6010 GSL Grammars

What is a Grammar? n Specifies what can be said—all the possible sentences and

What is a Grammar? n Specifies what can be said—all the possible sentences and phrases that can be recognized n Developer’s goal to: n n Predict set of phrases Encode phrase set Non-procedural Written in Grammar Specification Language (GSL)

Writing a Good Grammar n Broad coverage n n n People express themselves in

Writing a Good Grammar n Broad coverage n n n People express themselves in a variety of ways Recognizer cannot recognize anything not in the grammar But not too broad n Recognition accuracy can be adversely affected

Writing Grammars n Grammar writing is an iterative process n n Make best guess

Writing Grammars n Grammar writing is an iterative process n n Make best guess Collect data Update grammar Out-of-grammar (OOG) n n When user’s phrase cannot be parsed 5 – 10 % OOG rate acceptable

Writing Grammars (cont’d) n n n Focus on most common ways users will respond

Writing Grammars (cont’d) n n n Focus on most common ways users will respond to question/prompt DON’T attempt to figure out ALL possible responses – wasted effort Two most common response types: n n Information item Literal response to question wording

Writing Grammars (cont’d) n Examples: n n Question: What is the departure city? Common

Writing Grammars (cont’d) n Examples: n n Question: What is the departure city? Common responses: n Charlotte n My departure city is Charlotte n Departing from Charlotte Question: What city would you like? Common responses: n Charlotte n I’d like Charlotte n Departing from Charlotte

Writing Grammars (cont’d) n Important: n n n Word prompts carefully Coordinate grammars and

Writing Grammars (cont’d) n Important: n n n Word prompts carefully Coordinate grammars and prompts If prompt changes, change grammar to suit

Writing Grammars (cont’d) n Process for developing grammar: 1. 2. 3. 4. 5. 6.

Writing Grammars (cont’d) n Process for developing grammar: 1. 2. 3. 4. 5. 6. Define dialog Identify information items and define slots Design prompts Anticipate caller responses Identify “core” and “filler” portions Write GSL code

Defining Dialog n n Good understanding of dialog required before grammar written Answer following

Defining Dialog n n Good understanding of dialog required before grammar written Answer following questions: n n n What pieces of information required to complete task? What order will information be requested? Will one piece of information be requested at a time (directed dialog), or several pieces (mixed initiative)?

Information and Slot Identification n n Allocate one slot for each piece of required

Information and Slot Identification n n Allocate one slot for each piece of required information Slot has: n n n Name Value format Value type

Slot Example n Air travel application Item Slot Name Value Format Value Type city

Slot Example n Air travel application Item Slot Name Value Format Value Type city #1 origin 3 -letter code string city #2 destination 3 -letter code string date [<month> <day>] NL structure time 0 – 2359 integer yes/no confirm “yes’ or “no” string

Prompt Design n Design prompt before writing grammar Prompt wording greatly affects user response

Prompt Design n Design prompt before writing grammar Prompt wording greatly affects user response Match prompt to slot

Prompt Design Example §Directed dialog Prompt Slot What city would you like to leave

Prompt Design Example §Directed dialog Prompt Slot What city would you like to leave from? origin What city would you like to fly to? destination What date would you like to leave? date What time would you like to depart? time You’re going from <origin> to <dest> on <date> at <time>. Is this correct? confirm

Prompt Design Example §Mixed initiative Prompt Slot Where would you like to travel? origin,

Prompt Design Example §Mixed initiative Prompt Slot Where would you like to travel? origin, dest, date, time What city would you like to leave from? origin What city would you like to fly to ? destination What date would you like to leave? date What time would you like to depart? time You’re going from <origin> to <dest> on <date> at <time>. Is this correct? Confirm

Anticipate Caller Response --------------------------------------What city would you like to leave from? Charlotte [city name

Anticipate Caller Response --------------------------------------What city would you like to leave from? Charlotte [city name alone] I’d like to leave from Charlotte [literal response] Uh, Charlotte [initial hesitation] Charlotte, please [final “please”] (I’m) leaving from Charlotte (I’m) departing from Charlotte [additional possibilities] ---------------------------------------------------What city would you like to fly to? New York [city name alone] I’m flying to New York [literal response] Um, New York [initial hesitation] New York, please [final “please”] (I’d) like to fly to New York (I’m) going to New York [additional possibilities]

Identify Grammar Core and Filler n Core n n n Portion with most important

Identify Grammar Core and Filler n Core n n n Portion with most important meaning-bearing words Highly reusable => defined as subgrammar Filler n Depends largely on prompt wording

Core and Filler Example n Core n n CITY – Charlotte, Raleigh, New York,

Core and Filler Example n Core n n CITY – Charlotte, Raleigh, New York, Miami, San Diego DATE TIME Filler What city would you like to leave from? CITY I’d like to leave from CITY Uh, CITY, please (I’m) leaving from CITY (I’m) departing from CITY

Grammar Specification Language n Create grammar file n n Text file File extension. grammar

Grammar Specification Language n Create grammar file n n Text file File extension. grammar Can contain more than one grammar definition Grammar definition contains the grammar name and description

GSL (cont’d) n Grammar definition format: Grammar. Name n Grammar. Description Grammar. Name n

GSL (cont’d) n Grammar definition format: Grammar. Name n Grammar. Description Grammar. Name n n Character string used to reference grammar Contains at least one uppercase letter (usually the first letter) No more 200 characters in length Can contain: n n n n Upper and lower-case letters Digits - dash _ underscore ‘ single quote @ at sign. period

GSL (cont’d) n Grammar. Description n n Recognizable word sequence or phrase Consists of

GSL (cont’d) n Grammar. Description n n Recognizable word sequence or phrase Consists of : n n n Word tokens Grammar names Operators Word tokens and grammar names separated by white space character (space, tab, newline) Word tokens are terminal symbols n n Represent actual word for recognition e. g. dog Must be lowercase

GSL Code ; This is a simple grammar Sentence ( good morning ) n

GSL Code ; This is a simple grammar Sentence ( good morning ) n n A semicolon (; ) indicates a comment Sentence is the name of the grammar

OR Construction [A B C … D] A or B or C or …

OR Construction [A B C … D] A or B or C or … or D Sentence( good [ morning afternoon evening ] )

Operators n (A B C) A followed by B then C (good morning) good

Operators n (A B C) A followed by B then C (good morning) good morning n [ A B C] A or B or C (good [morning afternoon evening night]) good morning, good afternoon, good evening, good night

Operators n ? A A is optional Command ( tell me my balance in

Operators n ? A A is optional Command ( tell me my balance in checking ? please) tell me my balance in checking, tell me my balance in checking please n +A One or more repetitions of A Sentence( thanks +very much ) thanks very much, thanks very …. much n *A Zero or more repetitions of A Sentence( thanks *very much ) thanks much, thanks very much

Natural Language Interpretation n n NL interpretation assigns meaning to word strings Many utterances.

Natural Language Interpretation n n NL interpretation assigns meaning to word strings Many utterances. . . n n “withdraw fifteen hundred bucks from savings” “take fifteen hundred out of savings” “give me one thousand five hundred dollars from my savings account” . . . may express the same meaning: <action "withdrawal"> <source_account "savings"> <amount 1500>

Interpretation n Slots are. . . n Defined for the domain n n command

Interpretation n Slots are. . . n Defined for the domain n n command amount source Associated with word strings in the grammar Filled with values when the associated word string is recognized by NL Interpretation

Interpretation n Define the relevant “slots” for the domain Slot Value command source-account destination-account

Interpretation n Define the relevant “slots” for the domain Slot Value command source-account destination-account amount "transfer" "savings" "checking" 125. 10 “Transfer one twenty five ten from savings to checking” “I want to transfer to checking from savings one hundred twenty five dollars and ten cents” “Please put a hundred twenty five dollars ten cents in checking from my savings account”

Slot-Filling Commands n NL commands go between curly braces: { … } n n

Slot-Filling Commands n NL commands go between curly braces: { … } n n Commands “attach” to the preceding item — either a word or a grammar construction NL commands are part of the grammar file: Command ( withdraw from [ checking {<source_account "checking">} savings {<source_account "savings">} ] ) {<action "withdrawal">}

More About Grammars n n n Subgrammars Return Commands NL Functions

More About Grammars n n n Subgrammars Return Commands NL Functions

Subgrammars n Subgrammars match a “part” of an utterance Account ( [ savings checking

Subgrammars n Subgrammars match a “part” of an utterance Account ( [ savings checking (money market) ] ? account ) n Subgrammars reduce redundancy Command [ ( tell me the balance in Account ) ( transfer from Account to Account ) ( withdraw from Account ) ]

Return Commands and Variables n To associate a return value with a grammar: {return("checking")}

Return Commands and Variables n To associate a return value with a grammar: {return("checking")} “return” is like other {} commands except no slot is filled; only the value is defined Assignment: A higher-level grammar can store the returned value in a variable: n n n <Sub-grammar>: <variable_name> Example: Account: acct results in the variable acct being set to the value returned by the grammar Account Dereferencing: To access a variable’s value, preface the variable name with ‘$’.

Return Commands and Variables Command [ ( tell me the balance in Account: acct

Return Commands and Variables Command [ ( tell me the balance in Account: acct ) {<account $acct>} ( transfer from Account: src to Account: dest ) {<source-account $src> <dest-account $dest>} ( withdraw from Account: src ) {<source-account $src>} ] Account ( [ checking {return("checking")} savings {return("savings")} ( money market ) {return("money_market")} ] ? account )

NL Functions n n Slot values and return values can be function calls Available

NL Functions n n Slot values and return values can be function calls Available functions: add sub mul div neg strcat n n returns the sum of two integers returns the result of subtracting the second integer from the first returns the product of two integers returns the truncated integer result of dividing the first integer by the second (e. g. , div(9 5) returns 1) returns the negation of an integer returns the concatenation of two strings Arguments separated by whitespace, not commas No space between function name and parenthesis

NL Functions n Example: Digit [ one two three. . . {return(1)} {return(2)} {return(3)}

NL Functions n Example: Digit [ one two three. . . {return(1)} {return(2)} {return(3)} twenty thirty forty. . . {return(20)} {return(30)} {return(40)} ] Decade [ ] Number ( Decade: d 1 Digit: d 2 ) {<number add($d 1 $d 2)>} n Matching the top-level grammar Number fills the slot number with the sum of NL variables d 1 and d 2