Linguistische...
Transcript of Linguistische...
Sprachstatistik
2Prof. Dr. G. Heyer Modul Linguistische Informatik
Das klassische Verarbeitungsmodell
Lexikon Grammatik
Parser
Input:
natürlichsprachlicher Satz
Output:
analysierter Satz
Sprachstatistik
3
Statistische Aspekte von Sprache
• Die lexikalischen Einträge werden nicht gleich häufig verwendet
• Die grammatischen Regeln werden nicht gleich häufig verwendet
• Der Erwartungswert bestimmter Wortformen bzw. Wortformenkombinationen hängt ab von der verwendeten Fachsprache
Prof. Dr. G. Heyer Modul Linguistische Informatik
Sprachstatistik
4Prof. Dr. G. Heyer Modul Linguistische Informatik
George K. Zipf: Für natürliche Sprache gilt das „Principle of Least Effort“.
Die am häufigsten gebrauchten
Wörter sind meist sehr kurze,
inhaltsleere Funktionswörter.
(vgl. Beispiel:
10 häufigste Wörter aus
Projekt Deutscher Wortschatz)
Wortform Häufigkeit
der 7.377.879
die 7.036.092
und 4.813.169
in 3.768.565
den 2.717.150
von 2.250.642
zu 1.992.268
das 1.983.589
mit 1.878.243
sich 1.680.106
Zipfsches Gesetz
Sprachstatistik
5
• Deutscher Wortschatz:
• Gilt Zipfsches Gesetz auch für Märchen „Ali-Baba und die 40 Räuber“?
Wortform Häufigkeit n Rang r r n
sich 1.680.106 10 16.801.060
immer 197.502 100 19.750.200
Mio 36.116 500 18.059.500
Medien 19.041 1.000 19.041.000
Miete 3.755 5.000 18.775.000
vorläufige 1.664 10.000 16.640.000
Beispiel
Prof. Dr. G. Heyer Modul Linguistische Informatik
Sprachstatistik
6
List wordforms (types!) of a text by frequency and assign a rank such that the most frequent wordform has rank 1
Now, the rank of a wordform multiplied by its frequency is about constant (for the selected text corpus)
r n k (with constant k dependent on selected text)
i.e. we get a simple hyperbola
n ~ k x 1/r or n ~ k x r -1
Zipf‘s law in detail
rank
fre
qu
en
cy
Prof. Dr. G. Heyer Modul Linguistische Informatik
Sprachstatistik
7
Graphische Darstellung
Prof. Dr. G. Heyer Modul Linguistische Informatik
Sprachstatistik
8Prof. Dr. G. Heyer Modul Linguistische Informatik
N Gesamtanzahl aller Wortformen des Textes (tokens)t Umfang des Vokabulars (types)n/N relative Häfigkeit der Wortformen, die n mal auftretenrn größter Rang derjenigen Wortformen, die genau n mal
auftretenIn Anzahl der Wortformen, die genau n mal auftreten
Es gilt:rn n/N = c (Konstante c ist textunabhängig, aber
sprachabhängig) also:
rn = c N/n
Zipfsches Gesetz: Formeln
Sprachstatistik
9Prof. Dr. G. Heyer Modul Linguistische Informatik
Für das Vokabular gilt: t ist so groß wie der größte Rang der häufigkeits-sortierten Liste. Falls Wörter mit Häufigkeit 1 vorkommen folgt damit:
t = r1 = c N/1 = c N
Für c gilt:c = r n/N (vgl. Formeln oben) = k/N (nach Zipfschem Gesetz)
Nach den Daten des Projekts Deutscher Wortschatz gilt damit fürs Deutsche:
c = 18.000.000 / 222.538.789 0.08
Herleitung der Formeln 2
Sprachstatistik
10Prof. Dr. G. Heyer Modul Linguistische Informatik
+----------+---------+--------+| Frequenz | Anzahl | Anteil |+----------+---------+--------+| 15 | 15312 | 0.00 || 14 | 17331 | 0.00 || 13 | 19890 | 0.00 || 12 | 22855 | 0.00 || 11 | 26324 | 0.01 || 10 | 31501 | 0.01 || 9 | 37459 | 0.01 || 8 | 46206 | 0.01 || 7 | 58359 | 0.01 || 6 | 76486 | 0.01 || 5 | 106427 | 0.02 || 4 | 158978 | 0.03 || 3 | 269435 | 0.05 || 2 | 602547 | 0.12 || 1 | 3304840 | 0.65 |+----------+---------+--------+
Anzahl verschied. Wortformen (types) : 5.122.776
Anzahl Wörter im Text (tokens)222.538.789
Beobachtungen:• Es gibt viele extrem seltene Wörter.
Ca. 65% der Wörter wurden nur einmal gesehen.
• Häufig begegnen uns neue Wörter. Wir können ca. jedes 70. Wort als neu erwarten.
• D.h. größerer Korpus liefert noch lange neue Wörter
Seltene Wörter
Sprachstatistik
11Prof. Dr. G. Heyer Modul Linguistische Informatik
Für In gilt:
In = rn – rn+1 = cN/n - cN/(n+1) = cN/(n(n+1)) = t/(n(n+1))
Für I1 gilt insbesondere:
I1 = t/2
Die hälfte des Vokabulars eines Textes tritt wahrscheinlich nur 1 mal auf.
allgemein: Anteil der Wortformen, die genau n mal auftreten, am Vokabular eines Textes
In/t = (t/(n(n+1))) / t = 1/(n(n+1))
Anteil von Wortformen, die nur 1 mal auftreten
Sprachstatistik
12Prof. Dr. G. Heyer Modul Linguistische Informatik
Wenn wir nur N
Wörter kennen,
welcher Anteil von
Text wird dadurch
abgedeckt?
N Textabdeckung (deutsch)
Textabdeckung (englisch)
1 3 % 5 %
10 16 % 23 %
100 40 % 42 %
1.000 60 % 65 %
10.000 79 % 90 %
100.000 92 % 99 %
1.000.000 98 %
Textabdeckung
Sprachstatistik
13Prof. Dr. G. Heyer Modul Linguistische Informatik
Das Wachstum des Vokabulars, wenn sich die Textmenge erhöht, läßt sich abschätzen mit:
t = kN
Typische Werte für die Parameter k und sind 20 < k < 100 und ~ 0,5.
Für das Projekt Deutscher Wortschatz gilt k = 20 und = 0.648.
Voraussage: Bei Erweiterung der Textmenge wird etwa jedes 70. Wort zum ersten mal gesehen.
Wachstum des Vokabulars – Heaps‘ Law
Sprachstatistik
14Prof. Dr. G. Heyer Modul Linguistische Informatik
Termfrequenz/inverse Dokumentfrequenz
Wir suchen Terme, die für bestimmte Dokumente besonders charakteristisch sind.
Diese Terme sind in einer Teilmenge der Dokumentkollektion relativ zur Gesamtmenge besonders häufig.
w1 w3 w5 w7 w1 w2 w4 w6 w2 w3 w7 w8 w1 w3 w5 w7 w1 w4 w5 w6
… … ...
Sprachstatistik
15Prof. Dr. G. Heyer Modul Linguistische Informatik
Der Zusammenhang zwischen Rang und Häufigkeit wird für Wortformen mit sehr kleinem oder sehr großem Rang nur unzureichend durch die Formel n~1/r wiedergegeben. Im Diagramm mit logarithmisch skalierten Achsen weichen diese Wortformen stärker von der vorausgesagten Geraden ab.
bessere Beschreibung liefert nach B. Mandelbrot:
n ~ 1/(r+c1)1+c2
bzw.
(r+c1)1+c2 n k(mit textabhängiger Konstante k)
Parameter c1 und c2 ermöglichen Anpassung an die konkreten Daten.
Verbesserung
Sprachstatistik
16
Graphische Darstellung
Prof. Dr. G. Heyer Modul Linguistische Informatik
Sprachstatistik
17Prof. Dr. G. Heyer Modul Linguistische Informatik
• Abschätzung über Anzahl an Wortformen, die n mal im Text vorkommen
• Abschätzung des Umfangs des Vokabulars• Abschätzung des Zuwachses des Vokabulars, wenn sich
Textmenge erhöht• Analyse von Suchanfragen• Termextraktion (für Indizierung)• Differenzanalyse (Vergleich von Dokumenten)
Anwendungen
Sprachstatistik
18Prof. Dr. G. Heyer Modul Linguistische Informatik
Termanalyse
• Fachtermini sind Wörter, die in Fachtexten einer Domäne (und nur dort) wesentlich häufiger auftreten als in anderen Texten:
Im wesentlichen drei Verfahren:● Fixe Vergleichsparameter● Tf/Idf● statistische Prüfgröße
Sprachstatistik
19Prof. Dr. G. Heyer Modul Linguistische Informatik
(Deutscher Wortschatz 1 - 100)
der, die, und, in, den, von, zu, das, mit, sich, des, auf, für, ist, im, dem, nicht, ein, Die, eine, als, auch, es, an, werden, aus, er, hat, daß, sie, nach, wird, bei, einer, Der, um, am, sind, noch, wie, einem, über, einen, Das, so, Sie, zum, war, haben, nur, oder, aber, vor, zur, bis, mehr, durch, man, sein, wurde, sei, In, Prozent, hatte, kann, gegen, vom, können, schon, wenn, habe, seine, Mark, ihre, dann, unter, wir, soll, ich, eines, Es, Jahr, zwei, Jahren, diese, dieser, wieder, keine, Uhr, seiner, worden, Und, will, zwischen, Im, immer, Millionen, Ein, was, sagte
Fixe Vergleichsparameter: Rangliste deutscher Wortformen
Sprachstatistik
20Prof. Dr. G. Heyer Modul Linguistische Informatik
(Fachwortschatz SAP 1 - 100)
die, Sie, der, und, in, werden, den, für, das, im, können, wird, zu, eine, auf, des, %N%, Die, ist, mit, ein, von, dem, the, oder, nicht, an, einer, aus, sind, In, einen, zur, als, über, System, kann, bei, einem, Wenn, Das, auch, nur, diesem, sich, eines, müssen, Daten, Der, daß, zum, to, haben, diese, alle, B, durch, z, R, wenn, nach, es, Feld, dann, of, wählen, Funktion, bzw, um, dieser, Wählen, Im, a, wie, is, Informationen, Diese, Bei, for, muß, and, vom, so, Für, Mit, unter, sein, keine, ob, soll, definieren, Es, verwendet, automatisch, Tabelle, Geben, wurde, finden, you, beim
Fixe Vergleichsparameter: Rangliste deutscher Wortformen
Sprachstatistik
21Prof. Dr. G. Heyer Modul Linguistische Informatik
Differenzliste signifikanter Fachwortschatzterme
SAP/Deutscher Wortschatz
Mindesthäufigkeitsklasse 8, Faktor 16
etc (314), TCP (164), INDX (28), dsn (25), Nachfolgeposition (24), SHIFT (24), TRANSLATE (24), entreprise (24), Abrechnungskostenart (23), Alternativmengeneinheit (23), Anordnungsbeziehung (23), Anwendungssicht (23), Bandstation (23), Banf-Position (23), Berichtsspalte (23), Berichtszeile (23), CO-PC (23), DBSTATC (23), DSplit (23), Datumsart (23), ELSE (23), ENDDO (23), Entries (23), Freigabecodes (23), Hauptkondition (23), Leiterplanstelle (23), Merkmalswertekombination (23), Nachfolgematerial (23), Nettoberechnung (23), ... ...
Fixe Vergleichsparameter: Rangliste deutscher Wortformen
Sprachstatistik
22Prof. Dr. G. Heyer Modul Linguistische Informatik
Termfrequenz/inverse Dokumentfrequenz
Wir suchen Terme, die für bestimmte Dokumente besonders charakteristisch sind.
Diese Terme sind in einer Teilmenge der Dokumentkollektion relativ zur Gesamtmenge besonders häufig.
w1 w3 w5 w7 w1 w2 w4 w6 w2 w3 w7 w8 w1 w3 w5 w7 w1 w4 w5 w6
… … ...
Sprachstatistik
23Prof. Dr. G. Heyer Modul Linguistische Informatik
Termfrequenz fik := Anzahl des Terms k im Dokument i
Inverse Dokumentfrequenz IDFk = log (N/d
k) +1 mit
N := Anzahl der Dokumente
dk := Anzahl der Dokumente, in denen k auftritt
TFIDF-Gewicht von Term k in Dokument i wik = f
ik * IDFk
[Salton 1975]
TFIDF
Sprachstatistik
24Prof. Dr. G. Heyer Modul Linguistische Informatik
Statistische Prüfgröße
Wie wahrscheinlich ist es, dass ein Wort w genau k-mal in einem Text der Länge n auftritt?
Wir stellen uns folgendes statistisches Experiment vor: man vergleicht w mit einem Wort x des Textes T; das Ergebnis des Experiments ist positiv, wenn x = w, sonst negativ. Diesen Test wiederholt man für jedes Wort des Textes, also n-mal, und fragt nach der Wahrscheinlichkeit p von k positiven Ergebnissen.
Diese Wahrscheinlichkeit p schätzen wir mit Bezug auf ein Referenz-korpus R.
Null-Hypothese: Die Wahrscheinlichkeit eines Auftretens von w ist gleich für T und R
Die statistische Prüfgröße quantifiziert das Maß der Überraschung, wenn T/R unter der Null-Hypothese beobachtet werden.
Sprachstatistik
25Prof. Dr. G. Heyer Modul Linguistische Informatik
Statistische Prüfgröße likelihood-ratio
Die Wahrscheinlichkeit, bei n Versuchen k positive Ergebnisse zu erzielen, is gegeben durch die Binominalverteilung (mit einem Erwartungswert von np und einer Varianz von np (1 − p)):
Die Wahrscheinlichkeit, ein Wort w in einem Text der Länge n1 k1-mal und im Vergleichskorpus der Länge n2 k2-mal zu sehen unter der Voraussetzung, dass die Auftretenswahrscheinlichkeit im Fachtext durch p1 und die im Korpus durch p2 gegeben ist, wird durch die likelihood-Funktion H beschrieben:
Sprachstatistik
26Prof. Dr. G. Heyer Modul Linguistische Informatik
Statistische Prüfgröße likelihood-ratio
Die Nullhypothese lautet: p1 = p2 = p
Die likelihood ratio ist der Quotient zweier Maxima: Dem maximalen Wert der likelihood-Funktion H auf dem Teilraum 0, der durch die Nullhypothese gegeben ist, geteilt durch das Maximum von H auf dem gesamten Ereignisraum:
Die Maxima werden erreicht durch die maximum likelihood estimates p
1 = k
1/n
1, p
2 = k
2/n
2 und p = k
1+k
2/n
1+n
2.
Nach Einsetzen und Umformen erhält man die eigentliche Prüfgröße −2 log λ.
Statistisch signifikant sind also alle Wörter, für die −2 log λ groß genug ist (und die mit einer gewissen Mindestfrequenz auftreten).
Sprachstatistik
27
Beispiel: Textprofil von Internetseiten (homepage ASV)
Sprachstatistik
28
Beispiel: Textprofil von Internetseiten (homepage ASV)
Sprachstatistik
29Prof. Dr. G. Heyer Modul Linguistische Informatik
Erweiterung: Differenzanalyse
Verfahren für die Ermittlung von diskriminierenden Termen, bei dem die unterschiedliche Verteilung von Wortformen in Texten ausgewertet werden.
Als Grundlage dient ein Menge von Referenztexten, gegen die ein Zieltext verglichen wird.
Vielfältige Anwendungsmöglichkeiten:● Analyse von Schlagwörtern in Pressemeldungen („Wörter
des Tages“)● Analyse von Webseiten● Analyse von social media Meldungen● Digital Humanities● … … ...
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
Example – DH research question
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
31
Questions
Question: Did Ernst Jünger use in his time already a rather nationalistic vocabulary or did it merely reflect the contemporary jargon?!
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
32
Question
- Question: Did Ernst Jünger use in his time already a rather nationalistic vocabulary or did it merely reflect the contemporary aspects?!
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
34
Questions
- Question: Did Ernst Jünger use in his time already a rather nationalistic vocabulary or did it merely reflect the contemporary aspects?!
1) Discover changes within Jünger's use of vocabulary
2) Discover differences in vocabulary between Jünger and reference work
Search for data and algorithms● Data: collections of texts matching the research question +
reference corpora ● Analysis: Difference Analysis between different years of Jünger's
work, as well as Ernst Jünger vs. reference corpora● Quantification of corpus similarity● Discovery of differences in vocabulary use● Detailed analysis of prominent results (vocabulary)
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
35
Operationalization
- data: collections of texts matching the re-search question + reference corporaalgorithms: difference analysis (sentence segmentation, tokenization, frequency ana-lysis, …)=> combined to more complex applications- results: structure, size, presentation (how to browse/search; find the data that lead to the result), ...- visualization
Questions
- Question: Did Ernst Jünger use in his time already a rather nationalistic vocabulary or did it merely reflect the contemporary aspects?!
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
36
Search for data: reference data
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
37
Search for data: reference data
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
38
DWDS KernkorpusTexts from the 20th century
● Fiction (approximately 26%)● Newspaper (about 27%)● Scientific literature (about 22%)● Literature (about 20%)● (Transcribed) texts of spoken language (about 5%)
● Tokens: 122 816 010● Types: 2 224 542● Documents: 79 830
Search for data: reference data
Sprachstatistik
40Prof. Dr. G. Heyer Modul Linguistische Informatik
Chaining of webservices
CLARIN text corpus format, tokenization/sentence segmentation, POS-tagging, frequency analysis, …
=> basis for more complex analysis services
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
41
Data analysis
1) REST-based Webservice● Access to word frequencies● No direct access to copyrighted texts
2) Web application● Built on Webservice● Difference Analysis using word lists● Results:
● Corpus similarities● Similarity Matrix● Clustering (dendrogram)
● Differences in vocabulary use● Timeline of usage frequency for
vocabulary● Visualization of results
Combination to workflows
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
42
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
43
Most frequent terms
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
44
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
45
Analysis – clustering of corpus similarity (Jünger internal)
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
46
Analysis – clustering of corpus similarity (Jünger + newspaper)
Analysis – clustering of corpus similarity (Jünger internal)
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
47
Analysis – Difference analysis (Jünger 1929 vs. Jünger 1925)
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
48
Nouns – only used by Jünger
WillensElementareVerwesungMißverhältnisSchauweckerIdeologieKriegserlebnisZoneDämonFrontsoldat
Nouns – more frequently used by Jünger
NationalismusLiberalismusGestaltenErstaunenErlebnisBeständeBindungenSchärfeChaosUnruhe
Analysis – Difference analysis (Jünger 1929 vs. Newspaper 1929)
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
49
Analysis – Vocabulary use over time
Sprachstatistik
Prof. Dr. G. Heyer Modul Linguistische Informatik
50
Analysis – Vocabulary use over time
Sprachstatistik
51Prof. Dr. G. Heyer Modul Linguistische Informatik
Literaturhinweise
• Manning/Schütze, Statistical Natural Language Processing• Heyer/Quasthoff/Wittig, Text Mining – Wissensrohstoff Text