首页 > 解决方案 > 将 azure luis 输出提取到熊猫数据框

问题描述

在 luis 服务中发布了一个应用程序,希望通过 python 以编程方式使用它

from azure.cognitiveservices.language.luis.runtime import LUISRuntimeClient
from msrest.authentication import CognitiveServicesCredentials

// Create client with SubscriptionKey and Endpoint
client = LUISRuntimeClient(
'https://westus.api.cognitive.microsoft.com',             # Change "westus" to your region if necessary
CognitiveServicesCredentials("[LUIS_SUBSCRIPTION_KEY]"),  # Put your LUIS Subscription key
)

// Predict
 df['utternace'].apply(lambda x: client.prediction.resolve('XXXXXXXXXXXXX',x)) 

(XXXXXXX 是应用程序 ID)

输出未根据文档提供分数

{'additional_properties': {}, 'query': 'implication the entity may not be able to monitor details effectively ', 'altered_query': None, 'top_scoring_intent': **<azure.cognitiveservices.language.luis.runtime.models.intent_model_py3.IntentModel object at 0x000001FEBBC81588>**, 'intents': None, 'entities': [], 'composite_entities': None, 'sentiment_analysis': **<azure.cognitiveservices.language.luis.runtime.models.sentiment_py3.Sentiment object at 0x000001FEBBC810B8>}**

从文档输出应该是这样的

样本输出: 在此处输入图像描述

如何将 LUIS 结果提取到熊猫数据框

标签: pythonpandasazureazure-language-understanding

解决方案


推荐阅读