oberbics commited on
Commit
841b0f8
·
verified ·
1 Parent(s): 746b711

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +84 -194
app.py CHANGED
@@ -299,208 +299,98 @@ h2 {
299
 
300
  with gr.Blocks(css=custom_css, title="Daten Strukturieren und Analysieren") as demo:
301
  gr.HTML("""
302
-
303
- <style>
304
- @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Source+Sans+Pro:wght@300;400;600&display=swap');
305
-
306
- .methodology-container {
307
- max-width: 100%;
308
- padding: 30px;
309
- background: linear-gradient(to right, #f8f9fa, #ffffff);
310
- border-radius: 12px;
311
- box-shadow: 0 5px 15px rgba(0,0,0,0.05);
312
- color: #2d3748;
313
- font-family: 'Source Sans Pro', sans-serif;
314
- line-height: 1.6;
315
- }
316
-
317
- .methodology-container h2 {
318
- font-family: 'Playfair Display', serif;
319
- color: #2c5282;
320
- font-size: 2.2rem;
321
- margin-bottom: 20px;
322
- border-bottom: 2px solid #4299e1;
323
- padding-bottom: 10px;
324
- }
325
-
326
- .methodology-container h3 {
327
- font-family: 'Playfair Display', serif;
328
- color: #2b6cb0;
329
- font-size: 1.8rem;
330
- margin-top: 30px;
331
- margin-bottom: 15px;
332
- }
333
-
334
- .methodology-container h4 {
335
- font-family: 'Source Sans Pro', sans-serif;
336
- color: #3182ce;
337
- font-size: 1.3rem;
338
- font-weight: 600;
339
- margin-top: 25px;
340
- margin-bottom: 12px;
341
- }
342
-
343
- .methodology-container p {
344
- font-size: 1.1rem;
345
- margin-bottom: 15px;
346
- text-align: justify;
347
- }
348
-
349
- .methodology-container .intro {
350
- font-size: 1.2rem;
351
- color: #4a5568;
352
- line-height: 1.7;
353
- border-left: 4px solid #4299e1;
354
- padding-left: 15px;
355
- margin: 20px 0;
356
- }
357
-
358
- .methodology-container ol, .methodology-container ul {
359
- padding-left: 20px;
360
- margin-bottom: 20px;
361
- }
362
-
363
- .methodology-container li {
364
- margin-bottom: 12px;
365
- }
366
-
367
- .methodology-container strong {
368
- color: #2c5282;
369
- font-weight: 600;
370
- }
371
-
372
- .methodology-container code {
373
- background-color: #edf2f7;
374
- border-radius: 3px;
375
- font-family: monospace;
376
- padding: 3px 5px;
377
- color: #2d3748;
378
- }
379
-
380
- .methodology-container pre {
381
- background-color: #f7fafc;
382
- border-radius: 6px;
383
- padding: 15px;
384
- margin: 15px 0;
385
- overflow: auto;
386
- border-left: 3px solid #4299e1;
387
- }
388
-
389
- .methodology-container pre code {
390
- background-color: transparent;
391
- padding: 0;
392
- color: #2d3748;
393
- }
394
 
395
- .process-step {
396
- background-color: #ebf8ff;
397
- border-radius: 8px;
398
- padding: 15px 15px 15px 20px;
399
- margin-bottom: 15px;
400
- border-left: 5px solid #4299e1;
401
- transition: transform 0.2s ease-in-out;
402
- }
403
-
404
- .process-step:hover {
405
- transform: translateX(5px);
406
- box-shadow: 0 4px 6px rgba(0,0,0,0.05);
407
- }
408
-
409
- .section-divider {
410
- height: 3px;
411
- background: linear-gradient(to right, #4299e1, transparent);
412
- margin: 30px 0;
413
- }
414
-
415
- .highlight-box {
416
- background-color: #e6fffa;
417
- border-radius: 8px;
418
- padding: 20px;
419
- margin: 20px 0;
420
- border-left: 5px solid #38b2ac;
421
- }
422
- </style>
423
- <div class="methodology-container">
424
- <h2>Historische Textanalyse und Kartierung</h2>
425
- <p class="intro">In dieser Unterrichtseinheit befassen wir uns mit einer Methode zur Strukturierung unstrukturierter historischer Texte. Im Kern verbindet unsere Anwendung die systematische Strukturierung von Daten mit einem auf Informationsextrahierung trainiertes Sprachmodell, das auf der Question-Answering-Methode basiert. Diese Methode extrahiert Text auf der Basis von Fragen, wie etwa „Wo fand das Erdbeben statt"? Dies ermöglicht die Extrahierung des Erdbebenortes, auch wenn im Text selbst noch andere Orte genannt werden.</p>
426
-
427
- <div class="section-divider"></div>
428
-
429
- <h3>Methodik: Vom unstrukturierten Text zur strukturierten Information</h3>
430
-
431
- <p>Die grundlegende Herausforderung bei der Arbeit mit historischen Quellen ist, dass relevante Informationen in langen Fließtexten eingebettet sind und manuell mühsam extrahiert werden müssen. Dieser Ansatz automatisiert diesen Prozess.</p>
432
 
433
- <h4>Wie funktioniert die Informationsextraktion?</h4>
434
-
435
- <ol>
436
- <li class="process-step">
437
- <strong>Template-Definition</strong>: Sie definieren ein JSON-Template mit den Informationstypen, die Sie extrahieren möchten:
438
- <pre><code>{"earthquake location": "", "dateline location": ""}</code></pre>
439
- </li>
 
 
440
 
441
- <li class="process-step">
442
- <strong>Question-Answering-Methode</strong>: Das Sprachmodell interpretiert jedes leere Feld als implizite Frage:
443
- <ul>
444
- <li><code>"earthquake location": ""</code> → "Wo ist das Erdbeben passiert?"</li>
445
- <li><code>"dateline location": ""</code> "Von wo wird berichtet?"</li>
 
 
 
 
 
 
 
 
446
  </ul>
447
- </li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
 
449
- <li class="process-step">
450
- <strong>Sprachmodell-Verarbeitung</strong>: Das NuExtract-1.5 Modell (ein Sequence-to-Sequence Transformer) analysiert den Text vollständig und identifiziert die relevanten Informationen für jedes Template-Feld.
451
- </li>
452
 
453
- <li class="process-step">
454
- <strong>Strukturierte Ausgabe</strong>: Das Modell füllt das Template mit den extrahierten Informationen:
455
- <pre><code>{"earthquake location": "Japan, Yokohama", "dateline location": "Tokio"}</code></pre>
456
- </li>
457
- </ol>
458
-
459
- <div class="section-divider"></div>
460
-
461
- <h4>Technische Funktionsweise des Sprachmodells</h4>
462
-
463
- <p>Intern erfolgt die Verarbeitung in mehreren Schritten:</p>
464
-
465
- <ol>
466
- <li class="process-step">
467
- <strong>Tokenisierung</strong>: Der Text wird in bearbeitbare Einheiten zerlegt.
468
- </li>
469
- <li class="process-step">
470
- <strong>Kontextuelle Analyse</strong>: Der Transformer-Mechanismus ermöglicht die Analyse von Beziehungen zwischen allen Textteilen gleichzeitig.
471
- </li>
472
- <li class="process-step">
473
- <strong>Selektive Aufmerksamkeit</strong>: Das Modell fokussiert sich auf Textpassagen, die Antworten auf die impliziten Fragen enthalten könnten.
474
- </li>
475
- <li class="process-step">
476
- <strong>Generierung</strong>: Die erkannten Informationen werden in das vorgegebene Template eingefügt.
477
- </li>
478
- </ol>
479
-
480
- <div class="section-divider"></div>
481
-
482
- <h3>Die Kartierungsfunktion</h3>
483
-
484
- <div class="highlight-box">
485
- <p>Nach der Extraktion der Ortsangaben ermöglicht unsere Anwendung die automatische Visualisierung dieser Daten auf einer interaktiven Karte:</p>
486
- </div>
 
 
 
 
 
487
 
488
- <ol>
489
- <li class="process-step">
490
- <strong>Geokodierung</strong>: Die extrahierten Ortsnamen werden mittels eines geografischen Dienstes in geografische Koordinaten (Längen- und Breitengrade) umgewandelt.
491
- </li>
492
- <li class="process-step">
493
- <strong>Kartenerstellung</strong>: Die Koordinaten werden auf einer interaktiven Karte platziert, wobei jeder Ort durch einen Marker dargestellt wird.
494
- </li>
495
- <li class="process-step">
496
- <strong>Kontextinformationen</strong>: Beim Klick auf einen Marker werden zusätzliche Informationen aus dem Originaltext angezeigt.
497
- </li>
498
- <li class="process-step">
499
- <strong>Räumliche Analyse</strong>: Die Karte ermöglicht die visuelle Analyse der räumlichen Verteilung historischer Ereignisse.
500
- </li>
501
- </ol>
502
 
503
- <p>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.</p>
504
  </div>
505
  """)
506
 
 
299
 
300
  with gr.Blocks(css=custom_css, title="Daten Strukturieren und Analysieren") as demo:
301
  gr.HTML("""
302
+ <div style="font-family: 'Source Sans Pro', sans-serif; max-width: 900px; margin: 0 auto; color: #333; line-height: 1.7; font-size: 1.15rem;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
 
304
+ <p style="font-size: 1.3rem; margin-bottom: 1.8rem; color: #2c3e50; font-weight: 400; padding: 0 1rem;">
305
+ In dieser Unterrichtseinheit befassen wir uns mit einer Methode zur Strukturierung unstrukturierter historischer Texte. Im Kern verbindet unsere Anwendung die systematische Strukturierung von Daten mit einem auf Informationsextrahierung trainierten Sprachmodell, das auf der Question-Answering-Methode basiert. Diese Methode extrahiert Text auf der Basis von Fragen, wie etwa „Wo fand das Erdbeben statt"? Dies ermöglicht die Extrahierung des Erdbebenortes, auch wenn im Text selbst noch andere genannt werden.
306
+ </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
 
308
+ <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #3498db;">
309
+ <h3 style="margin-top: 0; color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 0.8rem; font-size: 1.5rem;">
310
+ Methodik: Vom unstrukturierten Text zur strukturierten Information
311
+ </h3>
312
+
313
+ <p style="margin-bottom: 1.8rem; font-size: 1.2rem;">
314
+ Die grundlegende Herausforderung bei der Arbeit mit historischen Quellen ist, dass relevante Informationen in langen
315
+ Fließtexten eingebettet sind und manuell mühsam extrahiert werden müssen. Dieser Ansatz automatisiert diesen Prozess.
316
+ </p>
317
 
318
+ <h4 style="color: #2980b9; margin-top: 2rem; font-size: 1.35rem;">Wie funktioniert die Informationsextraktion?</h4>
319
+
320
+ <ol style="padding-left: 2rem; font-size: 1.15rem;">
321
+ <li style="margin-bottom: 1.5rem;">
322
+ <strong style="color: #2c3e50; font-size: 1.2rem;">Template-Definition</strong>: Sie definieren ein JSON-Template mit den Informationstypen, die Sie extrahieren möchten:
323
+ <pre style="background: #f5f5f5; padding: 1.2rem; border-radius: 6px; overflow-x: auto; margin: 1rem 0 1.5rem; font-size: 1.1rem;"><code>{"earthquake location": "", "dateline location": ""}</code></pre>
324
+ </li>
325
+
326
+ <li style="margin-bottom: 1.5rem;">
327
+ <strong style="color: #2c3e50; font-size: 1.2rem;">Question-Answering-Methode</strong>: Das Sprachmodell interpretiert jedes leere Feld als implizite Frage:
328
+ <ul style="margin-top: 1rem; padding-left: 2rem; font-size: 1.15rem;">
329
+ <li style="margin-bottom: 0.8rem;"><code style="background: #f0f0f0; padding: 0.3rem 0.5rem; border-radius: 4px; font-size: 1.1rem;">"earthquake location": ""</code> → "Wo ist das Erdbeben passiert?"</li>
330
+ <li style="margin-bottom: 0.8rem;"><code style="background: #f0f0f0; padding: 0.3rem 0.5rem; border-radius: 4px; font-size: 1.1rem;">"dateline location": ""</code> → "Von wo wird berichtet?"</li>
331
  </ul>
332
+ </li>
333
+
334
+ <li style="margin-bottom: 1.5rem;">
335
+ <strong style="color: #2c3e50; font-size: 1.2rem;">Sprachmodell-Verarbeitung</strong>: Das NuExtract-1.5 Modell (ein Sequence-to-Sequence Transformer) analysiert den Text vollständig und identifiziert die relevanten Informationen für jedes Template-Feld.
336
+ </li>
337
+
338
+ <li style="margin-bottom: 1rem;">
339
+ <strong style="color: #2c3e50; font-size: 1.2rem;">Strukturierte Ausgabe</strong>: Das Modell füllt das Template mit den extrahierten Informationen:
340
+ <pre style="background: #f5f5f5; padding: 1.2rem; border-radius: 6px; overflow-x: auto; margin: 1rem 0 1.5rem; font-size: 1.1rem;"><code>{"earthquake location": "Japan, Yokohama", "dateline location": "Tokio"}</code></pre>
341
+ </li>
342
+ </ol>
343
+ </div>
344
+
345
+ <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #9b59b6;">
346
+ <h4 style="color: #2980b9; margin-top: 0; font-size: 1.35rem;">Technische Funktionsweise des Sprachmodells</h4>
347
 
348
+ <p style="font-size: 1.2rem;">Intern erfolgt die Verarbeitung in mehreren Schritten:</p>
 
 
349
 
350
+ <ol style="padding-left: 2rem; font-size: 1.15rem;">
351
+ <li style="margin-bottom: 1rem;"><strong style="color: #2c3e50; font-size: 1.2rem;">Tokenisierung</strong>: Der Text wird in bearbeitbare Einheiten zerlegt.</li>
352
+ <li style="margin-bottom: 1rem;"><strong style="color: #2c3e50; font-size: 1.2rem;">Kontextuelle Analyse</strong>: Der Transformer-Mechanismus ermöglicht die Analyse von Beziehungen zwischen allen Textteilen gleichzeitig.</li>
353
+ <li style="margin-bottom: 1rem;"><strong style="color: #2c3e50; font-size: 1.2rem;">Selektive Aufmerksamkeit</strong>: Das Modell fokussiert sich auf Textpassagen, die Antworten auf die impliziten Fragen enthalten könnten.</li>
354
+ <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>
355
+ </ol>
356
+ </div>
357
+
358
+ <div style="background: #f8f9fa; padding: 2rem; border-radius: 10px; margin-bottom: 2.5rem; border-left: 5px solid #27ae60;">
359
+ <h3 style="margin-top: 0; color: #2c3e50; border-bottom: 2px solid #eee; padding-bottom: 0.8rem; font-size: 1.5rem;">
360
+ Die Kartierungsfunktion
361
+ </h3>
362
+
363
+ <p style="margin-bottom: 1.8rem; font-size: 1.2rem;">
364
+ Nach der Extraktion der Ortsangaben ermöglicht unsere Anwendung die automatische Visualisierung dieser Daten auf einer interaktiven Karte:
365
+ </p>
366
+
367
+ <ol style="padding-left: 2rem; font-size: 1.15rem;">
368
+ <li style="margin-bottom: 1.2rem;">
369
+ <strong style="color: #2c3e50; font-size: 1.2rem;">Geokodierung</strong>: Die extrahierten Ortsnamen werden mittels eines geografischen Dienstes in geografische Koordinaten (Längen- und Breitengrade) umgewandelt.
370
+ </li>
371
+
372
+ <li style="margin-bottom: 1.2rem;">
373
+ <strong style="color: #2c3e50; font-size: 1.2rem;">Kartenerstellung</strong>: Die Koordinaten werden auf einer interaktiven Karte platziert, wobei jeder Ort durch einen Marker dargestellt wird.
374
+ </li>
375
+
376
+ <li style="margin-bottom: 1.2rem;">
377
+ <strong style="color: #2c3e50; font-size: 1.2rem;">Kontextinformationen</strong>: Beim Klick auf einen Marker werden zusätzliche Informationen aus dem Originaltext angezeigt.
378
+ </li>
379
+
380
+ <li style="margin-bottom: 1rem;">
381
+ <strong style="color: #2c3e50; font-size: 1.2rem;">Räumliche Analyse</strong>: Die Karte ermöglicht die visuelle Analyse der räumlichen Verteilung historischer Ereignisse.
382
+ </li>
383
+ </ol>
384
+
385
+ <p style="font-size: 1.2rem; margin-top: 1.5rem;">
386
+ 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.
387
+ </p>
388
+ </div>
389
 
390
+ <div style="margin-top: 2.5rem; padding: 1.5rem; background: #e8f4fd; border-radius: 10px; text-align: center; font-size: 1.1rem;">
391
+ <p style="margin: 0;">Diese Methode ermöglicht die effiziente Extraktion und Visualisierung historischer Daten aus unstrukturierten Quellen.</p>
392
+ </div>
 
 
 
 
 
 
 
 
 
 
 
393
 
 
394
  </div>
395
  """)
396