|
8 | 8 | #' The changes are made directly to the files. Please check carefully before |
9 | 9 | #' committing them to the git repository. |
10 | 10 | #' |
11 | | -#' @param article Article id, such as "2025-03". |
| 11 | +#' @param articles A vector of article ids, such as "2025-42". Ignored if issue |
| 12 | +#' is provided. |
| 13 | +#' @param issue An issue id, such as "2025-1". If provided, the function will |
| 14 | +#' construct the vector of associated article ids. |
12 | 15 | #' @param type Type of files to copyedit. Options are "all" (default), "bib", "tex", or "rmd". |
13 | 16 | #' @param ellmer_timeout_s Timeout for the LLM API in seconds. Default is 600 seconds. |
14 | 17 | #' @examples |
|
19 | 22 | #' @export |
20 | 23 | #' |
21 | 24 | llm_copyedit <- function( |
22 | | - article, |
| 25 | + articles = NULL, |
| 26 | + issue = NULL, |
23 | 27 | type = c("all", "bib", "tex", "rmd"), |
24 | 28 | ellmer_timeout_s = 600 |
25 | 29 | ) { |
26 | 30 | type <- match.arg(type) |
27 | 31 | options(ellmer_timeout_s = ellmer_timeout_s) |
28 | | - article <- as.article(article) |
| 32 | + if (!is.null(issue)) { |
| 33 | + if (!is.character(issue) || length(issue) != 1) { |
| 34 | + stop("Issue must be a single character string, e.g., '2025-1'.") |
| 35 | + } |
| 36 | + articles <- list.files( |
| 37 | + file.path(get_articles_path(), "Proofs", issue), |
| 38 | + pattern = "\\d{4}-\\d{2}", |
| 39 | + full.names = TRUE |
| 40 | + ) |
| 41 | + articles <- basename(articles) |
| 42 | + } else if (is.null(articles)) { |
| 43 | + stop("Please provide either article ids or an issue id") |
| 44 | + } |
| 45 | + for (article in articles) { |
| 46 | + article <- as.article(article) |
| 47 | + message(paste("Processing article:", article$id)) |
| 48 | + llm_copyedit_article(article, type) |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +llm_copyedit_article <- function(article, type) { |
29 | 53 | bibfiles <- rmdfiles <- texfiles <- character(0) |
30 | 54 | if (type %in% c("all", "bib")) { |
31 | 55 | bibfiles <- list.files( |
|
0 commit comments