Spaces:
Sleeping
Sleeping
Commit
·
1f692f1
1
Parent(s):
58a590b
add logging
Browse files
app.py
CHANGED
|
@@ -1,7 +1,16 @@
|
|
| 1 |
import json
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from textblob import TextBlob
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
def sentiment_analysis(text: str) -> str:
|
| 6 |
"""
|
| 7 |
Analyze the sentiment of the given text.
|
|
@@ -21,7 +30,7 @@ def sentiment_analysis(text: str) -> str:
|
|
| 21 |
"assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
|
| 22 |
}
|
| 23 |
|
| 24 |
-
|
| 25 |
return json.dumps(result)
|
| 26 |
|
| 27 |
# Create the Gradio interface
|
|
|
|
| 1 |
import json
|
| 2 |
+
import logging
|
| 3 |
import gradio as gr
|
| 4 |
from textblob import TextBlob
|
| 5 |
|
| 6 |
+
logging.basicConfig(
|
| 7 |
+
level=logging.DEBUG, # Set the logging level
|
| 8 |
+
format="%(asctime)s - %(levelname)s - %(message)s", # Define the log format
|
| 9 |
+
handlers=[
|
| 10 |
+
logging.StreamHandler() # Ensure logs are displayed on the console
|
| 11 |
+
]
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
def sentiment_analysis(text: str) -> str:
|
| 15 |
"""
|
| 16 |
Analyze the sentiment of the given text.
|
|
|
|
| 30 |
"assessment": "positive" if sentiment.polarity > 0 else "negative" if sentiment.polarity < 0 else "neutral"
|
| 31 |
}
|
| 32 |
|
| 33 |
+
logging.info(f"Sentiment analysis result: {result}")
|
| 34 |
return json.dumps(result)
|
| 35 |
|
| 36 |
# Create the Gradio interface
|