Partager via


Date Rules for English (United Kingdom)

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Date rules recognize dates expressed in a number of forms. The particular form that is recognized by a rule is encoded in the name of the rule. For example, the Date_Month_Day_Year rule recognizes date expressions such as "March twenty second two thousand and five."

When the year, month, or day in a date expression is ambiguous, the rules return an alternate semantic value. The default semantic value assumes a future date. Alternate semantic values presume a past date. For example, if today is June 1, 2005, and the user says "May twenty fourth," the Date_Month_Day rule returns the following values:

  • Day = 24
  • Month = 5
  • Year = 2006
  • AlternateYear = 2005

Default date semantic item values are error checked for consistency (for example, that February 29th only falls on leap years). Alternate date semantic item values are not checked for consistency. The IsValidDate semantic item value is set to false if the default semantic date is not valid.

What the Date Rules Recognize

The Date rules recognize dates expressed as the following:

  • A month name or a cardinal month number. For example, "February; April; December; oh four; six."
  • A cardinal month number followed by a cardinal day number. For example, "five twenty one; three two; six nine."
  • A month name followed by an ordinal day number or an ordinal day number followed by a month name. For example, "May the twenty first; Tuesday March second; June ninth; the twenty first of May; Tuesday the second of March; the ninth of June."
  • All of the previously noted expressions followed by a cardinal year number in two-digit or four-digit form. For example, "May the twenty first two thousand and five; Tuesday March second ninety seven; June ninth nineteen sixty five; the twenty first of May two thousand and five; Tuesday the second of March ninety seven; the ninth of June nineteen sixty two; five twenty one two thousand six; three two nineteen ninety seven; six nine two thousand five; five twenty one; three two thousand and five; six nineteen ninety seven; May twenty one; March two thousand and five; June nineteen ninety seven."
  • A cardinal year number in two-digit or four-digit form or a relative year expression. For example, "nineteen hundred and five; ninety nine; oh one; two thousand and five; two thousand and eleven; next year."
  • An ordinal or a cardinal day number. For example, "on the first; the twenty second; one; eleven; twenty nine."
  • Common relative day expressions. For example, "yesterday; today; tomorrow; next Tuesday; Tuesday; last Tuesday."
  • Weekday names. For example, "Sunday; Friday."

Rules

Date

Date_Day

Date_Month_Day

Date_Month_Day_Year

Date_Day_Month

Date_Day_Month_Year

Date_MonthNum_DayNum

Date_MonthNum_DayNum_Year

Date_Relative

Date_MonthNum_Year

Date_Month_Year

Date_Weekday

Date_Month

Date_MonthNum

Date_DayNum

Date_Year

Usage

<ruleref uri="Library.grxml#Date" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Day" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Month_Day" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Month_Day_Year" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Day_Month" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Day_Month_Year" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_MonthNum_DayNum" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_MonthNum_DayNum_Year" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Relative" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_MonthNum_Year" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Month_Year" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Weekday" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Month" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_MonthNum" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_DayNum" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Date_Year" type="application/srgs+xml"/>

The grammar can be used as follows (using the Date rule as an example).

<grammar xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
         xml:lang="en-GB" tag-format="semantics-ms/1.0" version="1.0" mode="voice"
         root="Rule1" xmlns="http://www.w3.org/2001/06/grammar">
    <rule id="Rule1" scope="public">
        <ruleref uri="Library.grxml#Date" type="application/srgs+xml"/>
    <tag>$ = $$</tag>
    </rule>
</grammar>

JScript Objects

Rule Name Returned JScript objects

Date

$Date.IsValidDate: string ["true", "false"]
$Date.Month:
????????$Date.Month._value: integer [1...12]
????????$Date.Month._attributes.name: string ["Assumed", "Derived", "Explicit"]
$Date.Day:
????????$Date.Day._value: integer [1...31]
????????$Date.Day._attributes.name: string ["Assumed", "Derived", "Explicit"]
$Date.Year: 
????????$Date.Year._value: integer [1900...2099]
????????$Date.Year._attributes.name: string ["Assumed", "Derived", "Explicit"]
????????$Date.Year._attributes.form: string ["ShortForm", "LongForm", "Relative"] Only specified if _name == "Explicit" or "Derived"
$Date.AlternateMonth (Optional):
????????$Date.AlternateMonth._value: integer [1...12]
$Date.AlternateDay (Optional):
????????$Date.AlternateDay._value: integer [1...31]
$Date.AlternateYear (Optional):
????????$Date.AlternateYear._value: integer [1900...2099]

Date_Day

$Date_Day.IsValidDate: string ["true", "false"]
$Date_Day.Month:
????????$Date_Day.Month._value: integer [1...12]
????????$Date_Day.Month._attributes.name: string ["Assumed"]
$Date_Day.Day:
????????$Date_Day.Day._value: integer [1...31]
????????$Date_Day.Day._attributes.name: string ["Explicit"]
$Date_Day.Year: 
????????$Date_Day.Year._value: integer [1900...2099]
????????$Date_Day.Year._attributes.name: string ["Assumed"]
$Date_Day.AlternateMonth:
????????$Date_Day.AlternateMonth._value: integer [1...12]
$Date_Day.AlternateYear:
????????$Date_Day.AlternateYear._value: integer [1900...2099]

Date_Month_Day

$Date_Month_Day.IsValidDate: string ["true", "false"]
$Date_Month_Day.Month:
????????$Date_Month_Day.Month._value: integer [1...12]
????????$Date_Month_Day.Month._attributes.name: string ["Explicit"]
$Date_Month_Day.Day:
????????$Date_Month_Day.Day._value: integer [1...31]
????????$Date_Month_Day.Day._attributes.name: string ["Explicit"]
$Date_Month_Day.Year: 
????????$Date_Month_Day.$Year._value: integer [1900...2099]
????????$Date_Month_Day.$Year._attributes.name: string ["Assumed"]
$Date_Month_Day.AlternateYear:
????????$Date_Month_Day.AlternateYear._value: integer [1900...2099]

Date_Month_Day_Year

$Date_Month_Day_Year.IsValidDate: string ["true", "false"]
$Date_Month_Day_Year.Month:
????????$Date_Month_Day_Year.Month._value: integer [1...12]
????????$Date_Month_Day_Year.Month._attributes.name: string ["Explicit"]
$Date_Month_Day_Year.Day:
????????$Date_Month_Day_Year.Day._value: integer [1...31]
????????$Date_Month_Day_Year.Day._attributes.name: string ["Explicit"]
$Date_Month_Day_Year.Year: 
????????$Date_Month_Day_Year.Year._value: integer [1900...2099]
????????$Date_Month_Day_Year.Year._attributes.name: string ["Assumed"]
????????$Date_Month_Day_Year.Year._attributes.form: string ["ShortForm", "LongForm", "Relative"]

Date_Day_Month

$Date_Day_Month.IsValidDate: string ["true", "false"]
$Date_Day_Month.Month:
????????$Date_Day_Month.Month._value: integer [1...12]
????????$Date_Day_Month.Month._attributes.name: string ["Explicit"]
$Date_Day_Month.Day:
????????$Date_Day_Month.Day._value: integer [1...31]
????????$Date_Day_Month.Day._attributes.name: string ["Explicit"]
$Date_Day_Month.Year: 
????????$Date_Day_Month.Year._value: integer [1900...2099]
????????$Date_Day_Month.Year._attributes.name: string ["Assumed"]
$Date_Day_Month.AlternateYear:
????????$Date_Day_Month.AlternateYear._value: integer [1900...2099]

Date_Day_Month_Year

$Date_Day_Month_Year.IsValidDate: string ["true", "false"]
$Date_Day_Month_Year.Month:
????????$Date_Day_Month_Year.Month._value: integer [1...12]
????????$Date_Day_Month_Year.Month._attributes.name: string ["Explicit"]
$Date_Day_Month_Year.Day:
????????$Date_Day_Month_Year.Day._value: integer [1...31]
????????$Date_Day_Month_Year.Day._attributes.name: string ["Explicit"]
$Date_Day_Month_Year.Year: 
????????$Date_Day_Month_Year.Year._value: integer [1900...2099]
????????$Date_Day_Month_Year.Year._attributes.name: string ["Derived", "Explicit"]
????????$Date_Day_Month_Year.Year._attributes.form: string ["ShortForm", "LongForm", "Relative"]

Date_MonthNum_DayNum

$Date_MonthNum_DayNum.IsValidDate: string ["true", "false"]
$Date_MonthNum_DayNum.Month:
????????$Date_MonthNum_DayNum.Month._value: integer [1...12]
????????$Date_MonthNum_DayNum.Month._attributes.name: string ["Explicit"]
$Date_MonthNum_DayNum.Day:
????????$Date_MonthNum_DayNum.Day._value: integer [1...31]
????????$Date_MonthNum_DayNum.Day._attributes.name: string ["Explicit"]
$Date_MonthNum_DayNum.Year: 
????????$Date_MonthNum_DayNum.Year._value: integer [1900...2099]
????????$Date_MonthNum_DayNum.Year._attributes.name: string ["Assumed"]
$Date_MonthNum_DayNum.AlternateYear:
????????$Date_MonthNum_DayNum.AlternateYear._value: integer [1900...2099]

