Method, device and related equipment for merging tables across pages of PDF documents

Through the structured processing of PDF documents and the use of header recognition models, the problem of poor judgment of complex cross-page table merging in the prior art is solved, and higher accuracy and automated processing are achieved.

CN114036909BActive Publication Date: 2024-11-19SHENZHEN FORTUNE TREND TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111299246.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-04
Publication Date
2024-11-19
Estimated Expiration
2041-11-04

AI Technical Summary

Technical Problem

It is difficult for the prior art to effectively judge whether complex spreadsheets need to be merged, and the rules and methods are not effective in judging under complex situations.

Method used

By structuring the PDF document, we judge whether the adjacent pages meet the merge conditions, and use the pre-trained header recognition model to determine the consistency of the table header. If it is consistent, the table body will be merged. If it is inconsistent or there is no header, it will not be merged.

Benefits of technology

Improve the accuracy of cross-page table merging, ensuring the judgment and merge processing of complex cross-page tables.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114036909B_ABST
    Figure CN114036909B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method, device and related equipment for merging tables across pages of a PDF document. The method comprises performing structured processing on a PDF document to obtain a structured document of the PDF document; judging whether there is a merging condition between two adjacent pages in the PDF document according to the structured document; if there is a merging condition between two adjacent pages, performing header recognition on the table in each page of the structured document through a pre-trained header recognition model to judge whether both adjacent pages have headers; if both adjacent pages have headers, judging whether the headers are consistent, and if the headers are consistent, removing the header of the next page and merging the table bodies of the two pages; if the headers are inconsistent, no merging is performed; if both adjacent pages do not have headers, merging the table bodies of the two pages. Compared with traditional methods, the method has a higher accuracy rate in judging whether cross-page tables need to be merged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text processing, and in particular to a method and device for merging cross-page tables of a PDF document and related equipment. Background Art

[0002] PDF format is widely used for the storage and transmission of various files, and it is often necessary to extract information from PDF documents. Since tables often appear in PDF documents, but there is no table format in the PDF document format, the table obtained after parsing the PDF document only has text and image lines. When a table appears at the bottom of a page and at the top of the next page in a PDF document, it is necessary to judge whether it is the same table. In the prior art, the merging of tables across pages in PDF documents mainly uses rules to judge whether the two tables across pages contain the same number of columns. For complex tables across pages, the rule method cannot play a good judgment effect. Summary of the invention

[0003] The embodiments of the present invention provide a method, an apparatus and related equipment for merging tables across pages of a PDF document, aiming to solve the problem in the prior art of determining whether complex tables across pages need to be merged.

[0004] In a first aspect, an embodiment of the present invention provides a method for merging tables across pages of a PDF document, which includes:

[0005] Performing structural processing on the PDF document to obtain a structured document of the PDF document, wherein the body of each page in the structured document is divided into text and a table;

[0006] determining, according to the structured document, whether there is a merging condition between two adjacent pages in the PDF document, wherein the merging condition is that the bottom of the body text of one of the two adjacent pages is a table, the top of the body text of the next page is a table, and the width and number of cells of the tables are equal;

[0007] If there is a merging condition between two adjacent pages, the table header in each page of the structured document is recognized by using a pre-trained table header recognition model to determine whether the two adjacent pages both have table headers;

[0008] If the headers of two adjacent pages exist, determine whether the headers are consistent. If they are consistent, remove the header of the next page and merge the table bodies of the two pages. If the headers are inconsistent, do not merge.

[0009] If there is no table header on two adjacent pages, the table bodies of the two pages will be merged.

[0010] In a second aspect, an embodiment of the present invention provides a device for merging tables across pages of a PDF document, comprising:

[0011] A structuring module, used for performing structural processing on the PDF document to obtain a structured document of the PDF document, wherein the body of each page in the structured document is divided into text and a table;

[0012] a judging module, configured to judge whether there is a merging condition between two adjacent pages in the PDF document according to the structured document, wherein the merging condition is that the bottom of the body text of one of the two adjacent pages is a table, the top of the body text of the next page is a table, and the width and number of cells of the table are equal;

[0013] A header recognition module is used to recognize the header of the table in each page of the structured document by using a pre-trained header recognition model if there is a merging condition between two adjacent pages, and to determine whether the two adjacent pages both have headers;

