-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Cognitive - Text Analytics
Milestone
Description
azure-ai-textanalytics script:
sample_alternative_document_input.py
sample_alternative_document_input_async.py

Reason:
AttributeError: 'AnalyzeSentimentResult' object has no attribute 'primary_language'.
Suggestion:
Refer to sample_analyze_sentiment.py and sample_detect_language.py
If we need to print information about analyze_sentiment, we can use the code snippet1; If we need to print information about detect_language, we can use the code snippet2.
Code snippet1:
result = text_analytics_client.analyze_sentiment(documents)
for idx, doc in enumerate(result):
print("Document text: {}".format(documents[idx]))
print("Overall sentiment: {}".format(doc.sentiment))
print("Overall confidence scores: positive={}; neutral={}; negative={} \n".format(
doc.confidence_scores.positive,
doc.confidence_scores.neutral,
doc.confidence_scores.negative,
))
for idx, sentence in enumerate(doc.sentences):
print("Sentence {} sentiment: {}".format(idx+1, sentence.sentiment))
print("Sentence confidence scores: positive={}; neutral={}; negative={}".format(
sentence.confidence_scores.positive,
sentence.confidence_scores.neutral,
sentence.confidence_scores.negative,
))
print("------------------------------------")
Code snippet2:
result = text_analytics_client.detect_language(documents)
for idx, doc in enumerate(result):
if not doc.is_error:
print("Document text: {}".format(documents[idx]))
print("Language detected: {}".format(doc.primary_language.name))
print("ISO6391 name: {}".format(doc.primary_language.iso6391_name))
print("Confidence score: {}\n".format(doc.primary_language.score))
if doc.is_error:
print(doc.id, doc.error)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ClientThis issue points to a problem in the data-plane of the library.This issue points to a problem in the data-plane of the library.Cognitive - Text Analytics