Add script to fetch metadata for all texts
Change-Id: I58e959da2c3b0cc31435dd5adb8c7ca49327715d
diff --git a/scripts/fetchDeLiKoMetadata.R b/scripts/fetchDeLiKoMetadata.R
new file mode 100644
index 0000000..ae0a947
--- /dev/null
+++ b/scripts/fetchDeLiKoMetadata.R
@@ -0,0 +1,33 @@
+library(RKorAPClient)
+library(tidyverse)
+library(urltools)
+VC = "" # no virtual corpus, i.e. all texts
+deliko <- KorAPConnection("https://korap.dnb.de", verbose = TRUE)
+query <- corpusQuery(
+ deliko,
+ "<base/s=t>",
+ # this finds each text once
+ vc = VC,
+ fields = c(
+ "textSigle",
+ "title",
+ "subTitle",
+ "author",
+ "textType",
+ "textTypeRef",
+ "publisher",
+ "pubDate",
+ "pubPlace",
+ "ISBN",
+ "URN",
+ "award"
+ )
+) %>%
+ fetchAll()
+
+df <- query@collectedMatches %>%
+ mutate(publisher = str_replace_all(publisher, "data:,", ""),
+ URN = URLdecode(str_replace_all(URN, ".*,", ""))) %>%
+ select(-c("matchStart", "matchEnd"))
+
+write_tsv(df, "deliko_metadata.tsv")