Python 100 project #16: Generate sentiment plot

I used a few libraries in this project, to create a plot chart from the transcripts I retrieved in the previous project.

  • google-cloud-language … to retrieve the sentiment score from google cloud natural language
  • pandas … to create a dataframe (might not be necessary, but I will use this heavily later)
  • seaborn … to create plot chart.

 

Here is the output result. It is visible the Doctor become excited as it goes towards the end.

 

This code uses google-cloud-language library, and it returns the sentiment of the sentence it received.

 

Using the sentence list I retrieved in the previous project, assuming “speeches” is the list of conversations, and “names” are literally the names who spoke that sentence in respective index.

This is to retrieve all the sentiments for all the speeches.

 

This is data wrangling to make the format easier to process. It actually doesn’t process data much, maybe in the later project I will dive into more statistics using these transcripts or Japanese statistics I used on project#5.

 

This is the actual code to display the plot using the data retrieved.