[0014] The merging module is used to determine whether the headers of two adjacent pages are consistent if both pages have headers. If the headers are consistent, the header of the next page is removed and the table bodies of the two pages are merged. If the headers are inconsistent, no merging is performed. If neither page has a header, the table bodies of the two pages are merged.

[0015] In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for merging cross-page tables of a PDF document as described in the first aspect above is implemented.

[0016] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the method for merging tables across pages of a PDF document as described in the first aspect above.

[0017] The embodiment of the present invention provides a PDF document cross-page table merging method, device and related equipment. The method includes performing structured processing on a PDF document to obtain a structured document of the PDF document, wherein the body of each page in the structured document is divided into text and table; judging whether there is a merging condition between two adjacent pages in the PDF document according to the structured document, wherein the merging condition is that the bottom of the body of one page of the two adjacent pages is a table, the top of the body of the next page is a table, and the width and number of cells of the table are equal; if there is a merging condition between the two adjacent pages, the table in each page of the structured document is recognized by a pre-trained header recognition model to judge whether the two adjacent pages have headers; if the two adjacent pages have headers, judging whether the headers are consistent, and if the headers are consistent, removing the header of the next page and merging the table bodies of the two pages; if the headers are inconsistent, no merging is performed; if the two adjacent pages do not have headers, merging the table bodies of the two pages. In this method, based on the structured document of the PDF document, it is judged whether there is a merging condition between two adjacent pages in the PDF document. If there is a merging condition between the two adjacent pages, the pre-trained header recognition model is used to recognize the header of the table in each page of the structured document, and the table body is merged according to the header recognition result. It has a high accuracy rate in judging whether the cross-page tables need to be merged. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0019] Figure 1 A flowchart of a method for merging tables across pages of a PDF document provided by an embodiment of the present invention;

[0020] Figure 2 for Figure 1 Schematic diagram of the sub-process of step S110;

[0021] Figure 3 for Figure 1 Schematic diagram of the sub-process of step S141;

[0022] Figure 4 A schematic diagram of a sub-flow chart of step S410 in the method for merging tables across pages of a PDF document provided by an embodiment of the present invention;

[0023] Figure 5 A schematic diagram of a sub-flow chart of step S410 in the method for merging tables across pages of a PDF document provided by an embodiment of the present invention;

[0024] Figure 6 A schematic block diagram of a device for merging tables across pages of a PDF document provided by an embodiment of the present invention;

[0025] Figure 7 A schematic diagram before merging when column information is inconsistent in the method for merging tables across pages of a PDF document provided by an embodiment of the present invention;

[0026] Figure 8 A schematic diagram of a method for merging tables across pages of a PDF document provided in an embodiment of the present invention after merging with inconsistent column information;

[0027] Fig. 9 A schematic diagram of a method for merging tables across pages of a PDF document provided by an embodiment of the present invention before merging a group of cells with segmented contents;

[0028] Fig.10 A schematic diagram of a method for merging tables across pages of a PDF document provided by an embodiment of the present invention after merging a group of cells with segmented contents;

[0029] Fig.11 A schematic diagram of a method for merging tables across pages of a PDF document provided in an embodiment of the present invention in which other cell groups except for the split cell group in two connected rows of cells do not all have blank contents before merging;

[0030] Fig.12 A schematic diagram of a method for merging tables across pages of a PDF document provided in an embodiment of the present invention in which two connected rows of cells do not all have blank contents in other cell groups except for the split cell group after merging. DETAILED DESCRIPTION

[0031] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0032] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0033] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0034] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0035] See also Figure 1 As shown, Figure 1 The present invention provides a flowchart of a method for merging tables across pages of a PDF document, which method includes steps S110 to S142.

[0036] Step S110: Structuring the PDF document to obtain a structured document of the PDF document, wherein the body of each page in the structured document is divided into text and a table;

[0037] In this embodiment, for merging tables across pages of a PDF document, the PDF document is firstly structured to determine the position of the table in the PDF document, thereby providing a judgment condition for the subsequent merging of the table bodies.

[0038] like Figure 2 As shown, in one embodiment, step S110 includes:

[0039] Step S210: remove text elements and picture elements in the PDF document page to obtain a line page;

