Document paragraph analysis method and related device
By extracting the atomic attribute information of the document and determining connectivity and clustering based on the relationship, the problem of high complexity and high cost of document paragraph parsing is solved, and efficient and accurate paragraph parsing under diverse layouts is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANHUI IFLYREC TECH CO LTD
- Filing Date
- 2025-10-11
- Publication Date
- 2026-04-10
AI Technical Summary
Existing document paragraph parsing methods are complex, costly, and their parsing effectiveness is limited by the size of the labeled samples, making them unable to effectively handle diverse document formats.
By extracting document atoms and their attribute information, the connectivity between document atoms is determined based on the correlation between attribute information, and document atoms are clustered into paragraphs using clustering methods. This reduces the dependence on labeled samples, reduces the need for manual rule setting, and improves parsing efficiency and accuracy.
It achieves efficient and accurate paragraph parsing under different document formats, reduces parsing complexity and cost, improves parsing interpretability and noise resistance, and reduces the phenomenon of incorrect paragraph merging caused by noise.
Smart Images

Figure CN121835649A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, in particular to a document paragraph parsing method and related device. BACKGROUND
[0002] Document paragraph parsing refers to a process of automatically identifying paragraphs in an original document. The original document can be a word document, a PDF document, etc. The document paragraph parsing methods in the related art are generally divided into two categories: 1. Rule method: relying on artificially set rules to analyze the document, thereby performing paragraph-level parsing on the document, such as XY-cut, projection histogram, white area analysis, and line block alignment-based hierarchical segmentation. This method requires artificial setting and adjustment of rules, and thus has high complexity. 2. Deep learning supervised method: taking a layout target detection / segmentation or structured document understanding network as the core, which requires large-scale labeling. This method needs to use labeled samples for model training, and the model training effect is limited by the size of the labeled samples, thus having high cost and limited parsing effect. SUMMARY
[0003] The present application provides a document paragraph parsing method and related device, which can solve at least part of the problems of high complexity of document parsing in the related art, limited document parsing by the size of labeled samples, and high cost of document parsing.
[0004] The present application provides a document paragraph parsing method, comprising: extracting a plurality of document atoms and attribute information thereof from an original document; combining the plurality of document atoms in pairs to obtain a plurality of document atom groups; determining connectivity between two document atoms in a document atom group based on an association relationship between the attribute information of the two document atoms in the document atom group for each document atom group; and clustering the document atoms based on the connectivity to obtain a plurality of paragraphs.
[0005] The present application provides a document paragraph parsing device, comprising: an extraction module, a combination module, a determination module, and a clustering module. The extraction module is configured to extract a plurality of document atoms and attribute information thereof from an original document. The combination module is configured to combine the plurality of document atoms in pairs to obtain a plurality of document atom groups. The determination module is configured to determine connectivity between two document atoms in a document atom group based on an association relationship between the attribute information of the two document atoms in the document atom group for each document atom group. The clustering module is configured to cluster the document atoms based on the connectivity to obtain a plurality of paragraphs.
[0006] The present application provides an electronic device comprising a memory and a processor, wherein the processor is configured to execute program instructions stored in the memory to implement the above method.
[0007] The application provides a computer readable storage medium, which stores program instructions, and the program instructions are executed by a processor to implement the method.
[0008] The application provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the method.
[0009] According to the scheme, on the one hand, the connectivity between different document atoms is determined based on the association relationship between the attribute information of different document atoms, and each document atom is clustered into a plurality of paragraphs based on the connectivity between the document atoms, so that the paragraph analysis of the original document can be realized. On the other hand, compared with the deep learning method, the interpretability is strong, and the document analysis cost can be reduced without labeled samples, and the document paragraph analysis effect is not limited by the size of the labeled samples. On the other hand, compared with the rule method, the complexity of the document paragraph analysis is reduced and the efficiency of the document paragraph analysis is improved without manually setting too many rules. On the other hand, the clustering process has strong noise resistance and is not sensitive to noise (such as annotations, headers and footers, page numbers, watermarks, and isolated document atoms with abnormal word spacing) in the original document, and the noise will not be forcibly included in any paragraph, so that the missegmentation caused by the noise can be avoided, and the accuracy of the paragraph analysis is improved.
[0010] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, but not limiting the application. BRIEF DESCRIPTION OF DRAWINGS
[0011] The accompanying drawings incorporated into the specification and forming a part thereof illustrate embodiments consistent with the present application and, together with the specification, serve to explain the technical solutions of the present application.
[0012] Figure 1 is a flowchart of a document paragraph analysis method embodiment provided by the application; Figure 2 is a flowchart of a document paragraph analysis method embodiment provided by the application; Figure 3 is a flowchart of a document paragraph analysis method embodiment provided by the application; Figure 4 is a flowchart of a document paragraph analysis method embodiment provided by the application; Figure 5 is a schematic diagram of a document atom in an original document provided by the application; Figure 6 is a schematic diagram of a paragraph in an original document provided by the application; Figure 7 is a schematic diagram of clustering of a document atom provided by the application; Figure 8A connectivity threshold distribution diagram of an atom of the present application document; Figure 9 A structure schematic diagram of an embodiment of a document paragraph analysis device provided by the present application; Figure 10 A structure schematic diagram of an embodiment of an electronic device provided by the present application; Figure 11 A structure schematic diagram of an embodiment of a computer readable storage medium provided by the present application. DETAILED DESCRIPTION
[0013] The scheme of the embodiments of the present application will be described in detail below with reference to the accompanying drawings of the specification.
[0014] In the following description, specific details are set forth in order to provide a thorough understanding of the present application, such as specific system structures, interfaces, techniques, etc., but the present application is not limited thereto.
[0015] The term "and / or" herein is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent the existence of A alone, the existence of A and B together, and the existence of B alone. In addition, the character " / " in this paper generally represents that the front and rear associated objects are in an "or" relationship. In addition, "multiple" in this paper means two or more than two. In addition, the term "at least one" in this paper means any one of multiple or any combination of at least two of multiple, for example, including at least one of A, B and C, which can mean including any one or more elements selected from the set consisting of A, B and C. In addition, the term "several" in this paper means any integer greater than 0, such as 1, 2, 3, 4, 5, ….
[0016] Document paragraph analysis refers to the process of automatically identifying paragraphs in an original document. The original document can be a word document, a PDF document, etc. The document paragraph analysis method in the related art is roughly divided into two categories: 1. Rule method: relying on artificially set rules to analyze the document, thereby performing paragraph-level analysis on the document, such as XY-cut, projection histogram, white area analysis, and line block alignment hierarchical segmentation. Under this method, rules need to be set and adjusted by humans, so the complexity is high.
[0017] 2. Deep learning supervised method: taking layout target detection / segmentation or structured document understanding network as the core, which needs large-scale labeling (frame / relationship / order). This method needs to use labeled samples for model training, and the model training effect is limited by the size of the labeled samples, so the cost is high and the analysis effect is limited.
[0018] Therefore, the present application provides a document paragraph analysis method.
[0019] Therefore, the present application provides a document paragraph analysis method.
[0019] Figure 1 is a flowchart of an embodiment of a document paragraph parsing method provided by the present application. As shown in the figure, in this embodiment, the document paragraph parsing method can include the following steps: Figure 1 S110: Extracting a plurality of document atoms and their attribute information from an original document.
[0020] The execution subject of this embodiment is a document paragraph parsing device, which can be an electronic device with document paragraph parsing capability.
[0021] From the perspective of generating channels, the original document can be LaTeX, Word, DTP, scanned OCR, etc. From the perspective of layout, the original document can be a journal paper, a newspaper layout, an academic PPT lecture note, a report, etc.
[0022] The document atom can be a character, a word, a line, etc. The character can be text, punctuation, indentation, etc. The attribute information of the document atom can include the spatial information, style information, context information, and page structure metadata of the document atom.
[0023] The spatial information of the document atom can include the position box, position, baseline, column index, and spacing (such as character spacing, line spacing) with adjacent document atoms of the document atom. The position box of the document atom can be (x_min, y_min, x_max, y_max), where x_min, y_min, x_max, and y_max represent the minimum horizontal position, the minimum vertical position, the maximum horizontal position, and the maximum vertical position, respectively. The position of the document atom can include the horizontal position, the vertical position, and the center position. The horizontal position can be a horizontal position within the range of the minimum horizontal position and the maximum horizontal position, the vertical position can be a vertical position within the range of the minimum horizontal position and the maximum horizontal position, and the center position can be the center of the position box.
[0024] The style information of the document atom can include the font style information and the layout style information of the document atom. The font style information of the document atom can include the font family, font size, font weight, italic, color, etc. of the document atom. The layout style information of the document atom can include the alignment of the document atom, such as left alignment, right alignment, center alignment, etc.
[0025] The context information of the document atom represents the interval document atom between the document atom and other document atoms.
[0026] The page structure metadata of the document atom can include the page number, rotation angle, page size (MediaBox, page height, page width) of the page where the document atom is located.
[0027] S120: combine each two document atoms to obtain a plurality of document atom groups.
[0028] Each document atom group includes two document atoms, and each two different document atoms are combined into a document atom group.
[0029] S130: for each document atom group, determine the connectivity between the two document atoms in the document atom group based on the association relationship between the attribute information of the two document atoms in the document atom group.
[0030] The connectivity between the two document atoms represents the possibility that the two document atoms belong to the same paragraph. The stronger the connectivity between the two document atoms, the greater the possibility that the two document atoms belong to the same paragraph.
[0031] In some embodiments, the association relationship between the attribute information of the two document atoms includes a spatial association relationship between the spatial information of the two document atoms. The spatial association relationship represents the degree of spatial proximity, and the spatial association relationship includes the horizontal distance, the vertical distance, the center distance, and the column index difference of the two document atoms. The horizontal distance is the distance of the horizontal / row position (Δx), the vertical distance is the distance of the vertical / column position (Δy), the center distance is the distance of the center position, and the column index difference is the difference between the column indexes.
[0032] In some embodiments, the association relationship between the attribute information of the two document atoms includes a style association relationship between the style information of the two document atoms. The style association relationship represents the style similarity. The style association relationship can include at least one of a font style association relationship between the font style information and a layout style association relationship between the layout style information. The font style association relationship can include font style similarity, such as whether the font size is the same, whether the font family is the same, whether the font weight is the same, and whether they are both italic. The smaller the difference between the font style information, the greater the font style similarity. The layout style association relationship can include layout style similarity, such as whether the alignment is the same. The smaller the difference between the layout style information, the greater the layout style similarity.
[0033] In some embodiments, the association relationship between the attribute information of the two document atoms includes a context association relationship between the context information of the two document atoms. The context association relationship represents the possibility of segmentation between the two document atoms. The context association relationship includes whether there is a segmentation identifier between the two document atoms, and the segmentation identifier includes a question mark, a period, an exclamation point, an indentation, etc. The segmentation possibility is large in the case of the segmentation identifier, and the segmentation possibility is small in the case of no segmentation identifier.
[0034] S140: cluster the document atoms based on the connectivity to obtain a plurality of paragraphs.
[0035] The above scheme, on the one hand, determines the connectivity between different document atoms based on the correlation between their attribute information, and clusters each document atom into several paragraphs based on the connectivity between them, thus enabling paragraph parsing of the original document. On the other hand, compared with deep learning methods, it has strong interpretability and reduces document parsing costs by eliminating the need for labeled samples, and the parsing effect is not limited by the size of the labeled samples. Furthermore, compared with rule-based methods, it eliminates the need for manually setting too many rules, reducing the complexity of document paragraph parsing and improving its efficiency. Moreover, the clustering process is highly robust to noise in the original document (such as isolated document atoms like annotations, headers and footers, page numbers, watermarks, and abnormal character spacing), and does not forcibly classify noise into any paragraph, thereby avoiding incorrect paragraph merging caused by noise and improving the accuracy of paragraph parsing.
[0036] In addition, when attribute information is multidimensional (such as spatial information, style information, and contextual information), the connectivity between different document atoms can be measured more comprehensively and accurately through the correlation between multidimensional attribute information.
[0037] Furthermore, in some embodiments, the connectivity threshold used for clustering is a global connectivity threshold. The global connectivity threshold can be manually input and fixed, or it can be dynamically determined during the clustering process. S140 includes: clustering different document atoms with connectivity greater than the global connectivity threshold into the same paragraph. In this case, the greater the connectivity between two document atoms, the greater the probability that the two document atoms will be clustered into the same paragraph; conversely, the smaller the connectivity between two document atoms, the smaller the probability that the two document atoms will be clustered into the same paragraph. When the global connectivity threshold is dynamically determined, the global connectivity threshold can be adaptively adjusted according to the connectivity distribution corresponding to each group of document atoms to adapt to original documents with different connectivity distributions.
[0038] In some embodiments, the connectivity threshold used for clustering is a dynamically determined local connectivity threshold. Based on this, the foregoing embodiments can be extended as follows: Figure 2 This is a flowchart illustrating Embodiment 2 of the document paragraph parsing method provided in this application. Steps S210-S220 are steps that may be included before S140, and steps S230-S260 are steps that may be included in S140, as follows... Figure 2 As shown, in this embodiment, the document paragraph parsing method may include the following steps: S210: For each document atom, determine the neighborhood atom density based on the spatial distance between the document atom and other document atoms.
[0039] Spatial distance refers to the distance between the positions of atoms in a document.
[0040] In some embodiments, S210 includes: counting the number of other document atoms in the neighborhood of a document atom to obtain the number of neighboring document atoms of the document atom; and determining the neighborhood atom density of the document atom based on the number of neighboring document atoms of the document atom, wherein the number of document atoms is positively correlated with the neighborhood atom density.
[0041] S220: Determine the connectivity threshold of document atoms based on the neighborhood atom density of document atoms.
[0042] The connectivity threshold is positively correlated with the density of neighboring atoms.
[0043] Understandably, a high density of neighboring atoms in a document atom indicates a highly concentrated local region where the atom resides, and strong connectivity between document atoms in different paragraphs. Dynamically determining a larger connectivity threshold can reduce or even avoid mistakenly clustering document atoms from different paragraphs into the same paragraph. Conversely, a low density of neighboring atoms in a document atom indicates a low density local region where the atom resides, and weak connectivity between document atoms in the same paragraph. Dynamically determining a smaller connectivity threshold can reduce or even avoid mistakenly clustering document atoms from the same paragraph into different paragraphs.
[0044] In some embodiments, document atoms with neighborhood atom densities within the same neighborhood atom density range have the same connectivity threshold.
[0045] In some embodiments, a positive correlation transformation relationship between a connectivity threshold and the density of neighboring atoms is preset, and the neighboring atom density is transformed using the preset positive correlation transformation relationship to obtain the connectivity threshold.
[0046] S230: For each document atom group, use one of the connectivity thresholds of the two document atoms in the document atom group as the connectivity threshold of the document atom group.
[0047] In some embodiments, the connectivity threshold of a document atom group is the smaller of the connectivity thresholds of the two document atoms in the document atom group. In this case, a more lenient standard is adopted to prioritize avoiding the mistaken clustering of document atoms belonging to the same paragraph into different paragraphs.
[0048] In some embodiments, the connectivity threshold of a document atom group is the larger of the connectivity thresholds of the two document atoms in the document atom group. In this case, a stricter standard is adopted to prioritize avoiding the mistaken clustering of document atoms belonging to different paragraphs into the same paragraph.
[0049] S240: Determine whether the connectivity between two document atoms in a document atom group is greater than the connectivity threshold of the document atom group.
[0050] If the connectivity threshold is greater than that of the document atom group, execute S250; if the connectivity threshold is not greater than that of the document atom group, execute S260.
[0051] S250: Determines that two document atoms in a document atom group belong to the same paragraph.
[0052] S260: Determine if two document atoms in a document atom group belong to different paragraphs.
[0053] Understandably, document formats are flexible and diverse, such as journal articles, newspaper layouts, academic PPT presentations, and reports. The density of document atoms in paragraphs may differ across document formats. Rule-based methods in related technologies require manual adjustment or rule resetting to adapt to different formats. Deep learning methods require model retraining to adapt to different formats. Therefore, rule-based and deep learning methods have poor generalization capabilities, and generalizing to various formats requires significant time and cost. Furthermore, rule-based methods are prone to failure in complex formats (such as multi-column, cross-column headings, irregularly shaped text boxes, mixed charts and graphs, annotations, and watermarks), and deep learning methods have limited stability in documents with complex formats.
[0054] In the above scheme, the connectivity threshold of a document atom group is one of the connectivity thresholds of two document atoms. The connectivity threshold of a document atom is a dynamic local connectivity threshold determined based on the density of neighboring atoms, while the density of neighboring atoms is determined based on the number of neighboring atoms. Therefore, even if a change in layout alters the density of document atoms within the same paragraph in the original document, the connectivity threshold of document atoms and even document atom groups can be adaptively adjusted according to the density of document atoms in their local regions. This reduces or even avoids the mis-clustering of document atoms from different paragraphs into the same paragraph, or the mis-clustering of document atoms from the same paragraph into different paragraphs, thus lowering the probability of mis-segmentation and adapting to paragraph parsing in documents with diverse layouts. Figure 3 This is a flowchart illustrating Embodiment 3 of the document paragraph parsing method provided in this application. This embodiment is a further extension of S130, where the attribute information of a document atom includes its spatial information, style information, and context information. For example... Figure 3 As shown, in this embodiment, the document paragraph parsing method may include the following steps: S310: Based on the spatial association between two document atoms in a document atom group, determine the spatial connectivity between two document atoms in the document atom group; based on the style association between two document atoms in the document atom group, determine the style connectivity between two document atoms in the document atom group; and based on the context association between two document atoms in the document atom group, determine the context connectivity between two document atoms in the document atom group.
[0055] Spatial connectivity can include connectivity corresponding to various spatial relationships. For example, spatial connectivity includes horizontal positional connectivity corresponding to horizontal distance, vertical positional connectivity corresponding to vertical distance, center connectivity corresponding to center distance, and column index connectivity corresponding to column index difference. Specifically, the smaller the horizontal distance, the stronger the horizontal positional connectivity. The smaller the vertical distance, the stronger the vertical positional connectivity. The smaller the center distance, the stronger the center positional connectivity. The smaller the column index difference, the stronger the column index connectivity.
[0056] Style connectivity can include connectivity corresponding to various style associations. For example, style connectivity includes font style connectivity corresponding to font style similarity and layout style connectivity corresponding to layout style similarity. The greater the font style similarity, the stronger the font style connectivity. The greater the layout style similarity, the stronger the layout style connectivity.
[0057] Contextual connectivity can include connectivity corresponding to whether or not a segment identifier is spaced. Connectivity is weaker when a segment identifier is spaced and stronger when no segment identifier is spaced.
[0058] S320: Perform statistics on spatial connectivity, style connectivity, and contextual connectivity to obtain the connectivity between two document atoms in a document atom group.
[0059] In some embodiments, S320 includes: weighting various spatial connectivity, various style connectivity and contextual connectivity to obtain the final connectivity.
[0060] In some embodiments, S320 includes averaging various spatial connectivity, various style connectivity and contextual connectivity to obtain the final connectivity.
[0061] In some embodiments, prior to S320, the process includes: normalizing spatial connectivity, style connectivity, and context connectivity. The normalization process may be, but is not limited to, IQR.
[0062] The above scheme measures the connectivity between two document atoms from three dimensions: spatial, style, and contextual attribute information. This makes the connectivity between two document atoms more accurate and more expressive of whether they belong to the same paragraph, thereby improving the accuracy of subsequent clustering.
[0063] Figure 4 This is a flowchart illustrating Embodiment 4 of the document paragraph parsing method provided in this application. S410-S420 are further extensions of S310, and S430 is a further extension of S320. Spatial relationships include horizontal distance, vertical distance, center distance, and column index difference; style relationships include font style similarity and layout style similarity. For example... Figure 4 As shown, in this embodiment, the document paragraph parsing method may include the following steps: S410: Based on the horizontal distance, vertical distance, center distance, and column index difference between two document atoms in the document atom group, determine the horizontal position connectivity, vertical position connectivity, center position connectivity, and column index connectivity between the two document atoms in the document atom group, respectively.
[0064] S420: Based on the font style similarity and layout style similarity between the style information of two document atoms in the document atom group, respectively determine the font style connectivity and layout style connectivity between the two document atoms in the document atom group.
[0065] S430: The connectivity is obtained by weighting the horizontal position connectivity, vertical position connectivity, center position connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity.
[0066] Furthermore, in some embodiments, prior to S430, the method further includes: determining whether the original document is a single-column or multi-column layout based on the attribute information of each document atom; enhancing vertical connectivity in response to a single-column layout; and enhancing layout style connectivity in response to a multi-column layout. This allows for personalized enhancement of key connectivity aspects based on the characteristics of both single-column and multi-column layouts, resulting in more accurate final connectivity and stronger expression of whether elements belong to the same paragraph.
[0067] Furthermore, in some embodiments, vertical connectivity is enhanced by: obtaining a preset single-column weight set, which includes first weights corresponding to horizontal connectivity, vertical connectivity, center connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity, respectively; increasing the first weights corresponding to vertical connectivity to obtain an actual single-column weight set; and applying each first weight in the actual single-column weight set to the horizontal connectivity, vertical connectivity, center connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity. The application method can be multiplication, addition, etc.
[0068] Furthermore, in some embodiments, enhancing the connectivity of layout styles includes: obtaining a preset multi-column weight set, which includes second weights corresponding to horizontal position connectivity, vertical position connectivity, center position connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity, respectively; increasing the second weights corresponding to layout style connectivity to obtain an actual multi-column weight set; and applying each second weight in the actual multi-column weight set to the horizontal position connectivity, vertical position connectivity, center position connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity. The application method can be multiplication, addition, etc.
[0069] Furthermore, in some embodiments, after S140, the method further includes: restoring the line order of each paragraph to update each paragraph; and integrating the paragraphs to obtain a structured document.
[0070] Furthermore, in some embodiments, the document paragraph parsing method provided in this application can be implemented in a GPU / CPU environment, and the determination of the connectivity threshold and clustering support multi-threaded parallelism.
[0071] Furthermore, in some embodiments, clustering can be implemented, but is not limited to, using the clustering algorithm HDBSCAN.
[0072] Furthermore, in some embodiments, obtaining the number of neighboring atoms can be achieved, but is not limited to, through a kernel density estimation algorithm (KDE).
[0073] To facilitate understanding, the document paragraph parsing method provided in this application will be explained below with a specific example.
[0074] M1. Extract the document atom set T from the original PDF document.
[0075] 1. Extract a number of document atoms from the original PDF document. Extracting document atoms can be achieved, but is not limited to, using PDFBOX.
[0076] 2. Obtain the attribute information of each document atom. Attribute information includes spatial information, style information, context information, and page structure metadata. Each document atom with attribute information constitutes a document atom set T.
[0077] Spatial information: the bounding box of the document atom (x_min, y_min, x_max, y_max), where x_min, y_min, x_max, and y_max represent the minimum horizontal position, minimum vertical position, maximum horizontal position, and maximum vertical position, respectively; the position of the document atom; the baseline of the document atom; the column index of the document atom; and the spacing between the document atom and other adjacent document atoms (such as character spacing and line spacing).
[0078] Style information: Font style information (font family, font size, font weight, italics, color) and layout style information (alignment) of the document atoms.
[0079] Context information: The space between document atoms and other document atoms.
[0080] Page structure metadata: page number, page rotation angle, page size (MediaBox, page height, page width).
[0081] M2. Get the connectivity between every two document atoms.
[0082] 1. Combine each document atom in pairs to obtain several document atom groups.
[0083] 2. For each document atom group, obtain the initial connectivity between two document atoms in the document atom group.
[0084] Take one of the document atom groups (document atom i, document atom j) as an example: (1) Obtain the spatial relationship between document atom i and document atom j: horizontal distance, vertical distance, center distance, and column index difference.
[0085] (2) Obtain the style association relationship between document atom i and document atom j: font style association relationship, layout style association relationship. The font style association relationship includes font style similarity, and the layout style association relationship includes layout style similarity.
[0086] (3) Obtain the contextual relationship between document atom i and document atom j: whether it is an interval segment identifier.
[0087] (4) Obtain the horizontal position connectivity, vertical position connectivity, center position connectivity, and column index connectivity corresponding to horizontal distance, vertical distance, center distance, and column index difference, respectively. Obtain the font style connectivity and layout style connectivity corresponding to font style similarity and layout style similarity, respectively. Obtain the context connectivity corresponding to whether the interval segmentation identifier is used. IQR can be used to normalize the connectivity of each dimension, but is not limited to this.
[0088] M3. For each document atom group, enhance the specific dimension connectivity between two document atoms in the document atom group.
[0089] 1. Perform column detection based on the document atom set T to determine whether the original PDF document is a multi-column or single-column layout.
[0090] Projecting the position boxes of each document atom onto the horizontal direction (x-axis) yields the blank bands between columns. The boundaries of each column can be fitted using RANSAC, but is not limited to this method.
[0091] 2. For each document atom group, dynamically adjust the connectivity of specific dimensions based on the column detection results.
[0092] Take one of the document atom groups (document atom i, document atom j) as an example: (1) In the case of a single-column layout, obtain a preset single-column weight set, which includes the first weights corresponding to horizontal position connectivity, vertical position connectivity, center position connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity respectively; increase the first weight corresponding to vertical position connectivity to obtain the actual single-column weight set; apply each first weight in the actual single-column weight set to horizontal position connectivity, vertical position connectivity, center position connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity respectively.
[0093] (2) In the case of a multi-column layout, obtain a preset multi-column weight set, which includes second weights corresponding to horizontal position connectivity, vertical position connectivity, center position connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity respectively; increase the second weight corresponding to layout style connectivity to obtain the actual multi-column weight set; apply each second weight in the actual multi-column weight set to horizontal position connectivity, vertical position connectivity, center position connectivity, column index connectivity, font style connectivity, layout style connectivity, and context connectivity respectively.
[0094] 3. Weight the connectivity of horizontal position, vertical position, center position, column index, font style, layout style, and context to obtain the connectivity between document atom i and document atom j.
[0095] ; in, This represents the connectivity distance between document atom i and document atom j. The smaller the connectivity distance, the stronger the connectivity. Let represent the initial connected distance in the k-th dimension, and let represent the first weight / second weight in the k-th dimension.
[0096] M4. Obtain the connectivity threshold for each document atom group.
[0097] Take one of the document atom groups (document atom i, document atom j) as an example: 1. Obtain the neighborhood atom density of document atom i and document atom j.
[0098] (1) Get the number of neighboring atoms of document atom i.
[0099] (2) Based on the number of neighboring atoms of document atom i, the neighboring atom density of document atom i is obtained. The neighboring atom density is positively correlated with the number of neighboring atoms. Document atom i is denoted as... The number of neighboring atoms of atom i in document i is denoted as The number of neighboring atoms can be obtained, but is not limited to, through a kernel density estimation algorithm (KDE).
[0100] (3) Based on the neighborhood atom density of document atom i, the connectivity threshold of document atom i is obtained. The connectivity threshold is positively correlated with the neighborhood atom density. The connectivity threshold of document atom i is denoted as... .
[0101] Similarly, the connectivity threshold of the neighborhood atom density of document atom j is obtained, denoted as . .
[0102] 2. For each document atom group, determine the connectivity threshold of the document atom group based on the connectivity threshold of the two document atoms in the document atom group.
[0103] The smaller of the connectivity thresholds of the two document atoms is used as the connectivity threshold of the document atom group. .
[0104] M5. Cluster each document atomically into a paragraph set, denoted as [paragraph set]. , This represents the k-th paragraph. Clustering can be performed using, but is not limited to, the clustering algorithm HDBSCAN.
[0105] For each document atom group, determine whether the connectivity between two document atoms in the document atom group is greater than a connectivity threshold (whether the connectivity distance is less than the connectivity threshold). If the connectivity is greater than the connectivity threshold, determine that the two document atoms in the document atom group belong to the same paragraph; otherwise, they belong to different paragraphs.
[0106] Take one of the document atom groups (document atom i, document atom j) as an example: When the connectivity condition is satisfied If the connection distance is less than the connectivity threshold, document atom i and document atom j belong to the same paragraph; otherwise, document atom i and document atom j belong to different paragraphs.
[0107] M6. respectively for The line order of each paragraph is restored to update the paragraph set. .
[0108] 1. Restore the reading order within a paragraph: (1) Sort by column from top to bottom and from left to right.
[0109] (2) Detect and merge word breaks (line-end hyphens, word splits).
[0110] (3) Distinguish between “line break within a paragraph” and “paragraph break” (using the median line spacing threshold).
[0111] 2. Identify and maintain cross-column elements (titles, image captions) in the correct position for reading order.
[0112] M7. The various paragraphs are integrated to obtain the structured document corresponding to the original PDF document.
[0113] 1. Merge text lines within a paragraph and restore indentation, bullet points, and numbering.
[0114] 2. Mark the hierarchy according to style information (font family, font size, bold): title, body text, footnote.
[0115] 3. Construct a hierarchical document tree (page → column → paragraph → line → word → character).
[0116] 4. Export structured documents in standardized formats (JSON, XML, Markdown).
[0117] The above solution has at least the following technical effects: (1) Cross-format generalization: robustly forms paragraphs in different format scenarios, reducing misaligned paragraphs; derived from clustering noise reduction and KDE adaptation.
[0118] (2) Not dependent on annotation: High-quality paragraph parsing can be achieved without annotation.
[0119] (3) The project is feasible: it has few parameters and strong interpretability, making it suitable for integration of offline batch processing and online extraction links.
[0120] (4) Dynamic threshold + multi-dimensional attribute information + adaptive layout fusion to improve segmentation accuracy: On the one hand, each document atom group has a corresponding connectivity threshold, and the connectivity threshold is dynamically adjusted according to the density of the two document atoms in the document atom group. This can reduce or even avoid missegmentation caused by changes in density due to changes in layout, thus improving segmentation accuracy. On the other hand, combining the three dimensions of space, style, and context to measure the final connectivity of the two document atoms can make the final connectivity of the two document atoms more accurate and more expressive of whether they belong to the same paragraph, further improving segmentation accuracy. Furthermore, based on the characteristics of multi-column and single-column layouts, the connectivity that needs to be focused on is personalized and enhanced, making the final connectivity obtained by weighting multi-dimensional connectivity more accurate and more expressive of whether they belong to the same paragraph, further improving segmentation accuracy.
[0121] Figure 5 This is a schematic diagram of the document atoms in the original document of this application, such as... Figure 5 As shown, the original document includes a top header, a bottom footer, a column title, a column body text, and a rightmost header. Multiple document atoms are extracted from the header, footer, column title, column body text, and header of the original document.
[0122] Figure 6 This is a diagram of a paragraph in the original document of this application, such as... Figure 6 As shown, the document paragraph parsing method provided in this application is used to respectively parse the document paragraphs. Figure 5 Each document is atomically clustered into the corresponding paragraphs for header, footer, cross-column title, cross-column body text, and running head.
[0123] Figure 7 This is a schematic diagram illustrating the clustering of document atoms in this application, as shown below. Figure 7 As shown, each circle represents a document atom, and the document atoms are clustered into 3 classes, with each class representing a paragraph. Some atoms, although very close to one of the classes in terms of connectivity, are not clustered into any of the classes but are instead considered noise that cannot be clustered into any of the 3 classes.
[0124] Figure 8 This is a schematic diagram of the connectivity threshold distribution of atoms in this application document, as shown below. Figure 8As shown, the horizontal axis represents the connectivity threshold (Distance), and the vertical axis represents the frequency of occurrence (Density). The height of the histogram represents the frequency of occurrence of the corresponding connectivity threshold. The connectivity threshold with the highest frequency of occurrence (Peak Distance) is 11.91. The KDE curve is a smoothed version of the histogram.
[0125] Figure 9 This is a schematic diagram of the structure of an embodiment of the document paragraph parsing device provided in this application. Figure 9 As shown, the document paragraph parsing device includes an extraction module, a combination module, a determination module, and a clustering module. Among them: The extraction module is used to extract several document atoms and their attribute information from the original document.
[0126] The combination module is used to combine several document atoms in pairs to obtain several document atom groups.
[0127] The determination module is used to determine the connectivity between two document atoms in a document atom group based on the association relationship between the attribute information of two document atoms in the document atom group.
[0128] The clustering module is used to cluster individual documents atomically based on connectivity, resulting in several paragraphs.
[0129] For further detailed descriptions of this embodiment, please refer to the preceding embodiments, which will not be repeated here.
[0130] Figure 10 This is a schematic diagram of the structure of an embodiment of the electronic device of this application. Figure 10 As shown, the electronic device 50 includes a memory 51 and a processor 52. The processor 52 is used to execute program instructions stored in the memory 51 to implement the steps in any of the above method embodiments. In a specific implementation scenario, the electronic device 50 may include, but is not limited to, a microcomputer or a server. In addition, the electronic device 50 may also include a laptop computer, a tablet computer, or other carrier device, which is not limited here.
[0131] Specifically, processor 52 controls itself and memory 51 to implement the steps in any of the above method embodiments. Processor 52 may also be referred to as a CPU (Central Processing Unit). Processor 52 may be an integrated circuit chip with signal processing capabilities. Processor 52 may also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component. A general-purpose processor may be a microprocessor or any conventional processor. Furthermore, processor 52 may be implemented using integrated circuit chips.
[0132] Please see Figure 11 , Figure 11 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 60 stores program instructions 601 thereon, which, when executed by a processor, implement the steps in any of the above method embodiments.
[0133] This application also provides a computer program product comprising a computer program that, when executed by a processor, can implement the steps of the methods described in any of the foregoing embodiments. Specifically, the computer program product can be a software or program product containing a computer program, capable of running on a computing device or stored on any available medium.
[0134] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0135] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0136] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. In another image location, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0137] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A document paragraph parsing method, characterized in that, include: Several document atoms and their attribute information are extracted from the original document; The document atoms are combined in pairs to obtain several document atom groups; For each document atom group, the connectivity between two document atoms in the document atom group is determined based on the association relationship between the attribute information of two document atoms in the document atom group; Based on the connectivity, the atoms of each document are clustered to obtain several paragraphs.
2. The method according to claim 1, characterized in that, Before the atom clustering of each document based on the connectivity to obtain several paragraphs, the process includes: For each document atom, the neighborhood atom density of the document atom is determined based on the spatial distance between the document atom and each other document atom; Based on the neighborhood atom density of the document atom, a connectivity threshold for the document atom is determined, and the connectivity threshold is positively correlated with the neighborhood atom density; The atomic clustering of each document based on the connectivity yields several paragraphs, including: For each document atom group, one of the connectivity thresholds of the two document atoms in the document atom group is used as the connectivity threshold of the document atom group; Determine whether the connectivity between two document atoms in the document atom group is greater than the connectivity threshold of the document atom group; In response to a connectivity threshold greater than that of the document atom group, it is determined that two document atoms in the document atom group belong to the same paragraph.
3. The method according to claim 2, characterized in that, Determining the neighborhood atom density of a document atom based on the spatial distance between the document atom and other document atoms includes: The number of other document atoms located in the neighborhood of the document atom is counted to obtain the number of neighboring document atoms of the document atom; The neighborhood atom density of the document atom is determined based on the number of neighboring document atoms of the document atom, and the number of document atoms is positively correlated with the neighborhood atom density.
4. The method according to claim 1, characterized in that, The attribute information of the document atom includes the spatial information, style information, and context information of the document atom; Determining the connectivity between two document atoms in the document atom group based on the association relationship between the attribute information of two document atoms in the document atom group includes: Based on the spatial association between the spatial information of two document atoms in the document atom group, the spatial connectivity between the two document atoms in the document atom group is determined; based on the style association between the style information of two document atoms in the document atom group, the style connectivity between the two document atoms in the document atom group is determined; and based on the context association between the context information of two document atoms in the document atom group, the context connectivity between the two document atoms in the document atom group is determined. The connectivity between two document atoms in the document atom group is obtained by statistically analyzing the spatial connectivity, the style connectivity, and the context connectivity.
5. The method according to claim 4, characterized in that, The spatial relationships include horizontal distance, vertical distance, center distance, and column index difference; the style relationships include font style similarity and layout style similarity. Determining the spatial connectivity between two document atoms in the document atom group based on the spatial association between the spatial information of two document atoms in the document atom group includes: Based on the horizontal distance, vertical distance, center distance, and column index difference between two document atoms in the document atom group, the horizontal position connectivity, vertical position connectivity, center position connectivity, and column index connectivity between two document atoms in the document atom group are determined respectively. Determining the style connectivity between two document atoms in the document atom group based on the style association relationship between the style information of two document atoms in the document atom group includes: Based on the font style similarity and layout style similarity between the style information of two document atoms in the document atom group, the font style connectivity and layout style connectivity between the two document atoms in the document atom group are determined respectively. The step of statistically analyzing the spatial connectivity, style connectivity, and context connectivity to obtain the connectivity between two document atoms in the document atom group includes: The connectivity is obtained by weighting the horizontal position connectivity, the vertical position connectivity, the center position connectivity, the column index connectivity, the font style connectivity, the layout style connectivity, and the context connectivity.
6. The method according to claim 5, characterized in that, Before obtaining the connectivity by weighting the horizontal position connectivity, the vertical position connectivity, the center position connectivity, the column index connectivity, the font style connectivity, the layout style connectivity, and the context connectivity, the following steps are included: Based on the attribute information of each document atom, determine whether the original document is a single-column layout or a multi-column layout; In response to the single-column layout, the vertical connectivity is enhanced; In response to the multi-column layout, the connectivity of the layout style is enhanced.
7. The method according to claim 6, characterized in that, The enhancement of vertical connectivity includes: Obtain a preset single-column weight set, the preset single-column weight set including first weights corresponding to the horizontal position connectivity, the vertical position connectivity, the center position connectivity, the column index connectivity, the font style connectivity, the layout style connectivity, and the context connectivity respectively; Increase the first weight corresponding to the vertical position connectivity to obtain the actual single column weight set; The actual single-column weight set applies each of the first weights to the horizontal position connectivity, the vertical position connectivity, the center position connectivity, the column index connectivity, the font style connectivity, the layout style connectivity, and the context connectivity. And / or, the enhancement of the connectivity of the typography style includes: Obtain a preset multi-column weight set, which includes second weights corresponding to the horizontal position connectivity, the vertical position connectivity, the center position connectivity, the column index connectivity, the font style connectivity, the layout style connectivity, and the context connectivity, respectively. Increase the second weight corresponding to the connectivity of the layout style to obtain the actual multi-column weight set; The actual multi-column weight set applies each of the second weights to the horizontal position connectivity, the vertical position connectivity, the center position connectivity, the column index connectivity, the font style connectivity, the layout style connectivity, and the context connectivity.
8. A document paragraph parsing device, characterized in that, include: The extraction module is used to extract several document atoms and their attribute information from the original document; The combination module is used to combine the plurality of document atoms in pairs to obtain a plurality of document atom groups; The determination module is used to determine the connectivity between two document atoms in each document atom group based on the association relationship between the attribute information of two document atoms in the document atom group; The clustering module is used to cluster the various document atoms based on the connectivity to obtain several paragraphs.
9. An electronic device, characterized in that, It includes a memory and a processor, the processor being configured to execute program instructions stored in the memory to implement the method of any one of claims 1 to 7.
10. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the method of any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.