1 / 34

ITCS 6010

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

kimi
Télécharger la présentation

ITCS 6010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ITCS 6010 GSL Grammars

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

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

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

  5. Writing Grammars (cont’d) • 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: • Information item • Literal response to question wording

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

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

  8. Writing Grammars (cont’d) • Process for developing grammar: • Define dialog • Identify information items and define slots • Design prompts • Anticipate caller responses • Identify “core” and “filler” portions • Write GSL code

  9. Defining Dialog • Good understanding of dialog required before grammar written • Answer following questions: • 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)?

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

  11. Slot Example • Air travel application

  12. Prompt Design • Design prompt before writing grammar • Prompt wording greatly affects user response • Match prompt to slot

  13. Prompt Design Example • Directed dialog

  14. Prompt Design Example • Mixed initiative

  15. 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]

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

  17. Core and Filler Example • Core • 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 CITY, please (I’m) leaving from CITY (I’m) departing from CITY

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

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

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

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

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

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

  24. Operators • ?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 • +A One or more repetitions of A Sentence( thanks +very much ) thanks very much, thanks very very much, thanks very ….much • *A Zero or more repetitions of A Sentence( thanks *very much ) thanks much, thanks very much, thanks very very much

  25. Natural Language Interpretation • NL interpretation assigns meaning to word strings • Many utterances. . . • “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>

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

  27. Interpretation • Define the relevant “slots” for the domain Slot Value command "transfer" source-account "savings" destination-account "checking" amount 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”

  28. Slot-Filling Commands • NL commands go between curly braces:{ … } • 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">}

  29. More About Grammars Subgrammars Return Commands NL Functions

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

  31. Return Commands and Variables • 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: • <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 ‘$’.

  32. 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 )

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

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

More Related