Spaces:
Sleeping
Sleeping
Create sentiment_analysis.py
Browse files- sentiment_analysis.py +13 -0
sentiment_analysis.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
|
| 3 |
+
# Step 1: Load the sentiment-analysis pipeline
|
| 4 |
+
sentiment_analyzer = pipeline("sentiment-analysis")
|
| 5 |
+
|
| 6 |
+
# Step 2: Provide some input text
|
| 7 |
+
text = "I love using Hugging Face models! They are amazing."
|
| 8 |
+
|
| 9 |
+
# Step 3: Get the prediction
|
| 10 |
+
result = sentiment_analyzer(text)
|
| 11 |
+
|
| 12 |
+
# Step 4: Print the result
|
| 13 |
+
print(result)
|