# تثبيت المكتبات المطلوبة # !pip install transformers torch from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline # نختار موديل فارسي جاهز model_name = "HooshvareLab/bert-fa-base-uncased-sentiment-snappfood" # تحميل التوكنيزر والموديل tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name) # نعمل Pipeline للتحليل sentiment_pipeline = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer) # نجرب نصوص بالفارسية texts = [ "من این فیلم را خیلی دوست دارم", # جملة إيجابية "این غذا افتضاح بود", # جملة سلبية "امروز یک روز معمولی است" # جملة محايدة ] for t in texts: result = sentiment_pipeline(t) print(f"متن: {t}") print(f"نتیجه: {result}\n")