Dhom1 commited on
Commit
3a838cd
·
verified ·
1 Parent(s): a83b920

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +4 -7
src/streamlit_app.py CHANGED
@@ -76,11 +76,11 @@ with col2:
76
  uploaded_text = st.text_area("✍️ أدخل نص الإعلان هنا:", height=150)
77
 
78
  # ✅ تصنيف الإعلان + فحص العبارات في نفس الوقت
 
79
  if uploaded_text:
80
  try:
81
  # تصنيف النموذج ML
82
  pred = classifier.predict([uploaded_text])[0]
83
- ml_label = "✅ إعلان سليم" if pred == 1 else "❌ إعلان مخالف"
84
 
85
  # فحص العبارات المخالفة
86
  violations = [kw for kw in offensive_keywords if kw in uploaded_text]
@@ -88,22 +88,19 @@ if uploaded_text:
88
 
89
  # منطق التصنيف النهائي
90
  if has_violations:
91
- final_label = "❌ إعلان مخالف (عبارات)"
92
  elif pred == 1:
93
  final_label = "✅ إعلان سليم"
94
  else:
95
  final_label = "❌ إعلان مخالف"
96
 
97
- # ✅ عرض التصنيف النهائي
98
  st.markdown(f'<div class="metric-container"><h4>{final_label}</h4></div>', unsafe_allow_html=True)
99
 
100
- # ✅ عرض تنبيه إن كان فيه تعارض منطقي
101
- if has_violations and pred == 1:
102
- st.warning("⚠️ تم تصنيفه كـ 'إعلان سليم' حسب النموذج، لكنه يحتوي على عبارات قد تُعد مخالفة.")
103
-
104
  except Exception as e:
105
  st.error(f"حدث خطأ في التنبؤ: {str(e)}")
106
 
 
107
  # ✅ تحليل العبارات (تفصيل العبارات المخالفة + نسبة)
108
  if st.button("🔍 تحليل العبارات"):
109
  if uploaded_text:
 
76
  uploaded_text = st.text_area("✍️ أدخل نص الإعلان هنا:", height=150)
77
 
78
  # ✅ تصنيف الإعلان + فحص العبارات في نفس الوقت
79
+ # ✅ تصنيف الإعلان + فحص العبارات في نفس الوقت (بدون عرض تفاصيل النموذج)
80
  if uploaded_text:
81
  try:
82
  # تصنيف النموذج ML
83
  pred = classifier.predict([uploaded_text])[0]
 
84
 
85
  # فحص العبارات المخالفة
86
  violations = [kw for kw in offensive_keywords if kw in uploaded_text]
 
88
 
89
  # منطق التصنيف النهائي
90
  if has_violations:
91
+ final_label = "❌ إعلان مخالف"
92
  elif pred == 1:
93
  final_label = "✅ إعلان سليم"
94
  else:
95
  final_label = "❌ إعلان مخالف"
96
 
97
+ # ✅ عرض التصنيف النهائي فقط
98
  st.markdown(f'<div class="metric-container"><h4>{final_label}</h4></div>', unsafe_allow_html=True)
99
 
 
 
 
 
100
  except Exception as e:
101
  st.error(f"حدث خطأ في التنبؤ: {str(e)}")
102
 
103
+
104
  # ✅ تحليل العبارات (تفصيل العبارات المخالفة + نسبة)
105
  if st.button("🔍 تحليل العبارات"):
106
  if uploaded_text: