【问题标题】:Possible to run two ContentHandlers for a single parse in Apache-Tika?可以在 Apache-Tika 中为单个解析运行两个 ContentHandler 吗?
【发布时间】:2020-05-22 07:36:38
【问题描述】:

我正在使用 Apache Tika 解析文档并生成文档的纯文本版本和 HTML 预览。如果我调用parse 函数两次并传入两个单独的ContentHandlers,我能够生成两者都很好——这对于纯文本文档非常有用。但是当我得到需要使用 tesseract 进行 OCR 的文档时,这就有点问题了——调用 parse 函数两次是非常浪费的,因为它同时执行了两次 OCR(可能需要一分钟左右)。

我知道我可以编写自己的 ContentHandler,但只是想知道是否有人知道为此提供开箱即用的解决方案?非常感谢!

【问题讨论】:

    标签: java tesseract apache-tika


    【解决方案1】:

    好消息 - Apache Tika 为此提供了一些开箱即用的功能!

    TeeContentHandler - Content handler proxy that forwards the received SAX events to zero or more underlying content handlers.

    只需创建 2+ 个真正的内容处理程序,将它们传递给 constructor of TeeContentHandler,然后在进行解析时将 TeeContentHandler 交给 Tika

    【讨论】:

    • 轰隆隆,来了!非常感谢。
    猜你喜欢
    • 2019-04-05
    • 1970-01-01
    • 2017-09-09
    • 1970-01-01
    • 1970-01-01
    • 2017-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多