refactor fraktion -> fraction
This commit is contained in:
+7
-7
@@ -1,4 +1,4 @@
|
||||
fraktionen <- c("AFD" = "AfD",
|
||||
fractions <- c("AFD" = "AfD",
|
||||
"BÜNDNIS90/" = "BÜNDNIS 90 / DIE GRÜNEN",
|
||||
"BÜNDNIS90/DIEGRÜNEN" = "BÜNDNIS 90 / DIE GRÜNEN",
|
||||
"FRAKTIONSLOS" = "Fraktionslos",
|
||||
@@ -7,9 +7,9 @@ fraktionen <- c("AFD" = "AfD",
|
||||
"CDU/CSU" = "CDU/CSU",
|
||||
"FDP" = "FDP")
|
||||
|
||||
repair_fraktion <- function(fraktion) {
|
||||
cleaned <- str_to_upper %$% str_replace_all(fraktion, "\\s", "")
|
||||
fraktionen[cleaned]
|
||||
repair_fraction <- function(fraction) {
|
||||
cleaned <- str_to_upper %$% str_replace_all(fraction, "\\s", "")
|
||||
fractions[cleaned]
|
||||
}
|
||||
|
||||
# takes vector of titel and keeps longest
|
||||
@@ -26,17 +26,17 @@ repair_speaker <- function(speaker) {
|
||||
if (nrow(speaker) == 0) return(speaker)
|
||||
speaker %>%
|
||||
filter(id != "10000") %>% # invalid id's
|
||||
mutate(fraktion = Vectorize(repair_fraktion)(fraktion)) %>% # fix fraktion
|
||||
mutate(fraction = Vectorize(repair_fraction)(fraction)) %>% # fix fraction
|
||||
group_by(id) %>%
|
||||
summarize(vorname = head(vorname, 1),
|
||||
nachname = head(nachname, 1),
|
||||
fraktion = collect_unique(fraktion),
|
||||
fraction = collect_unique(fraction),
|
||||
titel = longest_titel(titel),
|
||||
rolle_kurz = collect_unique(str_squish(rolle_kurz)),
|
||||
rolle_lang = collect_unique(str_squish(rolle_lang))) %>%
|
||||
ungroup() #%>%
|
||||
# arrange(id) %>%
|
||||
# distinct(vorname, nachname, fraktion, titel)
|
||||
# distinct(vorname, nachname, fraction, titel)
|
||||
}
|
||||
|
||||
repair_speeches <- function(speeches) {
|
||||
|
||||
Reference in New Issue
Block a user