Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -476,45 +476,106 @@ def format_results(analysis_result):
|
|
476 |
</div>
|
477 |
''' if analysis_result["verification_needed"] else ''}
|
478 |
|
479 |
-
<div class="
|
480 |
-
<
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
</div>
|
503 |
|
504 |
{f'''
|
505 |
-
<div class="alert-success">
|
506 |
β
<strong>Event Validated:</strong> The extracted information meets confidence thresholds.
|
507 |
</div>
|
508 |
''' if not analysis_result["verification_needed"] else ''}
|
509 |
|
510 |
{f'''
|
511 |
<div class="related-events">
|
512 |
-
<h4
|
513 |
<ul>
|
514 |
-
{''.join(f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
</ul>
|
516 |
</div>
|
517 |
''' if analysis_result.get('related_events') else ''}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
</div>
|
519 |
"""
|
520 |
return html
|
|
|
476 |
</div>
|
477 |
''' if analysis_result["verification_needed"] else ''}
|
478 |
|
479 |
+
<div class="grid grid-cols-2 gap-4">
|
480 |
+
<div class="space-y-4">
|
481 |
+
<div class="entity-section">
|
482 |
+
<h4>π€ People Detected</h4>
|
483 |
+
<ul>{''.join(f'<li>{person}</li>' for person in analysis_result['entities']['people']) or '<li>None detected</li>'}</ul>
|
484 |
+
</div>
|
485 |
+
|
486 |
+
<div class="entity-section">
|
487 |
+
<h4>π’ Organizations</h4>
|
488 |
+
<ul>{''.join(f'<li>{org}</li>' for org in analysis_result['entities']['organizations']) or '<li>None detected</li>'}</ul>
|
489 |
+
</div>
|
490 |
+
|
491 |
+
<div class="entity-section">
|
492 |
+
<h4>π Locations</h4>
|
493 |
+
<ul>{''.join(f'<li>{loc}</li>' for loc in analysis_result['entities']['locations']) or '<li>None detected</li>'}</ul>
|
494 |
+
</div>
|
495 |
+
</div>
|
496 |
+
|
497 |
+
<div class="space-y-4">
|
498 |
+
<div class="entity-section">
|
499 |
+
<h4>π Temporal References</h4>
|
500 |
+
<ul>{''.join(f'<li>{time}</li>' for time in analysis_result['entities']['temporal']) or '<li>None detected</li>'}</ul>
|
501 |
+
</div>
|
502 |
+
|
503 |
+
<div class="entity-section">
|
504 |
+
<h4># Hashtags</h4>
|
505 |
+
<ul>{''.join(f'<li>{tag}</li>' for tag in analysis_result['entities']['hashtags']) or '<li>None detected</li>'}</ul>
|
506 |
+
</div>
|
507 |
+
|
508 |
+
{f'''
|
509 |
+
<div class="entity-section">
|
510 |
+
<h4>π Entity Relationships</h4>
|
511 |
+
<ul>
|
512 |
+
{''.join(f"""
|
513 |
+
<li class="mb-2">
|
514 |
+
<strong>{rel['source']}</strong> β
|
515 |
+
<span class="text-blue-600">{rel['type'].replace('_to_', ' β ')}</span> β
|
516 |
+
<strong>{rel['target']}</strong>
|
517 |
+
<br/>
|
518 |
+
<small class="text-gray-600">Confidence: {int(rel['confidence'] * 100)}%</small>
|
519 |
+
</li>
|
520 |
+
""" for rel in analysis_result['entity_relationships'])}
|
521 |
+
</ul>
|
522 |
+
</div>
|
523 |
+
''' if analysis_result.get('entity_relationships') else ''}
|
524 |
+
</div>
|
525 |
</div>
|
526 |
|
527 |
{f'''
|
528 |
+
<div class="alert-success mt-4">
|
529 |
β
<strong>Event Validated:</strong> The extracted information meets confidence thresholds.
|
530 |
</div>
|
531 |
''' if not analysis_result["verification_needed"] else ''}
|
532 |
|
533 |
{f'''
|
534 |
<div class="related-events">
|
535 |
+
<h4>π Related Events</h4>
|
536 |
<ul>
|
537 |
+
{''.join(f"""
|
538 |
+
<li class="mb-2">
|
539 |
+
<div class="flex justify-between items-center">
|
540 |
+
<div>{event["text"]}</div>
|
541 |
+
<div class="text-sm text-gray-600">
|
542 |
+
{event["timestamp"]} |
|
543 |
+
Confidence: {int(event["confidence"] * 100)}%
|
544 |
+
{f' | Shared Entities: {event["shared_entities"]}' if event.get("shared_entities") else ''}
|
545 |
+
</div>
|
546 |
+
</div>
|
547 |
+
</li>
|
548 |
+
""" for event in analysis_result['related_events'])}
|
549 |
</ul>
|
550 |
</div>
|
551 |
''' if analysis_result.get('related_events') else ''}
|
552 |
+
|
553 |
+
<div class="entity-stats mt-4 p-4 bg-gray-50 rounded-lg">
|
554 |
+
<h4 class="mb-2">π Analysis Metrics</h4>
|
555 |
+
<div class="grid grid-cols-3 gap-4 text-sm">
|
556 |
+
<div>
|
557 |
+
<strong>Confidence Breakdown:</strong>
|
558 |
+
<ul class="mt-1">
|
559 |
+
<li>Base Confidence: {int(analysis_result['confidence'] * 70)}%</li>
|
560 |
+
<li>Entity Boost: {int((analysis_result['confidence'] - 0.7 if analysis_result['confidence'] > 0.7 else 0) * 100)}%</li>
|
561 |
+
</ul>
|
562 |
+
</div>
|
563 |
+
<div>
|
564 |
+
<strong>Entity Coverage:</strong>
|
565 |
+
<ul class="mt-1">
|
566 |
+
<li>Types Detected: {len([t for t in ['people', 'organizations', 'locations', 'temporal', 'hashtags'] if analysis_result['entities'].get(t)])}</li>
|
567 |
+
<li>Total Entities: {sum(len(e) for e in analysis_result['entities'].values() if isinstance(e, list))}</li>
|
568 |
+
</ul>
|
569 |
+
</div>
|
570 |
+
<div>
|
571 |
+
<strong>Relationships:</strong>
|
572 |
+
<ul class="mt-1">
|
573 |
+
<li>Direct: {len(analysis_result.get('entity_relationships', []))}</li>
|
574 |
+
<li>Related Events: {len(analysis_result.get('related_events', []))}</li>
|
575 |
+
</ul>
|
576 |
+
</div>
|
577 |
+
</div>
|
578 |
+
</div>
|
579 |
</div>
|
580 |
"""
|
581 |
return html
|