<jupyter_start><jupyter_text>Data for Sentiment Analysis<jupyter_code>#Import the movie reviews corpus
with open("Batman Review 1986.txt", 'r') as fh:  
    reviews = fh.readlines()
print(reviews[:2])<jupyter_output>['A beautiful and very entertaining animated sequel that makes me have a nice time for a magical hour and a half.\n', 'Frozen II may sing about change, but that progress is what you project onto it.\n']<jupyter_text>Sentiments by Review<jupyter_code>#install textblob if not already installed using "pip install -U textblob"
from textblob import TextBlob

print('{:40} : {:10} : {:10}'.format("Review", "Polarity", "Subjectivity") )

for review in reviews:
    #Find sentiment of a review
    sentiment = TextBlob(review)
    #Print individual sentiments
    print('{:40} :   {: 01.2f}    :   {:01.2f}'.format(review[:40]\
                , sentiment.polarity, sentiment.subjectivity) )<jupyter_output><empty_output><jupyter_text>02_04 Summarizing Sentiment<jupyter_code>#Categorize Polarity into Positive, Neutral or Negative
labels = ["Negative", "Neutral", "Positive"]
#Initialize count array
values =[0,0,0]

#Categorize each review
for review in reviews:
    sentiment = TextBlob(review)
    
    #Custom formula to convert polarity 
    # 0 = (Negative) 1 = (Neutral) 2=(Positive)
    polarity = round(( sentiment.polarity + 1 ) * 3 ) % 3
    
    #add the summary array
    values[polarity] = values[polarity] + 1
    
print("Final summarized counts :", values)

import matplotlib.pyplot as plt
#Set colors by label
colors=["Yellow","Azure","Blue"]

print("\n Pie Representation \n-------------------")
#Plot a pie chart
plt.pie(values, labels=labels, colors=colors, \
        autopct='%1.1f%%', shadow=True, startangle=140)
plt.axis('equal')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1345514950166113, 'fraction_numerical': 0.0221483942414175, 'mean_word_length': 4.377976190476191, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '291372', 'license': 'MIT', 'n_tokens_mistral': 619, 'n_tokens_neox': 576, 'n_words': 172, 'path': 'Sentimental Analysis-Batman.ipynb', 'repo_name': 'BLUEBAYcreater/Sentimental-Analysis-using-Python-for-Android-App', 'size': '1806'}