將Azure Cognitive Services Text Analytics REST APIS與生成的Swagger定義一起使用時,請使用WithOperationalResponseAsync方法來獲取與請求相關的操作響應。從那你可以查詢原始請求的狀態。簡化的C#示例如下:
AzureMachineLearningTextAnalytics textAnalyzer = new AzureMachineLearningTextAnalytics();
var topicResult = textAnalyzer.DetectTopicsWithOperationResponseAsync(textAnalyticsAccountKey, null, null, null, topicDetection);
string operationId = topicResult.Result.Response.Headers.Location.Segments[topicResult.Result.Response.Headers.Location.Segments.Length - 1];
var status = textAnalyzer.OperationStatus(operationId, textAnalyticsAccountKey);
while ((((MySample.TextAnalytics.Models.OperationResult)status).Status == "NotStarted") ||
(((MySample.TextAnalytics.Models.OperationResult)status).Status == "Running"))
{
System.Threading.Thread.Sleep(20000);
status = textAnalyzer.OperationStatus(operationId, textAnalyticsAccountKey);
}
if (((Terawe.Retail.TextAnalytics.Models.OperationResult)status).Status == "Failed")
{
// Log an error to the console
Console.WriteLine($"Topic detection failed with status: {((MySample.TextAnalytics.Models.OperationResult)status).Message}");
}
else
{
// Process the phrases
}
請澄清您的具體問題或添加其他詳細信息以突出顯示您需要的內容。正如目前所寫,很難確切地說出你在問什麼。請參閱「如何問問」頁面以獲取有關澄清此問題的幫助。 –
請參閱鏈接瞭解更多詳情。 35 35 012 012 012 012 012 012 012 – Athira