import numpy as np
import collections
# Matplotlib and associated plotting modules
import matplotlib.cm as cm
import matplotlib.colors as colors
import matplotlib.pyplot as plt
from matplotlib import rcParams
from stop_words import get_stop_words #The words we want to ignore
stop_words_en = get_stop_words('en') #English StopWords
from wordcloud import WordCloud, STOPWORDS
stop_words = ["and", "or", "I", "And", "I'm", "-", "The", "Yeah", "yeah)", "(Oh"] + stop_words_en #Adding more StopWords
import csv
f = open("albums_lyrics/Core_Album.txt", "r")
core_lyrics = f.read().replace("\n", " ")
f.close()
current_album = core_lyrics
print('{}'.format(current_album))
#initiate world cloud object
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(current_album)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(current_album)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in current_album.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count/ "Core" (1992) ')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)
import csv
f = open("albums_lyrics/Purple_Album.txt", "r")
purple_lyrics = f.read().replace("\n", " ")
f.close()
current_album = purple_lyrics
print('{}'.format(current_album))
#initiate world cloud object
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(current_album)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(current_album)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in current_album.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count/ Album "Purple" (1994)')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)
import csv
f = open("albums_lyrics/Tiny_Music_Album.txt", "r")
tiny_lyrics = f.read().replace("\n", " ")
f.close()
current_album = tiny_lyrics
print('{}'.format(current_album))
#initiate world cloud object
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(current_album)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(current_album)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in current_album.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count/ Album "Tiny Music... Songs From The Vatican Gift Shop" (1996)')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)
import csv
f = open("albums_lyrics/No_4_Album.txt", "r")
No_4_lyrics = f.read().replace("\n", " ")
f.close()
current_album = No_4_lyrics
print('{}'.format(current_album))
#initiate world cloud object
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(current_album)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(current_album)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in current_album.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count/ Album "No. 4" (1999)')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)
import csv
f = open("albums_lyrics/Shangri-La_Dee_Da.txt", "r")
Shangri_La_Dee_Da_lyrics = f.read().replace("\n", " ")
f.close()
current_album = Shangri_La_Dee_Da_lyrics
print('{}'.format(current_album))
#initiate world cloud object
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(current_album)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(current_album)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in current_album.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count/ Album "Shangri-La Dee Da" (2001)')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)
import csv
f = open("albums_lyrics/Stone_Temple_Pilots.txt", "r")
Stone_Temple_Pilots_Lyrics = f.read().replace("\n", " ")
f.close()
current_album = Stone_Temple_Pilots_Lyrics
print('{}'.format(current_album))
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(Stone_Temple_Pilots_Lyrics)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(Stone_Temple_Pilots_Lyrics)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in Stone_Temple_Pilots_Lyrics.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count/ Album "Stone Temple Pilots" (2010)')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)
import csv
f = open("albums_lyrics/High_Rise.txt", "r")
High_Rise = f.read().replace("\n", " ")
f.close()
current_album = High_Rise
print('{}'.format(current_album))
type(current_album)
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(current_album)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(current_album)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in current_album.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count (Album High Rise (2013))')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)
import csv
f = open("albums_lyrics/Stone_Temple_Pilots_2018.txt", "r")
STP_2018 = f.read().replace("\n", " ")
f.close()
current_album = STP_2018
print('{}'.format(current_album))
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(current_album)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(current_album)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in current_album.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count/ Album "Stone Temple Pilots" (2018)')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)
import csv
f = open("albums_lyrics/Perdida_Album.txt", "r")
perdida_lyrics = f.read().replace("\n", " ")
f.close()
current_album = perdida_lyrics
print('{}'.format(current_album))
Album_wc = WordCloud(
background_color='white',
max_words=2000,
stopwords=stop_words
)
# generate the word cloud
Album_wc.generate(current_album)
# display the word cloud
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
# re-generate the word cloud
Album_wc.generate(current_album)
# display the cloud
fig = plt.figure()
fig.set_figwidth(14) # set width
fig.set_figheight(18) # set height
plt.imshow(Album_wc, interpolation='bilinear')
plt.axis('off')
plt.show()
filtered_words = [word for word in current_album.split() if word not in stop_words]
counted_words = collections.Counter(filtered_words)
words = []
counts = []
for letter, count in counted_words.most_common(10):
words.append(letter)
counts.append(count)
colors = cm.rainbow(np.linspace(0, 1, 10))
rcParams['figure.figsize'] = 20, 10
plt.title('Top words in the text vs their count/ Album "Perdida" (2020))')
plt.xlabel('Count')
plt.ylabel('Words')
plt.barh(words, counts, color=colors)