The NuGramDynamic Grammar Language<br />Supported by NuGram 2.2<br />June 16th, 2010<br />
Background<br />Extension to W3C’s SRGS ABNF format<br />Supported by a complete development environment –NuGram IDE<br />...
Expressions<br />Constants<br />null, false, true<br />StringsEx: “abc”, “John Smith”, “05/30/2010”<br />NumbersEx: 10, 32...
Expressions<br />Properties<br />Syntax: obj.propertyName<br />Property name must be a valid Java identifier<br />Method c...
Expressions<br />Comparison operators<br />== <br />!=<br />Logical operators<br />! (negation)<br />&& (conjunction)<br /...
Dynamic Words<br />Syntax@word ( Expressions… )<br />Values of all expressions are concatenated<br />Example<br />Copyrigh...
Dynamic Rule References<br />Syntax@ref ( Expressions… )<br />Values of all expressions are concatenated<br />Resulting va...
Dynamic Tags<br />Syntax@tag ( Expressions… )<br />Values of all expressions are concatenated <br />Example<br />Copyright...
Iterations<br />Syntax@for ( var: Expression )    Expansions…@end<br />Repeats the expansions for each value in the collec...
Iterations<br />Example<br />Copyright © 2010 Nu Echo Inc.<br />
Dynamic Sequences<br />Syntax@seqExpansions… @end<br />All direct expansions become part of the sequence<br />Copyright © ...
Dynamic sequences<br />Example<br />Copyright © 2010 Nu Echo Inc.<br />
Dynamic Choices<br />Syntax@altExpansions… @end<br />All direct expansions become alternative choices<br />Copyright © 201...
Dynamic Choices<br />Example 1<br />Copyright © 2010 Nu Echo Inc.<br />
Example 2<br />Beware: @alt and @for may produce unexpected results<br />Dynamic Choices<br />Copyright © 2010 Nu Echo Inc...
Example 2 (cont'd)<br />Solution: use grouping<br />Dynamic Choices<br />Copyright © 2010 Nu Echo Inc.<br />
Local Variable Definitions<br />Syntax@varIdent = Expression :Expansions… @end<br />Ident is visible for the Expansions<br...
Conditionals<br />Syntax@if ( Expression )Expansions… @elseif ( Expression )Expansions… @elseExpansions… @end<br />A singl...
Macros Definitions<br />Syntax@defineIdent (Parameters):Expansions… @end<br />Parameters are comma-separated identifiers<b...
Macros Invocations<br />Syntax@callIdent (Expressions…)<br />Arguments are comma-separated<br />Example@for (name : names)...
Dynamic Rules<br />Syntax@ruleExpression = Expansions… @end<br />All direct expansions become alternative choices<br />Esp...
Dynamic Headers<br />Syntaxmode @stringExpression;root @stringExpression;language @stringExpression;lexicon @stringExpress...
Conditional Headers<br />Syntax<br />Add a @when clause at the end of the header form<br />Examplelexicon <mylexicon.xml> ...
Upcoming SlideShare
Loading in …5
×

The NuGram dynamic grammar language

1,533 views

Published on

Details the extensions to W3C's SRGS ABNF format for dynamic grammars supported by the NuGram Platform.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,533
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

The NuGram dynamic grammar language

  1. 1. The NuGramDynamic Grammar Language<br />Supported by NuGram 2.2<br />June 16th, 2010<br />
  2. 2. Background<br />Extension to W3C’s SRGS ABNF format<br />Supported by a complete development environment –NuGram IDE<br />Dynamic grammars are deployable on NuGram Server<br />Copyright © 2010 Nu Echo Inc.<br />
  3. 3. Expressions<br />Constants<br />null, false, true<br />StringsEx: “abc”, “John Smith”, “05/30/2010”<br />NumbersEx: 10, 325.64<br />Variables<br />Must be a legal Java identifier<br />Top-level variables are provided by the instantiation context<br />Copyright © 2010 Nu Echo Inc.<br />
  4. 4. Expressions<br />Properties<br />Syntax: obj.propertyName<br />Property name must be a valid Java identifier<br />Method calls<br />Syntax: obj.methodName(arguments…)<br />Arguments are comma-separate<br />Array elements<br />Syntax: obj[indexValue]<br />Copyright © 2010 Nu Echo Inc.<br />
  5. 5. Expressions<br />Comparison operators<br />== <br />!=<br />Logical operators<br />! (negation)<br />&& (conjunction)<br />|| (disjunction)<br />Copyright © 2010 Nu Echo Inc.<br />
  6. 6. Dynamic Words<br />Syntax@word ( Expressions… )<br />Values of all expressions are concatenated<br />Example<br />Copyright © 2010 Nu Echo Inc.<br />
  7. 7. Dynamic Rule References<br />Syntax@ref ( Expressions… )<br />Values of all expressions are concatenated<br />Resulting value must start with “#” for a local rule reference<br />Example<br />Copyright © 2010 Nu Echo Inc.<br />
  8. 8. Dynamic Tags<br />Syntax@tag ( Expressions… )<br />Values of all expressions are concatenated <br />Example<br />Copyright © 2010 Nu Echo Inc.<br />
  9. 9. Iterations<br />Syntax@for ( var: Expression ) Expansions…@end<br />Repeats the expansions for each value in the collection resulting from evaluating Expression.<br />Copyright © 2010 Nu Echo Inc.<br />
  10. 10. Iterations<br />Example<br />Copyright © 2010 Nu Echo Inc.<br />
  11. 11. Dynamic Sequences<br />Syntax@seqExpansions… @end<br />All direct expansions become part of the sequence<br />Copyright © 2010 Nu Echo Inc.<br />
  12. 12. Dynamic sequences<br />Example<br />Copyright © 2010 Nu Echo Inc.<br />
  13. 13. Dynamic Choices<br />Syntax@altExpansions… @end<br />All direct expansions become alternative choices<br />Copyright © 2010 Nu Echo Inc.<br />
  14. 14. Dynamic Choices<br />Example 1<br />Copyright © 2010 Nu Echo Inc.<br />
  15. 15. Example 2<br />Beware: @alt and @for may produce unexpected results<br />Dynamic Choices<br />Copyright © 2010 Nu Echo Inc.<br />
  16. 16. Example 2 (cont'd)<br />Solution: use grouping<br />Dynamic Choices<br />Copyright © 2010 Nu Echo Inc.<br />
  17. 17. Local Variable Definitions<br />Syntax@varIdent = Expression :Expansions… @end<br />Ident is visible for the Expansions<br />Multiple variables can be declared at once<br />Example@varfirstname = name.firstname,lastname = name.lastname : ( [@wordlastname] [@wordfirstname] @wordlastname )@end<br />Copyright © 2010 Nu Echo Inc.<br />
  18. 18. Conditionals<br />Syntax@if ( Expression )Expansions… @elseif ( Expression )Expansions… @elseExpansions… @end<br />A single branch of the conditional is executed<br />@elseifand @else branches are optional<br />There can be more than one @elseif, but a single @else<br />Copyright © 2010 Nu Echo Inc.<br />
  19. 19. Macros Definitions<br />Syntax@defineIdent (Parameters):Expansions… @end<br />Parameters are comma-separated identifiers<br />Can only appear as a top-level form<br />Example@define fullname (name) : [@word name.firstname] @word name.lastname@end<br />Copyright © 2010 Nu Echo Inc.<br />
  20. 20. Macros Invocations<br />Syntax@callIdent (Expressions…)<br />Arguments are comma-separated<br />Example@for (name : names) @call fullname (name)@end<br />Copyright © 2010 Nu Echo Inc.<br />
  21. 21. Dynamic Rules<br />Syntax@ruleExpression = Expansions… @end<br />All direct expansions become alternative choices<br />Especially useful inside a top-level @for<br />Example@for (typeSet : addresses.getStreetTypes())@rule typeSet.getUniqueId() =@call streetTypes(typeSet)@end@end<br />Copyright © 2010 Nu Echo Inc.<br />
  22. 22. Dynamic Headers<br />Syntaxmode @stringExpression;root @stringExpression;language @stringExpression;lexicon @stringExpression;meta “string” is @stringExpression;tag-format @stringExpression;<br />Expression must evaluate to a string<br />Useful for engine-specific headers<br />Copyright © 2010 Nu Echo Inc.<br />
  23. 23. Conditional Headers<br />Syntax<br />Add a @when clause at the end of the header form<br />Examplelexicon <mylexicon.xml> @when engine == “osr”;tag-format <swi-semantics/1.0> @when engine == “osr”;meta “com.nuecho.generation.omit-tags” is “true” @when engine != “osr”;<br />Copyright © 2010 Nu Echo Inc.<br />

×