Date Rule for Spanish (United States)
Allows dialogue authors to retrieve a date. Dates are composed of three main elements that are always returned by the library: Day, Month, and Year. If some main elements are not mentioned in an utterance, it is derived or assumed by the module based on the context of the utterance and the rule in use. In some cases, other elements are returned by the library, for example, DayOfWeek, AlternativeDay, AlternativeWeek, and AlternativeYear.
The following three types of dates can be retrieved. Future and past dates for each type can be retrieved.
Date Type | Description |
---|---|
Precise Date | A precise date (Day, Month, and Year) for which the elements are either uttered or derived (or assumed) from the context of the utterance. |
U.S. Holiday | The precise date of a U.S. holiday. |
Evaluated Relative Date | The precise date is computed, based on an utterance that contains no specific date elements, and using the context of the utterance. |
Date Recognition Notes:
- Recognizes the phrases "este año," "el año pasado," and "el próximo año."
- Recognizes "este," "pasado/pasada" and "próximo/próxima" as qualifiers to date elements (for example, holidays, days, months, years and days of week).
- Recognizes short forms of the year element, for example, "noventa y ocho" is returned as 1998 when the utterance is in the context of the year element.
- Assumes the form mm dd yy for integer date utterances.
- Returns noreco for obvious invalid dates (for example, "el treinta de febrero").
- Recognizes "el veintinueve de febrero"; however, it will be marked as an invalid date for years that are not leap years. (See the following example.)
Precise Date
Rules
- Date. When the Date rule is activated, the following rules are also activated.
- precise_date
- USHoliday
- evaluated_relative_date
- DateFuture. When the DateFuture rule is activated, the following rules are also activated.
- precise_date_future
- USHoliday_future
- evaluated_relative_date_future
- DatePast. When the DatePast rule is activated, the following rules are also activated.
- precise_date_past
- USHoliday_past
- evaluated_relative_date_past
The Date, DateFuture, and DatePast rules are also exposed to dialogue authors. These rules can be activated in dialogues requiring certain restrictions on the date being retrieved.
Usage
<ruleref uri="cmnrules.cfg#Date" />
<ruleref uri="cmnrules.cfg#DateFuture" />
<ruleref uri="cmnrules.cfg#DatePast" />
Using the DateFuture rule as an example, the grammar can be
<grammar version="1.0" mode="voice" root="Rule1" tag-format="semantics-ms/1.0"
xml:lang="es-US" xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="https://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">
<rule id="Rule1">
<ruleref uri="cmnrules.cfg#DateFuture" />
<tag>$ = $$</tag>
</rule>
</grammar>
Rules
- precise_date
- precise_date_future. The precise_date_future rule favors future dates if there is any ambiguity. It accepts the exact same set of sentences as rule precise_date.
- precise_date_past. The precise_date_past rule favors past dates if there is any ambiguity. It accepts the exact same set of sentences as rule precise_date.
Usage
<ruleref uri="cmnrules.cfg#precise_date" />
<ruleref uri="cmnrules.cfg#precise_date_future" />
<ruleref uri="cmnrules.cfg#precise_date_past" />
Using the precise_date rule as an example, the grammar can be
<grammar version="1.0" mode="voice" root="Rule1" tag-format="semantics-ms/1.0"
xml:lang="es-US" xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="https://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">
<rule id="Rule1">
<ruleref uri="cmnrules.cfg#precise_date" />
<tag>$ = $$</tag>
</rule>
</grammar>
JScript Objects
$precise_date.Year : $Year
$precise_date.Month._value : integer
$precise_date.Month._attributes.name : string ("Derived", "Assumed", "Common")
$precise_date.Day._value : integer
$precise_date.Day._attributes.name : string ("Common")
$precise_date._attributes.name : string ("PreciseDate")
Examples: precise_date rule
Example 1
User says: el primero de julio del año dos mil. All three main elements of the date are recognized.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" text="el primero de julio del año dos mil" utteranceConfidence="1.000">
<Year confidence="1.000" name="CompleteForm" text="año dos mil">2000</Year>
<Month confidence="1.000" text="julio" name="Common">7</Month>
<Day confidence="1.000" text="el primero" name="Common">1</Day>
</SML>
Example 2
User says: mayo uno del pasado año All three main elements of the date are recognized. The year is based on the current system date.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" text="mayo uno del pasado año" utteranceConfidence="1.000">
<Year confidence="1.000" name="Derived" text="pasado año">2001</Year>
<Month confidence="1.000" text="mayo" name="Common">5</Month>
<Day confidence="1.000" text="uno" name="Common">1</Day>
</SML>
Example 3
User says: mayo primero del noventa y ocho All three main elements of the date are recognized.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" text="mayo primero del noventa y ocho" utteranceConfidence="1.000">
<Year confidence="1.000" name="ShortForm" text="noventa y ocho">1998</Year>
<Month confidence="1.000" text="mayo" name="Common">5</Month>
<Day confidence="1.000" text="primero" name="Common">1</Day>
</SML>
Example 4
User says: el primero de julio Two of the three main elements of the date are recognized. The year returned is the current year.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" text="el primero de julio" utteranceConfidence="1.000">
<Year name="Assumed" confidence="1.000">2002</Year>
<Month confidence="1.000" text="julio" name="Common">7</Month>
<Day confidence="1.000" text="primero" name="Common">1</Day>
</SML>
Example 5
Assume the current date is Monday, August 19, 2002. User says: el cinco del mes que viene
One of the three main elements of the date is recognized. The year returned is the current year. The month returned is relative to the current month.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" text="el cinco del mes que viene" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000" text="mes que viene">2002</Year>
<Month confidence="1.000" name="Derived" text="mes que viene">9</Month>
<Day confidence="1.000" text="el cinco" name="Common">5</Day>
</SML>
Example 6
Assume the current date is Wednesday, February 6, 2002. User says: el cinco
One of the three main elements of the date is recognized. The year returned is the current year. The month returned is the current month.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" text="el cinco" utteranceConfidence="1.000">
<Year name="Assumed" confidence="1.000">2002</Year>
<Month confidence="1.000" name="Assumed">2</Month>
<Day confidence="1.000" text="el cinco" name="Common">5</Day>
</SML>
Example 7
User says: cuatro once del setenta y dos All three main elements of the date are recognized.
SML returned by the recognition engine:
<SML confidence="1.000" text="cuatro de once del setenta y dos" utteranceConfidence="1.000">
<Year confidence="1.000" name="ShortForm" text="setenta y dos">1972</Year>
<Month confidence="1.000" text="once" name="Common">11</Month>
<Day confidence="1.000" text="cuatro" name="Common">4</Day>
</SML>
Example 8
User says: el veintinueve de febrero del año dos mil cuatro This is a valid leap year date.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" text="el veintinueve de febrero del año dos mil cuatro" utteranceConfidence="1.000">
<Year confidence="1.000" name="CompleteForm" text="dos mil cuatro">2004</Year>
<Month confidence="1.000" text="febrero" name="Common">2</Month>
<Day confidence="1.000" text="veintinueve" name="Common">29</Day>
</SML>
Example 9
Assume the current date is Wednesday, February 6, 2002. User says: el veintinueve de febrero de este año
This date is invalid.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" invalidDate="true" text="el veintinueve de febrero de este año" utteranceConfidence="1.000">
<Year confidence="1.000" name="Derived" text="este año">2002</Year>
<Month confidence="1.000" text="febrero" name="Common">2</Month>
<Day confidence="1.000" text="veintinueve" name="Common">29</Day>
</SML>
Examples: precise_date_future rule
Example 1
Assume the current date is Monday, August 19, 2002. User says: el primero de enero
Two of the three main elements of the date are recognized. Because the active rule favors future dates, the year is returned as the year in which the month next occurs.
SML returned by the recognition engine:
<SML confidence="1.000" name="el primero de enero" utteranceConfidence="1.000">
<Year name="Assumed" confidence="1.000">2003</Year>
<Month confidence="1.000" text="enero" name="Common">1</Month>
<Day confidence="1.000" text="primero" name="Common">1</Day>
</SML>
Example 2
Assume the current date is Wednesday, February 6, 2002. User says: el cinco
One of the three main elements of the date is recognized. Because the active rule favors future dates, the month returned is the month in which the day ("the 5th") next occurs. The year returned is the current year.
SML returned by the recognition engine:
<SML confidence="1.000" name="PreciseDate" text="el cinco" utteranceConfidence="1.000">
<Year name="Assumed" confidence="1.000">2002</Year>
<Month confidence="1.000" name="Assumed">4</Month>
<Day confidence="1.000" text="cinco" name="Common">5</Day>
</SML>
U.S. Holiday
Recognizes the following U.S. holidays:
Día de Año Nuevo, Día del amor, Día de San Valentín, Día de los presidentes, Día de Martin Luther King, Día de la recordación, Día de la Independencia, Día de la Raza, Víspera de Navidad, Día de Navidad, Viernes Santo, Año Nuevo, Domingo de Pascua, Lunes de resurrección, Día de la madre, Día de los padres, Día del trabajo, Acción de gracias , Navidad, Víspera de Año Nuevo. |
Rules
- USHoliday
- USHoliday_future. The USHoliday_future rule favors future dates if there is any ambiguity. It accepts the same set of sentences as the USHoliday rule.
- USHoliday_past. The USHoliday_past rule favors past dates if there is any ambiguity. It accepts the same set of sentences as the USHoliday rule.
Usage
<ruleref uri="cmnrules.cfg#USHoliday" />
<ruleref uri="cmnrules.cfg#USHoliday_future" />
<ruleref uri="cmnrules.cfg#USHoliday_past" />
Using the USHoliday rule as an example, the grammar can be
<grammar version="1.0" mode="voice" root="Rule1" tag-format="semantics-ms/1.0"
xml:lang="es-US" xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="https://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">
<rule id="Rule1">
<ruleref uri="cmnrules.cfg#USHoliday" />
<tag>$ = $$</tag>
</rule>
</grammar>
JScript Objects
$USHoliday.Year : $Year
$USHoliday.Month._value : integer
$USHoliday.Month._attributes.name : string ("Derived")
$USHoliday.Day._value : integer
$USHoliday.Day._attributes.name : string ("Derived")
$USHoliday.Holiday : string ("Christmas", "Easter", "LaborDay"...)
$USHoliday._attributes.name : string ("Holiday")
Examples: USHoliday
Example 1
Assume the current date is Monday, August 19, 2002. User says: Navidad
The USHoliday rule Date Library returns the date of the next Christmas. The USHoliday_future rule would return the same date.
SML returned by the recognition engine:
<SML confidence="1.000" name="Holiday" text="Navidad" utteranceConfidence="1.000">
<Year name="Assumed" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">12</Month>
<Day name="Derived" confidence="1.000">25</Day>
<Holiday confidence="1.000" text="Navidad">Christmas</Holiday>
</SML>
Example 2
Assume the current date is Monday, August 19, 2002. User says: el Domingo de Pascua pasado
SML returned by the recognition engine:
<SML confidence="1.000" name="Holiday" text="el Domingo de Pascua pasado" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">3</Month>
<Day name="Derived" confidence="1.000">31</Day>
<Holiday confidence="1.000" text="Domingo de Pascua">Easter</Holiday>
</SML>
Example 3
Assume the current date is Monday, August 19, 2002. User says: Domingo de Pascua del próximo año
SML returned by the recognition engine:
<SML confidence="1.000" name="Holiday" text="Domingo de Pascua del próximo año" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2003</Year>
<Month name="Derived" confidence="1.000">4</Month>
<Day name="Derived" confidence="1.000">20</Day>
<Holiday confidence="1.000" text="Domingo de Pascua">Easter</Holiday>
</SML>
Example 4
Assume the current date is Monday, August 19, 2002. User says: este Día de las madres
SML returned by the recognition engine:
<SML confidence="1.000" name="Holiday" text="este Día de las madres" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">5</Month>
<Day name="Derived" confidence="1.000">12</Day>
<Holiday confidence="1.000" text="Día de las madres">MothersDay</Holiday>
</SML>
Example 5
Assume the current date is Monday, August 19, 2002. User says: el Día del trabajo del año próximo
SML returned by the recognition engine:
<SML confidence="1.000" name="Holiday" text="el Día del trabajo del año próximo" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2003</Year>
<Month name="Derived" confidence="1.000">9</Month>
<Day name="Derived" confidence="1.000">1</Day>
<Holiday confidence="1.000" text="el Día del trabajo">LaborDay</Holiday>
</SML>
Examples: USHoliday_future rule
Example 1
Assume current date is Monday, August 19, 2002. User says: Año Nuevo
SML returned by the recognition engine:
<SML confidence="1.000" name="Holiday" text="Año Nuevo" utteranceConfidence="1.000">
<Year name="Assumed" confidence="1.000">2003</Year>
<Month name="Derived" confidence="1.000">1</Month>
<Day name="Derived" confidence="1.000">1</Day>
<Holiday confidence="1.000" text="Año Nuevo">NewYear</Holiday>
</SML>
Evaluated Relative date
Rules
- evaluated_relative_date
- evaluated_relative_date_future
- evaluated_relative_date_past
Usage
<ruleref uri="cmnrules.cfg#evaluated_relative_date" />
<ruleref uri="cmnrules.cfg#evaluated_relative_date_future" />
<ruleref uri="cmnrules.cfg#evaluated_relative_date_past" />
Using the evaluated_relative_date rule as an example, the grammar can be
<grammar version="1.0" mode="voice" root="Rule1" tag-format="semantics-ms/1.0"
xml:lang="es-US" xmlns="http://www.w3.org/2001/06/grammar"
xmlns:sapi="https://schemas.microsoft.com/Speech/2002/06/SRGSExtensions">
<rule id="Rule1">
<ruleref uri="cmnrules.cfg#evaluated_relative_date" />
<tag>$ = $$</tag>
</rule>
</grammar>
JScript Objects
$evaluated_relative_date.Year : $Year
$evaluated_relative_date.Month._value : integer
$evaluated_relative_date.Month._attributes.name : string ("Derived")
$evaluated_relative_date.Day._value : integer
$evaluated_relative_date.Day._attributes.name : string ("Derived")
$evaluated_relative_date._attributes.name : string ("EvaluatedRelativeDate")
$evaluated_relative_date.AlternativeDateCode : string ("Yesterday", "tomorrow")
$evaluated_relative_date.AlternativeYear : $Year
$evaluated_relative_date.AlternativeMonth._value : integer
$evaluated_relative_date.AlternativeMonth._attributes.name : string ("Derived")
$evaluated_relative_date.AlternativeDay._value : integer
$evaluated_relative_date.AlternativeDay._attributes.name : string ("Derived")
Examples: evaluated_relative_date rule
Example 1
Assume the current date is Monday, August 19, 2002. User says: hoy
SML returned by the recognition engine:
<SML confidence="1.000" text="hoy" utteranceConfidence="1.000" name="EvaluatedRelativeDate">
<Year confidence="1.000" text="hoy" name="Derived">2002</Year>
<Month confidence="1.000" text="hoy" name="Derived">8</Month>
<Day confidence="1.000" text="hoy" name="Derived">19</Day>
</SML>
Example 2
Assume the current date is Monday, August 19, 2002. User says: hace dos días
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="hace dos días" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">17</Day>
</SML>
Example 3
Assume the current date is Monday, August 19, 2002. User says: miércoles
Because the evaluated_relative_date rule was not provided a preference, the Date rule returns the date for the Wednesday occurring during the same week (Monday through Sunday) as the current date.
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="miércoles" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">21</Day>
</SML>
Example 4
Assume the current date is Monday, August 19, 2002. User says: el próximo miércoles
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="el próximo miércoles" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">21</Day>
</SML>
Example 5
Assume the current date is Monday, August 19, 2002. User says: este miércoles no el próximo.
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="este miércoles no el próximo" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">28</Day>
</SML>
Example 6
Assume the current date is Monday, August 19, 2002. User says: el miércoles antepasado
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="el miércoles antepasado" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">7</Day>
</SML>
Example 7
Assume the current date is Monday, August 19, 2002. User says: de aquí a dos semanas
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="de aquí a dos semanas" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">9</Month>
<Day name="Derived" confidence="1.000">2</Day>
</SML>
Example 8
Assume the current date is Monday, August 19, 2002. User says: un mes después del próximo miércoles
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="un mes después del próximo miércoles" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">9</Month>
<Day name="Derived" confidence="1.000">21</Day>
</SML>
Examples: evaluated_relative_date_future rule
Example 1
Assume the current date is Monday, August 19, 2002. User says: miércoles
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="miércoles" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">21</Day>
</SML>
Example 2
Assume the current date is Wednesday, August 21, 2002. User says: miércoles
Because the rule is a future rule, the Date ruleset interprets the utterance as referring to the next occurring Wednesday.
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="miércoles" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">28</Day>
</SML>
Example 3
Assume the current date is Monday, August 19, 2002. User says: este miércoles
Because the rule is a future rule, the Date ruleset interprets the utterance as referring to the next occurring Wednesday. The following SML output is the same as the SML output returned in Example 2 (of evaluated_relative_date_future rule).
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="este miércoles" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">21</Day>
</SML>
Example 4
Assume the current date is Monday, August 19, 2002. User says: el próximo miércoles
The Date ruleset interprets the utterance as referring to the next occurring Wednesday.
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="el próximo miércoles" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">21</Day>
</SML>
Example 5
Assume current date is Monday, August 19, 2002. User says: el próximo martes
Because the day spoken is so near (in the future) to the current day, the Date ruleset returns the next occurring Tuesday and the Tuesday after as an alternative.
SML returned by the recognition engine:
<SML confidence="1.000" name="EvaluatedRelativeDate" text="el próximo martes" utteranceConfidence="1.000">
<Year name="Derived" confidence="1.000">2002</Year>
<Month name="Derived" confidence="1.000">8</Month>
<Day name="Derived" confidence="1.000">27</Day>
</SML>