Specifying, Compiling, and Testing Grammars

Slides:



Advertisements
Similar presentations
The Web Warrior Guide to Web Design Technologies
Advertisements

Lecture 2 Introduction to C Programming
 2005 Pearson Education, Inc. All rights reserved Introduction.
Introduction to C Programming
CMT Programming Software Applications
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Introduction to C Programming
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
C Programming. Chapter – 1 Introduction Study Book for one month – 25% Learning rate Use Compiler for one month – 60%
Fortran 1- Basics Chapters 1-2 in your Fortran book.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Input, Output, and Processing
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
More about Strings. String Formatting  So far we have used comma separators to print messages  This is fine until our messages become quite complex:
Speech in, speech out. 24 listopad 2006WS0607 – elevator2/15 Nuance server compiled recognition grammar, master language package, licence manager Nuance.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Chapter 1.2 Introduction to C++ Programming
Chapter 2 Variables.
Chapter 1.2 Introduction to C++ Programming
Topics Designing a Program Input, Processing, and Output
CS 330 Class 7 Comments on Exam Programming plan for today:
Chapter 6 JavaScript: Introduction to Scripting
Content Programming Overview The JVM A brief look at Structure
Chapter 1.2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
A Simple Syntax-Directed Translator
CMSC201 Computer Science I for Majors Lecture 22 – Binary (and More)
Chapter 2 - Introduction to C Programming
Introduction to C# Applications
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Revision Lecture
The Selection Structure
Chapter 2 - Introduction to C Programming
Intro to PHP & Variables
MATLAB: Structures and File I/O
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 2 - Introduction to C Programming
Topics Introduction to File Input and Output
Number and String Operations
Introduction to C++ Programming
Chapter 4 void Functions
WEB PROGRAMMING JavaScript.
Use of Mathematics using Technology (Maltlab)
Chapter 2 - Introduction to C Programming
Subject Name:Sysytem Software Subject Code: 10SCS52
R.Rajkumar Asst.Professor CSE
T. Jumana Abu Shmais – AOU - Riyadh
Introduction to C Topics Compilation Using the gcc Compiler
Classes and Objects.
New Perspectives on XML
Chapter 2 - Introduction to C Programming
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Topics Designing a Program Input, Processing, and Output
Introduction to C Topics Compilation Using the gcc Compiler
Topics Designing a Program Input, Processing, and Output
Chapter 2 - Introduction to C Programming
1.5 Regular Expressions (REs)
12th Computer Science – Unit 5
Chapter 2 Variables.
Topics Introduction to File Input and Output
Introduction to C Programming
Introduction to Computer Science
Presentation transcript:

Nuance Speech Technology ______________________ Developing Applications

Specifying, Compiling, and Testing Grammars

Overview Grammar specification basics Natural language (NL) specification Compiling grammars Testing grammars

What is a Grammar? Specifies what can be said—all the possible sentences and phrases that can be recognized File is called application.grammar, where application is the name of the recognition package Written in Grammar Specification Language (GSL)

Grammar Basics A semicolon (;) indicates a comment ; This is a simple grammar .Sentence ( good morning ) A semicolon (;) indicates a comment .Sentence is the name of the grammar Grammar names must contain at least one uppercase character Words are lowercase (A B C … D) A and B and C and … and D

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

Optional Words and Repetition ?A A is optional .Command ( tell me my balance in checking ?please ) +A One or more repetitions of A .Sentence( thanks +very much ) *A Zero or more repetitions of A .Sentence( thanks *very much )

Writing a Good Grammar Broad coverage But not too broad 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

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>

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”

Interpretation The Nuance NL engine uses a “slot and filler” representation of meaning 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

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">}

The Slot Definitions File In conjunction with the grammar file, a slot definitions file defines the slots for the application The slot definitions file is simply a list of all the slot names: account source-account dest-account The slot definitions file must be called application.slot_definitions

Subgrammars Return Commands NL Functions Adding New Words More About Grammars Subgrammars Return Commands NL Functions Adding New Words

Subgrammars Subgrammars match a “part” of an utterance Account ( [ savings checking ( money market ) ] ?account ) Top-level grammars prefaced by ‘.’ Subgrammars reduce redundancy .Command [ ( tell me the balance in Account ) ( transfer from Account to Account ) ( withdraw from Account )

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 ‘$’.

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

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

Compiling Grammars % nuance-compile application-name model-set application-name is the name used for the grammar and slot definitions files model-set is the set of acoustic models for recognition. Successful compilation produces a “recognition package” in a directory called application-name. The package provides all the necessary files for recognition and understanding.

Testing Recognition and NL Xapp is a graphical application for exercising a grammar and NL specification: % Xapp -package recognition_package You must start a recognition server before running Xapp: % recserver –package recognition_package

Testing Recognition and NL parse-tool lets you type phrases to see if they match a particular grammar % parse-tool -package recognition_package The optional parameter -print-trees prints the entire parse tree—the full set of grammars and subgrammars traversed to match the sentence nl-tool lets you type sentences to see the interpretations that are produced: % nl-tool -package recognition_package For parse-tool or nl-tool, specify -grammar grammar if you want to use just one grammar to process the phrase

Adding New Words The Nuance toolkit includes a dictionary with pronunciations for more than 100,000 words. Some applications may require words that are not in the default dictionary, for example, unusual names. If the grammar contains words not in the dictionary, nuance-compile prints an error message saying so and lists the words in a file called application-name.missing.

Adding Words Phonetically Create application-name.dictionary Use normal text editor Copy application-name.missing Add new words directly For each word, supply a phonetic spelling (see the manual, Nuance Grammar Developer’s Guide\7.Creating application-specific dictionaries\The Nuance phoneme set). Multiple pronunciations Repeat the word on multiple lines. General rule: Limit to ~3

Adding Words Phonetically Examples apple a p * l book b U k hotel h o t E l You can use the pronounce tool to find pronunciations of similar words % pronounce English.America telephone telephone t E l * f o n

Summary of package files File extension Required? Contents .grammar Yes GSL code .dictionary No One word (or compound) followed by a sequence of phonemes per line .slot_definitions One slot name per line

Nuance sample grammars You can find sample grammars for: date.grammar money.grammar number.grammar time.grammar At %Nuance%\data\lang\English.America\grammars