It seems you are passing a wrong end point.Go to test API resource and find out the end point .Provide the end point then it should work.
Which endpoint should I be using for Text analytics API connection?
I am following the QuickStart Python tutorial for using the Text Analytics API and it suggests saving your endpoint and key from the deployed resource i.e. 'Key 1' and 'endpoint' url.
key = "<paste-your-text-analytics-key-here>"
endpoint = "<paste-your-text-analytics-endpoint-here>"
I then use:
from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential
def authenticate_client():
ta_credential = AzureKeyCredential(key)
text_analytics_client = TextAnalyticsClient(
endpoint=endpoint, credential=ta_credential)
return text_analytics_client
client = authenticate_client()
the above should connect to the API.
At the moment when I run one of the features, for example, sentiment analysis, as per:
def sentiment_analysis_example(client):
documents = ["I had the best day of my life. I wish you were there with me."]
response = client.analyze_sentiment(documents = documents)[0]
print("Document Sentiment: {}".format(response.sentiment))
print("Overall scores: positive={0:.2f}; neutral={1:.2f}; negative={2:.2f} \n".format(
response.confidence_scores.positive,
response.confidence_scores.neutral,
response.confidence_scores.negative,
))
for idx, sentence in enumerate(response.sentences):
print("Sentence: {}".format(sentence.text))
print("Sentence {} sentiment: {}".format(idx+1, sentence.sentiment))
print("Sentence score:\nPositive={0:.2f}\nNeutral={1:.2f}\nNegative={2:.2f}\n".format(
sentence.confidence_scores.positive,
sentence.confidence_scores.neutral,
sentence.confidence_scores.negative,
))
I get the following error:
ValueError: The value provided for the url part Endpoint was incorrect, and resulted in an invalid url
2 answers
Sort by: Oldest
-
-
YutongTie-MSFT 46,986 Reputation points
2020-08-04T16:26:18.78+00:00 Hi,
Please go to the Azure portal. If the Text Analytics resource you created in the Prerequisites section deployed successfully, click the Go to Resource button under Next Steps. You can find your key and endpoint in the resource's key and endpoint page, under resource management.
Regards,
Yutong