You can nest Choices
objects by going through an intermediate GrammarBuilder
object.
The Choices
object has a constructor that takes an array of GrammarBuilders
, and the GramarBuilder
object has a constructor that takes a Choices
object. You'll probably want to use SemanticResultKeys and SemanticValues so that you can figure out what was actually said, though (which I won't illustrate).
I'm not a VB.net expert, so the syntax might be off here; but it would look something like this:
Dim numChoices As New Choices '// create Choices with each number in the range
Dim y() As String = Enumerable.Range(1, count).Select(Function(t) t.ToString()).ToArray()
numChoices.Add(y)
gb.Append(numChoices)
Dim g As New Grammar(gb)
g.Name = "Numbers"
'// Page must be followed by Up or Down
Dim gb2 As New GrammarBuilder()
gb2.Append("Page")
gb2.Append(New Choices("Up", "Down"))
Dim gb3 As New GrammarBuilder()
gb3.Append("Prior")
Dim gb4 As New GrammarBuilder()
gb4.Append(New Choices("Bottom", "Top"))
Dim gbArray() as GrammarBuilder(4) = {gb1, gb2, gb3, gb4};
Dim g as new Grammar(new GrammarBuilder(new Choices(gbArray)));
g.Name = "All"
_engine.LoadGrammar(g);