oberbics commited on
Commit
7cba597
·
verified ·
1 Parent(s): 34676f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -110
app.py CHANGED
@@ -438,19 +438,16 @@ def create_map(df, location_col):
438
  custom_css = """
439
  <style>
440
  @import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;400;600;700&display=swap');
441
-
442
  body, .gradio-container {
443
  font-family: 'Source Sans Pro', sans-serif !important;
444
  color: #333333;
445
  }
446
-
447
  h1 {
448
  font-weight: 700 !important;
449
  color: #2c6bb3 !important;
450
  font-size: 2.5rem !important;
451
  margin-bottom: 1rem !important;
452
  }
453
-
454
  h2 {
455
  font-weight: 600 !important;
456
  color: #4e8fd1 !important;
@@ -458,16 +455,13 @@ h2 {
458
  margin-top: 1rem !important;
459
  margin-bottom: 0.75rem !important;
460
  }
461
-
462
  .gradio-button.primary {
463
  background-color: #ff7518 !important;
464
  }
465
-
466
  .gradio-button.secondary {
467
  background-color: #5a87ca !important;
468
  color: white !important;
469
  }
470
-
471
  .info-box {
472
  background-color: #e8f4fd;
473
  border-left: 4px solid #2c6bb3;
@@ -475,7 +469,6 @@ h2 {
475
  margin: 15px 0;
476
  border-radius: 4px;
477
  }
478
-
479
  .file-upload-box {
480
  border: 2px dashed #e0e0e0;
481
  border-radius: 8px;
@@ -483,14 +476,12 @@ h2 {
483
  text-align: center;
484
  transition: all 0.3s ease;
485
  }
486
-
487
  /* Fix for map container spacing */
488
  #map-container {
489
  height: 20vh !important;
490
  margin-bottom: 0 !important;
491
  padding-bottom: 0 !important;
492
  }
493
-
494
  /* Stats box styling */
495
  .stats-box {
496
  margin-top: 10px !important;
@@ -499,12 +490,10 @@ h2 {
499
  background: #f8f9fa;
500
  border-radius: 4px;
501
  }
502
-
503
  /* Remove extra space around components */
504
  .gr-box {
505
  margin-bottom: 0 !important;
506
  }
507
-
508
  /* Model status styling */
509
  .model-status {
510
  padding: 10px;
@@ -513,7 +502,6 @@ h2 {
513
  background-color: #f8f9fa;
514
  font-size: 14px;
515
  }
516
-
517
  .separator {
518
  margin: 20px 0;
519
  border-top: 1px solid #eaeaea;
@@ -527,15 +515,12 @@ with gr.Blocks(css=custom_css, title="Daten Strukturieren und Analysieren") as d
527
  <h1>Strukturierung und Visualisierung von historischen Daten</h1>
528
  </div>
529
  <div style="font-family: 'Source Sans Pro', sans-serif; max-width: 1000px; margin: 0 auto; color: #333; line-height: 1.7; font-size: 1.15rem;">
530
-
531
  <p style="font-size: 1.3rem; margin-bottom: 1.8rem; color: #2c3e50; font-weight: 400; padding: 0 1rem;">
532
  In dieser Unterrichtseinheit befassen wir uns mit der Strukturierung unstrukturierter historischer Texte und der Visualisierung von extrahierten Daten auf Karten. Die systematische Strukturierung von Daten wird mit einem für Informationsextrahierung trainiertem Sprachmodell durchgeführt, das auf der Question-Answering-Methode basiert. Diese Methode erlaubt es, Informationen mit Hilfe einer Frage zu extrahieren, wie etwa „Wo fand das Erdbeben statt"? Dies ermöglicht die Extrahierung des Ortes, an dem ein Erdbeben stattfand, auch wenn im Text selbst noch andere Orte genannt werden.
533
  </p>
534
-
535
  <div style="font-family: 'Source Sans Pro', sans-serif; line-height: 1.7; font-size: 1.15rem; background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 20px 0;">
536
  Die Katastrophe in <span style="background-color: #a8e6cf; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Earthquake Location">Japan</span> — 3 Millionen Tote. Mtb. <span style="background-color: #ffdfba; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Non-Earthquake Location">London</span>, 4. Sept. (Drahtbericht.) Zu dem Unglück in <span style="background-color: #a8e6cf; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Earthquake Location">Japan</span> liegen noch folgende Nachrichten vor: Wie die japanische Gesandtschaft in <span style="background-color: #ffdfba; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Non-Earthquake Location">Peking</span> meldet, sind Unterhandlungen mit <span style="background-color: #ffdfba; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Non-Earthquake Location">China</span> über die sofortige Lieferung von Lebensmitteln ausgenommen worden. Von <span style="background-color: #ffdfba; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Non-Earthquake Location">Peking</span> seien amerikanische, englische und italienische Schiffe mit Lebensmitteln nach <span style="background-color: #a8e6cf; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Earthquake Location">Japan</span> abgegangen.
537
  </div>
538
-
539
  <div style="display: flex; margin-top: 20px;">
540
  <div style="display: flex; align-items: center; margin-right: 20px;">
541
  <div style="width: 20px; height: 20px; background-color: #a8e6cf; margin-right: 10px; border-radius: 3px;"></div>
@@ -546,8 +531,6 @@ Die Katastrophe in <span style="background-color: #a8e6cf; font-weight: bold; pa
546
  <span>Andere Orte: London, Peking, China</span>
547
  </div>
548
  </div>
549
-
550
-
551
  <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #3498db;">
552
  <h3 style="margin-top: 0; color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 0.8rem; font-size: 1.5rem;">
553
  Methodik: Vom unstrukturierten Text zur strukturierten Information
@@ -584,7 +567,6 @@ Die Katastrophe in <span style="background-color: #a8e6cf; font-weight: bold; pa
584
  </li>
585
  </ol>
586
  </div>
587
-
588
  <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #9b59b6;">
589
  <h4 style="color: #2980b9; margin-top: 0; font-size: 1.35rem;">Technische Funktionsweise des Sprachmodells</h4>
590
 
@@ -597,7 +579,6 @@ Die Katastrophe in <span style="background-color: #a8e6cf; font-weight: bold; pa
597
  <li style="margin-bottom: 1rem;"><strong style="color: #2c3e50; font-size: 1.2rem;">Generierung</strong>: Die erkannten Informationen werden in das vorgegebene Template eingefügt.</li>
598
  </ol>
599
  </div>
600
-
601
  <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #27ae60;">
602
  <h3 style="margin-top: 0; color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 0.8rem; font-size: 1.5rem;">
603
  Die Kartierungsfunktion
@@ -629,15 +610,12 @@ Die Katastrophe in <span style="background-color: #a8e6cf; font-weight: bold; pa
629
  Dieser kombinierte Ansatz aus Textextraktion und geografischer Visualisierung eröffnet neue Möglichkeiten für die räumliche Analyse historischer Quellen und erlaubt es, geografische Muster zu erkennen, die in den reinen Textdaten nicht unmittelbar sichtbar wären.
630
  </p>
631
  </div>
632
-
633
  <div style="margin-top: 2.5rem; padding: 1.5rem; background: #e8f4fd; border-radius: 10px; text-align: center; font-size: 1.1rem;">
634
  <p style="margin: 0;">Diese Methode ermöglicht die effiziente Extraktion und Visualisierung historischer Daten aus unstrukturierten Quellen.</p>
635
  </div>
636
-
637
  </div>
638
  """)
