Skip to content

A lightweight tool built on top of lyricsgenius and nltk in order to analyze the sentiment of your favorite artists and songs.

Notifications You must be signed in to change notification settings

michaelbaluja/PyricalAnalysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pyrical Analysis

PyricalAnalysis is a python library combining aspects of the nltk package and LyricsGenius python-based genius.com api package to allow users to view the sentiment breakdown for the lyrics of their favorite artists and songs.

Installation

To install PyricalAnalysis, download the zip file from github or clone the reposity.

git clone https://github.com/michaelbaluja/PyricalAnalysis.git

Setup

A Geniuse API client key is required for use. A client access key can be gathered from https://genius.com/api-clients, but requires a genius account to do so. While the key can be passed in as a runtime argument, or given when prompted if not already provided, the key can also be added as an environment variable GENIUS_KEY. In the case that an api key is passed in as a runtime argument but the environment variable is already set, the runtime provided key will be used, and the environment variable key will be ignored.

Usage

In order to easily analyze an artist, run main.py from the command line with the proper artist/song to analyze, along with any other arguments for analysis (see chart below).

Artist Analysis

python src/main.py --from_cache --artist 'Childish Gambino' --by 'album' --plot 'line'

Song Analysis

python src/main.py --from_cache --artist 'Childish Gambino' --song 'The Longest Text Message' --plot 'line'

Note that for artist/song names that consist of more than one word, the name must be surrounded by a matching set of single or double quotations

Runtime Arguments

Argument Description
‐‐genius_key Genius API key. Only required if env variable not set
‐‐artist Artist to perform analysis on. Not required for song analysis
‐‐song Song to perform analysis on. Not required for artist analysis
‐‐by Specifies how to structure analysis (if artist search, can do album or song)
‐‐plot Specifies how to plot analysis (plot, line) (can pass multiple)
‐‐remove_remix Flag to remove songs containing remix keywords
‐‐remove_unfinished Flag to remove songs that have unfinished keywords
‐‐from_cache Flag to read artist/song info from cache
‐‐cache Flag to write artist/song info to cache

While all non-flag arguments require additional input, flag arguments do not require any additional parameter.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please ensure all suggested code does not cause issues with the current codebase.

License

MIT

About

A lightweight tool built on top of lyricsgenius and nltk in order to analyze the sentiment of your favorite artists and songs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages