Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -385,7 +385,54 @@ def create_visualizations(detection_result):
|
|
| 385 |
|
| 386 |
return fig_radar, fig_bar, fig_scores
|
| 387 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
|
|
|
|
| 389 |
def analyze_news_site(site_name):
|
| 390 |
"""Analyze pre-configured news sites"""
|
| 391 |
news_sites = {
|
|
|
|
| 385 |
|
| 386 |
return fig_radar, fig_bar, fig_scores
|
| 387 |
|
| 388 |
+
def analyze_website(url):
|
| 389 |
+
"""Analyze website URL"""
|
| 390 |
+
if not url.strip():
|
| 391 |
+
return "Please enter a URL to analyze.", None, None, None, None
|
| 392 |
+
|
| 393 |
+
# Scrape website
|
| 394 |
+
scraped_data = scrape_website(url)
|
| 395 |
+
|
| 396 |
+
if 'error' in scraped_data:
|
| 397 |
+
return scraped_data['error'], None, None, None, None
|
| 398 |
+
|
| 399 |
+
# Analyze the scraped text
|
| 400 |
+
detector = AIContentDetector()
|
| 401 |
+
detection_result = detector.get_detection_result(scraped_data['text'])
|
| 402 |
+
|
| 403 |
+
if 'error' in detection_result:
|
| 404 |
+
return detection_result['error'], None, None, None, None
|
| 405 |
+
|
| 406 |
+
# Create visualizations
|
| 407 |
+
fig_radar, fig_bar, fig_scores = create_visualizations(detection_result)
|
| 408 |
+
|
| 409 |
+
# Format results
|
| 410 |
+
ai_prob = detection_result['ai_probability']
|
| 411 |
+
confidence = detection_result['confidence']
|
| 412 |
+
word_count = detection_result['word_count']
|
| 413 |
+
|
| 414 |
+
# Create detailed analysis text
|
| 415 |
+
analysis = detection_result['detailed_analysis']
|
| 416 |
+
detailed_text = f"""
|
| 417 |
+
**Website:** {url}
|
| 418 |
+
**AI Probability:** {ai_prob:.1%}
|
| 419 |
+
**Confidence:** {confidence}
|
| 420 |
+
**Word Count:** {word_count}
|
| 421 |
+
|
| 422 |
+
**Detailed Analysis:**
|
| 423 |
+
- Perplexity: {analysis['perplexity']:.2f}
|
| 424 |
+
- Burstiness: {analysis['burstiness']:.3f}
|
| 425 |
+
- Vocabulary Diversity: {analysis['vocabulary_diversity']['type_token_ratio']:.3f}
|
| 426 |
+
- Avg Sentence Length: {analysis['sentence_structure']['avg_sentence_length']:.1f}
|
| 427 |
+
- Flesch Reading Ease: {analysis['readability']['flesch_reading_ease']:.1f}
|
| 428 |
+
- Topic Consistency: {analysis['semantic_coherence']['topic_consistency']:.3f}
|
| 429 |
+
|
| 430 |
+
**Sample Text:** {scraped_data['text'][:200]}...
|
| 431 |
+
"""
|
| 432 |
+
|
| 433 |
+
return detailed_text, fig_radar, fig_bar, fig_scores
|
| 434 |
|
| 435 |
+
|
| 436 |
def analyze_news_site(site_name):
|
| 437 |
"""Analyze pre-configured news sites"""
|
| 438 |
news_sites = {
|