Spaces:
Running
Running
Update sentiment_analysis.py
Browse files- sentiment_analysis.py +5 -3
sentiment_analysis.py
CHANGED
@@ -18,7 +18,7 @@ class SimpleSentimentTool(Tool):
|
|
18 |
}
|
19 |
}
|
20 |
# Use a standard authorized type
|
21 |
-
output_type = "
|
22 |
|
23 |
# Available sentiment analysis models
|
24 |
models = {
|
@@ -89,7 +89,9 @@ class SimpleSentimentTool(Tool):
|
|
89 |
for item in prediction[0]:
|
90 |
result[item['label']] = float(item['score'])
|
91 |
|
92 |
-
|
|
|
|
|
93 |
except Exception as e:
|
94 |
print(f"Error in sentiment analysis: {str(e)}")
|
95 |
-
return {"error": str(e)}
|
|
|
18 |
}
|
19 |
}
|
20 |
# Use a standard authorized type
|
21 |
+
output_type = "string"
|
22 |
|
23 |
# Available sentiment analysis models
|
24 |
models = {
|
|
|
89 |
for item in prediction[0]:
|
90 |
result[item['label']] = float(item['score'])
|
91 |
|
92 |
+
# Convert to JSON string for output
|
93 |
+
import json
|
94 |
+
return json.dumps(result, indent=2)
|
95 |
except Exception as e:
|
96 |
print(f"Error in sentiment analysis: {str(e)}")
|
97 |
+
return json.dumps({"error": str(e)}, indent=2)
|