Skip to content

Commit 91c4baa

Browse files
committed
Extended llm_copyedit to handle vectors of article ids or whole issues
1 parent 4e9c2bc commit 91c4baa

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

R/llm_copyedit.R

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
#' The changes are made directly to the files. Please check carefully before
99
#' committing them to the git repository.
1010
#'
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.
1215
#' @param type Type of files to copyedit. Options are "all" (default), "bib", "tex", or "rmd".
1316
#' @param ellmer_timeout_s Timeout for the LLM API in seconds. Default is 600 seconds.
1417
#' @examples
@@ -19,13 +22,34 @@
1922
#' @export
2023
#'
2124
llm_copyedit <- function(
22-
article,
25+
articles = NULL,
26+
issue = NULL,
2327
type = c("all", "bib", "tex", "rmd"),
2428
ellmer_timeout_s = 600
2529
) {
2630
type <- match.arg(type)
2731
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) {
2953
bibfiles <- rmdfiles <- texfiles <- character(0)
3054
if (type %in% c("all", "bib")) {
3155
bibfiles <- list.files(

0 commit comments

Comments
 (0)