Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -816,7 +816,9 @@ def analyze_news(news_text):
|
|
| 816 |
fake_confidence = 1 - combined_confidence
|
| 817 |
|
| 818 |
# Build the detailed report with better formatting
|
| 819 |
-
|
|
|
|
|
|
|
| 820 |
confidence_level = "Cao" if combined_confidence > 0.7 else "Trung bình" if combined_confidence > 0.4 else "Thấp"
|
| 821 |
confidence_emoji = "🟢" if combined_confidence > 0.7 else "🟡" if combined_confidence > 0.4 else "🔴"
|
| 822 |
|
|
@@ -860,13 +862,13 @@ def analyze_news(news_text):
|
|
| 860 |
## 🔍 **KẾT QUẢ PHÂN TÍCH TIN TỨC**
|
| 861 |
|
| 862 |
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; border-radius: 10px; margin: 20px 0; text-align: center;">
|
| 863 |
-
<h2 style="margin: 0; font-size: 24px;">{prediction_emoji} {'TIN THẬT' if
|
| 864 |
<p style="margin: 10px 0 0 0; font-size: 18px; opacity: 0.9;">{confidence_emoji} Độ tin cậy: {confidence_level} ({combined_confidence:.0%})</p>
|
| 865 |
</div>
|
| 866 |
|
| 867 |
### 🤖 **Phân tích bằng AI**
|
| 868 |
<div style="background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #007bff; margin: 10px 0;">
|
| 869 |
-
<p><strong>Kết quả:</strong> {prediction_emoji} {'Tin tức này có vẻ THẬT' if
|
| 870 |
<p><strong>Độ chắc chắn:</strong> {f"{distilbert_confidence:.0%}" if distilbert_confidence else 'Không có'} - {'Rất cao' if distilbert_confidence and distilbert_confidence > 0.8 else 'Cao' if distilbert_confidence and distilbert_confidence > 0.6 else 'Trung bình' if distilbert_confidence and distilbert_confidence > 0.4 else 'Thấp'}</p>
|
| 871 |
</div>
|
| 872 |
|
|
@@ -889,7 +891,7 @@ def analyze_news(news_text):
|
|
| 889 |
|
| 890 |
### 📊 **KẾT LUẬN CUỐI CÙNG**
|
| 891 |
<div style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
|
| 892 |
-
<p style="margin: 0; font-size: 16px;"><strong>Tin tức này có khả năng {'THẬT' if
|
| 893 |
<p style="margin: 5px 0 0 0; font-size: 14px; opacity: 0.9;">Dựa trên phân tích AI, kiểm tra nguồn tin và đánh giá thông minh</p>
|
| 894 |
</div>
|
| 895 |
|
|
|
|
| 816 |
fake_confidence = 1 - combined_confidence
|
| 817 |
|
| 818 |
# Build the detailed report with better formatting
|
| 819 |
+
# Use combined_confidence to determine the final classification (not just DistilBERT)
|
| 820 |
+
final_prediction = "REAL" if combined_confidence > 0.5 else "FAKE" if combined_confidence < 0.5 else "UNCERTAIN"
|
| 821 |
+
prediction_emoji = "✅" if final_prediction == "REAL" else "❌" if final_prediction == "FAKE" else "❓"
|
| 822 |
confidence_level = "Cao" if combined_confidence > 0.7 else "Trung bình" if combined_confidence > 0.4 else "Thấp"
|
| 823 |
confidence_emoji = "🟢" if combined_confidence > 0.7 else "🟡" if combined_confidence > 0.4 else "🔴"
|
| 824 |
|
|
|
|
| 862 |
## 🔍 **KẾT QUẢ PHÂN TÍCH TIN TỨC**
|
| 863 |
|
| 864 |
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; border-radius: 10px; margin: 20px 0; text-align: center;">
|
| 865 |
+
<h2 style="margin: 0; font-size: 24px;">{prediction_emoji} {'TIN THẬT' if final_prediction == 'REAL' else 'TIN GIẢ' if final_prediction == 'FAKE' else 'KHÔNG XÁC ĐỊNH'}</h2>
|
| 866 |
<p style="margin: 10px 0 0 0; font-size: 18px; opacity: 0.9;">{confidence_emoji} Độ tin cậy: {confidence_level} ({combined_confidence:.0%})</p>
|
| 867 |
</div>
|
| 868 |
|
| 869 |
### 🤖 **Phân tích bằng AI**
|
| 870 |
<div style="background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #007bff; margin: 10px 0;">
|
| 871 |
+
<p><strong>Kết quả:</strong> {prediction_emoji} {'Tin tức này có vẻ THẬT' if final_prediction == 'REAL' else 'Tin tức này có vẻ GIẢ' if final_prediction == 'FAKE' else 'Không thể xác định'}</p>
|
| 872 |
<p><strong>Độ chắc chắn:</strong> {f"{distilbert_confidence:.0%}" if distilbert_confidence else 'Không có'} - {'Rất cao' if distilbert_confidence and distilbert_confidence > 0.8 else 'Cao' if distilbert_confidence and distilbert_confidence > 0.6 else 'Trung bình' if distilbert_confidence and distilbert_confidence > 0.4 else 'Thấp'}</p>
|
| 873 |
</div>
|
| 874 |
|
|
|
|
| 891 |
|
| 892 |
### 📊 **KẾT LUẬN CUỐI CÙNG**
|
| 893 |
<div style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
|
| 894 |
+
<p style="margin: 0; font-size: 16px;"><strong>Tin tức này có khả năng {'THẬT' if final_prediction == 'REAL' else 'GIẢ' if final_prediction == 'FAKE' else 'KHÔNG XÁC ĐỊNH'} với độ tin cậy {max(real_confidence, fake_confidence):.0%}</strong></p>
|
| 895 |
<p style="margin: 5px 0 0 0; font-size: 14px; opacity: 0.9;">Dựa trên phân tích AI, kiểm tra nguồn tin và đánh giá thông minh</p>
|
| 896 |
</div>
|
| 897 |
|