Date_MonthNum_DayNum_Year

$Date_MonthNum_DayNum_Year.IsValidDate: string ["true", "false"]
$Date_MonthNum_DayNum_Year.Month:
????????$Date_MonthNum_DayNum_Year.Month._value: integer [1...12]
????????$Date_MonthNum_DayNum_Year.Month._attributes.name: string ["Explicit"]
$Date_MonthNum_DayNum_Year.Day:
????????$Date_MonthNum_DayNum_Year.Day._value: integer [1...31]
????????$Date_MonthNum_DayNum_Year.Day._attributes.name: string ["Explicit"]
$Date_MonthNum_DayNum_Year.Year: 
????????$Date_MonthNum_DayNum_Year.Year._value: integer [1900...2099]
????????$Date_MonthNum_DayNum_Year.Year._attributes.name: string ["Assumed"]

Date_Relative

$Date_Relative.Day.IsValidDate: string ["true", "false"]
$Date_Relative.Month:
$Date_Relative.Month._value: integer [1...12]
$Date_Relative.Month._attributes.name: string ["Assumed", "Derived"]
$Date_Relative.Day:
$Date_Relative.Day._value: integer [1...31]
$Date_Relative.Day._attributes.name: string ["Assumed", "Derived"]
$Date_Relative.Year:
$Date_Relative.Year._value: integer [1900...2099]
$Date_Relative.Year._attributes.name: string ["Derived"]
$Date_Relative.AlternateMonth (Optional):
$Date_Relative.AlternateMonth._value: integer [1...12]
$Date_Relative.AlternateDay (Optional):
$Date_Relative.AlternateDay._value: integer [1...31]
$Date_Relative.AlternateYear (Optional):
$Date_Relative.AlternateYear._value: integer [1900...2099]

Date_MonthNum_Year

$Date_MonthNum_Year.IsValidDate: string ["true", "false"]
$Date_MonthNum_Year.Month:
????????$Date_MonthNum_Year.Month._value: integer [1...12]
????????$Date_MonthNum_Year.Month._attributes.name: string ["Explicit"]
$Date_MonthNum_Year.Year: 
????????$Date_MonthNum_Year.Year._value: integer [1900...2099]
????????$Date_MonthNum_Year.Year._attributes.name: string ["Derived", "Explicit"]
????????$Date_MonthNum_Year.Year._attributes.form: string ["ShortForm", "LongForm", "Relative"]

Date_Month_Year

$Date_Month_Year.IsValidDate: string ["true", "false"]
$Date_Month_Year.Month:
????????$Date_Month_Year.Month._value: integer [1...12]
????????$Date_Month_Year.Month._attributes.name: string ["Explicit"]
$Date_Month_Year.Year: 
????????$Date_Month_Year.Year._value: integer [1900...2099]
????????$Date_Month_Year.Year._attributes.name: string ["Derived", "Explicit"]
????????$Date_Month_Year.Year._attributes.form: string ["ShortForm", "LongForm", "Relative"]

Date_Weekday

$Date_Weekday._value : integer [1...7] Sunday=1, Monday=2, ..., Saturday=7

Date_Month

$Date_Month._value: integer [1...12]

Date_MonthNum

$Date_MonthNum._value: integer [1...12]

Date_DayNum

$Date_DayNum._value: integer [1...31]

Date_Year

$Date_Year._value: integer [1900...2099]
$Date_Year._attributes.name: string ["Derived", "Explicit"]
$Date_Year._attributes.form: string ["Long Form", "Short Form", "Relative"]
Bb858315.note(en-us,office.12).gifNote:
The Date_Year rule supports years between 1900 and 2099. If the caller specifies only the last two digits (DD) of a year, the behavior is as follows: If DD > 30 returns 20DD; else if DD ??? 30 returns 19DD.

Examples: Date_MonthNum_DayNum

Example 1

Assume that the current date is Monday, April 4, 2005.

User says "Three three."

SML returned by the recognition engine.

<SML text="three three" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Explicit">3</Day>

????????<Month confidence="1.000" name="Explicit">3</Month>

????????<Year confidence="1.000" name="Assumed">2006</Year>

????????<AlternateYear confidence="1.000">2005</AlternateYear>

????????<IsValidDate confidence="1.000">true</IsValidDate>

</SML>

Example 2

Assume that the current date is Monday, April 4, 2005.

User says "Five three."

SML returned by the recognition engine.

<SML text="five three" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Explicit">5</Day>

