Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MansMeg committed Dec 13, 2023
1 parent 2db8833 commit 0df9b5a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.github$
todo.tdl
13 changes: 6 additions & 7 deletions R/extract_speeches.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions man/extract_speeches_from_record.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0df9b5a

Please sign in to comment.