[0040] Step S220: grayscale the line page to obtain a grayscale image, and scan the grayscale image to determine horizontal and vertical lines in the grayscale image;

[0041] Step S230, constructing one or more independent tables based on the horizontal and vertical lines, and determining a table area and a non-table area of ​​the PDF document page;

[0042] Step S240: Fill the text elements back into the table area and the non-table area, and identify the header and footer of the PDF document page to obtain the structured document.

[0043] In this embodiment, in order to facilitate the determination of the table area and non-table area in each page of the PDF document, the PDF document is structured. Specifically, it includes: first removing the text elements and image elements in each page of the PDF document to obtain a line page; then graying the line page to obtain a corresponding grayscale image, scanning the grayscale image, and determining the horizontal and vertical lines in the grayscale image; constructing one or more independent tables based on the horizontal and vertical lines in the grayscale image to obtain the table area and non-table area of ​​each page of the PDF document; finally, filling the text elements back into the table area and non-table area, and identifying the header and footer of the PDF document page to obtain a structured document of the PDF document. The non-table area organizes text elements by row. Each page of the structured document is divided into a header, a body, and a footer from top to bottom, and the body is divided into text and a table.

[0044] Step S120: judging whether there is a merging condition between two adjacent pages in the PDF document according to the structured document, wherein the merging condition is that the bottom of the body of one page of the two adjacent pages is a table, the top of the body of the next page is a table, and the width and number of cells of the table are equal;

[0045] In this embodiment, in order to determine whether there is a merging condition between two adjacent pages in a PDF document, based on the structured document of the PDF document, it is determined whether there is a situation in the structured document where the bottom of the text of the previous page is a table, the top of the text of the next page is a table, and the width and number of cells of the table are equal.

[0046] For example, in pages 69 and 70 of the structured document, there is the following situation: the bottom of the text of page 69 is a table, and the top of the text of page 70 is a table, then it is determined that there is a merge condition for pages 69 and 70.

[0047] Step S131: if there is a merging condition between two adjacent pages, the table header in each page of the structured document is recognized by using a pre-trained table header recognition model to determine whether both adjacent pages have table headers;

[0048] Step S141: if both adjacent pages have headers, determine whether the headers are consistent. If the headers are consistent, remove the header of the next page and merge the table bodies of the two pages. If the headers are inconsistent, do not merge.

[0049] Step S142: If there is no table header in two adjacent pages, merge the table bodies of the two pages.

[0050] In this embodiment, when there is a merging condition between two adjacent pages, the table header needs to be identified before the merging to determine whether the table bodies of the two adjacent pages belong to the same table. First, a pre-trained header recognition model is used to identify the table header in each page of the structured document to determine whether the two adjacent pages have headers. If the two adjacent pages have headers, it is determined whether the headers of the two adjacent pages are consistent, so as to determine whether the table bodies of the two pages belong to the same table. If the headers are consistent, it means that the table bodies of the two adjacent pages belong to the same table, then the header of the next page is removed, and the table bodies of the two pages are merged; if the headers are inconsistent, it means that the table bodies of the two adjacent pages do not belong to the same table, and no merging is performed. In addition, if there are no headers on the two adjacent pages, it means that the table bodies of the two pages belong to the same table, and the table bodies of the two pages are merged.

[0051] like Figure 3 As shown, in one embodiment, step S141 includes:

[0052] Step S310, detecting whether two rows of cells connected to two adjacent pages with the same headers meet the following conditions: the arrangement is the same, the column information is consistent, and there is no cross-row cell;

[0053] Step S321: If the conditions are met, merge the two adjacent rows of cells;

[0054] Step S322: If not satisfied, the two adjacent rows of cells are spliced.

