A method and apparatus for extracting and structuring the content of a PDF document
Patent Information
- Application Number
- CN202610873957.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-17
- Publication Date
- 2026-10-30
AI Technical Summary
[0007]本发明的主要目的在于提供一种用于提取并结构化PDF文档内容的方法、装置、系统及存储介质,用于解决现有技术中因单一模型能力局限或多源数据融合困难而导致的PDF内容提取布局混乱、元素识别不准及结构重构错误的问题
1. 本发明创新性地融合了两种深度学习模型,利用第一模型(如“纯文本+文本块坐标”方法)提取高精度文本,避免了OCR引入的文字错误;同时利用第二模型(如“图像+文本多模态”方法)识别复杂的版面结构,两者优势互补,为后续处理提供了高质量的基础数据。
Smart Images

Figure CN123016453A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer data processing technology, specifically relating to natural language processing, computer vision and deep learning, and particularly to a method, electronic device, system and computer-readable storage medium for extracting and structuring the content of PDF documents. Background Technology
[0002] Portable Document Format (PDF) has become the primary standard format for electronic document distribution and archiving due to its cross-platform compatibility and format fidelity. However, accurately and completely extracting content from PDF documents and restoring their original logical structure (such as paragraphs, lists, tables, multi-column layouts, etc.) is an extremely challenging task.
[0003] Existing PDF content extraction technologies can be mainly divided into two categories. The first category is based on text stream and coordinate information. This method directly parses the underlying instructions of the PDF to extract the text content and its coordinate data. The advantage of this type of method is that the text extraction accuracy is high and it is less prone to errors caused by optical character recognition (OCR). However, its disadvantage is that it is difficult to handle complex layouts. For example, for documents with multiple columns of text, cross-page tables, or mixed text and images, the output text order is often disordered, making it impossible to correctly reconstruct the reading order of the document.
[0004] The second category is based on computer vision and multimodal deep learning. This method first renders the PDF page as an image, then uses advanced layout analysis models (such as Transformer-based or convolutional neural network-based models) to identify different regions on the page, such as text blocks, images, and tables. This type of method has advantages in layout recognition, table and image localization, but its text content usually needs to be extracted from the image using OCR technology. This inevitably introduces text recognition errors, especially when processing low-resolution documents or documents containing special fonts, where the accuracy of text extraction drops significantly.
[0005] For example, Chinese patent application CN 121072695 A(D1) discloses a scheme for region division of PDF documents based on a layout recognition model. Although its overall process covers the process from structure recognition to layout optimization, it still mainly relies on a single multimodal model and fails to fundamentally solve the problem of insufficient OCR text extraction accuracy. At the same time, when processing data from two different sources (text parsing and image analysis), how to accurately align their heterogeneous coordinate systems, and how to specifically correct subtle errors in model recognition (such as text block fragmentation, misjudgment of headers and footers, etc.) remain technical challenges that the industry has not been able to effectively solve.
[0006] Therefore, how to effectively integrate the advantages of different extraction methods and overcome extraction errors caused by factors such as inconsistent coordinate systems, fragmented text blocks, and inaccurate recognition of headers and footers, so as to achieve high-precision and well-structured content extraction and reconstruction in PDF documents with complex layouts, is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0007] The main objective of this invention is to provide a method, apparatus, system, and storage medium for extracting and structuring PDF document content, in order to solve the problems of chaotic layout, inaccurate element identification, and structural reconstruction errors in PDF content extraction caused by the limitations of a single model or the difficulty in fusion of multi-source data in the prior art.
[0008] To achieve the above objectives, the present invention provides a method for extracting and structuring the content of a PDF document. This method is applied to an electronic device and executed by the processor of the electronic device. The method is characterized by comprising: Obtain the PDF document to be processed; The first deep learning model is invoked to process the PDF document in order to extract multiple text blocks and the first coordinate data corresponding to the multiple text blocks in the first coordinate system; The PDF document's pages are converted into page images, and a second deep learning model is invoked to process the page images to identify at least one layout element and the corresponding second coordinate data in a second coordinate system, wherein the first coordinate system and the second coordinate system are heterogeneous coordinate systems. According to the preset coordinate transformation rules, the first coordinate data and the second coordinate data are aligned to a unified coordinate system to generate aligned coordinate data; Based on the aligned coordinate data, a structured target document is generated.
[0009] Preferably, generating a structured target document based on the aligned coordinate data includes: Based on the aligned coordinate data, at least one post-processing strategy is applied to correct the multiple text blocks and the at least one layout element to generate corrected text content and corrected layout structure. The revised text content is integrated with the revised page layout to generate a structured target document.
[0010] Preferably, aligning the first coordinate data and the second coordinate data to a unified coordinate system according to a preset coordinate transformation rule includes: A preset transformation matrix is applied to perform a linear transformation on the first coordinate data or the second coordinate data to unify the coordinate origin and scaling ratio.
[0011] Preferably, the transformation matrix is a The transformation matrix; and, in the case that the text block contains rotated text, the coordinate transformation rule further includes: After applying the transformation matrix, an inverse rotation matrix corresponding to the rotation angle of the rotated text is applied to correct the coordinates of the rotated text.
[0012] Preferably, the at least one post-processing strategy includes a text block fragment merging strategy.
[0013] Preferably, the text block fragment merging strategy includes: for any two text blocks, based on the aligned coordinate data, determining whether the vertical coordinates of the two text blocks are consistent within a preset tolerance range and whether the horizontal coordinates are adjacent within a preset proximity distance; if the determination result is yes, then the two text blocks are merged into one text block.
[0014] Preferably, the at least one post-processing strategy includes a header / footer recognition strategy.
[0015] Preferably, the header and footer recognition strategy includes: extracting text lines from a preset area at the top of the page and a preset area at the bottom of the page in multiple consecutive pages of the PDF document; and comparing the feature similarity of text lines located in the same preset area across the multiple consecutive pages to identify highly similar repeated text lines as headers or footers.
[0016] Preferably, the at least one post-processing strategy includes a multi-column layout correction strategy.
[0017] Preferably, the layout elements include column boundary information identified by the second deep learning model; the multi-column layout correction strategy includes: dividing multiple text blocks in the page into different columns according to the column boundary information; reordering the multiple text blocks to ensure that text blocks in the same column are prioritized in the vertical direction, and then switching to the next column in the order from left to right or from right to left.
[0018] To achieve the above objectives, the present invention also provides an electronic device, comprising: a memory for storing a computer program; and a processor for executing the computer program; wherein, when the processor executes the computer program, it implements the method described above.
[0019] To achieve the above objectives, the present invention also provides a system for processing PDF documents, comprising: a first processing module configured to invoke a first deep learning model to extract multiple text blocks and corresponding first coordinate data; a second processing module configured to invoke a second deep learning model to identify at least one layout element and corresponding second coordinate data; a coordinate alignment module configured to align the first coordinate data and the second coordinate data to a unified coordinate system according to a preset coordinate transformation rule; and an integration module configured to generate a structured target document based on the aligned coordinate data.
[0020] Preferably, the system further includes: a post-processing module configured to apply at least one post-processing strategy for correction based on the aligned coordinate data; and an integration module further configured to integrate the corrected text content and layout structure to generate a structured target document.
[0021] To achieve the above objectives, the present invention also provides a computer program product, including computer instructions, which, when executed by a processor, implement the method described above.
[0022] To achieve the above objectives, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described above.
[0023] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention innovatively integrates two deep learning models. The first model (such as the "plain text + text block coordinates" method) is used to extract high-precision text, avoiding text errors introduced by OCR. At the same time, the second model (such as the "image + text multimodal" method) is used to identify complex page layout structures. The two complement each other and provide high-quality basic data for subsequent processing.
[0024] 2. By introducing specific transformation and inverse rotation matrices, this invention solves the key technical problem of the inability to align the heterogeneous coordinate systems output by the two models, enabling high-precision text content to be seamlessly integrated with accurate page layout information under a unified spatial reference.
[0025] 3. Based on the model output, this invention designs various rule-based post-processing strategies, such as text block fragment merging, high-precision header and footer recognition, and multi-column layout correction, specifically addressing the fine-grained problems that the model struggles to handle. Experimental data shows that these strategies can improve the accuracy of text block merging to over 99%, and the accuracy of header and footer recognition from 70%-80% to over 97%, ultimately achieving a complete text extraction accuracy of over 85% and a usability rate of over 92%, realizing high-fidelity extraction and structured reconstruction of complex PDF document content. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 is a structural block diagram of an electronic device provided in an embodiment of the present invention.
[0028] Figure 2 is a main flowchart of a method for extracting and structuring PDF document content provided by an embodiment of the present invention.
[0029] Figure 3 is a detailed flowchart of the coordinate alignment steps in an embodiment of the present invention.
[0030] Figure 4 is a detailed flowchart of the text block fragment merging strategy in an embodiment of the present invention.
[0031] Figure 5 is a detailed flowchart of the header and footer recognition strategy in an embodiment of the present invention.
[0032] Figure 6 is a detailed flowchart of the multi-column layout correction strategy in an embodiment of the present invention.
[0033] Figure 7 is a schematic diagram of heterogeneous coordinate system alignment in an embodiment of the present invention.
[0034] Figure 8 is a schematic diagram of the effect of the post-processing strategy in an embodiment of the present invention.
[0035] Explanation of reference numerals in the attached figures: 100: Electronic device; 101: Processor; 102: Memory; 103: First processing module; 104: Second processing module; 105: Coordinate alignment module; 106: Post-processing module; 107: Integration module; 701: First coordinate system; 702: Second coordinate system; 801: Fragmented text blocks; 802: Disordered multi-column text; 803: Complete paragraph; 804: Logically correct reading order. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0037] Example 1 This embodiment provides a technical solution for extracting and structuring the content of PDF documents. This solution can be integrated into an electronic device, such as a server, personal computer, or mobile terminal.
[0038] Referring to Figure 1, the electronic device (100) may include, but is not limited to, a processor (101), a memory (102), and a data interface (not shown) for communicating with other devices. The processor (101) may be a central processing unit (CPU), a graphics processing unit (GPU), or a dedicated AI acceleration chip, responsible for executing instructions stored in the memory (102). The memory (102) may be random access memory (RAM), read-only memory (ROM), solid-state drive (SSD), etc., used to store PDF documents to be processed, deep learning models, intermediate data, and the final generated structured documents. The electronic device (100) also runs an operating system to provide environmental support for model operation and data processing.
[0039] In this embodiment, when the computer program stored in the memory (102) is executed by the processor (101), it can be implemented as multiple functional modules, including a first processing module (103), a second processing module (104), a coordinate alignment module (105), a post-processing module (106), and an integration module (107). These modules work together to execute the method flow shown in FIG2.
[0040] Figure 2 is the main flowchart of the method provided in this embodiment. The flowchart in Figure 2 will be described in detail below with reference to the system architecture in Figure 1.
[0041] Step S201: Obtain the PDF document to be processed.
[0042] The processor (101) receives a PDF document to be processed from local storage or network via a data interface and loads it into memory (102) as input to the processing flow.
[0043] Step S202: Call the first deep learning model to extract the text block and the first coordinate data.
[0044] The first processing module (103) invokes a pre-trained first deep learning model. This model specializes in directly parsing text content and precise coordinate information from the underlying description of a PDF document, which can be understood as an extraction method of "plain text + text block coordinates". The model processes the input PDF document and outputs multiple text blocks and the first coordinate data that precisely corresponds to these text blocks. These coordinate data are located in the first coordinate system built into the PDF document. It should be noted that, in order to improve the model's performance on PDFs with specific complex layouts, the training process of this model can be mixed with a custom-constructed, highly targeted dataset in a general open-source dataset for mixed training, and then further enhanced and fine-tuned by adding the custom dataset again in the final stage of training. In this way, the first deep learning model can output highly accurate text content.
[0045] Step S203: Call the second deep learning model to identify layout elements and second coordinate data.
[0046] Meanwhile, the second processing module (104) renders or converts each page of the PDF document into a page image. Subsequently, a pre-trained second deep learning model is invoked. This model is a computer vision-based multimodal model specialized for layout analysis of page images, which can be understood as an "image + text multimodal" recognition method. The model processes the page image to identify various layout elements on the page, such as tables, images, formulas, column boundaries, etc. Simultaneously, the model also outputs the second coordinate data corresponding to these layout elements. This coordinate data is located in a second coordinate system based on the pixels of the page image.
[0047] Referring to Figure 7, the first coordinate system (701) and the second coordinate system (702) are heterogeneous. Their origins, scaling ratios, and even coordinate axis directions may be different, so they cannot be directly compared and merged.
[0048] Step S204: Align the first coordinate data and the second coordinate data to a unified coordinate system.
[0049] In order to combine the advantages of the two models, the coordinate alignment module (105) performs a coordinate alignment operation.
[0050] In a specific scenario of this embodiment, coordinate alignment is not a simple linear scaling. The system constructs a 2x2 transformation matrix for the width and height of the PDF page. This specific 2x2 matrix is used for spatial mapping of the 'first coordinate data' (from the PDF's built-in coordinate system) and the 'second coordinate data' (from the visual model's bounding box coordinate system). Specifically, for rotated text commonly found in scanned documents or typesetting, this application introduces an 'inverse rotation matrix'. Before alignment, the rotation angle of the text block is calculated. , build The inverse rotation matrix is used to correct the text vector to 0 degrees horizontally before subsequent coordinate normalization. This effectively solves the problem of positional drift of skewed text during multimodal fusion.
[0051] This is one of the key steps in this invention, and its detailed process is shown in Figure 3.
[0052] In step S301, the module acquires the first coordinate data from step S202 and the second coordinate data from step S203.
[0053] In step S302, a preset transformation matrix is applied to perform a linear transformation on one type of coordinate data. This transformation matrix aims to unify the origin and scaling of the two coordinate systems. Experiments have shown that, based on the physical width and height of the PDF page, a specific transformation matrix can be constructed to achieve effective transformation between the two coordinate systems. In a preferred embodiment, this transformation matrix can be a... The matrix is represented as:
[0054] in, The coefficients are pre-calculated based on the mapping relationship between the source coordinate system and the target coordinate system.
[0055] In step S303, the system detects whether the text block contains rotated text. For example, some table headers or sidebar notes in a PDF may be arranged vertically or obliquely.
[0056] If the determination is yes, proceed to step S304, after applying the above... After applying the transformation matrix, an additional inverse rotation matrix is applied. This inverse rotation matrix corrects the coordinates of the rotated text back to the horizontal (0 degrees) direction to ensure its position is correct in a unified coordinate system.
[0057] If the determination is negative, or after step S304 is completed, the process proceeds to step S305, outputting coordinate data aligned to a unified coordinate system. Through this step, the positional information of all text blocks and layout elements can be measured and analyzed under the same spatial reference.
[0058] Step S205: Apply post-processing strategies for correction.
[0059] Although the two deep learning models provide high-quality base data, some fine-grained errors still exist. The post-processing module (106) applies a series of rule-based post-processing strategies based on the aligned coordinate data to refine the text blocks and layout structure. In this embodiment, at least one post-processing strategy may include the following: 1. Text block fragment merging strategy The text blocks output by the first deep learning model can sometimes be fragmented; for example, a complete sentence may be split into multiple independent text blocks. As shown in Figure 4, this strategy aims to merge these fragments.
[0060] In step S401, for any two text blocks that are adjacent in reading order on the page (e.g., text block A and text block B), the system first determines whether the spatial merging condition is met based on their coordinates. This includes: determining whether the vertical coordinates of the two text blocks are consistent within a preset tolerance range (step S402), and determining whether their horizontal coordinates are adjacent within a preset proximity distance (step S403).
[0061] If the space conditions are met, the system can further determine whether their text attributes are consistent (step S404), such as whether the font size, font or color are the same, in order to avoid erroneously merging texts of different styles.
[0062] Furthermore, to handle cross-line paragraph merging, the system can also examine more refined linguistic features (step S405). For example, it checks whether the last character of the previous text block (text block A) is a predefined sentence-ending punctuation mark such as a period or question mark, and whether the first character of the next text block (text block B) is a lowercase letter. If A does not end with a sentence-ending punctuation mark, while B begins with a lowercase letter, this most likely means that they belong to the same sentence.
[0063] If all conditions are met, then in step S406, the two text blocks are merged into a logically more complete text block. This strategy achieves a text block merging accuracy of over 99%, improving text coherence.
[0064] 2. Header and Footer Recognition Strategy The recognition rate of two deep learning models for repetitive page elements such as headers, footers, and footnotes is typically low, around 70%-80%, which is insufficient for scenarios requiring the extraction of pure text. As shown in Figure 5, this strategy uses cross-page comparison to identify these elements with high accuracy.
[0065] In step S501, the system extracts all text lines from a preset area at the top of the page (e.g., the top 10% of the page) and a preset area at the bottom of the page (e.g., the bottom 10% of the page) in multiple consecutive PDF pages.
[0066] In step S502, the system crosses these consecutive pages and performs feature similarity comparison on text lines located within the same preset area.
[0067] In step S503, specifically, the system calculates the similarity score between the two text lines to be compared. This score is a weighted composite value, and its calculation is based on: the similarity of the normalized vertical coordinates of the two text lines on the page, the similarity of the text content after normalization processing (such as removing spaces and converting to lowercase), and the similarity of font size.
[0068] In step S504, the calculated similarity score is compared with a preset similarity threshold. The comparison is performed. The condition for judgment is: when a text line is compared with at least... indivual( For example, an integer greater than 1. The similarity scores of text lines in corresponding areas across consecutive pages all exceed the threshold. If the text line is not found in the header or footer, then the text line and similar text lines on subsequent pages are identified as headers or footers. Using this strategy based on the stability of cross-page content, the accuracy and recall rate for header and footer identification can both reach over 97%.
[0069] 3. Multi-column layout correction strategy For multi-column layout documents such as journals and newspapers, correctly restoring the reading order is crucial. As shown in Figure 6, this strategy uses layout information identified by a second deep learning model to correct the reading order of the text.
[0070] In step S601, the system uses the column boundary information identified by the second deep learning model.
[0071] In step S602, all text blocks within the page are divided into different columns based on these column boundaries.
[0072] In step S603, all text blocks are reordered. The sorting rule is as follows: first, text blocks within the same column are sorted vertically from top to bottom. After one column is sorted, the sorting proceeds from left to right (or right to left, depending on language conventions) to the next column. The second deep learning model achieves an overall text layout accuracy of approximately 90%. After this correction using precise coordinate information, the final text layout accuracy can reach over 95%.
[0073] It should be noted that although this embodiment uses the above three strategies as examples, the post-processing strategies of this application are not limited to these. In other embodiments, it may also include, for example, a paragraph segmentation strategy within the same text block based on coordinates, text length, font size, and punctuation analysis, or a structured recognition strategy for table content, etc.
[0074] Step S206: Integrate content and structure to generate the target document.
[0075] After all post-processing strategies have been applied, the integration module (107) performs the final integration work.
[0076] Based on the results of the header and footer recognition strategy, text identified as headers or footers is removed from the corrected text content.
[0077] If the layout elements contain tables, a specialized table structure recognition algorithm can be called to convert the text content within the table area into a structured data format (such as JSON or CSV) corresponding to the rows and columns.
[0078] The corrected and cleaned text content is organized according to the corrected page layout (especially the reading order after the multi-column layout is corrected) to generate the final structured target document, such as a Markdown, HTML or JSON file.
[0079] As shown in Figure 8, after processing by the method of the present invention, the originally fragmented text blocks (801) are merged into complete paragraphs (803), and the originally disordered multi-column texts (802) are rearranged into a logically correct reading order (804), thus achieving high-fidelity content extraction and structural reconstruction.
[0080] In summary, this embodiment systematically solves various challenges in PDF content extraction through the synergistic effect of dual-model fusion, heterogeneous coordinate alignment, and multi-level post-processing strategies. The extracted text achieves a complete accuracy rate of over 85% and a usability rate of over 92%, significantly outperforming existing technologies.
[0081] Example 2 This embodiment is a further extension and variation of Embodiment 1.
[0082] In this embodiment, the specific network structures of the first and second deep learning models are not limited. For example, they can be models based on the Transformer architecture, models based on convolutional neural networks (CNNs), or variants and combinations of recurrent neural networks (RNNs). The choice of model structure can be determined based on the specific application scenario and available computing resources.
[0083] The preset transformation matrix can be obtained in various ways. For example, the parameters of the matrix can be learned by sampling a large number of PDF documents and their corresponding page images, and performing regression analysis on corresponding points of the two coordinate systems. Alternatively, in some cases, it can be directly calculated based on the metadata of the PDF document (such as page size `MediaBox`, crop size `CropBox`) and the image rendering resolution (DPI).
[0084] The method disclosed in this invention can be implemented as a software program. This program can be stored on a computer-readable storage medium, such as a hard disk, USB flash drive, optical disk, or cloud storage server. When the processor of an electronic device executes the program, it performs the steps described in the above embodiments. Therefore, this invention also protects a computer program product comprising the above-described computer program, and a computer-readable storage medium storing the program.
[0085] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for extracting and structuring the content of a PDF document, characterized in that, include: Obtain the PDF document to be processed; The first deep learning model is invoked to process the PDF document in order to extract multiple text blocks and the first coordinate data corresponding to the multiple text blocks in the first coordinate system; The PDF document's pages are converted into page images, and a second deep learning model is invoked to process the page images to identify at least one layout element and the corresponding second coordinate data in a second coordinate system, wherein the first coordinate system and the second coordinate system are heterogeneous coordinate systems. According to the preset coordinate transformation rules, the first coordinate data and the second coordinate data are aligned to a unified coordinate system to generate aligned coordinate data; Based on the aligned coordinate data, a structured target document is generated.
2. The method according to claim 1, characterized in that, The step of generating a structured target document based on the aligned coordinate data includes: Based on the aligned coordinate data, at least one post-processing strategy is applied to correct the multiple text blocks and the at least one layout element to generate corrected text content and corrected layout structure. The revised text content is integrated with the revised page layout to generate a structured target document.
3. The method according to claim 1 or 2, characterized in that, The step of aligning the first coordinate data and the second coordinate data to a unified coordinate system according to a preset coordinate transformation rule includes: A preset transformation matrix is applied to perform a linear transformation on the first coordinate data or the second coordinate data to unify the coordinate origin and scaling ratio.
4. The method according to claim 3, characterized in that, The transformation matrix is a The transformation matrix; and, in the case that the text block contains rotated text, the coordinate transformation rule further includes: In application After applying the transformation matrix, an inverse rotation matrix corresponding to the rotation angle of the rotated text is applied to correct the coordinates of the rotated text.
5. The method according to claim 2, characterized in that, The at least one post-processing strategy includes a text block fragment merging strategy; Optionally, the text block fragment merging strategy includes: For any two text blocks, based on the aligned coordinate data, determine whether the vertical coordinates of the two text blocks are consistent within a preset tolerance range, and whether their horizontal coordinates are connected within a preset proximity distance. If the judgment result is yes, then the two text blocks will be merged into one text block; Optionally, the text block fragment merging strategy further includes: After determining that the coordinates of the two text blocks meet the merging condition, it is further determined whether the text attributes of the two text blocks are consistent, including font size, font, or color; merging is only performed when the text attributes are consistent. Optionally, the triggering conditions for the merging operation further include: The system detects whether the last character of the first text block is a preset sentence-ending punctuation mark, and detects whether the first character of the immediately following second text block is a lowercase letter; if the last character of the first text block is not a sentence-ending punctuation mark, and the first character of the second text block is a lowercase letter, then the merging operation is triggered.
6. The method according to claim 2, characterized in that, The at least one post-processing strategy includes a header / footer recognition strategy; Optionally, the header and footer recognition strategy includes: In multiple consecutive pages of the PDF document, extract the text lines from the preset areas at the top and bottom of the page, respectively; Across multiple consecutive pages, text lines located within the same preset area are compared for feature similarity to identify highly similar repeated text lines as headers or footers. Optionally, the feature similarity comparison includes: Calculate the similarity score between two lines of text to be compared. The similarity score is calculated by weighting the similarity of the normalized vertical coordinates, normalized text content, and font size of the two lines of text. Optionally, the criteria for identifying headers or footers are: When the similarity score of a text line and the corresponding text lines in at least N consecutive pages all exceed a preset similarity threshold T, the text line and its similar text lines in subsequent pages are determined as headers or footers, where N is an integer greater than 1.
7. The method according to claim 2, characterized in that, The at least one post-processing strategy includes a multi-column layout correction strategy; Optionally, the layout elements include column boundary information identified by the second deep learning model; The multi-column layout correction strategy includes: Based on the column boundary information, multiple text blocks within the page are divided into different columns; The multiple text blocks are reordered to ensure that text blocks in the same column are prioritized in the vertical direction, and then switched to the next column in either left-to-right or right-to-left order.
8. A computer program product, characterized in that, It includes computer instructions, which, when executed by a processor, implement the method as described in any one of claims 1 to 7.
9. A system for processing PDF documents, characterized in that, include: The first processing module is configured to call the first deep learning model to extract multiple text blocks and their corresponding first coordinate data; The second processing module is configured to call the second deep learning model to identify at least one layout element and its corresponding second coordinate data. The coordinate alignment module is configured to align the first coordinate data and the second coordinate data to a unified coordinate system according to a preset coordinate transformation rule; The integration module is configured to generate structured target documents based on aligned coordinate data.
10. The system according to claim 9, characterized in that, Also includes: The post-processing module is configured to apply at least one post-processing strategy to correct the alignment based on the aligned coordinate data. The integration module is further configured to integrate the revised text content and page layout to generate a structured target document; Optionally, the post-processing module is further configured to identify headers and footers by comparing the similarity of normalized vertical coordinates, normalized content, and font size of text lines within the page edge area across pages.
Citation Information
Patent Citations
Knowledge base document intention recognition method based on layout recognition
CN121072695A
