unstructured bug/两栏PDF分区结果文本不正确,

ejk8hzay  于 2个月前  发布在  其他
关注(0)|答案(3)|浏览(38)

描述问题

在对两列PDF进行分区时,文本提取将字符放在错误的位置。

重现问题

elements = partition("two_col.pdf", strategy="fast")
text attribute of elements[2] = '1. Exchange of Information. The parties agree to exchange Confidential Information for the purpose of (the evaluating a potential business "Purpose") in accordance with this Agreement.'
text attribute of elements[3] = 'relationship'

实际上的PDF文本为:'1.Exchange of Information. The parties agree to exchange Confidential Information for the purpose of evaluating a potential business relationship (the "Purpose") in accordance with this Agreement.'

预期行为

提取的文本与实际文本匹配。

截图

无法提供截图。

环境信息

请运行以下命令并将输出粘贴到这里。
操作系统版本:macOS-14.5-arm64-arm-64bit
Python版本:3.9.6
unstructured版本:0.14.9
unstructured-inference版本:0.7.36
pytesseract版本:0.3.10
Torch版本:2.3.1
未安装Detectron2
未安装PaddleOCR
Libmagic版本:file-5.41
来自/usr/share/file/magic的magic文件
LibreOffice版本:==> libreoffice: 24.2.4

gjmwrych

gjmwrych1#

看起来这是一个pdfminer库底层使用的问题。pdf.py中pdfminer.layout.LTTextBoxHorizontal对象的get_text()方法返回的数据是错误的。

vsdwdz23

vsdwdz232#

这似乎与文档的文本对齐以及单词之间的较大空间有关。这个问题似乎与pdfminer布局中find_neighbors的实现有关。在一定程度上,可以通过在init_pdfminer中初始化的LAParams来控制。其他库,如PyPDF和(Java)PDFBox,可以处理或通过特殊配置来解决这个问题。

wd2eg0qa

wd2eg0qa3#

使用pdfminer的pdf2txt.py运行此代码,不会使这段文字混乱,所以它一定是pdfminer在非结构化使用中的问题。

相关问题