我是 LUIS 的新手,我仍在努力解决问题,我似乎无法弄清楚的一件事是,当一个语句中有多个实例时,如何让我的 LUIS 应用识别哪些实体属于同一复合实体。我知道这很令人困惑,让我尝试更好地解释:
我的测试应用程序是关于订购东西的。
我有这样的话:
请为我购买 2 个红辣椒 albuns 和一个惊人的蜘蛛侠人物
返回的 JSON 是这样的:
{
"query": "purchase for me 2 red hot chilli pepper albuns and an amazing spiderman figure please",
"topScoringIntent": {
"intent": "Order",
"score": 0.9981847
},
"intents": [
{
"intent": "Order",
"score": 0.9981847
},
{
"intent": "Read",
"score": 0.0023417694
},
{
"intent": "None",
"score": 0.00118408469
}
],
"entities": [
{
"entity": "red hot chilli pepper albuns",
"type": "Item.Description",
"startIndex": 18,
"endIndex": 45,
"score": 0.8821352
},
{
"entity": "amazing spiderman figure",
"type": "Item.Description",
"startIndex": 54,
"endIndex": 77,
"score": 0.9167113
},
{
"entity": "2",
"type": "Item.Quantity",
"startIndex": 16,
"endIndex": 16,
"score": 0.9843564
},
{
"entity": "an",
"type": "Item.Quantity",
"startIndex": 51,
"endIndex": 52,
"score": 0.948889554
}
]
}
它正确识别实体,但它不知道"2"对应于"红辣椒albuns","an"对应于"惊人的蜘蛛侠人物">
我的实体是:
Item.Quantity - simple entity
Item.Description - simple entity
Item.Number - simple entity
Item - composite entity with the above as children
这甚至可能做到吗?
是的,这是完全可能的。而且您走在使用复合实体的正确轨道上,只是需要更改复合实体的训练。首先,对于复合实体,应添加和训练子实体(您已经这样做了)。
接下来是标记复合实体。转到订单意图,对于任何话语,让我们说:
为我购买 2 个红辣椒 albuns
选择Item.Quantity
实体,然后从列表中选择包装复合实体。在单词下方将出现一条绿线,现在将光标向右移动,直到红辣椒albuns(或直到您要包装的任何实体),您会注意到绿线后面表示复合实体。从显示的列表中选择复合名称Item
。
对于同一话语中的多个复合实体,例如
请为我购买 2 个红辣椒 albuns 和一个惊人的蜘蛛侠人物
重复相同的过程,只是第一个复合实体将被包装并训练2 red hot chilli pepper albuns
,下一个复合实体将被包装和训练以an amazing spiderman figure
不要忘记训练和发布 LUIS 应用。
若要更深入地了解复合实体,请参阅 Luis 教程 - 复合实体