diff --git a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py index 8d3ec48da743..417c66ea159f 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py +++ b/sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_models.py @@ -69,25 +69,25 @@ class DetectedLanguage(DictMixin): :param iso6391_name: A two letter representation of the detected language according to the ISO 639-1 standard (e.g. en, fr). :type iso6391_name: str - :param score: A confidence score between 0 and 1. Scores close + :param confidence_score: A confidence score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true. - :type score: float + :type confidence_score: float """ def __init__(self, **kwargs): self.name = kwargs.get("name", None) self.iso6391_name = kwargs.get("iso6391_name", None) - self.score = kwargs.get("score", None) + self.confidence_score = kwargs.get("confidence_score", None) @classmethod def _from_generated(cls, language): return cls( - name=language.name, iso6391_name=language.iso6391_name, score=language.score + name=language.name, iso6391_name=language.iso6391_name, confidence_score=language.confidence_score ) def __repr__(self): return "DetectedLanguage(name={}, iso6391_name={}, score={})" \ - .format(self.name, self.iso6391_name, self.score)[:1024] + .format(self.name, self.iso6391_name, self.confidence_score)[:1024] class RecognizeEntitiesResult(DictMixin): diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/test_text_analytics.py b/sdk/textanalytics/azure-ai-textanalytics/tests/test_text_analytics.py index 256eaae17a51..1af141c7d535 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/test_text_analytics.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/test_text_analytics.py @@ -142,15 +142,13 @@ def test_repr(self): self.assertEqual("SentimentConfidenceScores(positive=0.99, neutral=0.05, negative=0.02)", repr(sentiment_confidence_score_per_label)) self.assertEqual("SentenceSentiment(sentiment=neutral, confidence_scores=SentimentConfidenceScores(" - "positive=0.99, neutral=0.05, negative=0.02), grapheme_offset=0, grapheme_length=10, warnings=" - "['sentence was too short to find sentiment'])", repr(sentence_sentiment)) + "positive=0.99, neutral=0.05, negative=0.02), grapheme_offset=0, grapheme_length=10)", repr(sentence_sentiment)) self.assertEqual("AnalyzeSentimentResult(id=1, sentiment=positive, statistics=TextDocumentStatistics(" "grapheme_count=14, transaction_count=18), confidence_scores=SentimentConfidenceScores" "(positive=0.99, neutral=0.05, negative=0.02), " "sentences=[SentenceSentiment(sentiment=neutral, confidence_scores=" "SentimentConfidenceScores(positive=0.99, neutral=0.05, negative=0.02), " - "grapheme_offset=0, grapheme_length=10, " - "warnings=['sentence was too short to find sentiment'])], is_error=False)", + "grapheme_offset=0, grapheme_length=10)], is_error=False)", repr(analyze_sentiment_result)) self.assertEqual("DocumentError(id=1, error=TextAnalyticsError(code=invalidRequest, " "message=The request is invalid, target=request), is_error=True)", repr(document_error)) diff --git a/sdk/textanalytics/azure-ai-textanalytics/tests/testcase.py b/sdk/textanalytics/azure-ai-textanalytics/tests/testcase.py index 0ef00025aee4..bdd065c52732 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/tests/testcase.py +++ b/sdk/textanalytics/azure-ai-textanalytics/tests/testcase.py @@ -87,14 +87,20 @@ def __init__(self): ) def create_resource(self, name, **kwargs): - text_analytics_account = TextAnalyticsTest._TEXT_ANALYTICS_ACCOUNT - - return { - 'location': 'westus2', - 'resource_group': TextAnalyticsTest._RESOURCE_GROUP, - 'text_analytics_account': text_analytics_account, - 'text_analytics_account_key': TextAnalyticsTest._TEXT_ANALYTICS_KEY, - } + if self.is_live: + return { + 'location': 'westus2', + 'resource_group': TextAnalyticsTest._RESOURCE_GROUP, + 'text_analytics_account': os.environ['AZURE_TEXT_ANALYTICS_ENDPOINT'], + 'text_analytics_account_key': os.environ['AZURE_TEXT_ANALYTICS_KEY'], + } + else: + return { + 'location': 'westus2', + 'resource_group': TextAnalyticsTest._RESOURCE_GROUP, + 'text_analytics_account': "https://westus2.ppe.cognitiveservices.azure.com", + 'text_analytics_account_key': "fake_key", + } class TextAnalyticsClientPreparer(AzureMgmtPreparer): def __init__(self, client_cls, client_kwargs={}, **kwargs): @@ -129,15 +135,15 @@ def create_text_analytics_client(self, **kwargs): def text_analytics_account(): test_case = AzureTestCase("__init__") rg_preparer = ResourceGroupPreparer(random_name_enabled=True, name_prefix='pycog') - text_analytics_preparer = CognitiveServicesAccountPreparer(random_name_enabled=True, name_prefix='pycog', sku='S0') + text_analytics_preparer = CognitiveServicesAccountPreparer(random_name_enabled=True, name_prefix='pycog') try: rg_name, rg_kwargs = rg_preparer._prepare_create_resource(test_case) TextAnalyticsTest._RESOURCE_GROUP = rg_kwargs['resource_group'] try: text_analytics_name, text_analytics_kwargs = text_analytics_preparer._prepare_create_resource(test_case, **rg_kwargs) - TextAnalyticsTest._TEXT_ANALYTICS_ACCOUNT = os.environ['AZURE_TEXT_ANALYTICS_ENDPOINT'] #text_analytics_kwargs['cognitiveservices_account'] - TextAnalyticsTest._TEXT_ANALYTICS_KEY = os.environ['AZURE_TEXT_ANALYTICS_KEY'] # text_analytics_kwargs['cognitiveservices_account_key'] + TextAnalyticsTest._TEXT_ANALYTICS_ACCOUNT = text_analytics_kwargs['cognitiveservices_account'] + TextAnalyticsTest._TEXT_ANALYTICS_KEY = text_analytics_kwargs['cognitiveservices_account_key'] yield finally: text_analytics_preparer.remove_resource(