<jupyter_start><jupyter_text>Sentiment analysis with TextBlob<jupyter_code># Get polarity and subjectivity from TextBlob
pol = lambda x: TextBlob(x).sentiment.polarity
sub = lambda x: TextBlob(x).sentiment.subjectivity

data['polarity'] = data.content.apply(pol)
data['subjectivity'] = data.content.apply(sub)
data
# Let's plot the results
import matplotlib.pyplot as plt

plt.rcParams['figure.figsize'] = [8, 6]

for index, wing in enumerate(data.index):
    x = data.polarity.loc[wing]
    y = data.subjectivity.loc[wing]
    plt.scatter(x, y, color='blue')
    plt.text(x+.001, y+.001, data['wing'][index], fontsize=10)
    plt.xlim(.050, .43) 
    plt.ylim(.422, .47) 
    
plt.title('Sentiment Analysis', fontsize=20)
plt.xlabel('<-- Negative -------- Positive -->', fontsize=15)
plt.ylabel('<-- Facts -------- Opinions -->', fontsize=15)

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17853107344632768, 'fraction_numerical': 0.02937853107344633, 'mean_word_length': 4.3053892215568865, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '298519', 'license': 'MIT', 'n_tokens_mistral': 346, 'n_tokens_neox': 313, 'n_words': 66, 'path': 'nbs/04_sentiment_analysis.ipynb', 'repo_name': 'danhphan/aussie-sentiment', 'size': '885'}