Update README.md
Browse files
README.md
CHANGED
@@ -86,14 +86,22 @@ Positive: 0.79%
|
|
86 |
```pyhton
|
87 |
from transformers import pipeline
|
88 |
|
89 |
-
url = "
|
90 |
|
91 |
classifier = pipeline("sentiment-analysis", model=url)
|
92 |
|
93 |
text = "text to classify"
|
94 |
|
95 |
-
result = classifier(text)
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
```
|
98 |
|
99 |
## Metrics and results:
|
|
|
86 |
```pyhton
|
87 |
from transformers import pipeline
|
88 |
|
89 |
+
url = "delarosajav95/tw-roberta-base-sentiment-FT-v2"
|
90 |
|
91 |
classifier = pipeline("sentiment-analysis", model=url)
|
92 |
|
93 |
text = "text to classify"
|
94 |
|
95 |
+
result = classifier(text, return_all_scores=True)
|
96 |
+
|
97 |
+
label_mapping = {"LABEL_0": "Negative", "LABEL_1": "Neutral", "LABEL_2": "Positive"}
|
98 |
+
for i, predictions in enumerate(result):
|
99 |
+
print("==================================")
|
100 |
+
print(f"Text {i + 1}: {text}")
|
101 |
+
for pred in predictions:
|
102 |
+
label = label_mapping.get(pred['label'], pred['label'])
|
103 |
+
score = pred['score']
|
104 |
+
print(f"{label}: {score:.2%}")
|
105 |
```
|
106 |
|
107 |
## Metrics and results:
|