Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -135,18 +135,19 @@ async def test_classify_text(text: str = Form(...)):
|
|
135 |
# Perform text classification using the updated model that returns positive, neutral, or negative
|
136 |
result = nlp_classification_v2(text)
|
137 |
|
138 |
-
#
|
139 |
-
|
|
|
140 |
|
141 |
# Map the model labels to human-readable format
|
142 |
label_map = {
|
143 |
-
"
|
144 |
-
"
|
145 |
-
"
|
146 |
}
|
147 |
|
148 |
# Get the readable label from the map
|
149 |
-
formatted_label = label_map.get(
|
150 |
|
151 |
return {"label": formatted_label, "score": result[0]['score']}
|
152 |
except Exception as e:
|
|
|
135 |
# Perform text classification using the updated model that returns positive, neutral, or negative
|
136 |
result = nlp_classification_v2(text)
|
137 |
|
138 |
+
# Print the raw label for debugging purposes (can be removed later)
|
139 |
+
raw_label = result[0]['label']
|
140 |
+
print(f"Raw label from model: {raw_label}")
|
141 |
|
142 |
# Map the model labels to human-readable format
|
143 |
label_map = {
|
144 |
+
"negative": "Negative",
|
145 |
+
"neutral": "Neutral",
|
146 |
+
"positive": "Positive"
|
147 |
}
|
148 |
|
149 |
# Get the readable label from the map
|
150 |
+
formatted_label = label_map.get(raw_label, "Unknown")
|
151 |
|
152 |
return {"label": formatted_label, "score": result[0]['score']}
|
153 |
except Exception as e:
|