Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将LUIS Datetime V2转换为JS Date_Javascript_Node.js_Datetime_Botframework_Azure Language Understanding - Fatal编程技术网

Javascript 将LUIS Datetime V2转换为JS Date

Javascript 将LUIS Datetime V2转换为JS Date,javascript,node.js,datetime,botframework,azure-language-understanding,Javascript,Node.js,Datetime,Botframework,Azure Language Understanding,LUIS Sdk或Bot Sdk中是否有内置的帮助器方法将LUIS DatetimeV2实体转换为JS日期对象?我看到一些人一直在使用C#的慢性解析器,但我找不到任何适用于Nodejs的东西 const dt = builder.EntityRecognizer.findEntity(args.intent.entities, 'datetimeV2'); if (dt) { // this is just the matching intent, I believe. // e

LUIS Sdk或Bot Sdk中是否有内置的帮助器方法将LUIS DatetimeV2实体转换为JS日期对象?我看到一些人一直在使用C#的慢性解析器,但我找不到任何适用于Nodejs的东西

const dt = builder.EntityRecognizer.findEntity(args.intent.entities, 'datetimeV2');
if (dt) {
    // this is just the matching intent, I believe.
    // example intents; today, yesterday, 2/28, 31/5, ...
    // How do I convert this to a valid Date is where I am stuck.
}

要提取NodeJS中的
datetimeV2
实体,更具体的是您需要运行:

const dt = builder.EntityRecognizer.findEntity(args.intent.entities,
    'builtin.datetimeV2.date'); 

const dt_daterange = builder.EntityRecognizer.findEntity(args.intent.entities, 
    'builtin.datetimeV2.daterange');
要创建日期对象,您可以在此处查找

这里有一个on datetimeV2,它显示了LUIS响应对象中实体的结构

要创建日期对象,可以采用
dt.resolution.values[i]['value']
并将其放入构造函数中,如下所示:

const dt_obj = new Date(dt.resolution.values[i]['value']);

谢谢我不知道
IEntity
类型中有
resolution
属性。当
stringify
ing整个
dt
对象时才看到它。这很有魅力!非常感谢。这个答案对我帮助很大。。在我的例子中,我只得到第一个值,所以我这样做:
start\u date=new date(builder.EntityRecognizer.findEntity(intent.entities,'builtin.datetimeV2.daterange')。resolution.values[0].start)