Share via


Time Rules for English (United States)

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.

The Time rules recognize expressions of time based on a 12-hour clock.

When the user does not specify morning or afternoon, the Time rule returns a value in the Hour element representing the hours from 7 A.M. to 6 P.M. as the assumed value and a value in the AlternateHour hour element representing the hours from 7 P.M. to 6 A.M.

The Time rules recognize expressions such as the following: twelve a. m.; seven o'clock; seven thirty p.m.; five minutes before six o'clock p. m.; two past ten; a quarter till ten; half past three o'clock p.m.; three fifteen; six twenty at night; ten of five; two in the morning.

Rules

Time

Time_Hour

Time_HourNum

Time_BeforeAfter

Time_Minute

Time_AmPm

Usage

<ruleref uri="Library.grxml#Time" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Time_Hour" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Time_HourNum" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Time_BeforeAfter" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Time_Minute" type="application/srgs+xml"/>
<ruleref uri="Library.grxml#Time_AmPm" type="application/srgs+xml"/>

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

<grammar xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"
         xml:lang="en-US" 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#Time" type="application/srgs+xml"/>
    <tag>$ = $$</tag>
    </rule>
</grammar>

JScript Objects

Rule Name JScript Objects Returned

Time

$Time.Hour
????????$Time.Hour._value: integer [0...23]
????????$Time.Hour._name: string ["Assumed", "Explicit"]
$Time.Minute
????????$Time.Minute: integer [0...59]
$Time.AlternateHour._value: integer [0...23]

Time_Hour

$Time_Hour
????????$Time_Hour.Hour
????????????????$Time_Hour.Hour._value: integer [0...23]
????????????????$Time_Hour.Hour._name: string ["Assumed", "Explicit"]
????????$Time_Hour.AlternateHour._value: integer [0...23] optional

Time_HourNum

$Time_HourNum
????????$Time_HourNum._value: integer [1...12]

Time_BeforeAfter

$Time_BeforeAfter
????????$Time_BeforeAfter._value: integer [-59...59]

Time_Minute

$Time_Minute
????????$Time_Minute._value: integer [1...59]

Time_AmPm

$Time_AmPm
????????$Time_AmPm._value: string ["AM", "PM"]

Examples: Time

Example 1

User says: "Seven thirty P. M."

SML returned by the recognition engine.

<SML text="seven thirty P. M." utteranceConfidence="1.000" confidence="1.000">

????????<Hour confidence="1.000" name="Explicit">19</Hour>

????????<Minute confidence="1.000">30</Minute>

</SML>

Example 2

User says: "Seven thirty."

SML returned by the recognition engine.

<SML text="seven thirty" utteranceConfidence="1.000" confidence="1.000">

????????<Hour confidence="1.000" name="Assumed">7</Hour>

????????????????<Minute confidence="1.000">30</Minute>

????????????????<AlternateHour confidence="1.000">19</AlternateHour>

</SML>

Examples: Time_BeforeAfter

Example 1

User says: "A quarter after."

SML returned by the recognition engine.

<SML text="a quarter after" utteranceConfidence="1.000" confidence="1.000">15</SML>

Example 2

User says: "Forty three till."

SML returned by the recognition engine.

<SML text="forty three till" utteranceConfidence="1.000" confidence="1.000">-43</SML>

Examples: Time_AmPm

Example 1

User says: "A.M."

SML returned by the recognition engine.

<SML text="A. M." utteranceConfidence="1.000" confidence="1.000">AM</SML>

Example 2

User says: "In the evening."

SML returned by the recognition engine.

<SML text="in the evening" utteranceConfidence="1.000" confidence="1.000">PM</SML>

See Also

Concepts

Voice Mode Grammar Library for English (United States)