add option to lookup redner in repair and fix fraction list to ensure repaired tables are fixpoints of repair(, repair_comments = FALSE)

This commit is contained in:
2021-08-03 13:26:39 +02:00
parent f91456116f
commit 7771b2ebd8
+11 -3
View File
@@ -1,4 +1,5 @@
fraktionen <- c("AFD" = "AfD",
"AFD&FRAKTIONSLOS" = "AfD&Fraktionslos",
"BÜNDNIS90/" = "BÜNDNIS 90 / DIE GRÜNEN",
"BÜNDNIS90/DIEGRÜNEN" = "BÜNDNIS 90 / DIE GRÜNEN",
"FRAKTIONSLOS" = "Fraktionslos",
@@ -84,13 +85,20 @@ repair_comments <- function(comments, redner) {
#' Repair parsed tables
#'
#' TODO: Explain repair_comments argument
#' (if TRUE, we try to lookup redner names in redner table)
#'
#' Possible test: check identical(repair(res), repair(repair(res))) == TRUE
#' Since repaired tables should be a fixpoint of repair.
#' @export
repair <- function(parse_output) {
repair <- function(parse_output, repair_comments = FALSE) {
list(redner = repair_redner(parse_output$redner),
reden = repair_reden(parse_output$reden),
talks = repair_talks(parse_output$talks),
#comments = repair_comments(parse_output$comments)
comments = parse_output$comments,
comments = if(repair_comments) repair_comments(parse_output$comments,
parse_output$redner)
else parse_output$comments,
applause = parse_output$applause
)
}