A document intelligent parsing method and system
By reconstructing the binary tree structure of PDF documents through deep learning and recursive algorithms, the problem of insufficient accuracy in complex layout parsing in existing technologies is solved, and efficient and accurate document intelligent parsing is achieved, which is suitable for the automated processing and information management of various complex PDF documents.
Patent Information
- Application Number
- CN202511056417.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-07-30
AI Technical Summary
Existing PDF document parsing methods are difficult to adapt to complex and changeable layouts, resulting in insufficient parsing accuracy and robustness. They are unable to accurately identify and associate multi-column layouts, complex mixed text and image layouts, cross-page tables, etc. The output parsing results are very different from human reading logic and require a lot of manual intervention.
A deep learning model is used for layout analysis, combined with a recursive algorithm to reconstruct the binary tree structure, blocks are merged using the nearest neighbor priority principle and the combination lossless principle, global semantic consistency assessment and adaptive adjustment are introduced, the tree structure is optimized to reflect the logical order of the document, and a large language model is used for error correction.
It achieves high-precision structured parsing of various complex PDF documents, ensuring that the parsing results conform to human reading habits, reducing manual intervention, and expanding the scope of application to document automation processing and knowledge management.
Smart Images

Figure CN120561344B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital document processing, and in particular to a document intelligent parsing method and system. Background Art
[0002] Currently, PDF documents, as a widely used electronic document format, carry a large amount of structured and unstructured information. However, intelligent parsing and structured extraction of PDF documents for subsequent data processing, information retrieval, knowledge management, and automated applications still face many technical challenges. Existing PDF document parsing methods are mainly based on preset rules and usually rely on fixed coordinates, fonts, spacing and other rigid features. Faced with the increasingly complex layout of PDF documents (for example, multi-column text, mixed text and graphics, irregular tables, nested structures, etc.), rule-based methods have difficulty adapting to this diversity and variability, resulting in a significant reduction in the accuracy and robustness of the parsing. Once the layout changes slightly, the rules need to be maintained and updated extensively, consuming huge manpower costs.
[0003] In addition, existing methods often fragment PDF pages and treat them as independent images or text layers, lacking an understanding of the document's overall logical structure and hierarchical relationships. The fragmented processing makes it difficult to reconstruct the logical connections between chapters, paragraphs, subheadings, charts, tables and their explanatory texts, making it difficult for the parsing results to reflect the document's true semantic structure and reading order. In particular, for documents with complex formats such as multi-column layouts, complex mixed text and graphics, and cross-page tables or paragraphs, the processing effects of existing methods are usually unsatisfactory. For example, they may not be able to correctly identify the reading direction of the text, resulting in confusion among multiple columns of text; they may not be able to accurately associate images or tables with their corresponding explanatory texts; or they may have difficulty identifying and connecting logical units across pages, making it extremely difficult to extract structured information from complex documents. Due to the existence of the above problems, the parsing results output by existing methods are often flat, disordered text blocks, or even if they are initially structured, their logical order and hierarchy are quite different from the structure understood by humans when reading the original PDF documents, which reduces the usability of the parsing results. When downstream applications process these unstructured or low-structured data, they still require a lot of manual intervention and post-processing. Therefore, a document intelligent parsing method and system based on deep learning is needed. Summary of the Invention
[0004] The purpose of the present invention is to solve the defects in the prior art and to propose a document intelligent parsing method and system.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A document intelligent parsing method, including, executed by a document intelligent parsing system, the method comprising the following steps:
[0007] a) Use a deep learning model to analyze the layout of PDF pages and obtain a block list containing location information, text content, and type;
[0008] b) based on the neighbor priority principle and the lossless combination principle, a recursive algorithm is used to merge the block lists from bottom to top to reconstruct the blocks into a binary tree structure, wherein each merge selects the best adjacent block and forms a new parent node, and the process is repeated until all blocks are organized into the tree;
[0009] c) optimizing the balance of the binary tree structure to ensure that the tree depth is moderate and adjusting the node relationships to better reflect the logical structure of the document;
[0010] d) Based on the global document semantic representation, the binary tree structure is evaluated for structural-semantic consistency, and adaptive adjustment and error correction are performed to eliminate ambiguity, fix logical errors, and maximize semantic consistency;
[0011] e) Outputting the processed binary tree structure using a pre-order traversal method, wherein the traversal sequence conforms to human reading habits and maintains the original hierarchical structure of the document
[0012] Furthermore, in step a), the deep learning model decomposes the PDF page into the block list, each of which contains the following attributes: location information (upper left and lower right coordinates), text content, and type (paragraph / image / table, etc.);
[0013] The deep learning model is a convolutional neural network model for object detection and semantic segmentation. It is trained on a PDF document dataset containing different layout types (such as multiple columns, mixed text and images, tables, and lists) to identify different types of blocks and their boundaries. The training dataset is obtained through manual annotation, and the recognition accuracy of the model is evaluated using the F1 score.
[0014] Furthermore, in step b), the neighbor priority principle refers to prioritizing the combination of blocks with similar physical locations; and the lossless combination principle refers to ensuring that the original semantic relationship is not lost during the reorganization process.
[0015] Furthermore, in step b), the selection of the optimal adjacent block is performed by minimizing an objective function J(block i ,block j )= •D(block i ,block j )+ •(1-T(block i ,block j ))+ •(1-F(block i ,block j ))+ •(1-S(block i ,block j )) is performed, and the objective function comprehensively considers the following criteria:
[0016] The distance metric D(block i , block j ), such as Euclidean distance;
[0017] Consistency of text flow T(block i , block j );
[0018] Similarity of font attributes F(block i , block j ), such as differences in font size and weight;
[0019] The semantic relevance of paragraphs S(block i , block j ), for example, based on the cosine similarity of the text content word vector; the objective function is expressed as:
[0020] J(block i ,block j )= •D(block i ,block j )+ •(1-T(block i ,block j ))+ •(1-F(block i ,block j ))+ •(1-S(block i ,block j ))
[0021] in, , , , is the preset weight coefficient.
[0022] Furthermore, in step c), the balance optimization includes adopting a balancing strategy such as an AVL tree or a red-black tree, and adjusting the node relationship to better reflect the logical hierarchy and reading order of the document. The adjustment process is guided by identifying and processing paragraph connections across pages, the hierarchical relationship between sub-sections and parent sections, and introducing a semantic relevance evaluation model to ensure that semantically continuous text blocks also maintain continuity in the tree structure.
[0023] Furthermore, the step d) comprises:
[0024] Inputting the text content in the binary tree structure into a large language model based on the Transformer architecture for encoding to obtain a global document semantic representation;
[0025] Based on the global document semantic representation, the semantic continuity score of the current binary tree structure is evaluated ( ), logical level score ( ) and thematic consistency scores ( );
[0026] According to the evaluation result, the binary tree structure is backtracked and re-merged, cross-node adjusted, level adjusted and / or ambiguity resolved.
[0027] Furthermore, in step e), the traversal output method also provides a variety of customized traversal methods, including depth-first traversal and breadth-first traversal, based on different application scenarios (such as tabular data); the output format includes JSON, XML, or other structured data formats.
[0028] A document intelligent parsing system, used to execute the above-mentioned document intelligent parsing method, comprising:
[0029] The layout analysis module is used to analyze the layout of PDF pages using a deep learning model to obtain a block list containing location information, text content, and type;
[0030] a recursive reconstruction module, configured to merge the block lists from bottom to top using a recursive algorithm based on a neighbor priority principle and a combination lossless principle, so as to reconstruct the blocks into a binary tree structure;
[0031] A tree structure optimization module, configured to optimize the balance of the binary tree structure to ensure a moderate depth of the tree and adjust the node relationships to better reflect the logical structure of the document;
[0032] A global semantic error correction module is used to evaluate the structure-semantic consistency of the binary tree structure based on the global document semantic representation, and to perform adaptive adjustment and error correction to eliminate ambiguity, repair logical errors and maximize semantic consistency;
[0033] The traversal output module is used to output the result of the processed binary tree structure in a pre-order traversal manner. The traversal sequence conforms to human reading habits and maintains the original hierarchical structure of the document.
[0034] Furthermore, the global semantic error correction module includes: a global document semantic representation learning unit, which is used to input the text content in the binary tree structure into a large language model based on the Transformer architecture for encoding;
[0035] A structure-semantic consistency evaluation unit is used to evaluate the semantic continuity score of the current binary tree structure based on the global document semantic representation ( ), logical level score ( ) and thematic consistency scores ( );
[0036] An adaptive structure adjustment and error correction unit is used to perform backtracking and re-merging, cross-node adjustment, level adjustment and / or ambiguity resolution on the binary tree structure according to the evaluation result.
[0037] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the document intelligent parsing method is implemented.
[0038] Compared with the prior art, the present invention has the following beneficial effects:
[0039] By employing deep learning models for layout analysis, it is possible to effectively identify and process various complex typesetting formats, such as multi-column layouts, mixed text and image layouts, tables, lists, and so on, overcoming the difficulty of commonly used rule-based methods in adapting to complex and changing layouts. Refined block type recognition and boundary detection ensure the accuracy of the initial parsing. An optimized deep learning model and efficient recursive algorithm, combined with intelligent structural optimization strategies, ensure high accuracy while maintaining high processing efficiency and performance throughout the parsing process. By employing a quantitative objective function to guide the selection of "optimal adjacent blocks" during the recursive reconstruction process, it is able to comprehensively consider physical distance, text flow, font attributes, and paragraph semantic relevance, enabling the reconstructed binary tree structure to more accurately reflect the document's true logical order, avoiding logical errors caused by pure physical proximity.
[0040] In addition, the tree structure optimization module effectively handles cross-page paragraph connections, identifies the hierarchical relationship between sub-chapter and parent chapter, and introduces a semantic relevance evaluation model to guide the adjustment of node relationships, ensuring that semantically continuous text blocks also maintain continuity in the tree structure. At the same time, by adding a global semantic error correction module to perform global document semantic representation learning, the preliminary structure is adaptively adjusted and corrected, thereby eliminating deep ambiguity, repairing logical errors and maximizing the consistency of the final parsing results with human reading logic at the semantic level. As a result, it is not restricted by specific document formats and can flexibly handle various types of PDF files such as presentation documents, multi-column papers, complex mixed text and graphics documents, and reports containing various complex tables, expanding its application scope in document automation processing, information extraction, and knowledge management. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.
[0042] Figure 1 This is a flow chart of the architecture of the document intelligent parsing system proposed by the present invention;
[0043] Figure 2 Schematic diagram of layout analysis results in an embodiment of the present invention;
[0044] Figure 3 This is a schematic diagram of a local structure of a binary tree reconstruction in an embodiment of the present invention;
[0045] Figure 4 This is a flow chart of the document intelligent parsing method proposed in the present invention. DETAILED DESCRIPTION
[0046] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0047] In the description of the present invention, it should be understood that the terms "upper", "lower", "front", "back", "left", "right", "top", "bottom", "inside", "outside", etc., indicating directions or positional relationships, are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore should not be understood as limiting the present invention.
[0048] This paper provides a deep learning-based intelligent document parsing method and system to address existing PDF document parsing technologies' shortcomings in handling complex layouts, lacking understanding of the document's overall structure, and generating parsing results inconsistent with human reading habits. This method uses deep learning to analyze layout, employs an innovative recursive algorithm to reconstruct the document structure, and introduces an adaptive error correction and optimization mechanism based on global contextual semantic understanding, resulting in more accurate, logically accurate, and structured parsing results that align with human reading habits.
[0049] The embodiments of the present invention can be applied to a variety of complex PDF documents, including but not limited to presentation documents, multi-column papers, complex mixed text and image documents, and mixed documents containing tables and lists.
[0050] Reference Figure 1-4 The document intelligent parsing system can be deployed on a server, cloud computing platform, or a local device with sufficient computing power. It mainly includes the following core modules:
[0051] Layout analysis module: responsible for performing deep learning model-driven layout analysis on the input PDF page, identifying and extracting the basic structural blocks in the page.
[0052] Recursive reconstruction module: responsible for reconstructing the block list obtained from layout analysis into a binary tree structure with logical hierarchy through a recursive algorithm.
[0053] Tree structure optimization module: adjusts the balance and optimizes the node relationships of the initially reconstructed binary tree structure to better reflect the logical hierarchy of the document.
[0054] Global semantic error correction module: uses a large language model to obtain global document semantics, and adaptively verifies and corrects the binary tree structure based on semantic consistency evaluation.
[0055] Traversal output module: responsible for outputting the final structured parsing results according to the preset or user-specified traversal method.
[0056] Among them, each module works together to complete the conversion from original PDF documents to high-precision structured data.
[0057] For better explanation, each module is further described below.
[0058] The layout analysis module uses a deep learning model to perform precise layout analysis on each page of a PDF document.
[0059] In this embodiment, the deep learning model preferably adopts a convolutional neural network (CNN) model for object detection and semantic segmentation, such as but not limited to Mask R-CNN, YOLO series (such as YOLOv8-seg), U-Net or its variants. The above models can effectively identify objects of different categories and their precise boundaries from visual images, corresponding to various types of "blocks" in the PDF page, where:
[0060] Input: Rasterized image of a PDF page (e.g. converted to PNG or JPEG format).
[0061] Output: A list of detected blocks. Each block has the following key properties:
[0062] Position information: usually in the upper left and lower right corner coordinates Indicates that the block is limited to a rectangular area on the page.
[0063] Text content: Plain text content extracted via OCR (Optical Character Recognition) technology or directly from the PDF text layer.
[0064] Type: The category of the block identified by the deep learning model, for example: paragraph, heading1, heading2, image, table, list_item, caption, footer, header, etc.
[0065] To ensure the model's recognition accuracy and robustness, sufficient training is required. The training dataset was sourced and annotated by constructing a large-scale, diverse dataset of PDF documents covering a variety of complex layouts, such as multi-column papers, scientific reports, legal documents, financial statements, and presentations. Each PDF page in the dataset was manually annotated, with each visual element (i.e., "block") accurately labeled with its bounding box, text content (if applicable), and correct type. The annotation tools used included annotation platforms such as Labelme and DocLayNet.
[0066] The training method is supervised learning. The optimizer is Adam or SGD. The loss function is selected based on the model type. Examples include classification loss (such as cross entropy) and bounding box regression loss (such as L1Loss and IoULoss), which are commonly used in object detection tasks. During training, the model continuously adjusts weights using a backpropagation algorithm to minimize the difference between the predicted output and the true annotation.
[0067] The recognition accuracy of the model is evaluated using the F1 score: the F1 score is the harmonic mean of precision and recall, and can comprehensively measure the performance of the model, especially in scenarios with class imbalance or sensitivity to missed detections and false detections.
[0068]
[0069]
[0070]
[0071] True Positives represent correctly identified blocks, False Positives represent incorrectly identified blocks, and False Negatives represent unrecognized blocks. A high F1 score indicates that the model can accurately and comprehensively identify various layout elements on the page.
[0072] The recursive reconstruction module is used to reconstruct the flattened block list output by the layout analysis module into a binary tree structure that is easy for computers to process and humans to understand, according to the logical order and hierarchical structure of the document. The recursive reconstruction module adopts a recursive algorithm and follows the "nearest neighbor priority principle" and "combination lossless principle" as well as a set of quantitative "optimal" selection strategies.
[0073] The recursive reconstruction module applies a corresponding recursive algorithm. The recursive algorithm adopts a bottom-up merging strategy, starting from the smallest, independent block, and gradually merging logically adjacent and most related blocks into larger composite blocks (parent nodes). This process is repeated until all blocks are organized into a single binary tree. The recursive function can be abstracted as reconstruct_tree, and its logic is as follows:
[0074] Base case: If the length of the input block list blocks is less than or equal to 1, the list is returned directly because there are no blocks that can be merged.
[0075] Find the best adjacent blocks: Use the find_best_neighbors(blocks) function to find a pair of adjacent blocks that are most suitable for merging from the current blocks list.
[0076] Merge adjacent blocks: Through the merge_blocks(best_pair) function, the best adjacent blocks found are merged into a new composite block (parent node).
[0077] Recursive processing: remove the merged blocks from the original blocks list, add the new composite block to the list of remaining blocks, and then recursively call reconstruct_tree on the new list.
[0078] During recursive refactoring, follow these strategies:
[0079] Neighbor priority principle: prioritize combining the two blocks that are closest in physical location (such as distance on the page) to ensure that spatial continuity is reflected in the preliminary merge.
[0080] The principle of lossless combination: During the reorganization process, ensure that the original semantic relationship is not lost. When making merging decisions, not only the physical location is considered, but also whether the merger will cause semantic interruption or logical confusion in the text flow.
[0081] In addition, the selection and quantization of the optimal neighboring blocks are achieved by introducing the objective function J(block i , block j ) to evaluate any two adjacent blocks i and block j The merging preference between them is selected so that a pair of adjacent blocks is merged to minimize the objective function.
[0082] The objective function comprehensively considers the following criteria:
[0083] The distance metric D(block i , block j ): Measures the spatial proximity of two blocks on the page. The measurement methods include: Euclidean distance: calculates the Euclidean distance between the center points of two blocks.
[0084] Boundary Distance: Calculates the distance between the closest edges of two blocks. For vertically arranged text, the Y-axis distance is prioritized; for horizontally arranged text (such as multi-columns), the X-axis distance is prioritized.
[0085] Consistency of text flow T(block i , block j ): Evaluates whether the text content of two blocks conforms to a normal reading flow. For example, for Chinese documents, left-to-right and top-to-bottom ordering should be prioritized; for multi-column documents, vertical-first, then horizontal reading order should be considered. This value is typically 0 (inconsistent) or 1 (consistent), or a continuous value between 0 and 1 indicating the degree of consistency.
[0086] Similarity of font attributes F(block i , block j ): Evaluates the similarity between two blocks of text based on properties such as font size, weight (boldness), and font type. Logically consecutive blocks of text typically have similar font properties. For example, the absolute or relative difference in font size can be calculated; smaller differences indicate higher similarity.
[0087] The semantic relevance of paragraphs S(block i , block j ): Measures the semantic relevance of the text content of two blocks. Blocks with high semantic relevance are more likely to belong to the same logical unit. This is achieved through the following methods:
[0088] Word vector similarity: Convert the text content of each block into a word vector (for example, using a pre-trained language model like Word2Vec, GloVe, or BERT), and then calculate the cosine similarity between the text vectors of two blocks. Cosine similarity values range from -1 to 1, with values closer to 1 indicating greater semantic similarity.
[0089] Topic model: Analyze the topic distribution of blocks through topic models such as LDA and NMF to evaluate the degree of overlap between two blocks in terms of topics.
[0090] The objective function is expressed as the following weighted combination:
[0091] J(block i ,block j )= •D(block i ,block j)+ •(1-T(block i ,block j ))+ •(1-F(blocki,block j ))+ •(1-S(block i,blockj ))
[0092] in, , , , is a preset weight coefficient, whose value is adjusted according to the document type, training data and experience to balance the importance of different discrimination criteria. For example, Determine the importance of physical distance, Determines the importance of semantic relevance. By minimizing the J value, the system can intelligently select the best merging path to build a binary tree that is more consistent with the document logic.
[0093] In an example: Recursive procedure example
[0094] Assume the initial block list is [B1, B2, B3, B4, B5].
[0095] First iteration: The system calculates the J value of all adjacent block pairs (e.g., J(B1, B2), Assuming J(B2, B3) is the smallest, merge B2 and B3 into a new block P1. The current block list becomes [B1, P1, B4, B5].
[0096] Second iteration: The system repeats the above process on the new list. Assuming J(B1, P1) is the smallest, B1 and P1 are merged into a new block P2, and the current block list becomes [P2, B4, B5].
[0097] And so on: until all blocks are merged into one root node, forming the final binary tree structure.
[0098] The tree structure optimization module intervenes after the recursive reconstruction module generates a preliminary binary tree structure. It is used to make further fine-tuning adjustments to the tree's balance, node relationships, and logical hierarchy to ensure that the final document structure can more accurately and clearly reflect the original document's logical layout and human reading habits.
[0099] To ensure the tree has a moderate depth and avoid structural imbalance or inefficient traversal due to long paths, the tree structure optimization module adopts the classic self-balancing binary search tree balancing strategy, such as the balancing algorithm of AVL trees or red-black trees. These algorithms dynamically adjust the tree structure through operations such as rotation and recoloring when nodes are inserted or deleted (corresponding to the merging or splitting of blocks, or structural adjustments), so that it always remains in an approximately balanced state. This optimizes the tree traversal performance and ensures that the logical hierarchy of the document is clear and not distorted. Although directly applying the strict balance factors of AVL or red-black trees may not be fully applicable to the logical structure of the document, its core logic can still be used as a reference, such as maintaining global balance through local adjustments. For example, when it is detected that the depth of a subtree far exceeds that of its sibling subtrees, the module attempts to adjust the organization of its internal nodes, or considers promoting or demoting some nodes.
[0100] The tree structure optimization module adjusts node relationships through logical reasoning and semantic judgment, including processing common complex logical relationships in documents, such as:
[0101] Text flow adjustment: In multi-column layouts, ensure that text flows in the correct reading order, for example, from the end of one column to the beginning of the next, rather than simply from left to right based on physical position. For mixed text and graphics that span columns, adjust their relative position in the tree to maintain reading continuity.
[0102] The impact of font size and weight: Identify significant changes in font size or weight (such as bold) as an important indicator of the hierarchy of titles, subtitles, and body text. For example, a block with a significantly larger font size is more likely to be a parent node or a higher-level title.
[0103] Line spacing and paragraph spacing: Use the relative size of line spacing and paragraph spacing to distinguish lines within the same paragraph, to separate different paragraphs, and to distinguish the relationship between headings and body text. For example, a larger paragraph spacing may indicate the beginning of a new logical paragraph.
[0104] Identify and process cross-page paragraph connections: When a paragraph is truncated at the end of a PDF page and continues on the next page, the tree structure optimization module can identify these two physically discontinuous blocks and logically connect them in the tree structure as subnodes of the same paragraph or directly merge them. This is usually achieved by determining the coherence of the text content, the consistency of the font style, and the logical connection between the pages.
[0105] Identifying the hierarchical relationship between sub-sections and parent sections: By analyzing features such as heading numbers (e.g., 1.1, 1.1.1), font size, and indentation, the tree structure optimization module accurately identifies the multi-level chapter structure in a document and correctly establishes parent-child relationships in the binary tree. For example, all paragraphs and sub-headings belonging to the same section are organized under the sub-tree of that section title.
[0106] Furthermore, to ensure the accuracy of logical adjustments, the tree structure optimization module also introduces a semantic relevance evaluation model. The semantic relevance evaluation model is based on deep learning text embedding (for example, block text vectors obtained through pre-trained language models such as BERT and RoBERTa) and calculates the semantic similarity between blocks (for example, cosine similarity). It should be further explained that when it is necessary to determine whether two potentially merged blocks should belong to the same logical unit, a high semantic relevance score will be an important determining factor.
[0107] When adjusting the tree structure, for example, when associating a picture caption with a picture, or associating a table title with a table, the semantic relevance evaluation model can ensure that the semantic consistency between them is maximized. Even if there may be some discontinuity or ambiguity in the physical layout, the semantic relevance evaluation model can help ensure that semantically continuous text blocks remain continuous in the tree structure.
[0108] In addition, the tree structure optimization module adjustment strategy adopts greedy algorithm or heuristic search, specifically:
[0109] Greedy strategy: Each execution is a local adjustment that can bring the maximum structural optimization effect (such as minimizing structural irrationality or maximizing semantic consistency).
[0110] Heuristic search: Define a series of structural adjustment rules (such as "there must be text under the title" and "list items should be continuous") and their priorities. The system traverses and corrects the binary tree according to these rules.
[0111] The global semantic error correction module is used to solve the problems of logical order errors, semantic breaks, and insufficient parsing of complex nested structures that may still exist even after layout analysis and recursive reconstruction, thereby ensuring that the final parsing results are maximized in terms of logical consistency with human reading at the semantic level.
[0112] The global semantic error correction module acquires the deep semantic context of the entire document and builds a semantic representation of the document. Specifically, after the initial binary tree structure is reconstructed, the entire document's text content (the text sequence initially organized according to the current tree structure) is input into a large language model based on the Transformer architecture for encoding. This large language model can be a pre-trained general language model (such as BERT, RoBERTa, GPT series, etc.) or a specialized model fine-tuned for document structure understanding tasks.
[0113] Input: The text sequence after layout analysis and preliminary recursive reconstruction can include its corresponding structured metadata (such as block type, hierarchical information, physical location, etc.). These metadata can be used as additional input features of LLM or encoded through special tags.
[0114] Output:
[0115] Document embeddings: low-dimensional vector representations that capture the global themes and semantic relevance of an entire document.
[0116] Block-level embeddings: deep semantic vectors of each block’s text content.
[0117] Semantic relevance matrix: a quantitative value representing the degree of semantic relevance between any two blocks or subtrees in a document.
[0118] Among them, the structural and semantic consistency evaluation indicators include:
[0119] Semantic continuity score ( ) : Calculates the semantic similarity of the text content between logically adjacent nodes (e.g., parent-child nodes, sibling nodes) in the current tree structure. A high score indicates good semantic coherence. This can be obtained by calculating the mean cosine similarity of adjacent block-level embeddings, for example:
[0120]
[0121] in, is the number of logically connected edges in the tree, 、 are adjacent nodes.
[0122] Logical level score (L H): Evaluates the logical structure of the current node within its parent node and whether the hierarchy within the subtree conforms to document conventions. For example, it determines whether subheadings contain related paragraphs or whether the hierarchy of list items is correct, quantified by analyzing thematic consistency or specific pattern matching.
[0123] Thematic consistency score (T M ): Evaluates the degree of match between the content represented by each subtree or node and the theme of the entire document. A high score indicates that the local content is consistent with the global theme. It is obtained by calculating the cosine similarity between the subtree root node embedding and DocumentEmbedding.
[0124] Comprehensive evaluation function ( ): Define a comprehensive evaluation function to quantify the overall quality of the current tree structure:
[0125]
[0126] Among them, α, β, and γ are adjustable weight coefficients used to balance the importance of various indicators. The maximization of this function indicates better structural-semantic consistency. According to the consistency evaluation results, the binary tree structure is adjusted and corrected intelligently and semantically to improve value.
[0127] It is also necessary to further explain that in this module, if a merger operation or structural adjustment results in If the performance drops significantly, the system attempts to backtrack to previous states and re-evaluate other potential merge paths or adjustments, thus operating within a limited search space.
[0128] The module can also perform cross-node adjustments, identifying and correcting the connections of blocks that cross physical boundaries but have strong semantic connections. For example, when a paragraph is interrupted at the end of a page and its remaining part is on the next page, but the layout analysis fails to correctly identify its connection, the semantic continuity score ( ) forces the two parts to be connected as one logical block. The same applies to the association between the caption of a picture or table and the main body of the corresponding chart. For example, if the caption block A and the picture block B are physically far apart, but their semantic association is evaluated by LLM If the degree of association between a text and other surrounding texts is much higher than that between them, they can be associated as parent-child nodes in the tree structure.
[0129] The global semantic error correction module also performs hierarchical adjustments by using global semantic information and LH scores to correct incorrect hierarchical relationships. For example, if a block is initially identified as a normal paragraph, but its text content (such as "Conclusion" or "Abstract") and contextual semantics (distance to other section headings and semantic relevance) indicate it is more likely a first-level heading or an important section, the system can move it up in the tree structure. This can correct the problem of incorrect hierarchical identification in multi-level lists or nested tables.
[0130] The global semantic error correction module also performs ambiguity resolution. The steps are as follows: for areas with ambiguous layout (for example, a paragraph of text at the edge of the page can belong to either the left column or the right column), the semantic relevance score is used to and thematic consistency scores Make a decision and assign it to the logical unit that best matches semantics.
[0131] The global semantic error correction module also applies a decision algorithm, and the adaptive adjustment process includes the following algorithms:
[0132] Greedy search: Each choice can bring Single structural adjustment operation for maximum gain.
[0133] Heuristic search: Define a set of adjustment patterns based on semantic rules (e.g., “if block X is an image and its semantic relevance to block Y is The system iteratively optimizes the structure according to the rules.
[0134] Optimization based on reinforcement learning: The structural adjustment process is regarded as a sequential decision problem. The reinforcement learning agent performs different adjustment actions and The reward signal is used to learn and find the optimal structure.
[0135] By introducing a global semantic error correction module, we can effectively handle complex logical and semantic errors that are difficult to resolve using traditional methods and in the initial reconstruction phase, so that the final output document structure is highly consistent in semantics and logic, greatly improving the quality and usability of the parsing results.
[0136] The traversal output module is used to convert the final binary tree structure generated after layout analysis, recursive reconstruction, tree structure optimization, and global semantic error correction into the structured data format required by users or downstream applications, thereby providing flexible output options to maximize the usability and compatibility of the parsing results.
[0137] The traversal output module uses pre-order traversal to output processing results. The order of pre-order traversal is: visit the root node, traverse the left subtree, traverse the right subtree, from the whole to the part, from the chapter title to the paragraphs and subtitles under it, ensuring the preservation of the original hierarchical structure of the document and the coherence of logical reading. The traversal sequence is in line with the human habit of reading documents.
[0138] In addition, in order to adapt to the needs of different application scenarios, the traversal output module includes a variety of customized traversal methods, specifically:
[0139] Depth-first traversal: In addition to the standard pre-order traversal, in-order traversal and post-order traversal can also be implemented to meet the requirements of a specific node access order.
[0140] Breadth-first traversal: Visit nodes in hierarchical order. For example, first output all first-level headings, then all second-level headings, then the first batch of paragraphs, etc. This is very useful in some scenarios where information needs to be aggregated hierarchically.
[0141] Traversing specific data types: For tabular data contained in documents, specialized traversal or extraction methods are provided. For example, the row and column structure of a table is identified and output as a two-dimensional array or similar data frame rather than as ordinary paragraph text. If the table is a block, the cells within the block are parsed again and their contents are extracted.
[0142] After the data is obtained through the above traversal, the parsed binary tree structure is serialized into a variety of standard or custom structured data formats to facilitate processing and utilization by downstream systems. Among them, the supported output formats include:
[0143] JSON: A lightweight data exchange format that's easy for humans to read and write, and also easy for machines to parse and generate. The parsed document tree structure can be naturally mapped to nested JSON objects, where each node (block) can be a JSON object with properties such as type, content, location, and an array of child nodes.
[0144] XML: A markup language used to describe data. The logical structure of a document can be mapped to a hierarchy of XML elements and attributes.
[0145] Other structured data formats: Based on specific application requirements, including support for YAML, CSV (for tabular data), or custom text protocols.
[0146] During the output process, the traversal output module maintains the original hierarchical structure of the document reflected by the binary tree to ensure the accuracy of the parsing results. The specific steps are as follows:
[0147] Perform hierarchical indentation: When outputting text, use indentation to visually indicate the logical hierarchical relationship of the document (for example, title, subtitle, paragraph, list item, etc.).
[0148] Semantic tagging: In JSON or XML output, each structured block (such as a title, paragraph, image, or table) is accompanied by its type label, allowing downstream applications to perform targeted processing based on the type.
[0149] Ensure content integrity: Ensure that all text, image references, table content, etc. in the original PDF document are completely and accurately extracted and placed in the correct logical location.
[0150] Through flexible and diverse traversal methods and output formats, the traversal output module enables the parsed PDF document data to be seamlessly integrated into various information management, content analysis, knowledge graph construction or automated processing systems, greatly improving the compatibility of the solution of the present invention.
[0151] In addition, in an embodiment of the present invention, the parsing of multi-column documents is specifically implemented as follows:
[0152] (1) When the deep learning model analyzes the layout of a multi-column page, the block list it outputs not only includes the location, content, and type of the block, but also identifies the column to which the block belongs. For example, the model can output fine-grained categories such as left_column_paragraph (left column paragraph) and right_column_image (right column image). This recognition capability is achieved by training on a dataset of PDF documents containing multi-column layouts and mixed text and image layouts.
[0153] (2) In a multi-column document, physical proximity does not equate to logical proximity. For example, the block at the bottom of the left column and the block at the top of the right column may be very close physically, but they are not logically continuous. In the objective function J(block i ,block j ) will give priority to the text flow consistency score T(block i ,block j ), which significantly penalizes merging across hurdles.
[0154] Specifically, all blocks in the left column are first merged recursively from bottom to top to form a complete "left column subtree"; then, all blocks in the right column are merged similarly from bottom to top to form a "right column subtree";
[0155] Finally, after the column reconstruction is complete, the "left column subtree" and "right column subtree" are merged according to the document's reading order (from left to right, from top to bottom) to form part of the entire document tree structure. This strategy fundamentally avoids incorrect merging of cross-column blocks.
[0156] (3) The tree structure optimization module will perform logical verification on the reconstructed multi-column tree structure. For example, for cross-column charts and their descriptions, the tree structure optimization module will use its semantic relevance evaluation model to reorganize them into a composite node, ensuring that the position of the composite node in the document tree is logical. Even after the above reconstruction and optimization, if ambiguity still exists, the global semantic error correction module will use a large language model to obtain the global semantics of the document, further verify and correct the logical relationship between each column block, and ensure that the final output structure is highly consistent in semantics.
[0157] It should be further explained that a multi-column layout refers to the presence of two or more independent and vertically arranged text flow areas on a PDF page. The definition of "left column" and "right column" is not based on preset rigid rules, but is determined by intelligent analysis of the position information of the blocks identified by the layout analysis module.
[0158] Specifically, the layout analysis module first uses a deep learning model to perform layout analysis on the PDF page to obtain a list of blocks containing location information, text content, and type. The location information of these blocks, especially their horizontal coordinates (for example, the x-coordinates of the upper left corner and the x-coordinates of the upper right corner), is used as the key basis for determining the column to which they belong. By analyzing the horizontal coordinate distribution of all blocks on the page, it can identify obvious vertical separation bands or horizontal coordinate clusters, where:
[0159] Left column: Defined as the set of blocks whose horizontal coordinates lie on the left side of the page. That is, the left column is the vertical region consisting of all blocks whose top-left and top-right x-coordinates fall within a certain range on the left side of the page. For example, when there are two distinct vertical text flow regions on the page, the left column is the region containing all blocks with the smaller x-coordinate value.
[0160] Right column: is defined as the set of blocks whose horizontal coordinates are located in the right area of the page. That is, the right column is the vertical area consisting of all blocks whose upper left corner x coordinate and upper right corner x coordinate are both within a certain range on the right side of the page. For example, the right column is the area containing all blocks with larger x coordinate values;
[0161] During training, it has learned from a large amount of document data containing multi-column layouts, so it can directly output the column category to which the block belongs, such as: left_column_paragraph (left column paragraph) or right_column_image (right column image), thereby providing direct and fine-grained information for subsequent recursive reconstruction and logical processing. Among them, when implementing the "neighbor priority principle", the system can give priority to combining blocks in the same column, and avoid incorrectly merging the block at the bottom of the left column with the block at the top of the right column that is physically close but logically unrelated. This can ensure that the document tree structure can accurately reflect the correct reading order from the left column to the right column, thereby solving the pain points of multi-column document parsing.
[0162] In an example scenario:
[0163] Perform intelligent parsing and semantic error correction of complex multi-column academic papers;
[0164] Scenario description: Assume that a typical double-column academic paper PDF file is input, which contains:
[0165] Main title, author information, abstract.
[0166] Multi-level headings (e.g., "1. Introduction", "1.1 Background").
[0167] The main content is arranged in a double-column format, and there is a document image that spans the columns.
[0168] The captions for the document images are located below the images, but due to the compact layout, some of the text is physically very close to the first paragraph of the text in the right column, which may cause ambiguity.
[0169] The paper ends with a list of references, some of which span two pages.
[0170] There is a table in the body of the document, which contains multiple rows of headers.
[0171] On one page, the last sentence of a paragraph is cut off at the bottom of the page, and the rest of the paragraph is at the top of the next page.
[0172] Parsing process:
[0173] Input and Initialization: The system receives the complex, multi-column academic paper PDF file as input. The system first rasterizes each page, converting it into image data for subsequent deep learning model processing, and extracts the original text layer information of the PDF as auxiliary information.
[0174] Perform step a) of layout analysis through the layout analysis module: The layout analysis module uses a pre-trained Mask R-CNN model to process each PDF page image. The Mask R-CNN model outputs the precise bounding boxes, categories (such as heading, paragraph, image, table, caption, footer, reference, etc.), and confidence levels of all identified "blocks" on the page.
[0175] Results: For the first page of the paper, the model identifies the main title, author, abstract, two-column text area, and the document image and its caption. The model attempts to optimally identify the boundary between the document image caption and the right-column text, but there may be initial ambiguity due to physical proximity. Also, for paragraphs that span two pages, the model identifies them as two separate blocks (e.g., and ).
[0176] The recursive reconstruction module executes step b) for recursive reconstruction: the recursive reconstruction module constructs a binary tree using a bottom-up recursive algorithm based on the block list obtained by layout analysis. The specific steps are as follows:
[0177] Select the best adjacent block: The system traverses all adjacent block pairs and calculates their objective function value J (textblock i , j ), for example, for a continuous paragraph block in the left column and ( and is a block classified by the deep learning model as belonging to the "left column" and of type "paragraph"), its physical distance D is small, the text flow T is consistent, the font F is similar, and the semantic S correlation is high, so J( , ) value will be very small, and it will be merged into the parent node first. At the same time, for the description text block C 1 and the right column text block below it , although their physical distance D is small, their semantic relevance S may be lower than C 1 has a correlation with the image I1, and the text flow T may be discontinuous in logic. The calculated J(C 1, ) values are relatively large, so they will not be merged first.
[0178] When conducting a preliminary exploration of cross-page processing: and ,Due to the large physical distance, they may not be directly merged in the ,preliminary recursive reconstruction stage.
[0179] Result: A preliminary binary tree was formed, in which most consecutive text blocks were correctly merged, but paragraphs across pages might still be separated, and captions might still be in a relatively independent position but not completely correctly associated with their corresponding images.
[0180] The tree structure optimization module is used to fine-tune the initially reconstructed binary tree. The specific steps are as follows:
[0181] Perform hierarchical recognition and adjustment. The system accurately identifies and adjusts the parent-child hierarchical relationship between titles at all levels, such as "1. Introduction" and "1.1 Background", and the text below based on the title's font size, weight, number (such as 1.1.1) and indentation, ensuring that the tree depth and node organization conform to the standard document structure.
[0182] Connect paragraphs across pages. For paragraphs that are still separated in step b), and The tree structure optimization module will identify the potential text continuity between the two (for example, the connection between the end and the beginning of the text content, the consistency of font style and paragraph style). If it is determined to be the continuation of the same paragraph, the node relationship will be adjusted. and As sibling nodes (or directly merged into a larger node), they are logically connected into a complete paragraph, and the complex structure within the table is recognized. For example, multi-line table headers will be correctly identified and used as child nodes of the table node, and the table cell content will be accurately parsed and organized into rows and columns. After optimization, the multi-level title structure is clear, cross-page paragraphs are correctly connected, and the table structure is refined. However, the close semantic connection between the explanatory text and its image needs to be further optimized through the global semantic error correction module.
[0183] The steps for optimizing the global semantic error correction module are as follows:
[0184] Perform global document semantic representation learning, concatenate all text content in the current optimized binary tree structure into a document sequence, and input it into a pre-trained model (such as the BERT Large model) for encoding. The BERT model outputs the DocumentEmbedding of the entire document and the Block Embeddings of each block.
[0185] Calculation description text block BlockEmbedding with picture blocks (assuming that the image block itself can extract visual features or the surrounding text can provide context) and the first paragraph of the text block in the right column adjacent to it The semantic correlation (cosine similarity) between BlockEmbeddings, it is found that S( , ) was significantly higher than S( , ), and in the current tree structure Not directly child nodes, resulting in Values (especially and Based on the above evaluation results, the system determines and There is a strong semantic connection between them that is not fully captured by physical location or preliminary reconstruction.
[0186] Cross-node coordination is performed by decision-making algorithms (e.g., reinforcement learning-based policies). logically move it from its current position so that it becomes At the same time, for the reference list in the paper, if the initial parsing causes some entries to be incorrectly merged or split due to format changes, the global semantic error correction module will use its unique semantic features (for example, citation format, keywords, etc.) to identify and repair them, ensuring that each reference is an independent list item.
[0187] Results: After global semantic correction, the document image captions are now correctly associated with the document images, and the reference list structure is completely correct. The final binary tree structure is highly consistent in logic and semantics and conforms to reading habits.
[0188] Finally, the traversal output module executes step e) to perform traversal output. The specific steps are as follows:
[0189] The traversal output module serializes and outputs the final optimized binary tree structure. The default traversal method is pre-order traversal, ensuring a coherent reading sequence from the title to the text, figures, and references. For tabular data, a specialized table traversal method is used to output the table's rows, columns, and cell contents. The output format is to output the parsed results in JSON format.
[0190] In an example scenario:
[0191] Parsing corporate financial reports containing complex nested tables. The specific scenario is to input a corporate annual financial report PDF, which contains: complex, multi-page financial statements (such as balance sheets), which may contain merged cells and multi-level row / column headers; and a large number of analytical sections with mixed graphics and text, in which the graphics and analytical text are closely related.
[0192] Start parsing, the specific process is:
[0193] First, layout analysis: The model can accurately identify the financial report area and recognize the rows, columns, and cell blocks within the report. For mixed text and image areas, it can distinguish between images, titles, and text.
[0194] Prioritize building the row / column logic within the report and correctly linking merged cells. At the same time, perform a preliminary reconstruction of the graphics and text in the analysis chapter, completing the recursive reconstruction.
[0195] Focus on optimizing the tree structure of the table structure, handling cross-page headers and table data, and ensuring correct hierarchical recognition of complex headers. For mixed text and image layouts, adjust the relative position of the image and its caption.
[0196] Verify the semantic relevance of table data and external text, performing global semantic correction. For example, LLM assesses the semantic relevance of a table cell's numeric content (such as "net profit") to the explanatory text above or surrounding the table. If inconsistencies or ambiguities arise, appropriate structural adjustments are made (for example, if a number is incorrectly identified as ordinary text, but its contextual semantics indicate a financial indicator, the system attempts to associate it with the nearest table). Ensure semantic consistency between financial data and related analytical text.
[0197] Traverse and output the financial report in structured CSV or nested JSON format. The data of each row or each cell can be accurately extracted and accompanied by header information to facilitate subsequent financial analysis and data import. Finally, the mixed text and image part is output as a logically clear HTML or JSON structure.
[0198] In order to better understand the technical solution of the present invention, the following is further explained in conjunction with experiments.
[0199] Experimental environment:
[0200] The experiments were conducted on a typical deep learning computing platform to ensure the reliability and reproducibility of the test results.
[0201] Hardware configuration:
[0202] Central processing unit (CPU): Intel Xeon E5-2690 v4;
[0203] Graphics processor (GPU): NVIDIA V100; Memory (RAM): 128GB DDR4;
[0204] Storage: 2TB solid-state drive.
[0205] Software environment: Operating system: Ubuntu; Deep learning framework: PyTorch or TensorFlow (select according to model implementation); Programming language: Python; Dependent libraries: Transformers, scikit-learn, OpenCV, PyMuPDF, layoutparser.
[0206] Experimental preparation: A test dataset containing PDF documents of various types and complexities was pre-built and manually annotated to serve as the ground truth for evaluating the parsing results. The dataset was sourced from the following sources: some publicly available PDF document parsing datasets, including DocLayNet, PubLayNet, SciPDF, etc.; as well as various real PDF documents collected and manually screened from the Internet and academic resources, including academic papers, scientific reports, corporate annual reports, legal documents, product manuals, educational materials, etc.
[0207] The dataset files obtained above were categorized by complexity: 20% were standard single-column text layout documents. 40% were complex multi-column documents (e.g., double- and triple-column documents) with complex column spacing and spanning elements. 30% were documents with a high degree of mixed text and graphics or containing complex nested tables (e.g., multi-level headers, merged cells, tables that span pages). 10% were scanned PDFs or low-quality PDFs with text layers, simulating challenging scenarios in real-world applications.
[0208] Among them, each PDF page in the dataset is manually annotated, and each visual element (i.e., "block") is accurately marked with its bounding box, text content (if applicable), and correct type. For each document, its true logical structure and semantic relationship must also be manually annotated, such as: the chapter to which each block belongs, which chart it is associated with, the correct reading order between paragraphs, the row and column structure of the table and its association with the title, etc. The results of manual annotation are regarded as the "standard" for evaluating structural consistency and semantic consistency.
[0209] Evaluation metrics include:
[0210] The specific accuracy of layout element recognition is:
[0211] Average Precision: For object detection tasks (identifying block types and locations), measures the overall performance of the model in identifying different layout elements.
[0212] F1 score: The harmonic mean of precision and recall is calculated for each block type (such as paragraph, title, image, table, etc.) and averaged over all types.
[0213]
[0214]
[0215]
[0216] The quality of document logical structure reconstruction is specifically:
[0217] Structural accuracy: This measures the consistency between the parsed binary tree structure and the manually annotated true logical structure, defined as the proportion of correctly identified parent-child relationships and sibling node orders. For example, the correct association between the title and the body, and the correct order of list items.
[0218] Reading Fluency Index: This quantifies the degree to which the parsing results conform to human reading habits by evaluating the coherence of the text flow, the matching of titles and content, and the presence of logical breakpoints. Scoring is performed through small-scale manual review.
[0219] Semantic consistency and error correction effects specifically include:
[0220] Semantic consistency score: Comprehensive evaluation function in the global semantic error correction module The final value of reflects the rationality of the tree structure at the semantic level. For example, it can measure the average cosine similarity of text embeddings of adjacent nodes and the consistency of subtree content with the global document topic.
[0221] Specific error repair rate: For typical difficulties (such as errors in connecting paragraphs across pages, misaligned text and graphics, and errors in table structure recognition), the repair ratio of the method of the present invention relative to the control group is calculated.
[0222] The system processing performance specifically includes:
[0223] Average Parsing Time: The average time required to parse a single PDF page or the entire document (unit: seconds / page or seconds / document).
[0224] Memory usage: The peak memory resources used by the system during the parsing process (unit: MB or GB).
[0225] Comparison method:
[0226] The following PDF parsing methods are selected for comparison:
[0227] Comparative Example: Using common open source or commercial PDF parsing tools on the market that mainly rely on hard-coded rules and heuristic algorithms, such as parsing based on PyMuPDF or PDFMiner.
[0228] This application scheme adopts the above method steps to carry out layout analysis module, recursive reconstruction module, tree structure optimization module and global semantic error correction module.
[0229] The specific steps are as follows:
[0230] Dataset preprocessing: Standardize the original PDF dataset and complete all manual annotation work to form a training set (for model training) and a test set (for performance evaluation).
[0231] Model training and configuration: Train the deep learning layout analysis model in this invention (if a pre-trained model is not used, or fine-tune it).
[0232] Configure and fine-tune the LLM model for global semantic error correction and all comparison baseline methods.
[0233] Parsing task execution: All PDF documents in the test set are input into the comparative example and the present application method respectively, and the complete parsing process is executed. The time and memory resources consumed by each method during the parsing process are recorded, and the structured parsing results output by each method are saved.
[0234] Result evaluation and data collection: The parsing results of all methods were compared with the manually annotated true values. The corresponding values were calculated using the evaluation indicators defined above. For the structural accuracy and reading fluency indicators, all the collected experimental data were statistically analyzed. See Table 1 for details.
[0235] Table 1
[0236] Evaluation Metrics Comparative Example This application method Advantages Improvement Page layout recognition F1-Score (average) 0.75 0.93 4% Structural accuracy 0.6 0.91 13% Semantic consistency score N / A (Not Applicable) 0.88 18% Average parsing time (s / page) 2.5 2.2 +0.4s Multi-column document parsing success rate (%) 50 96 16% Correct rate of association between mixed text and images (%) 40 92 22% Correct rate of cross-page paragraph connection (%) 30 90 25% Complex table structure analysis SA 25 85 30%
[0237] As can be seen from the above table, the method of the present invention has a significant improvement in the F1-Score of layout recognition compared with the control group, indicating that the synergy between the deep learning model and subsequent processing has improved the basic recognition ability. In terms of document structure reconstruction quality, the structural accuracy and semantic consistency scores of the method of the present invention are much higher than those of the control group, verifying the effectiveness of the recursive reconstruction module, the tree structure optimization module, and especially the global semantic error correction module, and solving the pain points of existing methods in complex logical structure analysis and deep semantic understanding.
[0238] From the above, it can be seen that the method of the present invention can provide document intelligent parsing results that are more accurate, more logically coherent and highly consistent with human reading habits. By innovatively combining deep learning layout analysis, intelligent recursive reconstruction, fine tree structure optimization and key global semantic error correction mechanisms, and overcoming the limitations of existing technologies, it demonstrates excellent technical effects when processing complex documents with high-quality requirements.
[0239] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.
Claims
1. A document intelligent parsing method, characterized in that: This is performed by the document intelligent parsing system and includes the following steps: Step a): Use a deep learning model to analyze the layout of the PDF page and obtain a block list containing location information, text content and type; Step b): Based on the neighbor priority principle and the lossless combination principle, a recursive algorithm is used to merge the block list from bottom to top to reconstruct the blocks into a binary tree structure, wherein each merge selects the best adjacent block and forms a new parent node, and the process is repeated until all blocks are organized into the tree; Step c): Optimizing the balance of the binary tree structure to ensure that the depth of the tree is moderate, adjusting the node relationship, and reflecting the logical structure of the document; Step d): Based on the global document semantic representation, the binary tree structure is evaluated for structural-semantic consistency, and adaptive adjustment and error correction are performed to eliminate ambiguity, fix logical errors, and maximize semantic consistency; Step e): outputting the result of the processed binary tree structure using a pre-order traversal method.
2. The document intelligent parsing method according to claim 1, characterized in that: In step a), the deep learning model decomposes the PDF page into the block list, each block containing the following attributes: location information, text content, and type; The deep learning model is a convolutional neural network model for object detection and semantic segmentation. It is trained on a PDF document dataset containing different layout types to identify different types of blocks and their boundaries. The training dataset is obtained through manual annotation, and the recognition accuracy of the model is evaluated using the F1 score.
3. The document intelligent parsing method according to claim 1, characterized in that: In the step b), the neighbor priority principle is to give priority to combining blocks with similar physical locations; the lossless combination principle is to give priority to ensuring that the original semantic relationship is not lost during the reorganization process.
4. The document intelligent parsing method according to claim 1, characterized in that: In step b), the optimal neighboring block is selected by minimizing an objective function The objective function comprehensively considers the following criteria: The distance metric D(block i , block j ); Consistency of text flow T(block i , block j ); Similarity of font attributes F(block i , block j ); The semantic relevance of paragraphs S(block i , block j ); The objective function is expressed as: J(block i ,block j )= •D(block i ,block j )+ •(1-T(block i ,block j ))+ •(1-F(block i ,block j ))+ •(1-S(block i ,block j )) in, , , , is the preset weight coefficient.
5. The document intelligent parsing method according to claim 1, characterized in that: In step c), the balance optimization includes adopting a balance strategy and adjusting the node relationship to reflect the logical hierarchy and reading order of the document. The adjustment process is guided by identifying and processing paragraph connections across pages, the hierarchical relationship between sub-sections and parent sections, and introducing a semantic relevance evaluation model to ensure that semantically continuous text blocks also maintain continuity in the tree structure.
6. The document intelligent parsing method according to claim 1, characterized in that: The step d) specifically comprises the following steps: Inputting the text content in the binary tree structure into a large language model based on the Transformer architecture for encoding to obtain a global document semantic representation; Based on the global document semantic representation, the semantic continuity score of the current binary tree structure is evaluated ( ), logical level score ( ) and thematic consistency scores ( ); According to the evaluation result, the binary tree structure is backtracked and re-merged, cross-node adjusted, level adjusted and / or ambiguity resolved.
7. The document intelligent parsing method according to claim 1, characterized in that: In step e), the pre-order traversal method can also provide one or more customized traversal methods including depth-first traversal and breadth-first traversal according to different application scenarios; The output result may be in a format such as JSON, XML, or other structured data formats.
8. A document intelligent parsing system, characterized in that: The system for executing the document intelligent parsing method according to any one of claims 1 to 7 comprises: The layout analysis module is used to analyze the layout of PDF pages using a deep learning model to obtain a block list containing location information, text content, and type; A recursive reconstruction module is used to merge the block list from bottom to top using a recursive algorithm based on the neighbor priority principle and the combination lossless principle to reconstruct the blocks into a binary tree structure; The tree structure optimization module is used to optimize the balance of the binary tree structure to ensure that the tree depth is moderate and adjust the node relationship to better reflect the logical structure of the document; A global semantic error correction module is used to evaluate the structural-semantic consistency of the binary tree structure based on the global document semantic representation, and to perform adaptive adjustments and error corrections to eliminate ambiguity, fix logical errors, and maximize semantic consistency; The traversal output module is used to output the processed binary tree structure using a pre-order traversal method. The traversal sequence conforms to human reading habits and maintains the original hierarchical structure of the document.
9. The document intelligent parsing system according to claim 8, characterized in that: The global semantic error correction module includes: A global document semantic representation learning unit, which is used to input text content in a binary tree structure into a large language model based on the Transformer architecture for encoding; Structural-semantic consistency evaluation unit, used to evaluate the semantic continuity score of the current binary tree structure based on the global document semantic representation ( ), logical level score ( ) and thematic consistency scores ( ); The adaptive structure adjustment and error correction unit is used to backtrack and re-merge the binary tree structure, adjust across nodes, adjust levels and / or resolve ambiguities based on the evaluation results.
10. A computer-readable storage medium, characterized in that A computer program is stored thereon, and when the program is executed by a processor, the document intelligent parsing method described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and system for document content identification and intelligent paragraph and chapter disassembly
CN119598974A
Document segmentation method and device and electronic equipment
CN119849437A