<jupyter_start><jupyter_text>Sentiment Analysis  textblob | nltk<jupyter_code># load libraries
from textblob import TextBlob
message = '''Your problem is ill defined. What constitutes an anomaly can have a lot of different meanings. Is it deviation of the mean? Is it certain patterns of behaviour?'''
message
blob = TextBlob(message)
blob
blob.np_counts
blob.tokens
blob.ngrams(n=4)
blob.words
blob.word_counts
blob.tags
blob.noun_phrases
for sentence in blob.sentences:
    print(sentence, sentence.sentiment.polarity)
blob.translate(to="es")
message = '''You are wonderful to be with! I'd rather die than live with you. You should have a seat reserved in heaven!'''
message
blob = TextBlob(message)
blob
for sentence in blob.sentences:
    print(sentence, sentence.sentiment.polarity)<jupyter_output>You are wonderful to be with! 1.0
I'd rather die than live with you. 0.13636363636363635
You should have a seat reserved in heaven! 0.0
{'fraction_non_alphanumeric': 0.07995735607675906, 'fraction_numerical': 0.024520255863539446, 'mean_word_length': 5.387755102040816, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '224651', 'license': 'MIT', 'n_tokens_mistral': 307, 'n_tokens_neox': 284, 'n_words': 112, 'path': 'machinelearning/ml_python_sentiment_analysis_textblob_1.ipynb', 'repo_name': 'futureseadev/hgwxx7', 'size': '938'}