Skip to content

Commit

Permalink
rename functions and remove language from individual summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
bvreede committed Oct 6, 2023
1 parent 2a261e2 commit 463f48e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions R/summaries.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ report_summaries <- function(data, lang = NA, allsources = FALSE){
data <- data |>
dplyr::filter(.data$language==lang)
}
# ensure a translation column is present
if(!"translation" %in% colnames(data)){
data$translation <- NA
}

bylanguage <- summarize_source(data, lang)
bysource <- summarize_language(data, lang)
bylanguage <- summarize_stats(data)
bysource <- summarize_bysource(data)

## Overall summary of the utterances
nhours <- round(bylanguage$hours,1)
Expand Down Expand Up @@ -44,12 +48,8 @@ report_summaries <- function(data, lang = NA, allsources = FALSE){
print_summary(header = source_header, table = bysource)
}

summarize_language <- function(data, lang){
if(!"translation" %in% colnames(data)){
data$translation <- NA
}

data |>
summarize_bysource <- function(data){
summary <- data |>
dplyr::group_by(.data$source) |>
dplyr::mutate(translation = ifelse(is.na(.data$translation),0,1)) |>
dplyr::summarize(start=min.na(.data$begin),finish=max.na(.data$end),
Expand All @@ -65,9 +65,9 @@ summarize_language <- function(data, lang){
}


summarize_source <- function(data, lang){
summarize_stats <- function(data){
summary <- data |>
summarize_language(lang=lang) |> #TODO this uses another function?
summarize_bysource() |>
dplyr::summarize(turns = sum(.data$turns),
translated=round(mean.na(.data$translated),2),
words = sum(.data$words),
Expand Down

0 comments on commit 463f48e

Please sign in to comment.