Important
语言理解智能服务(LUIS)将于 2026 年 3 月 31 日完全停用。 LUIS 资源创建不可用。 从 2025 年 10 月 31 日开始,LUIS 门户将不再可用。 建议将 LUIS 应用程序迁移到对话语言理解,以便从持续的产品支持和多语言功能中受益。
The datetimeV2 prebuilt entity extracts date and time values. 将以标准化格式解析这些值,使客户端程序能够使用它们。 当某条陈述包含不完整的日期或时间时,LUIS 会在终结点响应中包含过去的值和未来的值。 由于此实体已经过训练,因此不需要将包含 datetimeV2 的陈述示例添加到应用程序意向中。
datetimeV2 的类型
DatetimeV2 is managed from the Recognizers-text GitHub repository.
Example JSON
下面显示了以下话语及其部分 JSON 响应。
8am on may 2nd 2019
"entities": {
"datetimeV2": [
{
"type": "datetime",
"values": [
{
"timex": "2019-05-02T08",
"resolution": [
{
"value": "2019-05-02 08:00:00"
}
]
}
]
}
]
}
datetimeV2 的子类型
The datetimeV2 prebuilt entity has the following subtypes, and examples of each are provided in the table that follows:
date
time
daterange
timerange
datetimerange
解析值
- 如果陈述中的日期或时间已完全指定且没有歧义,则数组包含一个元素。
- 如果 datetimeV2 值歧义,则数组包含两个元素。 歧义性包括缺少特定的年份、时间或时间范围。 See Ambiguous dates for examples. 不确定时间是上午还是下午时,将包括这两个值。
- 如果陈述包含两个有歧义的元素,则数组包含四个元素。 这种歧义性包括具有以下特征的元素:
- 日期或日期范围在年份方面存在歧义
- 上下午不确定的时间或时间范围,例如 4 月 3 日 3 点。
values
数组的每个元素可以包含以下字段:
Property name | Property description |
---|---|
timex | 时间、日期或日期范围以 TIMEX 格式表示,格式遵循 ISO 8601 标准,以及使用 TimeML 语言进行批注的 TIMEX3 属性。 |
mod | 术语,用于说明如何使用 before 、after 等值。 |
类型 | 子类型,可以是下述项目之一:datetime 、date 、time 、daterange 、timerange 、datetimerange 、duration 、set 。 |
value | Optional. 采用 yyyy-MM-dd(日期)、HH:mm:ss(时间)、yyyy-MM-dd HH:mm:ss(日期/时间)格式的日期/时间对象。 如果 type 为 duration ,则值是秒数(持续时间)仅当 type 为 datetime 、date 、time 或 `duration 时才使用。 |
有效日期值
The datetimeV2 supports dates between the following ranges:
Min | Max |
---|---|
1900 年 1 月 1 日 | 2099 年 12 月 31 日 |
Ambiguous dates
如果日期可以是过去或未来的日期,则 LUIS 会提供这两个值。 包括年份中的月份和日期的陈述就是一个例子。
例如,给定以下话语:
May 2nd
- 如果今天的日期是 2017 年 5 月 3 日,则 LUIS 会提供“2017-05-02”和“2018-05-02”作为值。
- 如果今天的日期是 2017 年 5 月 1 日,则 LUIS 会提供“2016-05-02”和“2017-05-02”作为值。
以下示例显示了实体“5 月 2 日”的解析。 此解析假设今天的日期是 2017 年 5 月 2 日和 2018 年 5 月 1 日之间的某个日期。
在 X
字段中包含 timex
的字段是未在陈述中显式指定的日期的一部分。
日期解析示例
下面显示了以下话语及其部分 JSON 响应。
May 2nd
"entities": {
"datetimeV2": [
{
"type": "date",
"values": [
{
"timex": "XXXX-05-02",
"resolution": [
{
"value": "2019-05-02"
},
{
"value": "2020-05-02"
}
]
}
]
}
]
}
数字日期的日期范围解析示例
datetimeV2
实体提取日期和时间范围。
start
和 end
字段指定范围的开始和结束。 For the utterance May 2nd to May 5th
, LUIS provides daterange values for both the current year and the next year. 在 timex
字段中,XXXX
值指示年份的歧义性。
P3D
指示时间段为三天。
下面显示了以下话语及其部分 JSON 响应。
May 2nd to May 5th
"entities": {
"datetimeV2": [
{
"type": "daterange",
"values": [
{
"timex": "(XXXX-05-02,XXXX-05-05,P3D)",
"resolution": [
{
"start": "2019-05-02",
"end": "2019-05-05"
},
{
"start": "2020-05-02",
"end": "2020-05-05"
}
]
}
]
}
]
}
星期日期的日期范围解析示例
The following example shows how LUIS uses datetimeV2 to resolve the utterance Tuesday to Thursday
. 在此示例中,当前日期为 6 月 19 日。 LUIS includes daterange values for both of the date ranges that precede and follow the current date.
下面显示了以下话语及其部分 JSON 响应。
Tuesday to Thursday
"entities": {
"datetimeV2": [
{
"type": "daterange",
"values": [
{
"timex": "(XXXX-WXX-2,XXXX-WXX-4,P2D)",
"resolution": [
{
"start": "2019-10-08",
"end": "2019-10-10"
},
{
"start": "2019-10-15",
"end": "2019-10-17"
}
]
}
]
}
]
}
Ambiguous time
如果时间或时间范围歧义,values 数组将包含两个 time 元素。 如果时间的上下午不确定,则值会同时包含上午时间和下午时间。
时间范围解析示例
DatetimeV2 JSON 响应在 API V3 中已更改。 The following example shows how LUIS uses datetimeV2 to resolve the utterance that has a time range.
自 API V2 以来的更改:
-
datetimeV2.timex.type
属性不再返回,因为它在父级别datetimev2.type
返回。 -
datetimeV2.value
属性已重名为datetimeV2.timex
。
下面显示了以下话语及其部分 JSON 响应。
from 6pm to 7pm
以下 JSON 的 verbose
参数设置为 false
:
"entities": {
"datetimeV2": [
{
"type": "timerange",
"values": [
{
"timex": "(T18,T19,PT1H)",
"resolution": [
{
"start": "18:00:00",
"end": "19:00:00"
}
]
}
]
}
]
}
时间解析示例
下面显示了以下话语及其部分 JSON 响应。
8am
"entities": {
"datetimeV2": [
{
"type": "time",
"values": [
{
"timex": "T08",
"resolution": [
{
"value": "08:00:00"
}
]
}
]
}
]
}
已弃用的预生成日期时间
The datetime
prebuilt entity is deprecated and replaced by datetimeV2.
若要在 LUIS 应用中将 datetime
替换为 datetimeV2
,请完成以下步骤:
- Open the Entities pane of the LUIS web interface.
- Delete the datetime prebuilt entity.
- 选择“添加预生成的实体”
- Select datetimeV2 and click Save.