def pubsub_callback(message): # TODO: Acknowledge the message message.ack() # END TODO # TODO: Log the message log.info('Message received') log.info(message) # END TODO data = json.loads(message.data) # TODO: Use the languageapi module to # analyze the sentiment score = languageapi.analyze(str(data['feedback'])) # END TODO # TODO: Log the sentiment score log.info('Score: {}'.format(score)) # END TODO # TODO: Assign the sentiment score to # a new score property data['score'] = score # END TODO # TODO: Use the spanner module to save the feedback spanner.save_feedback(data) # END TODO # TODO: Log a message to say the feedback # has been saved log.info('Feedback saved')
def pubsub_callback(message): # TODO: Acknowledge the message message.ack() # END TODO log.info('Message received') # TODO: Log the message log.info(message) # END TODO data = json.loads(message.data) # TODO: Use the languageapi module to analyze the sentiment score = languageapi.analyze(str(data['feedback'])) # END TODO # TODO: Log the sentiment score log.info('Score: {}'.format(score)) # END TODO # TODO: Assign the sentiment score to a new score property data['score'] = score # END TODO # TODO: Use the spanner module to save the feedback spanner.save_feedback(data) # END TODO # TODO: Log a message to say the feedback has been saved log.info('Feedback saved')