You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importTextAnalyticsfrom"@azure/textanalytics-lowlevel";import{DefaultAzureCredential}from"@azure/identity";constendpoint="https://<accountName>.cognitiveservices.azure.com"asyncfunctionanalyzeLanguage(){constclient=TextAnalytics(newDefaultAzureCredential(),endpoint);constlanguagesResult=awaitclient.request("POST /languages",{body: {documents: [{id: "1",text: "This is a test text"}]},});if(languagesResult.status===200){for(constresultoflanguagesResult.body.documents){console.log(`Sentence with Id: '${result.id}' detected language: ${result.detectedLanguage.name} with ${result.detectedLanguage.confidenceScore*100}% confidence`);}}else{throwlanguagesResult.body.error;}}analyzeLanguage().catch(console.error)
Call an arbitrary endpoint with requestUnchecked
importTextAnalyticsfrom"@azure/textanalytics-lowlevel";import{DefaultAzureCredential}from"@azure/identity";constendpoint="https://<accountName>.cognitiveservices.azure.com"asyncfunctionanalyzeLanguage(){constclient=TextAnalytics(newDefaultAzureCredential(),endpoint);constlanguagesResult=awaitclient.requestUnchecked("POST /languages",{body: {documents: [{id: "1",text: "This is a test text"}]},});if(languagesResult.status===200){for(constresultoflanguagesResult.body.documents){console.log(`Sentence with Id: '${result.id}' detected language: ${result.detectedLanguage.name} with ${result.detectedLanguage.confidenceScore*100}% confidence`);}}else{throwlanguagesResult.body.error;}}analyzeLanguage().catch(console.error)