Passa ai contenuti principali

A Word Never Comes Alone. A Glance at Cooccurences

Enumerating words can be helpful. With a simple command (tokens_ngrams), in R we also got lists of word pairs and triples and so on. But usually we want to know which words appear within the same documents. What about co-occurences within the same song? Which words appear in the same songs? With the fcm() command in R we obtain a neat little table, more or less like the following

                ich     du     gut     liebe     kalt     bitte     sonne

ich           2775 1289  474    550      352      25       143

du            0       920  209   183       279      25       19

gut           0       0      91       19         0         2         20

lust          627    1     2         0           280     0          1

deutschl  209    532  0         76        152      0         171

liebe                                    140       55       41         11

kalt                                                     84       28         4

bitte                                                             36         0

sonne                                                                       166


As a plot: 





We see a bridge from "ich" to "du", to "lust""liebe" and a lighter one to "kalt". This really looks like the word center of Rammstein songs. 

From the table, we see that "liebe" has no connection to "ich" and "du", while "lust" co-occurs with "ich" and "kalt". Reflect!

Note: Some of the above numbers are very high because co-occurences are calculated within a V*V matrix. Hence, the square of the term frequency is the basis. For definitive results, we should calculate the relative frequency. 

technically
Packages quanteda, readtext

my_stopwords <- stopwords("de")%>%
  char_remove(pattern=c("ich", "du"))
toks_fund <- tokens(basis, remove_punct = TRUE, remove_numbers = TRUE, remove_symbol = TRUE)%>%
        tokens_remove(pattern = my_stopwords)
matrixa <- dfm(toks_fund)

toks_zusammen <- fcm(matrixa)
feat <- names(topfeatures(toks_zusammen, 20))
fcmat_tokszus_subset <- toks_zusammen %>%
  fcm_select(feat)
tplot_zusammen <- textplot_network(fcmat_tokszus_subset)
set.seed(134)
tplot_zusammen
write.table(fcmat_tokszus_subset, file = "")


Commenti

Post popolari in questo blog

Between Goethe and Brecht. Rammstein texts and the poems of Till Lindemann

Till Lindemann is a poet better known as the song writer and lead singer of Rammstein. It  could be interesting to compare the texts band’s lyrics and his poems, maybe gaining a better  insight in how both of them are made. For automated analysis, however, both kinds of texts might seem of little interest. With very  short texts, the basis for statistical reasoning is too small. Indeed, we cannot reasonably apply  the various readability indexes we usually employ when analyzing corpora. But if we restrict  our statistical glimpse to some very elementary calculations, something similar to an  “author’s footprint” might emerge.  I will first use the TTR, the ratio between  the number of single words (“types”) that appear in the text and the total number of words  (“tokens”).Then I will have a look at the numeric relation between functional words  (prepositions articles, conjunctions, etc.) and content words. Some characteristics of Till...

Till Lindemann as a Poet and with his Band (1)

Till Lindemann, lead singer of the Rammstein group, has also published some collections of poems. You should not forget: he is the son of Werner Lindemann, who used to be a prominent writer in the times of the socialist German Democratic Rebublic.  As I am (together with Claudia Lisa Moeller) translating one of these books,  "In stillen Nächten"/ "On Quiet Nights" (English translation by Ehren Fordyce,  Raw Dog Screaming Press, Bowie MD in 2025)  into Italian, I took out my R Quanteda package in order to take a more distant view on the poems.  The most frequent words ("stopwords" excluded) in Lindemann's poems are "Herz" ("heart"), which appears 33 times, and "Liebe" ("love") with 26 occurrences. This might seem similar to the frequencies in Rammstein songs, where we read the leading word "Liebe" 46 times, followed  by "Mann"/ man (45).  We might assume that, since "Herz" is often ta...

The center of Lindemann's Writing? Co-occurences ...

2879 words (tokens) are not very much, unique tokens: 1570, when stemmed: 1317. All the same, finding patterns across the 97 poems in Till Lindemann's "Quiet Nights" seems to be difficult. Looking for n-gams and skipgrams: found nothing that went beyond the limits of single poems. Asking with R Quanteda for co-occurences, with n=50 we get a cloud: What we see? A predominance of words for human and animal bodies or parts of them: "hund", "mund", "haar", "schweiß", "blut", "fleisch", "herz" .... Inquiring on these elements could be an interesting project. As a net of words, though, the entire image is only confusing. Lowering n to 20, the picture gets clearer, but the connecting lines are really weak. "Dass" should be eliminated, right.  Going down to n=7. The animals have vanished, "heart" and "face" are the only remaning parts of the body. At the end, after stemming and low...