def test_recognize_pii_entities_result(self, pii_entity, text_analytics_warning, text_document_statistics): model = _models.RecognizePiiEntitiesResult( id="1", entities=[pii_entity[0]], warnings=[text_analytics_warning[0]], statistics=text_document_statistics[0], is_error=False) model_repr = "RecognizePiiEntitiesResult(id=1, entities=[{}], warnings=[{}], statistics={}, is_error=False)".format( pii_entity[1], text_analytics_warning[1], text_document_statistics[1]) assert repr(model) == model_repr
def recognize_pii_entities_result(pii_entity, text_analytics_warning, text_document_statistics): model = _models.RecognizePiiEntitiesResult( id="1", entities=[pii_entity[0]], redacted_text="***********", warnings=[text_analytics_warning[0]], statistics=text_document_statistics[0], is_error=False ) model_repr = "RecognizePiiEntitiesResult(id=1, entities=[{}], redacted_text=***********, warnings=[{}], " \ "statistics={}, is_error=False)".format( pii_entity[1], text_analytics_warning[1], text_document_statistics[1] ) assert repr(model) == model_repr return model, model_repr
def test_repr(self): detected_language = _models.DetectedLanguage(name="English", iso6391_name="en", score=1.0) categorized_entity = _models.CategorizedEntity(text="Bill Gates", category="Person", subcategory="Age", grapheme_offset=0, grapheme_length=8, score=0.899) pii_entity = _models.PiiEntity(text="555-55-5555", category="SSN", subcategory=None, grapheme_offset=0, grapheme_length=8, score=0.899) text_document_statistics = _models.TextDocumentStatistics(grapheme_count=14, transaction_count=18) recognize_entities_result = _models.RecognizeEntitiesResult( id="1", entities=[categorized_entity], statistics=text_document_statistics, is_error=False ) recognize_pii_entities_result = _models.RecognizePiiEntitiesResult( id="1", entities=[pii_entity], statistics=text_document_statistics, is_error=False ) detect_language_result = _models.DetectLanguageResult( id="1", primary_language=detected_language, statistics=text_document_statistics, is_error=False ) text_analytics_error = _models.TextAnalyticsError( code="invalidRequest", message="The request is invalid", target="request", ) extract_key_phrases_result = \ _models.ExtractKeyPhrasesResult( id="1", key_phrases=["dog", "cat", "bird"], statistics=text_document_statistics, is_error=False ) linked_entity_match = _models.LinkedEntityMatch(score=0.999, text="Bill Gates", grapheme_offset=0, grapheme_length=8) linked_entity = _models.LinkedEntity( name="Bill Gates", matches=[linked_entity_match, linked_entity_match], language="English", data_source_entity_id="Bill Gates", url="https://en.wikipedia.org/wiki/Bill_Gates", data_source="wikipedia" ) recognize_linked_entities_result = \ _models.RecognizeLinkedEntitiesResult( id="1", entities=[linked_entity], statistics=text_document_statistics, is_error=False ) sentiment_confidence_score_per_label = \ _models.SentimentConfidenceScores(positive=0.99, neutral=0.05, negative=0.02) sentence_sentiment = _models.SentenceSentiment( sentiment="neutral", confidence_scores=sentiment_confidence_score_per_label, grapheme_offset=0, grapheme_length=10, warnings=["sentence was too short to find sentiment"] ) analyze_sentiment_result = _models.AnalyzeSentimentResult( id="1", sentiment="positive", statistics=text_document_statistics, confidence_scores=sentiment_confidence_score_per_label, sentences=[sentence_sentiment], is_error=False ) document_error = _models.DocumentError(id="1", error=text_analytics_error, is_error=True) detect_language_input = _models.DetectLanguageInput(id="1", text="hello world", country_hint="US") text_document_input = _models.TextDocumentInput(id="1", text="hello world", language="en") text_document_batch_statistics = _models.TextDocumentBatchStatistics( document_count=1, valid_document_count=2, erroneous_document_count=3, transaction_count=4 ) self.assertEqual("DetectedLanguage(name=English, iso6391_name=en, score=1.0)", repr(detected_language)) self.assertEqual("CategorizedEntity(text=Bill Gates, category=Person, subcategory=Age, grapheme_offset=0, " "grapheme_length=8, score=0.899)", repr(categorized_entity)) self.assertEqual("PiiEntity(text=555-55-5555, category=SSN, subcategory=None, grapheme_offset=0, " "grapheme_length=8, score=0.899)", repr(pii_entity)) self.assertEqual("TextDocumentStatistics(grapheme_count=14, transaction_count=18)", repr(text_document_statistics)) self.assertEqual("RecognizeEntitiesResult(id=1, entities=[CategorizedEntity(text=Bill Gates, category=Person, " "subcategory=Age, grapheme_offset=0, grapheme_length=8, score=0.899)], " "statistics=TextDocumentStatistics(grapheme_count=14, transaction_count=18), " "is_error=False)", repr(recognize_entities_result)) self.assertEqual("RecognizePiiEntitiesResult(id=1, entities=[PiiEntity(text=555-55-5555, category=SSN, " "subcategory=None, grapheme_offset=0, grapheme_length=8, score=0.899)], " "statistics=TextDocumentStatistics(grapheme_count=14, transaction_count=18), " "is_error=False)", repr(recognize_pii_entities_result)) self.assertEqual("DetectLanguageResult(id=1, primary_language=DetectedLanguage(name=English, " "iso6391_name=en, score=1.0), statistics=TextDocumentStatistics(grapheme_count=14, " "transaction_count=18), is_error=False)", repr(detect_language_result)) self.assertEqual("TextAnalyticsError(code=invalidRequest, message=The request is invalid, target=request)", repr(text_analytics_error)) self.assertEqual("ExtractKeyPhrasesResult(id=1, key_phrases=['dog', 'cat', 'bird'], statistics=" "TextDocumentStatistics(grapheme_count=14, transaction_count=18), is_error=False)", repr(extract_key_phrases_result)) self.assertEqual("LinkedEntityMatch(score=0.999, text=Bill Gates, grapheme_offset=0, grapheme_length=8)", repr(linked_entity_match)) self.assertEqual("LinkedEntity(name=Bill Gates, matches=[LinkedEntityMatch(score=0.999, text=Bill Gates, " "grapheme_offset=0, grapheme_length=8), LinkedEntityMatch(score=0.999, text=Bill Gates, " "grapheme_offset=0, grapheme_length=8)], language=English, data_source_entity_id=Bill Gates, " "url=https://en.wikipedia.org/wiki/Bill_Gates, data_source=wikipedia)", repr(linked_entity)) self.assertEqual("RecognizeLinkedEntitiesResult(id=1, entities=[LinkedEntity(name=Bill Gates, " "matches=[LinkedEntityMatch(score=0.999, text=Bill Gates, grapheme_offset=0, " "grapheme_length=8), LinkedEntityMatch(score=0.999, text=Bill Gates, grapheme_offset=0, " "grapheme_length=8)], language=English, data_source_entity_id=Bill Gates, " "url=https://en.wikipedia.org/wiki/Bill_Gates, data_source=wikipedia)], " "statistics=TextDocumentStatistics(grapheme_count=14, " "transaction_count=18), is_error=False)", repr(recognize_linked_entities_result)) 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)) 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)", 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)) self.assertEqual("DetectLanguageInput(id=1, text=hello world, country_hint=US)", repr(detect_language_input)) self.assertEqual("TextDocumentInput(id=1, text=hello world, language=en)", repr(text_document_input)) self.assertEqual("TextDocumentBatchStatistics(document_count=1, valid_document_count=2, " "erroneous_document_count=3, transaction_count=4)", repr(text_document_batch_statistics))
def test_repr(self): detected_language = _models.DetectedLanguage(name="English", iso6391_name="en", score=1.0) named_entity = _models.NamedEntity(text="Bill Gates", type="Person", subtype="Age", offset=0, length=8, score=0.899) text_document_statistics = _models.TextDocumentStatistics( character_count=14, transaction_count=18) recognize_entities_result = _models.RecognizeEntitiesResult( id="1", entities=[named_entity], statistics=text_document_statistics, is_error=False) recognize_pii_entities_result = _models.RecognizePiiEntitiesResult( id="1", entities=[named_entity], statistics=text_document_statistics, is_error=False) detect_language_result = _models.DetectLanguageResult( id="1", detected_languages=[detected_language], primary_language=detected_language, statistics=text_document_statistics, is_error=False) inner_error = _models.InnerError( code="invalidParameterValue", message="The parameter is invalid", details={"parameter": "invalid"}, target="parameter", inner_error=_models.InnerError(code="invalidParameterValue2", message="The parameter is invalid2", details={"parameter2": "invalid2"}, target="parameter2", inner_error=None)) text_analytics_error = _models.TextAnalyticsError( code="invalidRequest", message="The request is invalid", target="request", inner_error=inner_error, details=[ _models.TextAnalyticsError(code="invalidRequest2", message="The request is invalid2", target="request2", inner_error=None, details=None) ]) extract_key_phrases_result = \ _models.ExtractKeyPhrasesResult( id="1", key_phrases=["dog", "cat", "bird"], statistics=text_document_statistics, is_error=False ) linked_entity_match = _models.LinkedEntityMatch(score=0.999, text="Bill Gates", offset=0, length=8) linked_entity = _models.LinkedEntity( name="Bill Gates", matches=[linked_entity_match, linked_entity_match], language="English", id="Bill Gates", url="https://en.wikipedia.org/wiki/Bill_Gates", data_source="wikipedia") recognize_linked_entities_result = \ _models.RecognizeLinkedEntitiesResult( id="1", entities=[linked_entity], statistics=text_document_statistics, is_error=False ) sentiment_confidence_score_per_label = \ _models.SentimentConfidenceScorePerLabel(positive=0.99, neutral=0.05, negative=0.02) sentence_sentiment = _models.SentenceSentiment( sentiment="neutral", sentence_scores=sentiment_confidence_score_per_label, offset=0, length=10, warnings=["sentence was too short to find sentiment"]) analyze_sentiment_result = _models.AnalyzeSentimentResult( id="1", sentiment="positive", statistics=text_document_statistics, document_scores=sentiment_confidence_score_per_label, sentences=[sentence_sentiment], is_error=False) document_error = _models.DocumentError(id="1", error=text_analytics_error, is_error=True) detect_language_input = _models.DetectLanguageInput(id="1", text="hello world", country_hint="US") text_document_input = _models.TextDocumentInput(id="1", text="hello world", language="en") text_document_batch_statistics = _models.TextDocumentBatchStatistics( document_count=1, valid_document_count=2, erroneous_document_count=3, transaction_count=4) self.assertEqual( "DetectedLanguage(name=English, iso6391_name=en, score=1.0)", repr(detected_language)) self.assertEqual( "NamedEntity(text=Bill Gates, type=Person, subtype=Age, offset=0, length=8, score=0.899)", repr(named_entity)) self.assertEqual( "TextDocumentStatistics(character_count=14, transaction_count=18)", repr(text_document_statistics)) self.assertEqual( "RecognizeEntitiesResult(id=1, entities=[NamedEntity(text=Bill Gates, type=Person, " "subtype=Age, offset=0, length=8, score=0.899)], " "statistics=TextDocumentStatistics(character_count=14, transaction_count=18), " "is_error=False)", repr(recognize_entities_result)) self.assertEqual( "RecognizePiiEntitiesResult(id=1, entities=[NamedEntity(text=Bill Gates, type=Person, " "subtype=Age, offset=0, length=8, score=0.899)], " "statistics=TextDocumentStatistics(character_count=14, transaction_count=18), " "is_error=False)", repr(recognize_pii_entities_result)) self.assertEqual( "DetectLanguageResult(id=1, detected_languages=[DetectedLanguage(name=English, " "iso6391_name=en, score=1.0)], primary_language=DetectedLanguage(name=English, " "iso6391_name=en, score=1.0), statistics=TextDocumentStatistics(character_count=14, " "transaction_count=18), is_error=False)", repr(detect_language_result)) self.assertEqual( "InnerError(code=invalidParameterValue, message=The parameter is invalid, " "details={'parameter': 'invalid'}, target=parameter, inner_error=InnerError(code=" "invalidParameterValue2, message=The parameter is invalid2, " "details={'parameter2': 'invalid2'}, target=parameter2, inner_error=None))", repr(inner_error)) self.assertEqual( "TextAnalyticsError(code=invalidRequest, message=The request is invalid, target=request, " "inner_error=InnerError(code=invalidParameterValue, message=The parameter is invalid, " "details={'parameter': 'invalid'}, target=parameter, inner_error=InnerError(code=" "invalidParameterValue2, message=The parameter is invalid2, " "details={'parameter2': 'invalid2'}, target=parameter2, inner_error=None)), details=[" "TextAnalyticsError(code=invalidRequest2, message=The request is invalid2, target=request2, " "inner_error=None, details=None)])", repr(text_analytics_error)) self.assertEqual( "ExtractKeyPhrasesResult(id=1, key_phrases=['dog', 'cat', 'bird'], statistics=" "TextDocumentStatistics(character_count=14, transaction_count=18), is_error=False)", repr(extract_key_phrases_result)) self.assertEqual( "LinkedEntityMatch(score=0.999, text=Bill Gates, offset=0, length=8)", repr(linked_entity_match)) self.assertEqual( "LinkedEntity(name=Bill Gates, matches=[LinkedEntityMatch(score=0.999, text=Bill Gates, " "offset=0, length=8), LinkedEntityMatch(score=0.999, text=Bill Gates, offset=0, length=8)], " "language=English, id=Bill Gates, url=https://en.wikipedia.org/wiki/Bill_Gates, data_source=" "wikipedia)", repr(linked_entity)) self.assertEqual( "RecognizeLinkedEntitiesResult(id=1, entities=[LinkedEntity(name=Bill Gates, " "matches=[LinkedEntityMatch(score=0.999, text=Bill Gates, offset=0, length=8), " "LinkedEntityMatch(score=0.999, text=Bill Gates, offset=0, length=8)], language=English, " "id=Bill Gates, url=https://en.wikipedia.org/wiki/Bill_Gates, data_source=wikipedia)], " "statistics=TextDocumentStatistics(character_count=14, " "transaction_count=18), is_error=False)", repr(recognize_linked_entities_result)) self.assertEqual( "SentimentConfidenceScorePerLabel(positive=0.99, neutral=0.05, negative=0.02)", repr(sentiment_confidence_score_per_label)) self.assertEqual( "SentenceSentiment(sentiment=neutral, sentence_scores=SentimentConfidenceScorePerLabel(" "positive=0.99, neutral=0.05, negative=0.02), offset=0, length=10, warnings=" "['sentence was too short to find sentiment'])", repr(sentence_sentiment)) self.assertEqual( "AnalyzeSentimentResult(id=1, sentiment=positive, statistics=TextDocumentStatistics(" "character_count=14, transaction_count=18), document_scores=SentimentConfidenceScorePerLabel" "(positive=0.99, neutral=0.05, negative=0.02), sentences=[SentenceSentiment(sentiment=neutral, " "sentence_scores=SentimentConfidenceScorePerLabel(positive=0.99, neutral=0.05, negative=0.02), " "offset=0, length=10, warnings=['sentence was too short to find sentiment'])], is_error=False)", repr(analyze_sentiment_result)) self.assertEqual( "DocumentError(id=1, error=TextAnalyticsError(code=invalidRequest, " "message=The request is invalid, target=request, " "inner_error=InnerError(code=invalidParameterValue, message=The parameter is invalid, " "details={'parameter': 'invalid'}, target=parameter, inner_error=InnerError(code=" "invalidParameterValue2, message=The parameter is invalid2, " "details={'parameter2': 'invalid2'}, target=parameter2, inner_error=None)), details=[" "TextAnalyticsError(code=invalidRequest2, message=The request is invalid2, target=request2, " "inner_error=None, details=None)]), is_error=True)", repr(document_error)) self.assertEqual( "DetectLanguageInput(id=1, text=hello world, country_hint=US)", repr(detect_language_input)) self.assertEqual( "TextDocumentInput(id=1, text=hello world, language=en)", repr(text_document_input)) self.assertEqual( "TextDocumentBatchStatistics(document_count=1, valid_document_count=2, " "erroneous_document_count=3, transaction_count=4)", repr(text_document_batch_statistics))
def test_repr(self): detected_language = _models.DetectedLanguage(name="English", iso6391_name="en", confidence_score=1.0) categorized_entity = _models.CategorizedEntity(text="Bill Gates", category="Person", subcategory="Age", confidence_score=0.899) pii_entity = _models.PiiEntity(text="859-98-0987", category="SSN", subcategory=None, confidence_score=0.899) text_document_statistics = _models.TextDocumentStatistics( character_count=14, transaction_count=18) warnings = [ _models.TextAnalyticsWarning( code="LongWordsInDocument", message= "The document contains very long words (longer than 64 characters). These words will be truncated and may result in unreliable model predictions." ) ] recognize_entities_result = _models.RecognizeEntitiesResult( id="1", entities=[categorized_entity], warnings=warnings, statistics=text_document_statistics, is_error=False) recognize_pii_entities_result = _models.RecognizePiiEntitiesResult( id="1", entities=[pii_entity], warnings=warnings, statistics=text_document_statistics, is_error=False) detect_language_result = _models.DetectLanguageResult( id="1", primary_language=detected_language, warnings=warnings, statistics=text_document_statistics, is_error=False) text_analytics_error = _models.TextAnalyticsError( code="invalidRequest", message="The request is invalid", target="request", ) extract_key_phrases_result = \ _models.ExtractKeyPhrasesResult( id="1", key_phrases=["dog", "cat", "bird"], warnings=warnings, statistics=text_document_statistics, is_error=False ) linked_entity_match = _models.LinkedEntityMatch(confidence_score=0.999, text="Bill Gates") linked_entity = _models.LinkedEntity( name="Bill Gates", matches=[linked_entity_match, linked_entity_match], language="English", data_source_entity_id="Bill Gates", url="https://en.wikipedia.org/wiki/Bill_Gates", data_source="wikipedia") recognize_linked_entities_result = \ _models.RecognizeLinkedEntitiesResult( id="1", entities=[linked_entity], warnings=warnings, statistics=text_document_statistics, is_error=False ) sentiment_confidence_score_per_label = \ _models.SentimentConfidenceScores(positive=0.99, neutral=0.05, negative=0.02) sentence_sentiment = _models.SentenceSentiment( text="This is a sentence.", sentiment="neutral", confidence_scores=sentiment_confidence_score_per_label) analyze_sentiment_result = _models.AnalyzeSentimentResult( id="1", sentiment="positive", warnings=warnings, statistics=text_document_statistics, confidence_scores=sentiment_confidence_score_per_label, sentences=[sentence_sentiment], is_error=False) document_error = _models.DocumentError(id="1", error=text_analytics_error, is_error=True) detect_language_input = _models.DetectLanguageInput(id="1", text="hello world", country_hint="US") text_document_input = _models.TextDocumentInput(id="1", text="hello world", language="en") text_document_batch_statistics = _models.TextDocumentBatchStatistics( document_count=1, valid_document_count=2, erroneous_document_count=3, transaction_count=4) aspect_opinion_confidence_score = _models.SentimentConfidenceScores( positive=0.5, negative=0.5) opinion_sentiment = _models.OpinionSentiment( text="opinion", sentiment="positive", confidence_scores=aspect_opinion_confidence_score, offset=3, length=7, is_negated=False) aspect_sentiment = _models.AspectSentiment( text="aspect", sentiment="positive", confidence_scores=aspect_opinion_confidence_score, offset=10, length=6) mined_opinion = _models.MinedOpinion(aspect=aspect_sentiment, opinions=[opinion_sentiment]) self.assertEqual( "DetectedLanguage(name=English, iso6391_name=en, confidence_score=1.0)", repr(detected_language)) self.assertEqual( "CategorizedEntity(text=Bill Gates, category=Person, subcategory=Age, confidence_score=0.899)", repr(categorized_entity)) self.assertEqual( "PiiEntity(text=859-98-0987, category=SSN, subcategory=None, confidence_score=0.899)", repr(pii_entity)) self.assertEqual( "TextDocumentStatistics(character_count=14, transaction_count=18)", repr(text_document_statistics)) self.assertEqual( "RecognizeEntitiesResult(id=1, entities=[CategorizedEntity(text=Bill Gates, category=Person, " "subcategory=Age, confidence_score=0.899)], " "warnings=[TextAnalyticsWarning(code=LongWordsInDocument, message=The document contains very long words (longer than 64 characters). " "These words will be truncated and may result in unreliable model predictions.)], " "statistics=TextDocumentStatistics(character_count=14, transaction_count=18), " "is_error=False)", repr(recognize_entities_result)) self.assertEqual( "RecognizePiiEntitiesResult(id=1, entities=[PiiEntity(text=859-98-0987, category=SSN, " "subcategory=None, confidence_score=0.899)], " "warnings=[TextAnalyticsWarning(code=LongWordsInDocument, message=The document contains very long words (longer than 64 characters). " "These words will be truncated and may result in unreliable model predictions.)], " "statistics=TextDocumentStatistics(character_count=14, transaction_count=18), " "is_error=False)", repr(recognize_pii_entities_result)) self.assertEqual( "DetectLanguageResult(id=1, primary_language=DetectedLanguage(name=English, " "iso6391_name=en, confidence_score=1.0), " "warnings=[TextAnalyticsWarning(code=LongWordsInDocument, message=The document contains very long words (longer than 64 characters). " "These words will be truncated and may result in unreliable model predictions.)], " "statistics=TextDocumentStatistics(character_count=14, " "transaction_count=18), is_error=False)", repr(detect_language_result)) self.assertEqual( "TextAnalyticsError(code=invalidRequest, message=The request is invalid, target=request)", repr(text_analytics_error)) self.assertEqual( "ExtractKeyPhrasesResult(id=1, key_phrases=['dog', 'cat', 'bird'], " "warnings=[TextAnalyticsWarning(code=LongWordsInDocument, message=The document contains very long words (longer than 64 characters). " "These words will be truncated and may result in unreliable model predictions.)], " "statistics=TextDocumentStatistics(character_count=14, transaction_count=18), is_error=False)", repr(extract_key_phrases_result)) self.assertEqual( "LinkedEntityMatch(confidence_score=0.999, text=Bill Gates)", repr(linked_entity_match)) self.assertEqual( "LinkedEntity(name=Bill Gates, matches=[LinkedEntityMatch(confidence_score=0.999, text=Bill Gates), " "LinkedEntityMatch(confidence_score=0.999, text=Bill Gates)], " "language=English, data_source_entity_id=Bill Gates, " "url=https://en.wikipedia.org/wiki/Bill_Gates, data_source=wikipedia)", repr(linked_entity)) self.assertEqual( "RecognizeLinkedEntitiesResult(id=1, entities=[LinkedEntity(name=Bill Gates, " "matches=[LinkedEntityMatch(confidence_score=0.999, text=Bill Gates), " "LinkedEntityMatch(confidence_score=0.999, text=Bill Gates)], language=English, data_source_entity_id=Bill Gates, " "url=https://en.wikipedia.org/wiki/Bill_Gates, data_source=wikipedia)], " "warnings=[TextAnalyticsWarning(code=LongWordsInDocument, message=The document contains very long words (longer than 64 characters). " "These words will be truncated and may result in unreliable model predictions.)], " "statistics=TextDocumentStatistics(character_count=14, " "transaction_count=18), is_error=False)", repr(recognize_linked_entities_result)) self.assertEqual( "SentimentConfidenceScores(positive=0.99, neutral=0.05, negative=0.02)", repr(sentiment_confidence_score_per_label)) self.assertEqual( "SentenceSentiment(text=This is a sentence., sentiment=neutral, confidence_scores=SentimentConfidenceScores(" "positive=0.99, neutral=0.05, negative=0.02))", repr(sentence_sentiment)) self.assertEqual( "AnalyzeSentimentResult(id=1, sentiment=positive, " "warnings=[TextAnalyticsWarning(code=LongWordsInDocument, message=The document contains very long words (longer than 64 characters). " "These words will be truncated and may result in unreliable model predictions.)], " "statistics=TextDocumentStatistics(" "character_count=14, transaction_count=18), confidence_scores=SentimentConfidenceScores" "(positive=0.99, neutral=0.05, negative=0.02), " "sentences=[SentenceSentiment(text=This is a sentence., sentiment=neutral, confidence_scores=" "SentimentConfidenceScores(positive=0.99, neutral=0.05, negative=0.02))], 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)) self.assertEqual( "DetectLanguageInput(id=1, text=hello world, country_hint=US)", repr(detect_language_input)) self.assertEqual( "TextDocumentInput(id=1, text=hello world, language=en)", repr(text_document_input)) self.assertEqual( "TextDocumentBatchStatistics(document_count=1, valid_document_count=2, " "erroneous_document_count=3, transaction_count=4)", repr(text_document_batch_statistics)) opinion_sentiment_repr = ( "OpinionSentiment(text=opinion, sentiment=positive, confidence_scores=SentimentConfidenceScores(" "positive=0.5, neutral=0.0, negative=0.5), offset=3, length=7, is_negated=False)" ) self.assertEqual(opinion_sentiment_repr, repr(opinion_sentiment)) aspect_sentiment_repr = ( "AspectSentiment(text=aspect, sentiment=positive, confidence_scores=SentimentConfidenceScores(" "positive=0.5, neutral=0.0, negative=0.5), offset=10, length=6)") self.assertEqual(aspect_sentiment_repr, repr(aspect_sentiment)) self.assertEqual( "MinedOpinion(aspect={}, opinions=[{}])".format( aspect_sentiment_repr, opinion_sentiment_repr), repr(mined_opinion))