<jupyter_start><jupyter_text>Sentiment analysis avec Textblob-FR Documentation: https://textblob.readthedocs.io/en/dev/  Imports<jupyter_code>import sys
from textblob import Blobber
from textblob_fr import PatternTagger, PatternAnalyzer<jupyter_output><empty_output><jupyter_text>Fonction<jupyter_code>tb = Blobber(pos_tagger=PatternTagger(), analyzer=PatternAnalyzer())

def get_sentiment(input_text):
    blob = tb(input_text)
    polarity, subjectivity = blob.sentiment
    polarity_perc = f"{100*abs(polarity):.0f}"
    subjectivity_perc = f"{100*subjectivity:.0f}"
    if polarity > 0:
        polarity_str = f"{polarity_perc}% positive"
    elif polarity < 0:
        polarity_str = f"{polarity_perc}% negative"
    else:
        polarity_str = "neutral"
    if subjectivity > 0:
        subjectivity_str = f"{subjectivity}% subjective"
    else:
        subjectivity_str = "perfectly objective"
    print(f"This text is {polarity_str} and {subjectivity_str}.")<jupyter_output><empty_output><jupyter_text>Analyser le sentiment d'une phrase<jupyter_code>get_sentiment("Ce conseil municipal est vraiment super intéressant.")
get_sentiment("Cette phrase est négative et je ne suis pas content !")<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup