From 7771b2ebd8678e19a3c397392840c3cb43719b87 Mon Sep 17 00:00:00 2001 From: flavis Date: Tue, 3 Aug 2021 13:26:39 +0200 Subject: [PATCH] add option to lookup redner in repair and fix fraction list to ensure repaired tables are fixpoints of repair(, repair_comments = FALSE) --- R/repair.R | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/R/repair.R b/R/repair.R index 21d5738..ba62357 100644 --- a/R/repair.R +++ b/R/repair.R @@ -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 ) }