Apache Tika extract scanned PDF files起,它对于扫描文档非常有效。但是问题是,它占用了太多时间以及CPU利用率。

就我而言,具有15 MB23 pages文件占用~4.5 minute太高了。请在下面找到我的工作代码,

Parser parser = new AutoDetectParser();
BodyContentHandler handler = new BodyContentHandler(Integer.MAX_VALUE);

TesseractOCRConfig config = new TesseractOCRConfig();
PDFParserConfig pdfConfig = new PDFParserConfig();
pdfConfig.setExtractInlineImages(true);

ParseContext parseContext = new ParseContext();
parseContext.set(TesseractOCRConfig.class, config);
parseContext.set(PDFParserConfig.class, pdfConfig);
//need to add this to make sure recursive parsing happens!
parseContext.set(Parser.class, parser);

Metadata metadata = new Metadata();
parser.parse(inputStream, handler, metadata, parseContext);
String content = handler.toString();


如何使其更优化/更快?有什么建议么?

最佳答案

正如@Gagravarr在评论中提到的那样,这不是Tika的缓慢,因为Tesseract是消耗CPU的进程。

为了处理它,我已经使用FIFO方法在另一台服务器上分离了此过程。这样一次只处理一个文件。

07-27 13:39