AbbyyR包中的ocrFile函数出错
当我使用Abbyy cloud SDK进行OCR时,当我尝试使用Abbyr包中的ocrFile函数时,我不断遇到下面的错误 “curl_下载时出错(finishedlist$resultur[res$id==finishedlist$id],: 参数“url”必须是字符串。“ 当我将文件发送到云端并进行处理时,一切正常,但当云端返回文件时,下载文件时出现问题。我认为这可能是网络或证书问题,但我无法解决问题AbbyyR包中的ocrFile函数出错,r,ocr,abbyy,R,Ocr,Abbyy,当我使用Abbyy cloud SDK进行OCR时,当我尝试使用Abbyr包中的ocrFile函数时,我不断遇到下面的错误 “curl_下载时出错(finishedlist$resultur[res$id==finishedlist$id],: 参数“url”必须是字符串。“ 当我将文件发送到云端并进行处理时,一切正常,但当云端返回文件时,下载文件时出现问题。我认为这可能是网络或证书问题,但我无法解决问题 提前感谢源代码中有一个问题,需要为url使用as.character()函数。 我更新了o
提前感谢源代码中有一个问题,需要为url使用as.character()函数。 我更新了ocrFile函数,如下所示:
install.packages("curl")
library(curl)
new_ocrFile<-function (file_path = "", output_dir = "./", exportFormat = c("txt",
"txtUnstructured", "rtf", "docx", "xlsx", "pptx", "pdfSearchable",
"pdfTextAndImages", "pdfa", "xml", "xmlForCorrectedImage",
"alto"), save_to_file = TRUE)
{
exportFormat <- match.arg(exportFormat)
res <- processImage(file_path = file_path, exportFormat = exportFormat)
while (!(any(as.character(res$id) == as.character(listFinishedTasks()$id)))) {
Sys.sleep(1)
}
finishedlist <- listFinishedTasks()
res$id <- as.character(res$id)
finishedlist$id <- as.character(finishedlist$id)
if (identical(save_to_file, FALSE)) {
res <- curl_fetch_memory(as.character(finishedlist$resultUrl[res$id ==
finishedlist$id]))
return(rawToChar(res$content))
}
curl_download(as.character(finishedlist$resultUrl[res$id == finishedlist$id]),
destfile = paste0(output_dir, unlist(strsplit(basename(file_path),
"[.]"))[1], ".", exportFormat))
}
install.packages(“curl”)
图书馆(curl)
new_ocrFile源代码中有一个问题,它需要url的as.character()函数。
我更新了ocrFile函数,如下所示:
install.packages("curl")
library(curl)
new_ocrFile<-function (file_path = "", output_dir = "./", exportFormat = c("txt",
"txtUnstructured", "rtf", "docx", "xlsx", "pptx", "pdfSearchable",
"pdfTextAndImages", "pdfa", "xml", "xmlForCorrectedImage",
"alto"), save_to_file = TRUE)
{
exportFormat <- match.arg(exportFormat)
res <- processImage(file_path = file_path, exportFormat = exportFormat)
while (!(any(as.character(res$id) == as.character(listFinishedTasks()$id)))) {
Sys.sleep(1)
}
finishedlist <- listFinishedTasks()
res$id <- as.character(res$id)
finishedlist$id <- as.character(finishedlist$id)
if (identical(save_to_file, FALSE)) {
res <- curl_fetch_memory(as.character(finishedlist$resultUrl[res$id ==
finishedlist$id]))
return(rawToChar(res$content))
}
curl_download(as.character(finishedlist$resultUrl[res$id == finishedlist$id]),
destfile = paste0(output_dir, unlist(strsplit(basename(file_path),
"[.]"))[1], ".", exportFormat))
}
install.packages(“curl”)
图书馆(curl)
新文件