[0055] In this embodiment, the table bodies of two pages with consistent table headers are merged, specifically including: detecting two rows of cells connected to two adjacent pages with consistent table headers, if the two rows of cells connected to two adjacent pages with consistent table headers meet the conditions of the same cell arrangement, consistent column information, and no cross-row cells, then the two connected rows of cells are merged. This type of situation is generally that in the two connected rows of cells, the table to which the first row of cells belongs has not ended on the previous page, and the previous page cannot fully accommodate the entire table, so the first row of cells is used as the starting cell of the next page to indicate that the two table bodies are connected, so the two rows of cells in this case need to be merged. If the two rows of cells connected to two adjacent pages with consistent table headers do not meet the conditions of the same cell arrangement, consistent column information, and no cross-row cells, it means that the two rows of cells belong to the same table, but are cells in different rows, so the two connected rows of cells need to be spliced. Figure 7 As shown in FIG. 1 , the column information in the 40th row of cells is inconsistent with the column information in the 41st row of cells before merging. Then the 40th row of cells and the 41st row of cells are spliced ​​to obtain the following: Figure 8 The table shown.

[0056] In one embodiment, step S321 includes:

[0057] Step S410: take each two opposite cells in two connected rows of cells as a cell group, and detect whether the cell group in the two connected rows of cells has segmented content based on the pre-trained semantic recognition model. If so, merge the corresponding cell group; if not, do not merge the corresponding cell group.

[0058] In this embodiment, since there may be a row of cells in the cells distributed on two pages to form two divided rows of cells, and there may be a part of content in each of the two divided rows of cells, it is necessary to perform semantic recognition on each of the two opposite cells in the merged two rows of cells to determine whether each of the two opposite cells in the two rows of cells is the two divided rows of cells. For the convenience of presentation, each of the two opposite cells in the two connected rows of cells is regarded as a cell group. Determining whether each of the two opposite cells in the two rows of cells is the two divided rows of cells specifically includes: detecting whether each cell group in the two connected rows of cells has divided content based on a pre-trained semantic recognition model; if each cell group in the two connected rows of cells has divided content, merging the corresponding cell groups; if each cell group in the two connected rows of cells does not have divided content, not merging the corresponding cell groups, and retaining the corresponding cell groups.

[0059] Furthermore, when the semantic recognition model identifies whether there is segmented content in each cell group in two connected rows of cells according to the rules, the following series of rules can be used to train the semantic recognition model, for example: 1. The semantic recognition model identifies that the content of any cell in the cell group before merging does not conform to the preset regular expression, and conforms to the preset regular expression after merging (similar to the date: October 23, 2021, which can be expressed by a regular expression as [1-2][0-9]{3}year[0-9]?[1-9]month(([1-2]?[0-9])|([3][0-1]))day); 2. The semantic recognition model identifies that if there are double quotes and book title marks in any cell in the cell group, which need to appear in pairs, then the merge process must be performed; 3. The semantic recognition model identifies that if there are commas, commas, semicolons, and other symbols that are not suitable as endings in any cell in the cell group, then the text in the first cell ends with such symbols and needs to be merged. In addition, rules can be set according to the application, and a rule judgment module can be added.

[0060] In one embodiment, the semantic recognition model can also use a word segmentation model to detect the presence of segmented content in the cell group in the two connected rows of cells. Specifically, the text of each cell is input into the word segmentation model and disassembled into words, punctuation marks and stop words. Compare the word segmentation results of the text before merging and the word segmentation results of the text after merging. If the word segmentation result of the text after merging contains the word segmentation result of the text before word segmentation, no merging process is performed; if the word segmentation result of the text after merging does not contain the word segmentation result of the text before word segmentation, then merge processing is performed. For example, the word segmentation results of the first cell text are three words a, b, and c, and the word segmentation results of the merged text are five words a, b, c, d, and e. It can be judged that the word segmentation of the first cell is independent and unrelated, and no merging process is performed. If the word segmentation results of the first cell are three words a, b, and c, and the word segmentation results of the merged text are four words a, b, d, and e, it can be judged that the word segmentation of the first cell is non-independent and unrelated, and a merge process must be performed. If the word segmentation results of the first cell are four words a, b, c, and c1, of which c1 is a word or single word not included in the local vocabulary, and the word segmentation results of the merged text are five words a, b, c, d, and e, it can be judged that the word segmentation of the first cell is not independent and unrelated, and must be merged. If the word segmentation results of the first cell are four words a, b, c, and c1, of which c1 is a word or single word not included in the local vocabulary, and the word segmentation results of the merged text are six words a, b, c, c1, d, and e, it is impossible to judge from the granularity of the vocabulary, and it is necessary to use the semantic model to judge, or expand the local vocabulary to meet the word segmentation needs.

