2023-09-22 16:00:57 +02:00
|
|
|
create_glossardict <- function(artworks, glossar_files, xmlpath) {
|
2023-09-21 16:47:23 +02:00
|
|
|
|
|
|
|
x <- NULL
|
|
|
|
|
|
|
|
for (glossar_file in glossar_files) {
|
|
|
|
for (artwork in artworks) {
|
2023-09-22 16:00:57 +02:00
|
|
|
fnames <- dir(pattern = paste0(artwork, "_"), path = paste0(xmlpath, artwork))
|
2023-09-21 16:47:23 +02:00
|
|
|
for (fname in fnames) {
|
|
|
|
suppressWarnings(
|
2023-09-22 16:00:57 +02:00
|
|
|
lines <- readLines(paste0(xmlpath, artwork, "/", fname))
|
2023-09-21 16:47:23 +02:00
|
|
|
)
|
|
|
|
if (any(grepl(glossar_file, lines))) {
|
|
|
|
x <- rbind(x, data.frame(glossar_file, artwork))
|
|
|
|
break # if one match is found, we are done
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tapply(x$artwork, x$glossar_file, FUN = c)
|
|
|
|
}
|
|
|
|
# TODO: Get rid of (at least 2) loops
|
|
|
|
# TODO: Add progress bars
|
|
|
|
|