Error saying no app...
Notifications
Clear all

Error saying no applicable method for meta applied to an object of class when trying to create TermDocumentMatrix

RSS

(@abhijith)
Noble Member
Joined: 2 years ago
帖子:1350
11/05/2021 11:16 am

I'm trying to create TermDocumentMatrix and I'm facing the following error:

Error in UseMethod("meta", x) : no applicable method for 'meta' applied to an object of class "character" In addition: Warning message: In mclapply(unname(content(x)), termFreq, control) : all scheduled cores encountered errors in user code#Read in data policy.HTML.page <- readLines("http://policy.unt.edu/policy/3-5") #Obtain text and remove mark-up policy.HTML.page[186:202] id.1 <- 3 + which(policy.HTML.page == " TOTAL UNIVERSITY 
") id.2 <- id.1 + 5 text.data <- policy.HTML.page[id.1:id.2] td.1 <- gsub(pattern = "

", replacement = "", x = text.data, ignore.case = TRUE, perl = FALSE, fixed = FALSE, useBytes = FALSE) td.2 <- gsub(pattern = "

", replacement = "", x = td.1, ignore.case = TRUE, perl = FALSE, fixed = FALSE, useBytes = FALSE) text.d <- td.2; rm(text.data, td.1, td.2) #Create corpus and clean library(tm) library(SnowballC) txt <- VectorSource(text.d); rm(text.d) txt.corpus <- Corpus(txt) txt.corpus <- tm_map(txt.corpus, tolower) txt.corpus <- tm_map(txt.corpus, removeNumbers) txt.corpus <- tm_map(txt.corpus, removePunctuation) txt.corpus <- tm_map(txt.corpus, removeWords, stopwords("english")) txt.corpus <- tm_map(txt.corpus, stripWhitespace); #inspect(docs[1]) txt.corpus <- tm_map(txt.corpus, stemDocument) # NOTE ERROR WHEN CREATING TDM tdm <- TermDocumentMatrix(txt.corpus)

Quote
(@sathish)
Member Moderator
Joined: 2 years ago
Posts: 1391
11/05/2021 11:20 am

The following line of code

txt.corpus<-tm_map(txt.corpus,吐露港wer)

must be changed to

txt.corpus<-tm_map(txt.corpus,content_transformer(吐露港wer))

ReplyQuote
Share:
Baidu