#' Concatenate and Clean Intervention Text
#'
#' This function concatenates a vector of intervention strings after
#' removing a specified regular expression pattern from each string.  
#' This is often used to remove speaker tags before combining multiple
#' interventions into a single text block.
#'
#' @param intervention A character vector containing individual 
#'   intervention strings.
#' @param pattern The regular expression pattern to be removed from 
#'   each intervention string.
#'
#' @return A single string created by concatenating the cleaned 
#'   intervention strings with spaces in between.
#'
#' @examples
#' # Example usage:
#' speakers = retrieve_speaker(intrw)
#' pattern = generate_speaker_pattern(speakers)
#' structured_interview = prep_interview(intrw)
#' concatenated_text = so.ii:::concatenate_intervention(
#'      structured_interview[[1]], 
#'      pattern
#' )
#'
#' @family process interview
#' 
#' @keywords internal

concatenate_intervention = function(intervention, pattern){
    result = gsub(pattern = pattern, replacement = "", x = intervention)
    result = paste0(result, collapse = " ")
    return(result)
}