????????<Month confidence="1.000" name="Explicit">3</Month>

????????<Year confidence="1.000" name="Assumed">2006</Year>

????????<AlternateYear confidence="1.000">2005</AlternateYear>

????????<IsValidDate confidence="1.000">true</IsValidDate>

</SML>

Example: Date_Month_Day

Example 1

Assume that the current date is Monday, April 4, 2005.

User says "Tuesday March second."

SML returned by the recognition engine.

<SML text="Tuesday March second" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Explicit">2</Day>

????????<Month confidence="1.000" name="Explicit">3</Month>

????????<Year confidence="1.000" name="Assumed">2006</Year>

????????<AlternateYear confidence="1.000">2005</AlternateYear>

????????<IsValidDate confidence="1.000">true</IsValidDate>

</SML>

Example: Date_Day_Month

Example 1

Assume that the current date is Monday, April 4, 2005.

User says "Tuesday the second of March."

SML returned by the recognition engine.

<SML text="Tuesday the second of March" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Explicit">2</Day>

????????<Month confidence="1.000" name="Explicit">3</Month>

????????<Year confidence="1.000" name="Assumed">2006</Year>

????????<AlternateYear confidence="1.000">2005</AlternateYear>

????????<IsValidDate confidence="1.000">true</IsValidDate>

</SML>

Examples: Date_Month_Day_Year

Example 1

Assume that the current date is Monday, April 4, 2005.

User says "Tuesday March second two thousand five."

SML returned by the recognition engine.

<SML text="Tuesday March second two thousand five" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Explicit">2</Day>

????????<Month confidence="1.000" name="Explicit">3</Month>

????????<IsValidDate confidence="1.000">true</IsValidDate>

????????<Year confidence="1.000" name="Explicit" form="Long Form">2005</Year>

</SML>

Example 2

Assume that the current date is Monday, April 4, 2005.

User says "Tuesday March second oh five."

SML returned by the recognition engine.

<SML text="Tuesday March second oh five" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Explicit">2</Day>

????????<Month confidence="1.000" name="Explicit">3</Month>

????????<IsValidDate confidence="1.000">true</IsValidDate>

????????<Year confidence="1.000" name="Explicit" form="Short Form">2005</Year>

</SML>

Examples: Date_Year

Example 1

User says "Nineteen ninety seven."

SML returned by the recognition engine.

<SML text="nineteen ninety seven" utteranceConfidence="1.000" confidence="1.000" name="Explicit" form="Long Form ">1997</SML>

Example 2

User says "ninety seven."

SML returned by the recognition engine.

<SML text="ninety seven" utteranceConfidence="1.000" confidence="1.000" name="Derived" form="Short Form">1997</SML>

Examples: Date_Relative

Example 1

Assume that the current date is Monday, April 4, 2005.

User says "Sunday."

SML returned by the recognition engine.

<SML text="Sunday" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Derived">10</Day>

????????<Month confidence="1.000" name="Derived">4</Month>

????????<Year confidence="1.000" name="Derived">2005</Year>

????????<AlternateMonth confidence="1.000">4</AlternateMonth>

????????<AlternateYear confidence="1.000">2005</AlternateYear>

????????<AlternateDay confidence="1.000">3</AlternateDay>

????????<IsValidDate confidence="1.000">true</IsValidDate>

</SML>

Example 2

Assume that the current date is Monday, April 4, 2005.

User says "Next Sunday."

SML returned by the recognition engine.

<SML text="next Sunday" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Derived">10</Day>

????????<Month confidence="1.000" name="Derived">4</Month>

????????<Year confidence="1.000" name="Derived">2005</Year>

????????<AlternateMonth confidence="1.000">4</AlternateMonth>

????????<AlternateYear confidence="1.000">2005</AlternateYear>

????????<AlternateDay confidence="1.000">17</AlternateDay>

????????<IsValidDate confidence="1.000">true</IsValidDate>

</SML>

Example 3

Assume that the current date is Monday, April 4, 2005.

User says "Last Sunday."

SML returned by the recognition engine.

<SML text="last Sunday" utteranceConfidence="1.000" confidence="1.000">

????????<Day confidence="1.000" name="Derived">10</Day>

????????<Month confidence="1.000" name="Derived">4</Month>

????????<Year confidence="1.000" name="Derived">2005</Year>

????????<AlternateMonth confidence="1.000">3</AlternateMonth>

????????<AlternateYear confidence="1.000">2005</AlternateYear>

????????<AlternateDay confidence="1.000">27</AlternateDay>

????????<IsValidDate confidence="1.000">true</IsValidDate>

</SML>