639
-
640
-
641
  with gr.Tabs() as tabs:
642
  with gr.TabItem("🔍 Text Extrahierung"):
643
  gr.HTML("""
@@ -679,93 +657,6 @@ Die Katastrophe in <span style="background-color: #a8e6cf; font-weight: bold; pa
679
  inputs=[template, text],
680
  outputs=[status, output]
681
  )
682
-
683
-
684
-
685
- # Add dateline examples section below the extraction
686
- # Note: This HTML block must be properly indented to be within the first tab
687
- with gr.Row():
688
- gr.HTML("""
689
- <div style="margin-top: 30px; border-top: 1px solid #eaeaea; padding-top: 20px;">
690
- <h3 style="color: #4e8fd1; margin-bottom: 15px;">Dateline Examples in International News</h3>
691
- <p style="margin-bottom: 15px;">Here are some examples of how datelines work in international news reporting:</p>
692
-
693
- <div style="margin-bottom: 20px; padding: 15px; background-color: white; border-left: 4px solid #0066cc; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">
694
- <div style="font-weight: bold; margin-bottom: 8px;">BERLIN — </div>
695
- <div style="color: #444; line-height: 1.5;">
696
- Japanese authorities confirmed at least 12 people died after a magnitude 6.8 earthquake struck the northern island of Hokkaido early Tuesday morning. Rescue operations continue in affected areas, with dozens still reported missing.
697
- </div>
698
- <div style="margin-top: 10px; font-style: italic; color: #666; font-size: 0.9em; border-top: 1px dotted #ddd; padding-top: 8px;">
699
- Example of a Paris newspaper using its Berlin correspondent to report on a Japan earthquake, with a simple location-only dateline.
700
- </div>
701
- </div>
702
-
703
- <div style="margin-bottom: 20px; padding: 15px; background-color: white; border-left: 4px solid #0066cc; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">
704
- <div style="font-weight: bold; margin-bottom: 8px;">BERLIN, May 7, 2025 — </div>
705
- <div style="color: #444; line-height: 1.5;">
706
- Japan's Meteorological Agency has issued a tsunami warning for coastal regions following a strong offshore earthquake. Initial reports indicate waves of up to two meters could reach shorelines within hours.
707
- </div>
708
- <div style="margin-top: 10px; font-style: italic; color: #666; font-size: 0.9em; border-top: 1px dotted #ddd; padding-top: 8px;">
709
- Example with both location and date in the dateline, showing more complete dateline format.
710
- </div>
711
- </div>
712
-
713
- <div style="margin-bottom: 20px; padding: 15px; background-color: white; border-left: 4px solid #0066cc; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">
714
- <div style="font-weight: bold; margin-bottom: 8px;">BERLIN (AFP) — </div>
715
- <div style="color: #444; line-height: 1.5;">
716
- Economic impacts from last week's devastating earthquake in Japan have begun affecting global markets, with automotive supply chains particularly disrupted as several key parts manufacturers remain offline.
717
- </div>
718
- <div style="margin-top: 10px; font-style: italic; color: #666; font-size: 0.9em; border-top: 1px dotted #ddd; padding-top: 8px;">
719
- Example showing a dateline that includes the news agency source (AFP) along with the reporting location.
720
- </div>
721
- </div>
722
-
723
- <div style="margin-bottom: 20px; padding: 15px; background-color: white; border-left: 4px solid #0066cc; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">
724
- <div style="font-weight: bold; margin-bottom: 8px;">BERLIN/TOKYO — </div>
725
- <div style="color: #444; line-height: 1.5;">
726
- German Chancellor [Name] pledged humanitarian assistance today as Japanese officials announced the death toll from yesterday's earthquake has risen to 37. "Germany stands ready to provide whatever aid our Japanese friends request," the Chancellor stated at a Berlin press conference.
727
- </div>
728
- <div style="margin-top: 10px; font-style: italic; color: #666; font-size: 0.9em; border-top: 1px dotted #ddd; padding-top: 8px;">
729
- Example of a dual location dateline, indicating reporting from both Berlin and Tokyo.
730
- </div>
731
- </div>
732
-
733
- <div style="margin-bottom: 20px; padding: 15px; background-color: white; border-left: 4px solid #0066cc; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">
734
- <div style="font-weight: bold; margin-bottom: 8px;">BERLIN (Le Monde) — </div>
735
- <div style="color: #444; line-height: 1.5;">
736
- The powerful 7.2-magnitude earthquake that struck Japan's coastal regions yesterday has prompted international response, with the European Union mobilizing its emergency resources. Tokyo officials report widespread damage to infrastructure and at least 25 casualties.
737
- </div>
738
- <div style="margin-top: 10px; font-style: italic; color: #666; font-size: 0.9em; border-top: 1px dotted #ddd; padding-top: 8px;">
739
- Example of a French newspaper (Le Monde) with its Berlin correspondent reporting on the Japan earthquake.
740
- </div>
741
- </div>
742
-
743
- <div style="margin-bottom: 20px; padding: 15px; background-color: white; border-left: 4px solid #0066cc; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">
744
- <div style="font-weight: bold; margin-bottom: 8px;">BERLIN, For Le Figaro — </div>
745
- <div style="color: #444; line-height: 1.5;">
746
- Japanese Prime Minister [Name] declared a state of emergency following Tuesday's earthquake. German seismologists at the Potsdam Institute note this is the strongest seismic event in the region since 2011.
747
- </div>
748
- <div style="margin-top: 10px; font-style: italic; color: #666; font-size: 0.9em; border-top: 1px dotted #ddd; padding-top: 8px;">
749
- Example showing alternative format with newspaper name (Le Figaro) incorporated in the dateline.
750
- </div>
751
- </div>
752
- </div>
753
- """)
754
-
755
- # Second tab starts here with proper indentation
756
- with gr.TabItem("📍 Visualisierung von strukturierten Daten"):
757
- gr.HTML("""
758
- <div class="info-box">
759
- <h3 style="margin-top: 0;">Visualisieren Sie Daten auf Karten</h3>
760
- <p>Laden Sie eine Excel-Tabelle hoch und erstelle eine interaktive Karte.</p>
761
- </div>
762
- """)
763
-
764
-
765
-
766
-
767
-
768
- with gr.TabItem("📍 Visualisierung von strukturierten Daten"):
769
 
770
  with gr.TabItem("📍 Visualisierung von strukturierten Daten"):
771
  gr.HTML("""
 
438
  custom_css = """
439
  <style>
440
  @import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;400;600;700&display=swap');
 
441
  body, .gradio-container {
442
  font-family: 'Source Sans Pro', sans-serif !important;
443
  color: #333333;
444
  }
 
445
  h1 {
446
  font-weight: 700 !important;
447
  color: #2c6bb3 !important;
448
  font-size: 2.5rem !important;
449
  margin-bottom: 1rem !important;
450
  }
 
451
  h2 {
452
  font-weight: 600 !important;
453
  color: #4e8fd1 !important;
 
455
  margin-top: 1rem !important;
456
  margin-bottom: 0.75rem !important;
457
  }
 
458
  .gradio-button.primary {
459
  background-color: #ff7518 !important;
460
  }
 
461
  .gradio-button.secondary {
462
  background-color: #5a87ca !important;
463
  color: white !important;
464
  }
 
465
  .info-box {
466
  background-color: #e8f4fd;
467
  border-left: 4px solid #2c6bb3;
 
469
  margin: 15px 0;
470
  border-radius: 4px;
471
  }
 
472
  .file-upload-box {
473
  border: 2px dashed #e0e0e0;
474
  border-radius: 8px;
 
476
  text-align: center;
477
  transition: all 0.3s ease;
478
  }
 
479
  /* Fix for map container spacing */
480
  #map-container {
481
  height: 20vh !important;
482
  margin-bottom: 0 !important;
483
  padding-bottom: 0 !important;
484
  }
 
485
  /* Stats box styling */
486
  .stats-box {
487
  margin-top: 10px !important;
 
490
  background: #f8f9fa;
491
  border-radius: 4px;
492
  }
 
493
  /* Remove extra space around components */
494
  .gr-box {
495
  margin-bottom: 0 !important;
496
  }
 
497
  /* Model status styling */
498
  .model-status {
499
  padding: 10px;
 
502
  background-color: #f8f9fa;
503
  font-size: 14px;
504
  }
 
505
  .separator {
506
  margin: 20px 0;
507
  border-top: 1px solid #eaeaea;
 
515
  <h1>Strukturierung und Visualisierung von historischen Daten</h1>
516
  </div>
517
  <div style="font-family: 'Source Sans Pro', sans-serif; max-width: 1000px; margin: 0 auto; color: #333; line-height: 1.7; font-size: 1.15rem;">
 
518
  <p style="font-size: 1.3rem; margin-bottom: 1.8rem; color: #2c3e50; font-weight: 400; padding: 0 1rem;">
519
  In dieser Unterrichtseinheit befassen wir uns mit der Strukturierung unstrukturierter historischer Texte und der Visualisierung von extrahierten Daten auf Karten. Die systematische Strukturierung von Daten wird mit einem für Informationsextrahierung trainiertem Sprachmodell durchgeführt, das auf der Question-Answering-Methode basiert. Diese Methode erlaubt es, Informationen mit Hilfe einer Frage zu extrahieren, wie etwa „Wo fand das Erdbeben statt"? Dies ermöglicht die Extrahierung des Ortes, an dem ein Erdbeben stattfand, auch wenn im Text selbst noch andere Orte genannt werden.
520
  </p>
 
521
  <div style="font-family: 'Source Sans Pro', sans-serif; line-height: 1.7; font-size: 1.15rem; background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 20px 0;">
522
  Die Katastrophe in <span style="background-color: #a8e6cf; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Earthquake Location">Japan</span> — 3 Millionen Tote. Mtb. <span style="background-color: #ffdfba; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Non-Earthquake Location">London</span>, 4. Sept. (Drahtbericht.) Zu dem Unglück in <span style="background-color: #a8e6cf; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Earthquake Location">Japan</span> liegen noch folgende Nachrichten vor: Wie die japanische Gesandtschaft in <span style="background-color: #ffdfba; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Non-Earthquake Location">Peking</span> meldet, sind Unterhandlungen mit <span style="background-color: #ffdfba; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Non-Earthquake Location">China</span> über die sofortige Lieferung von Lebensmitteln ausgenommen worden. Von <span style="background-color: #ffdfba; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Non-Earthquake Location">Peking</span> seien amerikanische, englische und italienische Schiffe mit Lebensmitteln nach <span style="background-color: #a8e6cf; font-weight: bold; padding: 2px 5px; border-radius: 3px;" title="Earthquake Location">Japan</span> abgegangen.
523
  </div>
 
524
  <div style="display: flex; margin-top: 20px;">
525
  <div style="display: flex; align-items: center; margin-right: 20px;">
526
  <div style="width: 20px; height: 20px; background-color: #a8e6cf; margin-right: 10px; border-radius: 3px;"></div>
 
531
  <span>Andere Orte: London, Peking, China</span>
532
  </div>
533
  </div>
 
 
534
  <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #3498db;">
535
  <h3 style="margin-top: 0; color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 0.8rem; font-size: 1.5rem;">
536
  Methodik: Vom unstrukturierten Text zur strukturierten Information
 
567
  </li>
568
  </ol>
569
  </div>
 
570
  <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #9b59b6;">
571
  <h4 style="color: #2980b9; margin-top: 0; font-size: 1.35rem;">Technische Funktionsweise des Sprachmodells</h4>
572
 
 
579
  <li style="margin-bottom: 1rem;"><strong style="color: #2c3e50; font-size: 1.2rem;">Generierung</strong>: Die erkannten Informationen werden in das vorgegebene Template eingefügt.</li>
580
  </ol>
581
  </div>
 
582
  <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #27ae60;">
583
  <h3 style="margin-top: 0; color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 0.8rem; font-size: 1.5rem;">
584
  Die Kartierungsfunktion
 
610
  Dieser kombinierte Ansatz aus Textextraktion und geografischer Visualisierung eröffnet neue Möglichkeiten für die räumliche Analyse historischer Quellen und erlaubt es, geografische Muster zu erkennen, die in den reinen Textdaten nicht unmittelbar sichtbar wären.
611
  </p>
612
  </div>
 
613
  <div style="margin-top: 2.5rem; padding: 1.5rem; background: #e8f4fd; border-radius: 10px; text-align: center; font-size: 1.1rem;">
614
  <p style="margin: 0;">Diese Methode ermöglicht die effiziente Extraktion und Visualisierung historischer Daten aus unstrukturierten Quellen.</p>
615
  </div>
 
616
  </div>
617
  """)
618
+
 
619
  with gr.Tabs() as tabs:
620
  with gr.TabItem("🔍 Text Extrahierung"):
621
  gr.HTML("""
 
657
  inputs=[template, text],
658
  outputs=[status, output]
659
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
660
 
661
  with gr.TabItem("📍 Visualisierung von strukturierten Daten"):
662
  gr.HTML("""