mtt/R/create_glossardict.R

24 lines
674 B
R
Raw Normal View History

create_glossardict <- function(artworks, glossar_files, xmlpath) {
x <- NULL
for (glossar_file in glossar_files) {
for (artwork in artworks) {
fnames <- dir(pattern = paste0(artwork, "_"), path = paste0(xmlpath, artwork))
for (fname in fnames) {
suppressWarnings(
lines <- readLines(paste0(xmlpath, artwork, "/", fname))
)
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