[0061] like Figure 4 As shown, in one embodiment, step S410 includes:

[0062] Step S510, determining that there is a cell group with split contents in two adjacent rows of cells and using it as a split cell group;

[0063] Step S520, determine whether there are blank contents in all the cell groups except the split cell group in the two connected rows of cells, if so, merge all the cell groups in the two connected rows of cells, if not, merge only the split cell group.

[0064] In this embodiment, in the cell group that divides the content in two adjacent rows of cells, there may be a cell with blank content. This is because the content in the original cell is less after a row of cells spans two pages and does not automatically break into multiple lines, resulting in a cell with blank content. For this situation, determine the cell group that divides the content in two adjacent rows of cells and use it as the split cell group. Determine whether there are cells with blank content in other cell groups in two adjacent rows of cells except the split cell group. If so, perform a merging process on all cell groups in the two adjacent rows of cells; if not, only perform a merging process on the split cell group.

[0065] As shown in Figure 9, through the semantic recognition model, it is determined that the cells with the content of October 29, 2019, May 6, 2020, and the lock-up of new shares on the Science and Technology Innovation Board are the cell groups that divide the content. Since there are blank content cells in all other cell groups, a merging process is performed on all cell groups to obtain the table as shown in Fig.10 shown. For example Fig.11 As shown, through the semantic recognition model, it is determined that "XX Hati" and "YY Yiming" are the cell groups that divide the content of names. In the two adjacent rows of cells, not all other cell groups except the split cell group have cells with blank content. Therefore, only the split cells are merged, and the other cell groups are not merged, as shown in Fig.12 shown.

[0066] As Figure 5 shown, in one embodiment, step S410 further includes:

[0067] Step S510: Express the text of two cells in the cell group as a first semantic vector and a second semantic vector through the semantic recognition model;

[0068] Step S520: Calculate the average semantic similarity between the first semantic vector and the second semantic vector and the text in other cells in the same column respectively according to the cosine similarity function to obtain a first similarity and a second similarity;

[0069] Step S530: Calculate the average similarity between the text after merging the two cells in the cell group and the text in other cells in the same column after merging to obtain a target similarity;

[0070] Step S540: If the target similarity is greater than the first similarity and the second similarity, determine that there is split content in the cell group in two adjacent rows of cells.

[0071] In this embodiment, a semantic recognition model is used to determine whether there is segmented content in each cell group in two connected rows of cells. Specifically, it includes: expressing the two texts in the cell group as low-dimensional semantic vectors through a pre-trained semantic recognition model to obtain a first semantic vector and a second semantic vector; then calculating the average semantic similarity between the first semantic vector and the second semantic vector and the texts in other cells in the same column according to the cosine similarity function, and obtaining a first similarity S1 and a second similarity S2; then calculating the average similarity between the text after the two cells in the cell group are merged and the texts in other cells in the same column after the merger, and obtaining a target similarity S; if the target similarity is greater than the first similarity and the second similarity (i.e., S>S1 and S>S2), it is determined that there is segmented content in each cell group in the two connected rows of cells.

[0072] In this method, based on the structured document of the PDF document, it is judged whether there is a merging condition between two adjacent pages in the PDF document. If there is a merging condition between the two adjacent pages, the pre-trained header recognition model is used to recognize the header of the table in each page of the structured document, and the table body is merged according to the header recognition result, so as to realize the judgment of whether to merge complex cross-page tables and promote the automatic processing of data.

[0073] The embodiment of the present invention further provides a device for merging tables across pages of a PDF document, and the device for merging tables across pages of a PDF document is used to execute any embodiment of the aforementioned method for merging tables across pages of a PDF document. Figure 6 , Figure 6 1 is a schematic block diagram of a PDF document cross-page table merging device provided by an embodiment of the present invention. The PDF document cross-page table merging device 100 can be configured in a server.

[0074] like Figure 6 As shown, the PDF document cross-page table merging device 100 includes a structuring module 110 , a judging module 120 , a table header recognition module 130 , and a merging module 140 .

[0075] The structuring module 10 is used to perform structuring processing on the PDF document to obtain a structured document of the PDF document, wherein the body of each page in the structured document is divided into text and a table;

