【发布时间】:2016-04-22 17:48:02
【问题描述】:
我想使用 tm 包对this website 上的文件进行文本挖掘。我正在使用以下代码将其中一个文件(即 abell.pdf)下载到我的工作目录并尝试存储内容:
library("tm")
url <- "https://baltimore2006to2010acsprofiles.files.wordpress.com/2014/07/abell.pdf"
filename <- "abell.pdf"
download.file(url = url, destfile = filename, method = "curl")
doc <- readPDF(control = list(text = "-layout"))(elem = list(uri = filename),
language = "en", id = "id1")
但我收到以下错误和警告:
Error in strptime(d, fmt) : input string is too long
In addition: Warning messages:
1: In grepl(re, lines) : input string 1 is invalid in this locale
2: In grepl(re, lines) : input string 2 is invalid in this locale
这些 pdf 文件不是特别长(5 页,978 KB),而且我已经能够成功地使用 readPDF 功能在我的 Mac OSX 上读取其他 pdf 文件。我最想要的信息(2010 年人口普查的总人口)在每个 pdf 的第一页上,所以我尝试将 pdf 缩短到第一页,但我得到了相同的信息。
我是 tm 包的新手,所以如果我遗漏了一些明显的东西,我深表歉意。非常感谢任何帮助!
【问题讨论】: