rename some columns to english

This commit is contained in:
2021-08-09 15:31:20 +02:00
parent b02ab91c31
commit 4649658fa7
4 changed files with 30 additions and 32 deletions
+10 -12
View File
@@ -29,15 +29,13 @@ repair_speaker <- function(speaker) {
filter(id != "10000") %>% # invalid id's
mutate(fraction = Vectorize(repair_fraction)(fraction)) %>% # fix fraction
group_by(id) %>%
summarize(vorname = head(vorname, 1),
nachname = head(nachname, 1),
summarize(prename = head(prename, 1),
lastname = head(lastname, 1),
fraction = collect_unique(fraction),
titel = longest_titel(titel),
rolle_kurz = collect_unique(str_squish(rolle_kurz)),
rolle_lang = collect_unique(str_squish(rolle_lang))) %>%
title = longest_titel(title),
role_short = collect_unique(str_squish(role_short)),
role_long = collect_unique(str_squish(role_long))) %>%
ungroup() #%>%
# arrange(id) %>%
# distinct(vorname, nachname, fraction, titel)
}
repair_speeches <- function(speeches) {
@@ -68,7 +66,7 @@ repair_talks <- function(talks) {
lookup_speaker <- function(tb, speaker, name_variable) {
tobereplaced <- "[-–—‑­­-­­­ ]"
speaker %>%
unite(name, vorname, nachname, sep=".*") %>%
unite(name, prename, lastname, sep=".*") %>%
mutate(name = str_replace_all(name, tobereplaced, ".*")) ->
rs
find_match <- function(komm) {
@@ -88,10 +86,10 @@ repair_comments <- function(comments, speaker) {
"Use repair(, repair_commments = FALSE) to skip this.\n"))
# try to find a speaker id for each actual comment
comments %>%
filter(!is.na(kommentator)) %>%
lookup_speaker(speaker, kommentator) %>%
left_join(comments, ., by="kommentator") %>%
select(-kommentator)
filter(!is.na(commenter)) %>%
lookup_speaker(speaker, commenter) %>%
left_join(comments, ., by="commenter") %>%
select(-commenter)
}
#' Repair parsed tables