Spaces:
Running
Running
fix id labeling with sentiment label names
Browse files- interfaces/sentiment.py +3 -1
interfaces/sentiment.py
CHANGED
@@ -18,6 +18,8 @@ domains = {
|
|
18 |
"parliamentary speech": "parlspeech",
|
19 |
}
|
20 |
|
|
|
|
|
21 |
|
22 |
def build_huggingface_path(language: str):
|
23 |
return "poltextlab/xlm-roberta-large-pooled-MORES"
|
@@ -43,7 +45,7 @@ def predict(text, model_id, tokenizer_id):
|
|
43 |
predicted_class_id = {4: 2, 5: 1}.get(predicted_class_id, 0)
|
44 |
|
45 |
|
46 |
-
output_pred =
|
47 |
|
48 |
|
49 |
output_info = f'<p style="text-align: center; display: block">Prediction was made using the <a href="https://huggingface.co/{model_id}">{model_id}</a> model.</p>'
|
|
|
18 |
"parliamentary speech": "parlspeech",
|
19 |
}
|
20 |
|
21 |
+
SENTIMENT_LABEL_NAMES = {0: "Negative", 1: "No sentiment or Neutral sentiment", 2: "Positive"}
|
22 |
+
|
23 |
|
24 |
def build_huggingface_path(language: str):
|
25 |
return "poltextlab/xlm-roberta-large-pooled-MORES"
|
|
|
45 |
predicted_class_id = {4: 2, 5: 1}.get(predicted_class_id, 0)
|
46 |
|
47 |
|
48 |
+
output_pred = SENTIMENT_LABEL_NAMES.get(predicted_class_id, predicted_class_id)
|
49 |
|
50 |
|
51 |
output_info = f'<p style="text-align: center; display: block">Prediction was made using the <a href="https://huggingface.co/{model_id}">{model_id}</a> model.</p>'
|