【发布时间】:2018-05-28 08:24:27
【问题描述】:
(4) [{…}, {…}, {…}, {…}]
0: {entity: "lovely meeting", type: "Calendar.Subject", startIndex: 53, endIndex: 66, score: 0.9183444}
1: {entity: "california", type: "Calendar.Location", startIndex: 27, endIndex: 36, score: 0.922538459}
2: {entity: "today", type: "builtin.datetimeV2.date", startIndex: 18, endIndex: 22, resolution: {…}}
3: {entity: "4am", type: "builtin.datetimeV2.time", startIndex: 41, endIndex: 43, resolution: {…}}length: 4__proto__: Array(0)
这 4 个元素是 Entities 的一部分,我想要检查类型是否等于假设 Calender.Location 并且值得注意的是,我们并不总是拥有可以拥有一个或没有的 4 个元素,并且即使我们确实有 4 个实体类型 Calender.Location 不一定是索引号 1,我尝试过的包括 testvar.entities.length 和 testvar.entities[0].type 不知道每个的 ID 是不可能的。
我想要的示例:
我想在实体中解析Json 类型的Calendar.location 输入,它可能存在也可能不存在,并且它的确切ID 未知(范围在0 到4 之间),如果我找到它,我应该返回在这种情况下与它关联的实体california。
【问题讨论】: