Update app.py
Browse files
app.py
CHANGED
@@ -389,13 +389,24 @@ def analyze_single_text(text: str, language: str, theme: str, clean_text: bool,
|
|
389 |
if not text.strip():
|
390 |
return "Please enter text", None, None, "No analysis performed"
|
391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
preprocessing_options = {
|
393 |
'clean_text': clean_text,
|
394 |
'remove_punctuation': remove_punct,
|
395 |
'remove_numbers': remove_nums
|
396 |
}
|
397 |
|
398 |
-
result = SentimentAnalyzer.analyze_text(text,
|
399 |
|
400 |
# Add to history
|
401 |
history_entry = {
|
@@ -497,8 +508,8 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Advanced Sentiment Analyzer") as d
|
|
497 |
|
498 |
with gr.Row():
|
499 |
language_select = gr.Dropdown(
|
500 |
-
choices=[
|
501 |
-
value='
|
502 |
label="Language"
|
503 |
)
|
504 |
theme_select = gr.Dropdown(
|
|
|
389 |
if not text.strip():
|
390 |
return "Please enter text", None, None, "No analysis performed"
|
391 |
|
392 |
+
# Map display names back to language codes
|
393 |
+
language_map = {
|
394 |
+
'Auto Detect': 'auto',
|
395 |
+
'English': 'en',
|
396 |
+
'Chinese': 'zh',
|
397 |
+
'Spanish': 'es',
|
398 |
+
'French': 'fr',
|
399 |
+
'German': 'de'
|
400 |
+
}
|
401 |
+
language_code = language_map.get(language, 'auto')
|
402 |
+
|
403 |
preprocessing_options = {
|
404 |
'clean_text': clean_text,
|
405 |
'remove_punctuation': remove_punct,
|
406 |
'remove_numbers': remove_nums
|
407 |
}
|
408 |
|
409 |
+
result = SentimentAnalyzer.analyze_text(text, language_code, preprocessing_options)
|
410 |
|
411 |
# Add to history
|
412 |
history_entry = {
|
|
|
508 |
|
509 |
with gr.Row():
|
510 |
language_select = gr.Dropdown(
|
511 |
+
choices=['Auto Detect', 'English', 'Chinese', 'Spanish', 'French', 'German'],
|
512 |
+
value='Auto Detect',
|
513 |
label="Language"
|
514 |
)
|
515 |
theme_select = gr.Dropdown(
|