From 0df9b5a87decc79ce85a6fed286d26053d322ce7 Mon Sep 17 00:00:00 2001 From: Mans Magnusson Date: Wed, 13 Dec 2023 11:05:51 +0100 Subject: [PATCH] Minor fixes --- .Rbuildignore | 1 + R/extract_speeches.R | 13 ++++++------- man/extract_speeches_from_record.Rd | 2 -- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 3912071..946d32c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ ^.*\.Rproj$ ^\.Rproj\.user$ ^\.github$ +todo.tdl diff --git a/R/extract_speeches.R b/R/extract_speeches.R index 6d53999..5b77101 100644 --- a/R/extract_speeches.R +++ b/R/extract_speeches.R @@ -9,7 +9,6 @@ #' For multiple files, parallelism can be used. #' #' @param record_path a file path to a record XML file -#' @param record_paths a vector of file paths to record XML files #' #' #' @return @@ -41,16 +40,16 @@ extract_speeches_from_record <- function(record_path){ # Extract speeches xs <- xml_find_all(x, ".//note[@type = 'speaker']|.//u|.//seg") - df <- tibble(type_speaker = xml_attr(xs, attr = "type") == "speaker", - name = xml_name(xs), - who = xml_attr(xs, attr = "who"), - id = xml_attr(xs, attr = "id"), - text = xml_text(xs, trim = TRUE)) + df <- tibble("type_speaker" = xml_attr(xs, attr = "type") == "speaker", + "name" = xml_name(xs), + "who" = xml_attr(xs, attr = "who"), + "id" = xml_attr(xs, attr = "id"), + "text" = xml_text(xs, trim = TRUE)) df$type_speaker[is.na(df$type_speaker)] <- FALSE df$speech_no <- cumsum(df$type_speaker) df$speech_id <- df$id df$speech_id[!df$type_speaker] <- NA - df <- fill(df, who, speech_id) + df <- fill(df, "who", "speech_id") df <- df[df$name == "seg",] df$type_speaker <- NULL df$name <- NULL diff --git a/man/extract_speeches_from_record.Rd b/man/extract_speeches_from_record.Rd index 7b7e81d..28aae84 100644 --- a/man/extract_speeches_from_record.Rd +++ b/man/extract_speeches_from_record.Rd @@ -8,8 +8,6 @@ extract_speeches_from_record(record_path) } \arguments{ \item{record_path}{a file path to a record XML file} - -\item{record_paths}{a vector of file paths to record XML files} } \value{ The function returns a tibble data frame with the following variables: