1

I'm looking for a way to build a VXML grammar that requires a certain number of digits to be entered, but also requires that the input is not all zeros.

The use case for this is bank numbers. For example, I would like to force an input (voice or DTMF, doesn't matter) of 9 digits for routing numbers but require that not all digits are zero. (Disregard the modulus check for the moment, I'm not concerned about that here).

Given the grammar constructs of <one-of> and <item>, I can see this being possible by enumerating all possibilities such as the rule at this end of this question. However, this seems ridiculous. Is there a better way that I haven't come across yet? Any help would be appreciated.

<rule>
    <one-of>
        <item>
            <item repeat="1">
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
                <item>6</item>
                <item>7</item>
                <item>8</item>
                <item>9</item>
            </item>
            <item repeat="8">
                <item>0</item>
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
                <item>6</item>
                <item>7</item>
                <item>8</item>
                <item>9</item>
            </item>
        </item>
        <item>
            <item repeat="1">
                <item>0</item>
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
                <item>6</item>
                <item>7</item>
                <item>8</item>
                <item>9</item>
            </item>
            <item repeat="1">
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
                <item>6</item>
                <item>7</item>
                <item>8</item>
                <item>9</item>
            </item>
            <item repeat="7">
                <item>0</item>
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
                <item>6</item>
                <item>7</item>
                <item>8</item>
                <item>9</item>
            </item>
        </item>
        <item>
            <item repeat="2">
                <item>0</item>
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
                <item>6</item>
                <item>7</item>
                <item>8</item>
                <item>9</item>
            </item>
            <item repeat="1">
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
                <item>6</item>
                <item>7</item>
                <item>8</item>
                <item>9</item>
            </item>
            <item repeat="6">
                <item>0</item>
                <item>1</item>
                <item>2</item>
                <item>3</item>
                <item>4</item>
                <item>5</item>
                <item>6</item>
                <item>7</item>
                <item>8</item>
                <item>9</item>
            </item>
        </item>
                    etc....
    </one-of>
</rule>
Charles
  • 50,943
  • 13
  • 104
  • 142
butallmj
  • 1,531
  • 4
  • 14
  • 21

1 Answers1

1

How about something like this

<rule id="zero">
  <oneof>
    <item>0</item>
  </oneof>
</rule>

<rule id="nonzero">
  <oneof>
    <item>1</item>
    <item>2</item>
    <item>3</item>
    <item>4</item>
    <item>5</item>
    <item>6</item>
    <item>7</item>
    <item>8</item>
    <item>9</item>
  </oneof>
</rule>

<rule id="alldigits">
  <oneof>
    <item>
      <ruleref uri="#zero"/>
    </item>
    <item>
      <ruleref uri="#nonzero"/>
    </item>
  </oneof>
</rule>

<rule id="account-num">
  <oneof>
    <item>
      <item repeat="7">
       <ruleref uri="#alldigits"/>
      </item>
      <item repeat="1">
         <ruleref uri="#nonzero"/>
      </item>
    </item>
  </oneof>
</rule>

The rule account-num specifies that at least one number must not be zero.

Kevin Junghans
  • 17,475
  • 4
  • 45
  • 62
  • Hi Kevin. I ventured down this path of thought to begin with, but I didn't continue on it. While it does prevent all zeros from being entered, it also prevents all values that end in zero, even if they're non zero (e.g. 12345670). Thank you for your input though. – butallmj Jan 31 '13 at 16:23
  • Hi butallmj. You are correct about the results of my grammar. I think your original approach is the only way to do this because you are concerned with permutations. You usually do not worry about permutations in speech. But I would use the rulerefs like I did because it is more readable and easier to input. This will be a very inefficient grammar for a speech engine. I think a better approach is to validate for the zeros after the digits are returned in your app. That way you can provide a more specific error message to the user. – Kevin Junghans Feb 01 '13 at 19:33
  • Hey Kevin. Thanks for that input. I too felt like I was just trying to squeeze something out of voice grammars that they weren't built for; I'm going to do the non zero validation within the app. Thanks for your help! – butallmj Feb 05 '13 at 20:51