我的工作进展顺利,但我遇到了一些问题,因为我的一些 pdf 文件包含奇怪的符号(“📧”)
我已经回顾了较早的讨论,但这些解决方案都没有奏效: R tm package invalid input in 'utf8towcs'
到目前为止,这是我的代码:
setwd("E:/OneDrive/Thesis/Received comments document/Consultation 50")
getwd()
library(tm)
library(NLP)
library(tidytext)
library(dplyr)
library(pdftools)
files <- list.files(pattern = "pdf$")
comments <- lapply(files, pdf_text)
corp <- Corpus(VectorSource(comments))
corp <- VCorpus(VectorSource(comments));names(corp) <- files
Comments.tdm <- TermDocumentMatrix(corp, control = list(removePunctuation = TRUE,
stopwords = TRUE,
tolower = TRUE,
stemming = TRUE,
removeNumbers = TRUE,
bounds = list(global = c(3, Inf))))
结果:.tolower(txt) 中的错误:'utf8towcs' 中的无效输入'📧'
inspect(Comments.tdm[1:32,])
ap_td <- tidy(Comments.tdm)
write.csv(ap_td, file = "Terms 50.csv")
任何帮助深表感谢。ps,此代码在其他 pdf 上完美运行。