[0076] A judging module 20, configured to judge whether there is a merging condition between two adjacent pages in the PDF document according to the structured document, wherein the merging condition is that the bottom of the body of one of the two adjacent pages is a table, the top of the body of the next page is a table, and the width and number of cells of the table are equal;

[0077] A header recognition module 30 is used to perform header recognition on the table in each page of the structured document by using a pre-trained header recognition model if there is a merging condition between two adjacent pages, and to determine whether both adjacent pages have headers;

[0078] The merging module 40 is used to determine whether the headers of two adjacent pages are consistent if both pages have headers. If the headers are consistent, the header of the next page is removed and the table bodies of the two pages are merged. If the headers are inconsistent, no merging is performed. If neither page has a header, the table bodies of the two pages are merged.

[0079] In one embodiment, the structured module 10 includes:

[0080] A removing unit, used to remove text elements and image elements in the PDF document page to obtain a line page;

[0081] A grayscale processing unit, used for grayscale processing the line page to obtain a grayscale image, and scanning the grayscale image to determine the horizontal and vertical lines in the grayscale image;

[0082] A construction unit, configured to construct one or more independent tables based on the horizontal and vertical lines, and determine a table area and a non-table area of ​​the PDF document page;

[0083] The recognition unit is used to fill the text elements back into the table area and the non-table area, and recognize the header and footer of the PDF document page to obtain the structured document.

[0084] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for merging tables across pages of a PDF document when executing the computer program.

[0085] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the above-mentioned method for merging tables across pages of a PDF document.

[0086] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the above-described equipment, devices and units can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. Those of ordinary skill in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0087] In the several embodiments provided by the present invention, it should be understood that the disclosed equipment, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. Units with the same function may also be combined into one unit. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, or may be an electrical, mechanical or other form of connection.

[0088] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0089] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0090] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially 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. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), disk or optical disk and other media that can store program codes.

[0091] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for merging tables across pages of a PDF document, characterized in that: include: Performing structural processing on the PDF document to obtain a structured document of the PDF document, wherein the body of each page in the structured document is divided into text and a table; determining, according to the structured document, whether there is a merging condition between two adjacent pages in the PDF document, wherein the merging condition is that the bottom of the body text of one of the two adjacent pages is a table, the top of the body text of the next page is a table, and the width and number of cells of the tables are equal; If there is a merging condition between two adjacent pages, the table header in each page of the structured document is recognized by using a pre-trained table header recognition model to determine whether the two adjacent pages both have table headers; If the headers exist on both adjacent pages, determine whether the headers are consistent. If they are consistent, remove the header of the next page and merge the table bodies of the two pages. If the table headers are inconsistent, no merging will be performed; If there is no table header on two adjacent pages, the table bodies of the two pages will be merged; If the table headers are consistent, the table header of the next page is removed, and the table bodies of the two pages are merged, including: detecting whether two rows of cells connected to two adjacent pages with consistent table headers meet the following conditions: the arrangement is the same, the column information is consistent, and there are no cross-row cells; if so, the two rows of cells connected are merged; if not, the two rows of cells connected are spliced; The merging of two connected rows of cells includes: taking each two opposite cells in the two connected rows of cells as a cell group, detecting whether the cell group in the two connected rows of cells has segmented content based on a pre-trained semantic recognition model, and if so, merging the corresponding cell group; if not, not merging the corresponding cell group; The pre-trained semantic recognition model is used to detect whether there is segmented content in the cell group of the two connected rows of cells. If so, the corresponding cell group is merged; if not, the corresponding cell group is not merged, including: determining the cell group with segmented content in the two connected rows of cells and using it as the segmented cell group; judging whether there are blank contents in the cell groups other than the segmented cell group in the two connected rows of cells. If so, all the cell groups in the two connected rows of cells are merged, otherwise only the segmented cell group is merged; The method detects whether there is segmented content in a cell group in two connected rows of cells based on a pre-trained semantic recognition model, including: expressing texts of two cells in the cell group as a first semantic vector and a second semantic vector through the semantic recognition model; calculating the average semantic similarities of the first semantic vector and the second semantic vector with texts in other cells in the same column according to a cosine similarity function, to obtain a first similarity and a second similarity; calculating the average similarity between texts of two cells in the cell group after merging and texts in other cells in the same column after merging, to obtain a target similarity; if the target similarity is greater than the first similarity and the second similarity, determining that there is segmented content in the cell group in the two connected rows of cells.

