ccexpdate grammar

Collects the expiration date of a credit card.

Expiration dates are usually a month and a year, and are often embossed on a credit card in the form "mm/yy." The grammar recognizes variations on the date, for example (in US English), "December 2009," "oh four oh nine," "five of two thousand and eight," "eleven slash ten," etc.

Some credit cards are stamped with a day of the month as well as the month and year; the ccexpdate grammar recognizes these dates as well. However, the only day of the month it recognizes is the last day of a given month, for example, "November 30th, 2010," "oh two two nine oh nine," etc. The grammar does not check for leap years: both February 28 and February 29 are recognized, regardless of the given year.

Return keys/values

Upon return, the MEANING key is assigned to the recognized date in YYYYMMDD format, where YYYY is the year, MM is the month, and DD is the day. For example, 20080331 refers to March 31, 2008. The value is the same regardless of whether the caller specified a day of the month or not; the day is always set to the last day of the month. For example, both "oh six oh nine" and "oh six three oh oh nine" return 20090630. Note that if the expiration month is February, MMDD is always 0228, regardless of what the caller said or if the expiration year is a leap year.

Properties

The more narrowly you set these properties, the higher the recognition accuracy. However, narrow settings also limit the range of possibilities that callers are allowed to speak. Your settings must balance the need for accuracy with the expectations of your callers.

Property

Description

referencedate

Date (in YYYYMMDD format) to use in computing ranges. Latest allowed is 21991231. The default is the current date.

maxallowed

Latest date recognized expressed as a number of months beyond reference date. Default: 84 months.

maxexpected

Latest likely date recognized expressed as a number of months beyond reference date. Default: 48 months.

Note that the ccexpdate grammar supports two types of "closing month" constraints: maxallowed and maxexpected:

  • Setting maxallowed tells the Recognizer to allow only dates before or including that month. Dates after the allowed closing month or before the current month are not recognized.
  • Setting maxexpected tells the Recognizer to accept any date the caller says (inside an allowed range), but to give higher preference to recognition hypotheses that fall within the expected range.

The expected closing month must be the same or less than the allowed closing month.

DTMF interpretation

DTMF digits of form MMYY, MMDDYY, MMYYYY, and MMDDYYYY are all accepted. Note that the month/day/year formatting is designed to reflect the usual methods for imprinting expiration date on cards. As a result, it is different from that used in the date grammar.

One consequence of this format is that MEANING is ordered YYYYMMDD even though the entry is in the order MMDDYYYY.

Also note that consistent with the speech grammar, the full YYYYMMDD is filled in regardless of which DTMF format is used: for example, if the reference date is 20070630, entering 0908 results in a MEANING of 20080930.

Example

This example accepts expiration dates from September 2007 through September 2010.

builtin:grammar/ccexpdate?language=en-US;
referencedate=20070930;maxallowed=36