Requests, JSON, and basic NLP with spaCy

Complete the tasks in the Python Notebook in this repository. To be submitted for credit, all changes must be committed and pushed to this repository (do not create your own repository unless instructed to on the course website).

About The Assignment

Perform the following tasks:

  1. Write the result from an API search for lyrics to a JSON file
  2. Utilize the JSON file previously developed to print the lyrics of the song and use SpacyTextBlob to perform sentiment analysis on the lyrics. Print the polarity score of the sentiment analysis. Advise as to whether the lyrics have a more positive or negative connotation.
  3. Write a function that takes an artists, song, and filename, and acesses the api to get the song lyrics, and writes the results to the specified filename. Test the function by getting the lyrics to any four songs and storing them in different files.
  4. Write a function that takes the name of a file that contains song lyrics, loads the file, performs sentiment analysis, and returns the polarity score. Use the function to print the polarity scores (with the name of the song) of the three files created in the prior question. Answer the question as to whether the song's lyrics match the polarity score provided in a comment or a markdown cell under the code cell.

Getting Started

  1. Copy the base repository into your GitHub account by selecting the "Use this Template" button on GitHub and specifying yourself as the owner. The base repository is available at: https://github.com/wmnlp-materials/json-sentiment
  2. Clone YOUR new repo down to your machine.

Includes

  • Python
  • json
  • pickle
  • requests
  • spacy
  • spacytextblob.spacytextblob from SpacyTextBlob
  • lyrcisgenius

Rubric

  • (Question 1) Lyrics printed: 1 pt
  • (Question 1) File created and submitted with notebook: 1 pt
  • (Question 2) Correct polarity reported: 1 pt
  • (Question 2) Question answered thoughtfully: 1 pt
  • (Question 3) Function defined as specified: 1 pt
  • (Question 3) Song lyrics retrieved and stored in separate files (0.5 pts/song): 2 pts
  • (Question 4) Polarity scores printed (with appropriate label containing song title, .25 pts/song): 1 pt
  • (Question 4) Questions answered thoughtfully: 2 pts

Contact