I'm trying to check the confidence score of a language analysis module using the Azure AI Text Analysis skill. I've got it running in the portal and locally, and both are recognising languages and giving a response, but I can't get the confidence score component to work in either context.
In the local environment, i've tried this code set up:
key = "my-key"
endpoint = "my endpoint"
from azure.ai.textanalytics import TextAnalyticsClient
from azure.ai.textanalytics import DetectedLanguage
from azure.core.credentials import AzureKeyCredential
# Authenticate the client using your key and endpoint
def authenticate_client_ta():
ta_credential = AzureKeyCredential(key)
text_analytics_client = TextAnalyticsClient(
endpoint=endpoint,
credential=ta_credential)
return text_analytics_client
def authenticate_client_dl():
dl_credential = AzureKeyCredential(key)
language_analytics_client = DetectedLanguage(
endpoint=endpoint,
credential=dl_credential)
return language_analytics_client
client = authenticate_client_ta()
score = authenticate_client_dl()
# Example method for detecting the language of text
def language_detection_example(client):
try:
documents = ["Ce document est rédigé en Français."]
response = client.detect_language(documents = documents, country_hint = 'us')[0]
confscore = score.confidence_score(response)
print("Language: ", response.primary_language.name)
print(confscore)
except Exception as err:
print("Encountered exception. {}".format(err))
language_detection_example(client)
but it keeps returning the error "Encountered Exception 'None Type' Object is not callable"
I've tried moving around the confidence_score variable but the best response i've got out of it so far is a None or Null. I presume this is a really simple python error that i'm just being oblivious to. Any ideas?