2. The method for merging tables across pages of a PDF document according to claim 1, characterized in that: The step of performing structural processing on the PDF document to obtain a structured document of the PDF document includes: Remove the text elements and the picture elements in the PDF document page to obtain a line page; Gray-scale the line page to obtain a gray-scale image, and scan the gray-scale image to determine horizontal and vertical lines in the gray-scale image; Construct one or more independent tables based on the horizontal and vertical lines to determine a table area and a non-table area of ​​the PDF document page; The text elements are filled back into the table area and the non-table area, and the header and footer of the PDF document page are identified to obtain the structured document.

3. A device for merging tables across pages of a PDF document, characterized in that: include: A structuring module, used for performing structural processing on the PDF document to obtain a structured document of the PDF document, wherein the body of each page in the structured document is divided into text and a table; a judging module, configured to judge whether there is a merging condition between two adjacent pages in the PDF document according to the structured document, wherein the merging condition is that the bottom of the body text of one of the two adjacent pages is a table, the top of the body text of the next page is a table, and the width and number of cells of the table are equal; A header recognition module is used to perform header recognition on the table in each page of the structured document through a pre-trained header recognition model if there is a merging condition between two adjacent pages, and determine whether the two adjacent pages both have headers; The merging module is used to determine whether the headers of two adjacent pages are consistent if both pages have headers. If the headers are consistent, the header of the next page is removed and the table bodies of the two pages are merged. If the table headers are inconsistent, no merging will be performed; If there is no table header on two adjacent pages, the table bodies of the two pages will be merged; If the table headers are consistent, the table header of the next page is removed, and the table bodies of the two pages are merged, including: detecting whether two rows of cells connected to two adjacent pages with consistent table headers meet the following conditions: the arrangement is the same, the column information is consistent, and there are no cross-row cells; if so, the two rows of cells connected are merged; if not, the two rows of cells connected are spliced; The merging of two connected rows of cells includes: taking each two opposite cells in the two connected rows of cells as a cell group, detecting whether the cell group in the two connected rows of cells has segmented content based on a pre-trained semantic recognition model, and if so, merging the corresponding cell group; if not, not merging the corresponding cell group; The pre-trained semantic recognition model is used to detect whether there is segmented content in the cell group of the two connected rows of cells. If so, the corresponding cell group is merged; if not, the corresponding cell group is not merged, including: determining the cell group with segmented content in the two connected rows of cells and using it as the segmented cell group; judging whether there are blank contents in the cell groups other than the segmented cell group in the two connected rows of cells. If so, all the cell groups in the two connected rows of cells are merged, otherwise only the segmented cell group is merged; The method detects whether there is segmented content in a cell group in two connected rows of cells based on a pre-trained semantic recognition model, including: expressing texts of two cells in the cell group as a first semantic vector and a second semantic vector through the semantic recognition model; calculating the average semantic similarities of the first semantic vector and the second semantic vector with texts in other cells in the same column according to a cosine similarity function, to obtain a first similarity and a second similarity; calculating the average similarity between texts of two cells in the cell group after merging and texts in other cells in the same column after merging, to obtain a target similarity; if the target similarity is greater than the first similarity and the second similarity, determining that there is segmented content in the cell group in the two connected rows of cells.

4. The PDF document cross-page table merging device according to claim 3, characterized in that: The structured module includes: A removing unit, used to remove text elements and image elements in the PDF document page to obtain a line page; A grayscale processing unit, used for grayscale processing the line page to obtain a grayscale image, and scanning the grayscale image to determine the horizontal and vertical lines in the grayscale image; A construction unit, configured to construct one or more independent tables based on the horizontal and vertical lines, and determine a table area and a non-table area of ​​the PDF document page; The recognition unit is used to fill the text elements back into the table area and the non-table area, and recognize the header and footer of the PDF document page to obtain the structured document.

5. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for merging tables across pages of a PDF document as claimed in any one of claims 1 to 2 is implemented.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the method for merging tables across pages of a PDF document according to any one of claims 1 to 2.