refactor rede -> speech, redner -> speaker
This commit is contained in:
+15
-15
@@ -42,8 +42,8 @@ res <- read_from_csv('../csv/')
|
||||
and unpack our tibbles
|
||||
```{r}
|
||||
comments <- res$comments
|
||||
reden <- res$reden
|
||||
redner <- res$redner
|
||||
speeches <- res$speeches
|
||||
speaker <- res$speaker
|
||||
talks <- res$talks
|
||||
```
|
||||
|
||||
@@ -51,11 +51,11 @@ talks <- res$talks
|
||||
|
||||
Now we can start analysing our parsed dataset, e.g. find out which party gives the most talks:
|
||||
```{r, fig.width=7}
|
||||
join_redner(res$reden, res) %>%
|
||||
join_speaker(res$speeches, res) %>%
|
||||
group_by(fraktion) %>%
|
||||
summarize(n = n()) %>%
|
||||
arrange(n) %>%
|
||||
bar_plot_fraktionen(title="Number of speeches given by fraction",
|
||||
bar_plot_fractions(title="Number of speeches given by fraction",
|
||||
ylab="Number of speeches")
|
||||
```
|
||||
|
||||
@@ -64,13 +64,13 @@ or counting the occurences of a given word:
|
||||
```{r, fig.width=7}
|
||||
find_word(res, "Kohleausstieg") %>%
|
||||
filter(occurences > 0) %>%
|
||||
join_redner(res) %>%
|
||||
join_speaker(res) %>%
|
||||
select(content, fraktion) %>%
|
||||
filter(!is.na(fraktion)) %>%
|
||||
group_by(fraktion) %>%
|
||||
summarize(n = n()) %>%
|
||||
arrange(desc(n)) %>%
|
||||
bar_plot_fraktionen(title = "Parties using the word 'Kohleausstieg' the most (absolutely)",
|
||||
bar_plot_fractions(title = "Parties using the word 'Kohleausstieg' the most (absolutely)",
|
||||
ylab = "Number of uses of 'Kohleausstieg'",
|
||||
flipped = F)
|
||||
```
|
||||
@@ -78,11 +78,11 @@ find_word(res, "Kohleausstieg") %>%
|
||||
### Who gives the most speeches?
|
||||
|
||||
```{r}
|
||||
res$reden %>%
|
||||
group_by(redner) %>%
|
||||
res$speeches %>%
|
||||
group_by(speaker) %>%
|
||||
summarize(n = n()) %>%
|
||||
arrange(-n) %>%
|
||||
left_join(res$redner, by=c("redner" = "id")) %>%
|
||||
left_join(res$speaker, by=c("speaker" = "id")) %>%
|
||||
head(10)
|
||||
```
|
||||
|
||||
@@ -91,10 +91,10 @@ res$reden %>%
|
||||
```{r}
|
||||
res$talks %>%
|
||||
mutate(content_len = str_length(content)) %>%
|
||||
group_by(redner) %>%
|
||||
group_by(speaker) %>%
|
||||
summarize(avg_content_len = mean(content_len)) %>%
|
||||
arrange(-avg_content_len) %>%
|
||||
left_join(res$redner, by=c("redner" = "id")) %>%
|
||||
left_join(res$speaker, by=c("speaker" = "id")) %>%
|
||||
head(10)
|
||||
```
|
||||
|
||||
@@ -102,7 +102,7 @@ res$talks %>%
|
||||
|
||||
```{r}
|
||||
res$applause %>%
|
||||
left_join(res$redner, by=c("on_redner" = "id")) %>%
|
||||
left_join(res$speaker, by=c("on_speaker" = "id")) %>%
|
||||
select(on_fraktion = fraktion, where(is.logical)) %>%
|
||||
group_by(on_fraktion) %>%
|
||||
arrange(on_fraktion) %>%
|
||||
@@ -119,7 +119,7 @@ For plotting our results we reorganize them a bit and produce a bar plot:
|
||||
```{r, fig.width=7}
|
||||
pivot_longer(tb, where(is.numeric), "by_fraktion", "count") %>%
|
||||
filter(!is.na(on_fraktion)) %>%
|
||||
bar_plot_fraktionen(x_variable = on_fraktion,
|
||||
bar_plot_fractions(x_variable = on_fraktion,
|
||||
y_variable = value,
|
||||
fill = by_fraktion,
|
||||
title = "Number of rounds of applauses from fractions to fractions",
|
||||
@@ -134,7 +134,7 @@ pivot_longer(tb, where(is.numeric), "by_fraktion", "count") %>%
|
||||
|
||||
```{r}
|
||||
res$comments %>%
|
||||
left_join(res$redner, by=c("on_redner" = "id")) %>%
|
||||
left_join(res$speaker, by=c("on_speaker" = "id")) %>%
|
||||
select(by_fraktion = fraktion.x, on_fraktion = fraktion.y) %>%
|
||||
group_by(on_fraktion) %>%
|
||||
summarize(`AfD` = sum(str_detect(by_fraktion, "AfD"), na.rm=T),
|
||||
@@ -149,7 +149,7 @@ Analogously we plot the results:
|
||||
```{r, fig.width=7}
|
||||
pivot_longer(tb, where(is.numeric), "by_fraktion", "count") %>%
|
||||
filter(!is.na(on_fraktion)) %>%
|
||||
bar_plot_fraktionen(x_variable = on_fraktion,
|
||||
bar_plot_fractions(x_variable = on_fraktion,
|
||||
y_variable = value,
|
||||
fill = by_fraktion,
|
||||
title = "Number of comments from fractions to fractions",
|
||||
|
||||
@@ -31,8 +31,8 @@ Second, those `.xml` files, need to be parsed into `R` `tibbles`. This is accomp
|
||||
```r
|
||||
read_all("../records/") %>% repair() -> res
|
||||
|
||||
reden <- res$reden
|
||||
redner <- res$redner
|
||||
speeches <- res$speeches
|
||||
speaker <- res$speaker
|
||||
talks <- res$talks
|
||||
```
|
||||
We also used `repair` to fix a bunch of formatting issues in the records and unpacked
|
||||
@@ -43,8 +43,8 @@ For development purposes, we load the tables from csv files.
|
||||
tables <- read_from_csv('../csv/')
|
||||
|
||||
comments <- tables$comments
|
||||
reden <- tables$reden
|
||||
redner <- tables$redner
|
||||
speeches <- tables$speeches
|
||||
speaker <- tables$speaker
|
||||
talks <- tables$talks
|
||||
```
|
||||
|
||||
@@ -60,7 +60,7 @@ hitlerwords <- tibble(Worte)
|
||||
Now we extract the words that were used with higher frequency by one party and compare them with `hitlerwords`.
|
||||
```{r}
|
||||
talks %>%
|
||||
left_join(redner, by=c(redner='id')) %>%
|
||||
left_join(speaker, by=c(speaker='id')) %>%
|
||||
group_by(fraktion) %>%
|
||||
summarize(full_text=str_c(content, collapse="\n")) -> talks_by_fraktion
|
||||
```
|
||||
@@ -169,5 +169,5 @@ hitler_comparison
|
||||
```
|
||||
Finally, we want to plot our results:
|
||||
```{r, fig.width=7}
|
||||
bar_plot_fraktionen(hitler_comparison, y_variable = percent, title="Coincidence of party vocabulary with nazi vocabulary", ylab="unique 'nazi' words per total (unique) fraction words [%]")
|
||||
bar_plot_fractions(hitler_comparison, y_variable = percent, title="Coincidence of party vocabulary with nazi vocabulary", ylab="unique 'nazi' words per total (unique) fraction words [%]")
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user