如何访问Luis中的实体价值



我想打印Luis门户中已经定义的实体的值,我已经打印了TopIntent,但我需要访问实体并打印它的值

根据MS文档:

您可以获取实体和子实体,例如:

modelObject = client.model.get_entity(app_id, versionId, modelId)
toppingQuantityId = get_grandchild_id(modelObject, "Toppings", "Quantity")
pizzaQuantityId = get_grandchild_id(modelObject, "Pizza", "Quantity")

如果你想从运行时获得预测,例如:

# Production == slot name
predictionRequest = { "query" : "I want two small pepperoni pizzas with more salsa" }
predictionResponse = clientRuntime.prediction.get_slot_prediction(app_id, "Production", predictionRequest)
print("Top intent: {}".format(predictionResponse.prediction.top_intent))
print("Sentiment: {}".format (predictionResponse.prediction.sentiment))
print("Intents: ")
for intent in predictionResponse.prediction.intents:
print("t{}".format (json.dumps (intent)))
print("Entities: {}".format (predictionResponse.prediction.entities))

您可以参考如何使用python从Microsoft LUIS中提取实体?

最新更新