| |
| |
|
|
| 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) |
|
|
| |
| 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") |