Python Code used for Content Analysis

file = open(“X.txt”, “rt”)
data = file.read()
words = data.lower().split()
dic = {}

for word in words:
word = word.replace(“(“,””)
word = word.replace(“)”, “”)
word = word.replace(“?”, “”)
if word in dic.keys():
dic[word] += 1
else:
dic[word] = 1
# print(word)

arr = ({k: v for k, v in sorted(dic.items(), key=lambda item: item[1], reverse=True)})

for item in arr:
print(item, “:”, arr[item])

 

 

represents a single .txt file with only lyrics

 

css.php