python - 将 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 结果提取到熊猫数据框
解决方案
推荐阅读
- java - 读取文件以列出
- matlab - 调用函数中的 MATLAB tic/toc
- python - tf.data.Dataset 对象作为 tf.Keras 模型的输入——ValueError
- animation - 如何使用pygame在精灵后面留下痕迹?
- java - 使用 BufferedReader 读取文件时数组索引超出范围的问题
- c# - 为什么我不能使用 foreach 来填充 asp-for?
- python-3.x - python 3的高效结果显示
- javascript - 承诺 then() 和 catch() UnhandledPromiseRejectionWarnin
- javascript - 当前 TabStrip 无法刷新
- sql - 使用 EF Core 的 SQL 连接