Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +17 -1
src/streamlit_app.py
CHANGED
|
@@ -77,6 +77,22 @@ llm_client = load_llm_client()
|
|
| 77 |
if llm_client:
|
| 78 |
st.success("✅ GitHub Models API connected automatically!")
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
def predict_sentiment_enhanced(text):
|
| 81 |
"""Enhanced sentiment prediction ensuring 5-class output"""
|
| 82 |
if not text.strip():
|
|
@@ -89,7 +105,7 @@ def predict_sentiment_enhanced(text):
|
|
| 89 |
}
|
| 90 |
|
| 91 |
try:
|
| 92 |
-
results = sentiment_pipeline(text)
|
| 93 |
if isinstance(results[0], list):
|
| 94 |
results = results[0]
|
| 95 |
|
|
|
|
| 77 |
if llm_client:
|
| 78 |
st.success("✅ GitHub Models API connected automatically!")
|
| 79 |
|
| 80 |
+
def fix_problematic_words(text):
|
| 81 |
+
"""Quick fix for specific words causing classification issues"""
|
| 82 |
+
fixes = {
|
| 83 |
+
'phenomenal': 'absolutely amazing excellent',
|
| 84 |
+
'fabulous': 'excellent wonderful',
|
| 85 |
+
'superb': 'excellent great quality',
|
| 86 |
+
'marvelous': 'amazing wonderful',
|
| 87 |
+
'spectacular': 'outstanding excellent',
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
text_fixed = text
|
| 91 |
+
for problematic, replacement in fixes.items():
|
| 92 |
+
text_fixed = re.sub(rf'\b{problematic}\b', replacement, text_fixed, flags=re.IGNORECASE)
|
| 93 |
+
|
| 94 |
+
return text_fixed
|
| 95 |
+
|
| 96 |
def predict_sentiment_enhanced(text):
|
| 97 |
"""Enhanced sentiment prediction ensuring 5-class output"""
|
| 98 |
if not text.strip():
|
|
|
|
| 105 |
}
|
| 106 |
|
| 107 |
try:
|
| 108 |
+
results = sentiment_pipeline(fix_problematic_words(text))
|
| 109 |
if isinstance(results[0], list):
|
| 110 |
results = results[0]
|
| 111 |
|