def get_sentiment(instances_content):
    'Analyzing Sentiment in a String\n\n    Args:\n        text_content The text content to analyze\n    '
    scores = []
    client = language_v1.LanguageServiceClient()
    encoding_type = enums.EncodingType.UTF8
    language = 'en'
    type_ = enums.Document.Type.PLAIN_TEXT
    for content in instances_content:
        content = (content.encode('utf-8') if isinstance(content, unicode) else str(content))
        document = {'content': content, 'type': type_, 'language': language}
        try:
            response = client.analyze_sentiment(document, encoding_type=encoding_type, timeout=30, retry=retry.Retry(deadline=60))
            if response.document_sentiment.score:
                scores.append(response.document_sentiment.score)
            else:
                scores.append((- 1))
                logging.error('Document sentiment score not found for {}'.format(content))
        except exceptions.GoogleAPICallError as e:
            logging.exception(e)
        except exceptions.RetryError as e:
            logging.exception(e)
        except ValueError as e:
            logging.exception(e)
    return scores
Analyzing Sentiment in a String

Args:
    text_content The text content to analyze
def get_sentiment(instances_content):
    'Analyzing Sentiment in a String\n\n    Args:\n        text_content The text content to analyze\n    '
    scores = []
    client = language_v1.LanguageServiceClient()
    encoding_type = enums.EncodingType.UTF8
    language = 'en'
    type_ = enums.Document.Type.PLAIN_TEXT
    for content in instances_content:
        content = (content.encode('utf-8') if isinstance(content, unicode) else str(content))
        document = {'content': content, 'type': type_, 'language': language}
        try:
            response = client.analyze_sentiment(document, encoding_type=encoding_type, timeout=30, retry=retry.Retry(deadline=60))
            if response.document_sentiment.score:
                scores.append(response.document_sentiment.score)
            else:
                scores.append((- 1))
                logging.error('Document sentiment score not found for {}'.format(content))
        except exceptions.GoogleAPICallError as e:
            logging.exception(e)
        except exceptions.RetryError as e:
            logging.exception(e)
        except ValueError as e:
            logging.exception(e)
    return scores