Я сохраняю корпус ТМ в R.
writeCorpus(as.character(thecrp), dirdst, filenames = NULL)
Все нормально, пока не получу ошибку:
Error in UseMethod("meta", x) : no method applicable for meta applicable to an object of class "character"
NB. Я добавил три пользовательских метаполя в каждый документ в корпусе.
Вот воспроизводимый пример:
# Create corpus from a folder of documents on disk
thetxts <- readtext(pthtxt, cache = FALSE)
thecrp <- corpus(thetxts)
# Add docvars (= columns)
# Reference
# NOTE: Add Meta to the corpus
meta(thecrp, tag = "doctyp", type = "corpus") <- "Reports, 2018"
# NOTE: Add Meta to each of the documents
for (i in 1:length(thecrp)){
# ID derived from the name of the file (withdraw .txt)
meta(thecrp[[i]], tag = "id", type = "indexed") <- gsub("\\.txt", "", meta(thecrp[[i]], tag = "id", type = "indexed"))
# constants
meta(thecrp[[i]], tag = "author", type = "indexed") <- "author"
meta(thecrp[[i]], tag = "type", type = "indexed") <- "individual"
meta(thecrp[[i]], tag = "prov", type = "indexed") <- "ocr"
}
# Then I perform usual and **mildly** transformative actions on the corpus
...
# Then I save it to disk: the **error occurs here**
dirdst <- "~/test"
writeCorpus(as.character(thecrp), dirdst, filenames = NULL)