Skip to content

Commit f03b477

Browse files
committed
have no mined opinions return as [] for v3.1-preview.1, and None for v3.0
1 parent 5b804d2 commit f03b477

File tree

1 file changed

+8
-4
lines changed
  • sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics

1 file changed

+8
-4
lines changed

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,14 +722,18 @@ def __init__(self, **kwargs):
722722

723723
@classmethod
724724
def _from_generated(cls, sentence, results):
725+
if hasattr(sentence, "aspects"):
726+
mined_opinions = (
727+
[MinedOpinion._from_generated(aspect, results) for aspect in sentence.aspects] # pylint: disable=protected-access
728+
if sentence.aspects else []
729+
)
730+
else:
731+
mined_opinions = None
725732
return cls(
726733
text=sentence.text,
727734
sentiment=sentence.sentiment,
728735
confidence_scores=SentimentConfidenceScores._from_generated(sentence.confidence_scores), # pylint: disable=protected-access
729-
mined_opinions=(
730-
[MinedOpinion._from_generated(aspect, results) for aspect in sentence.aspects] # pylint: disable=protected-access
731-
if (hasattr(sentence, "aspects") and sentence.aspects) else None
732-
)
736+
mined_opinions=mined_opinions
733737
)
734738

735739
def __repr__(self):

0 commit comments

Comments
 (0)