Table identification method and electronic equipment

By converting tables into HTML text and inputting them into a table recognition model, the problem of multi-page table recognition and integration in traditional methods is solved, and intelligent recognition and structural consistency of cross-page tables are achieved.

CN120764508AInactive Publication Date: 2025-10-10HANGZHOU HENGSHENG JUYUAN INFORMATION TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511278004.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-09
Publication Date
2025-10-10
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional table recognition methods cannot effectively handle complex layout situations such as table offset, and cannot support the recognition and integration of multi-page continuous span tables.

Method used

By obtaining tables from adjacent pages, converting them into structured HTML text, and inputting them into a pre-trained table recognition model, the cell matching relationship and splicing type are analyzed to generate a unified spliced ​​table.

Benefits of technology

It improves the coherence and consistency of the structure and content of multi-page tables, and realizes the intelligent recognition and integration of continuous tables in documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120764508A_ABST
    Figure CN120764508A_ABST
Patent Text Reader

Abstract

The invention provides a table recognition method and electronic equipment, and relates to the technical field of data processing. The method comprises the steps that a first page and a second page which are adjacent to each other are acquired, a first table is extracted from the first page, and a second table is extracted from the second page; generating a first HTML text and a second HTML text; the first HTML text and the second HTML text are input into a pre-trained table recognition model, the table recognition model splices the first HTML text and the second HTML text according to cell information in the first HTML text and cell information in the second HTML text, and a spliced table of the first table and the second table is obtained. According to the method, the table content is converted into the structured HTML format text, compared with table representation in a plain text or image form, complex table layout can be described more accurately, and consistency and consistency of multi-page table recognition in structure and content are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular to a table recognition method and an electronic device. BACKGROUND

[0002] With the development of Optical Character Recognition (OCR) and document analysis technology, table recognition has become a core link in document content analysis.

[0003] Traditional table recognition methods mainly include two categories. One category is to process a complete table in a single page, extract the table content by detecting the table boundary, row and column structure, and determine whether it belongs to the same table based on column consistency and column width matching strategies, and then perform merging processing accordingly. However, this method cannot solve the problem of position offset of tables on different pages, and does not involve merging logic at the cell content level, so it cannot support the recognition of multi-page continuous cross-page tables. The other category is to introduce a large language model to process the table structure, filter out the table through semantic understanding, and judge the structural consistency to realize cross-page merging. Although this method improves the table filtering capability to some extent, its cross-page merging mechanism still relies on rules such as table structure and column number, and has high dependence on the accuracy of pre-table recognition.

[0004] In summary, traditional table recognition methods rely on static rules such as table position, column number, and column width for judgment, and cannot effectively handle complex layout situations such as table offset. Moreover, since only the merging of table structure is considered, there is a lack of semantic fusion and logical connection of cell content on different pages. When a table spans multiple pages, it is difficult to effectively complete the unified recognition of structure and content, so traditional table recognition methods cannot support the recognition and integration of multi-page continuous cross-page tables. SUMMARY

[0005] The present application aims to solve the problem that the existing technology cannot support the recognition and integration of multi-page continuous cross-page tables when a table spans multiple pages, by providing a table recognition method and an electronic device.

[0006] To achieve the above-mentioned purpose, the technical solutions adopted by the embodiments of the present application are as follows: In a first aspect, the embodiments of the present application provide a table recognition method, which comprises: obtaining adjacent first and second pages, extracting a first table from the first page, and extracting a second table from the second page, wherein the first table is the last table in the first page, and the second table is the first table in the second page; generate first HyperText Markup Language, HTML, text corresponding to the first table and second HTML text corresponding to the second table; input the first HTML text and the second HTML text into a pre-trained table recognition model, and perform splicing on the first HTML text and the second HTML text according to cell information in the first HTML text and cell information in the second HTML text by the table recognition model to obtain a spliced table of the first table and the second table.

[0007] In a second aspect, an embodiment of the present application provides a table recognition device, the device comprising: an extraction module configured to obtain a first page and a second page adjacent to each other, extract a first table from the first page, and extract a second table from the second page, wherein the first table is a last table in the first page, and the second table is a first table in the second page; a generation module configured to generate first HyperText Markup Language, HTML, text corresponding to the first table and second HTML text corresponding to the second table; a recognition module configured to input the first HTML text and the second HTML text into a pre-trained table recognition model, and perform splicing on the first HTML text and the second HTML text according to cell information in the first HTML text and cell information in the second HTML text by the table recognition model to obtain a spliced table of the first table and the second table.

[0008] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a storage medium, and a bus, the storage medium storing machine-readable instructions executable by the processor, when the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to perform the steps of the table recognition method according to any one of the first aspect.

[0009] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium storing a computer program, when the computer program is run by a processor, the steps of the table recognition method according to any one of the first aspect are performed.

[0010] According to the table recognition method and electronic device of the embodiment of the present application, the last and first tables are respectively extracted from adjacent pages (the first page and the second page) and converted into structured HTML format text, thereby retaining key semantic information such as the table's row and column structure, cell content, and merge relationship. Compared with table representations in plain text or image form, HTML format text can more accurately describe complex table layouts and provide a reliable structural basis for subsequent splicing judgments. The HTML texts of the two tables are then input into a pre-trained table recognition model, which automatically analyzes the cell matching relationship and splicing type of the two tables, and finally generates a unified spliced ​​table. This not only improves the coherence and consistency of the structure and content of multi-page tables, but also provides a feasible path for realizing the intelligent recognition and integration of continuous tables in documents. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0012] Figure 1 A schematic diagram of a flow chart of a table recognition method provided in an embodiment of the present application is shown; Figure 2 A schematic diagram of a process for determining a post-joining table provided in an embodiment of the present application is shown; Figure 3 A schematic diagram showing a splicing category of non-splicing provided by an embodiment of the present application is shown; Figure 4 A schematic diagram showing a splicing category of direct splicing provided by an embodiment of the present application is shown; Figure 5 A schematic diagram showing a splicing category of merge splicing provided by an embodiment of the present application is shown; Figure 6 A schematic diagram showing a flow chart of a method for constructing a table recognition model provided in an embodiment of the present application is shown; Figure 7 A flow chart of another table recognition model training method provided in an embodiment of the present application is shown; Figure 8 A schematic diagram of the architecture of a table recognition model provided in an embodiment of the present application is shown; Figure 9 A schematic structural diagram of a table recognition device provided in an embodiment of the present application is shown; Figure 10A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0013] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of illustration and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowcharts can be implemented out of sequence, and steps without logical context can be reversed or implemented simultaneously. In addition, those skilled in the art, under the guidance of the contents of this application, can add one or more other operations to the flowchart, or remove one or more operations from the flowchart.

[0014] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

[0015] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0016] The embodiment of the present application can be applied to the scenario of extracting cross-page table information in a file. The format of the file can be a PDF file or a picture.

[0017] Figure 1 The flowchart of a table recognition method provided by an embodiment of the present application is shown. The execution subject of the method can be any electronic device with computing and processing capabilities. Figure 1 As shown, the method specifically includes the following steps: S101 , obtaining a first page and a second page that are adjacent to each other, extracting a first table from the first page, and extracting a second table from the second page.

[0018] Optionally, a file to be processed containing text and tables is obtained, and the file to be processed can be, for example, a paginated file in PDF or image format. The first page and the second page are two adjacent continuous upper and lower pages in the file to be processed, such as page 1 and page 2, and page 2 and page 3 in the file to be processed. On this basis, taking the first page and the second page as an example of a spliced ​​page group, if the total number of pages of the file to be processed is n, n-1 spliced ​​page groups can be obtained from the file to be processed. For the first page and the second page in each spliced ​​page group, the two continuous pages of the first page and the second page can be spliced ​​in a double-page preview format, and the spliced ​​page group can be named {MD5}_{pg_up}_{pg_down}.jpg, where MD5 is a unique string identifier obtained by hashing the content of the text to be processed, pg_up represents the page number of the upper page in the spliced ​​page group (that is, the page number of the first page), and pg_down represents the page number of the lower page in the spliced ​​page group (that is, the page number of the second page). It should be noted that the first and second pages can be spliced ​​in a double-page preview format or directly spliced. The double-page preview format only applies to two adjacent pages in the file to be processed. Since directly splicing the top and bottom pages together will result in the image height of the spliced ​​page group being too high, which in turn affects visual reading, the double-page preview format is more convenient for users to read and more efficient in annotation than the direct splicing format.

[0019] Optionally, since users may encounter a cross-page table scenario when reading the file to be processed, that is, a table is split into two pages, in order to improve the effectiveness of table merging analysis, for the cross-page table, the last table in the first page can be extracted as the first table, and the first table in the second page can be extracted as the second table, that is, the cross-page table includes the first table and the second table split into two pages.

[0020] Optionally, the first table can be extracted from the first page of the file to be processed and the second table can be extracted from the second page by using optical character recognition (OCR) technology and a table structure recognition model. For example, the document to be processed is divided into multiple single-page images by page, and for each single-page image, the text content in the single-page image is recognized using OCR technology to obtain the position coordinates of the text content in the single-page image, and the table structure recognition model is used to detect the table area of ​​the single-page image to identify which areas in the single-page image contain the table, thereby combining the position coordinates of the text content in the single-page image obtained by OCR technology to extract the corresponding table from the single-page image.

[0021] Optionally, after the document to be processed is divided into multiple single-page images by page, each single-page image can be pre-processed, such as performing layout detection on the single-page image, removing the page footer, and performing denoising, grayscale processing, binarization and tilt correction, etc., in order to improve the accuracy of table recognition.

[0022] S102: Generate a first Hypertext Markup Language HTML text corresponding to the first table and a second HTML text corresponding to the second table.

[0023] Optionally, HyperText Markup Language (HTML) is a standard markup language for creating web pages, which uses a series of tags to describe the structure and semantics of web page content, such as titles, paragraphs, tables, images, links, etc. In the present application, the first table extracted from the first page and the second table extracted from the second page are converted into standard HTML format strings to facilitate subsequent model input. Exemplarily, based on OCR technology and a table structure recognition model, the first table is extracted from the first page, and the second table is extracted from the second page, respectively, and the original table structure information of the first table and the second table is output, such as cell coordinates, number of rows and columns, number of rows and columns spanned by a cell, and other structural information, and the structural information is converted into HTML table code text, which includes table ,OK , cell , number of rows of cells <rowspan>, the number of columns spanned by the cell <colspan>etc. tags.

[0024] Illustratively, the first table is shown in Table 1 below, and the second table is shown in Table 2 below.

[0025] Table 1 First Table

[0026] Table 2 Second Table

[0027] For the first table described above, the generated first HTML text contains the following nine lines: Line 1 contains the HTML text corresponding to the header of Table 1; Line 2 contains the HTML text corresponding to the first cell in Table 1, specifically the HTML for "Serial Number." The word "Serial Number" is represented by the string "u5e8f\u53f7" in the HTML text; Line 3 contains the HTML text corresponding to the second cell in Table 1, specifically the HTML for "Securities Code." The word "Securities Code" is represented by the string "u8bc1\u5238\u4ee3\u7801" in the HTML text; Line 4 contains the HTML text corresponding to the third cell in Table 1, specifically the HTML for "Securities Name." The word "Securities Name" is represented by the string "u8bc1\u5238\u540d\u79f0" in the HTML text; and Line 5 contains the HTML text corresponding to the fourth cell in Table 1, specifically the HTML for "Quantity (Pieces)." Among them, the word "quantity (pieces)" is represented by the string "u6570\u91cf(\u5f20)" in the HTML text. The 6th line is the HTML text corresponding to the fifth cell in Table 1, that is, the HTML corresponding to the cell "fair value (yuan)". Among them, the word "fair value (yuan)" is represented by the string "u516c\u5141\u4ef7\u503c(\u5143)" in the HTML text. The 7th-8th lines are the HTML text corresponding to the sixth cell in Table 1, that is, the HTML corresponding to the cell "percentage of net asset value of the fund (%)". Among them, the word "percentage of net asset value of the fund (%)" is represented by the string "u5360\u57fa\u91d1\u8d44\u4ea7\u51c0" in the HTML text.

[0028] table1: \u5e8f\u53f7 \u8bc1\u5238\u4ee3\u7801 \u8bc1\u5238\u540d\u79f0 \u6570\u91cf(\u5f20) \u516c\u5141\u4ef7\u503c(\u5143) \u5360\u57fa\u91d1\u8d44\u4ea7\u51c0 The generated second HTML text for the second table above contains the following 27 lines. Line 1 contains the HTML text corresponding to the header of Table 2. Lines 2-6 contain the HTML text corresponding to the first five cells in the first row of Table 2, respectively. Lines 7-8 contain the HTML text corresponding to the sixth cell in Table 2, specifically the HTML corresponding to the cell "Value Ratio (%)." The term "Value Ratio (%)" is represented in the HTML text by the string "u503c\u6bd4\uff08%\uff09." Line 9 contains the HTML text corresponding to the first cell in the second row of Table 2, specifically the HTML corresponding to the cell "1." Line 10 contains the HTML text corresponding to the second cell in the second row of Table 2, specifically the HTML corresponding to the cell "136393." Line 11 contains the HTML text corresponding to the third cell in the second row of Table 2, specifically the HTML corresponding to the cell "瑞新31A1." The term "瑞新31A1" is represented in the HTML text by the string "u745e\u65b031A1." Row 12 contains the HTML text corresponding to the fourth cell in the second row of Table 2, that is, the HTML corresponding to the cell "150,000.00". Row 13 contains the HTML text corresponding to the fifth cell in the second row of Table 2, that is, the HTML corresponding to the cell "14,995,500.00". Row 14 contains the HTML text corresponding to the sixth cell in the second row of Table 2, that is, the HTML corresponding to the cell "0.80". Rows 15-20 contain the HTML text corresponding to the cells in the third row of Table 2, respectively. Rows 21-26 contain the HTML text corresponding to the cells in the fourth row of Table 2, respectively.

[0029] table2: \u503c\u6bd4\uff08%\uff09 1 136393 \u745e\u65b031A1 150,000.00 14,995,500.00 0.80 2 - - - - - 3 - - - - - S103. Input the first HTML text and the second HTML text into a pre-trained table recognition model. The table recognition model splices the first HTML text and the second HTML text based on the cell information in the first HTML text and the cell information in the second HTML text to obtain a spliced ​​table of the first table and the second table.

[0030] Optionally, the table recognition model is a sequence-to-sequence model based on the Transformer architecture, including an encoder, a decoder, and a classification prediction head, such as the T5 model. The table recognition model can receive structured text (such as cross-page table text in HTML format). The encoder encodes the received cross-page table structured text into a high-dimensional semantic representation, and the classification prediction head determines the splicing category of the cross-page table and outputs the splicing category label. The decoder decodes the output of the encoder, gradually generates and outputs a new structured text (HTML text of the spliced ​​table).

[0031] Optionally, after obtaining the first HTML text and the second HTML text, an input sequence can be constructed based on the first HTML text and the second HTML text. Specifically, the first HTML text and the second HTML text can be concatenated into an input sequence acceptable to the table recognition model according to a specified format, and the constructed input sequence is input into the table recognition model. The format of the input sequence is as follows: input_seq=f''[CLS]{examples['table1'][i]}[SEP]{examples['table2'][i]}[SEP]'', where table1 represents the first HTML text, table2 represents the second HTML text, [CLS] represents a start tag used for classification tasks, and [SEP] represents a separator used to distinguish different table contents.

[0032] Optionally, the table recognition model is composed of an encoder, a decoder, and a classification prediction head. After the input sequence is input into the table recognition model, the encoder maps the input sequence into a context-aware semantic representation, specifically based on the structured semantic representation of the table composed of the cell information in the first HTML text and the cell information in the second HTML text, using the hidden state corresponding to [CLS] as a global feature, and feeding it into the classification prediction head. The classification prediction head outputs a probability distribution, selects the splicing category with the maximum probability, and outputs the splicing category label. The decoder outputs the spliced ​​HTML table string based on the encoder output. Among them, the cell information of the first HTML text and the second HTML text can be obtained through< / colspan> < / rowspan> Label, tag, <rowspan>Labels and <colspan>Labels, etc. Cell information can specifically include: text content, position information in the table, header attributes, number of rows spanned, number of columns spanned, data type, and contextual relationships. Text content refers to the text or numbers in the cell, position information refers to the row and column position of the cell in the table, header attributes refers to whether it is a header cell, number of rows spanned refers to the number of rows spanned by the cell, number of columns spanned refers to the number of columns spanned by the cell, data type refers to whether the content is numeric or string data such as numbers, text, and dates, and contextual relationships refer to whether it has logical consistency with a column in another table.

[0033] Based on this, according to the table recognition method of the embodiment of the present application, the last and first tables are respectively extracted from adjacent pages (the first page and the second page), and converted into structured HTML format text, thereby retaining key semantic information such as the table's row and column structure, cell content, and merge relationship. Compared with table representations in plain text or image form, HTML format text can more accurately describe complex table layouts and provide a reliable structural basis for subsequent splicing judgments. The HTML texts of the two tables are then input into a pre-trained table recognition model, and the table recognition model automatically analyzes the cell matching relationship and splicing type of the two tables, and finally generates a unified spliced ​​table. This not only improves the coherence and consistency of the structure and content of multi-page tables, but also provides a feasible path for realizing the intelligent recognition and integration of continuous tables in documents.

[0034] Figure 2 A flow chart of a method for determining a post-joining table provided in an embodiment of the present application is shown. As a possible implementation method, refer to Figure 2 As shown, the above steps splice the first HTML text and the second HTML text according to the cell information in the first HTML text and the cell information in the second HTML text to obtain the spliced ​​table of the first table and the second table, specifically including the following steps: S201. Determine a splicing category of the first HTML text and the second HTML text based on cell information in the first HTML text and cell information in the second HTML text, and splice the first HTML text and the second HTML text based on the splicing category to obtain and output a spliced ​​HTML text.

[0035] Optionally, based on the cell information in the first HTML text and the cell information in the second HTML text, the table recognition model determines the specific splicing category according to the header consistency information, structure matching information and content logical relationship represented by the cell information, for example,< / colspan> < / rowspan> Whether the content of the labels is consistent or complementary determines the consistency of the header, whether the number and order of columns are consistent, the continuity of the cell content and other information to determine which splicing method to use, thereby realizing the recognition and structural reconstruction of cross-page tables.

[0036] Optionally, the splicing categories include non-splicing, direct splicing, and merge splicing, as shown in Table 3 below: Table 3 Schematic diagram of splicing categories

[0037] For example, "unjoinable" means that the two tables are structurally unsuitable for merging, including situations such as different structures, the presence of independent headers, and no logical connection. For example, a different structure means one table has two columns and the other has three, with inconsistent numbers of rows and columns. "The presence of independent headers" means that both tables have their own header rows, and the headers are inconsistent and cannot be unified. "No logical connection" means that the two tables express completely different data content.

[0038] For example, direct concatenation means that two tables have the same structure, such as the number of columns, column names, and formats, but the contents have no direct contextual relationship. Simply concatenate the two tables' structures without merging the cell contents. For example, two tables display multiple pages of the same category (e.g., the first page shows the first 10 rows, and the second page shows the last 10 rows). The table headers are the same, but the data on each page is independent.

[0039] For example, merging and joining two tables means that the two tables have not only the same structure but also logically complement or continue each other in their contents. Therefore, both the structure and content of the two tables need to be merged to form a new, complete table. For example, a table that spans multiple pages (for example, only some columns are displayed on the first page, and the remaining columns are displayed on the next page) or a multi-section table where the tables on the previous and next pages complement each other.

[0040] Optionally, the above steps determine the splicing category of the first HTML text and the second HTML text based on the cell information in the first HTML text and the cell information in the second HTML text, including: if the table structure indicated by the first HTML text is different from the table structure indicated by the second HTML text, and / or there is text corresponding to the table header in both the first HTML text and the second HTML text, then the splicing category is determined to be non-splicable.

[0041] For example, referring to Figure 3 As shown, the left part is the first page, the right part is the second page, and the first table in the first page (such as Figure 3 Table 1) and the second table on the second page (as shown in Figure 3 Although Table 2 shown in the table has the same number of columns and rows in terms of table structure, the first table and the second table both have independent header rows. Accordingly, the text corresponding to the header row exists in both the first HTML text corresponding to the first table and the second HTML text corresponding to the second table. Therefore, it can be determined that the splicing category of the first HTML text corresponding to the first table and the second HTML text corresponding to the second table is non-splicable.

[0042] For example, if there is a first table in the first page, the first table has an independent header, and the first table is a table structure with five rows and three columns, and there is a second table in the second page, the second table also has an independent header, but the second table is a table structure with three rows and four columns. Correspondingly, that is, although the text corresponding to the header exists in the first HTML text corresponding to the first table and the second HTML text corresponding to the second table, the table structure indicated by the first HTML text corresponding to the first table is different from the table structure indicated by the second HTML text corresponding to the second table, so it can also be determined that the splicing category of the first HTML text corresponding to the first table and the second HTML text corresponding to the second table is non-splicable. In other words, when the first table in the first page and the second table in the second page are both independent tables, the splicing category of the first table and the second table is non-splicable.

[0043] Optionally, the step of determining the concatenation type of the first HTML text and the second HTML text based on the cell information in the first HTML text and the cell information in the second HTML text includes: if the cells in the last row of the first HTML text match the cells in the first row of the second HTML text, then determining the concatenation type as direct concatenation. Cell matching includes: the number of cells is the same, and the cells in the last row correspond one-to-one with the cells in the first row.

[0044] For example, referring to Figure 4 As shown, there is a first table in the first page of the left part (such as Figure 4 As shown in Table 3, the first table has an independent header, and the number of cells in the last row of the first table is 6. A second table exists on the second page on the right side. This second table does not have an independent header, and the number of cells in the first row of the second table is also 6. The cells in the last row of the first table correspond one-to-one with the cells in the first row of the second table, that is, the number of columns spanned by the corresponding cells is the same, both 1. Accordingly, that is, the cells in the last row of the first HTML text corresponding to the first table match the cells in the first row of the second HTML text corresponding to the second table, then the splicing category of the first HTML text corresponding to the first table and the second HTML text corresponding to the second table is determined to be direct splicing.

[0045] Correspondingly, the above steps splice the first HTML text and the second HTML text according to the splicing category to obtain and output the spliced ​​HTML text, including: if the splicing category is direct splicing, then merge the text of each cell in the first row of the second HTML text into the corresponding cell in the last row of the first HTML text in turn to obtain and output the spliced ​​HTML text.

[0046] For example, if the concatenation type of the first and second tables is direct concatenation, that is, it is determined that the first and second tables can be seamlessly connected, that is, the second table is directly attached to the first table to form a complete table. Correspondingly, that is, if the concatenation type of the first HTML text and the second HTML text is direct concatenation, the text of each cell in the first row of the second HTML text is sequentially merged into the corresponding cell in the last row of the first HTML text to obtain and output the concatenated HTML text.

[0047] Specifically, extract the text content of each cell in the last row of the first HTML text corresponding to the first table and the first row of the second HTML text corresponding to the second table, and merge the text content of each cell in the first row of the second table into the corresponding cell in the last row of the first table, to obtain the concatenated HTML text corresponding to the merged cells. For example, the first table is shown in Table 4.1 below, and the second table is shown in Table 4.2 below. If the concatenation category of the first HTML text and the second HTML text is direct concatenation, the concatenated table obtained after concatenation is shown in Table 4.3 below: Table 4.1 First Table

[0048] Table 4.2 Second Table

[0049] Table 4.3 after splicing

[0050] Optionally, the above steps determine the splicing category of the first HTML text and the second HTML text based on the cell information in the first HTML text and the cell information in the second HTML text, including: if the cells in the last row of the first HTML text do not match the cells in the first row of the second HTML text, determining the splicing category as merge splicing.

[0051] For example, referring to Figure 5 As shown, there is a first table in the first page of the left part (such as Figure 5 As shown in Table 4, the first table has an independent header, and the number of cells in the last row of the first table is 6. There is a second table in the second page on the right side. The second table does not have an independent header, and the number of cells in the first row of the second table is also 6. However, the number of rows spanned by the cell "Ratio of Net Asset Value of Funds" is 2, occupying the last row of the first table and the first row of the second table respectively, while the number of rows spanned by cells such as "Serial Number", "Securities Code", "Securities Name", "Quantity", and "Fair Value" is 1, occupying only the last row of the first table, so the cells in the last row of the first table do not match the cells in the first row of the second table. Accordingly, that is, the cells in the last row of the first HTML text do not match the cells in the first row of the second HTML text, then the splicing category of the first HTML text corresponding to the first table and the second HTML text corresponding to the second table is determined to be merge splicing.

[0052] Correspondingly, the above steps splice the first HTML text and the second HTML text according to the splicing category to obtain and output the spliced ​​HTML text, including: if the splicing category is merge splicing, then according to the cell attributes of each cell in the last row of the first HTML text and the cell attributes of each cell in the first row of the second HTML text, the last row and the first row are spliced ​​to obtain and output the spliced ​​HTML text.

[0053] Optionally, if the splicing category of the first HTML text and the second HTML text is merge splicing, that is, there is a logical continuity between the cells in the first table and the second table, when splicing the first table and the second table, the two tables are not simply stacked together, but a new table structure is reconstructed so that the contents of the first table and the second table are naturally connected.

[0054] For example, in the first HTML text and the second HTML text, each cell Or the header cell has a cell attribute of row span, column span, etc., when the splicing category of the first HTML text and the second HTML text is merging splicing, the last row of the first HTML text and the first row of the second HTML text are extracted respectively, each cell in the last row of the first HTML text and the first row of the second HTML text is parsed, the cell attribute of each cell is obtained, and a new table structure is constructed according to the cell attribute of each cell in the last row and the first row, and the spliced HTML text is output.

[0055] Optionally, according to the cell attribute of each cell in the last row of the first HTML text and the cell attribute of each cell in the first row of the second HTML text, the last row and the first row are spliced, including: traversing each cell in the first row of the second HTML text, for the current cell traversed, determining the target cell corresponding to the current cell in the last row of the first HTML text, determining whether to merge the current cell into the target cell according to the cell attribute of the current cell and the cell attribute of the target cell, if yes, merging the text of the current cell into the target cell, and adjusting the row span of the target cell.

[0056] Exemplarily, the two adjacent rows (the last row of the first table and the first row of the second table) in the first table and the second table are compared column by column, whether the cells can be merged is determined according to the cell attribute, if the cells can be merged, the row span of the cells is adjusted after merging. Specifically, each cell in the first row of the second HTML text is traversed, for the current cell traversed, the target cell corresponding to the current cell in the last row of the first HTML text is determined according to the column span of the current cell and the column span of each cell in the first HTML text, and then whether the current cell can be merged with the target cell is determined according to the cell attribute of the current cell and the target cell, if the current cell can be merged with the target cell, the text content of the current cell is merged into the target cell, and the row span of the target cell is dynamically adjusted, so as to realize the merging of the table with consistent structure.

[0057] Exemplarily, the first table is shown in Table 5.1, the second table is shown in Table 5.2, and if the splicing category of the first HTML text and the second HTML text is merging splicing, the spliced table obtained after splicing is shown in Table 5.3: Table 5.1 First Table

[0058] Table 5.2 Second Table

[0059] Table 5.3 Spliced Table

[0060] Optionally, the above step of determining the target cell corresponding to the current cell in the last row of the first HTML text includes: determining the target column where the current cell is located in the table, and using the cell in the target column in the last row of the first HTML text as the target cell.

[0061] For example, as shown in Table 6 below, the first row represents the last row of the first table corresponding to the first HTML text, and the second row represents the first row of the second table corresponding to the second HTML text. For the current cell traversed in the second HTML text, the target column of the current cell in the table can be determined based on the number of columns spanned by the current cell. Taking the cells in the second row of Table 6 as an example, the first cell "1" has a span of 1, and its target column in the second table is column 1. The cell corresponding to the target column in the first row is "Serial Number". Therefore, for the current cell with text content "1", its corresponding target cell is the cell with text content "Serial Number". The second cell "C" in the second row has a span of 2, and its target column in the second table is column 2. The cell corresponding to the target column in the first row is "A". Therefore, for the current cell with text content "C", its corresponding target cell is the cell with text content "A". The third cell "E" in the second row has a span of 1 column, and its target column in the second table is the third column. However, since the previous cell "C" of cell "E" has a span of 2 columns, the cell "D" in the first row that corresponds to cell "E" is in the target column. Therefore, for the current cell with text content "E", its corresponding target cell is the cell with text content "D".

[0062] Table 6

[0063] Optionally, the above steps determine whether to merge the current cell into the target cell based on the cell properties of the current cell and the cell properties of the target cell, including: if the number of spanned columns of the current cell is the same as the number of spanned columns of the target cell, determining to merge the current cell into the target cell.

[0064] For example, continuing with the parameters shown in Table 6 above, the number of columns spanned by the current cell "C" is 2, and the number of columns spanned by the corresponding target cell "A" is 1. The number of columns spanned by the current cell "C" and the target cell "A" are not the same, so the current cell "C" and the target cell "A" cannot be merged, and the text content of the current cell "C" cannot be merged into the target cell "A".

[0065] For example, continuing with the parameters shown in Table 6 above, the number of columns spanned by the current cell "E" is 1, and the number of columns spanned by the corresponding target cell "D" is 1. The number of columns spanned by the current cell "E" and the target cell "D" is the same, so the current cell "E" and the target cell "D" can be merged, that is, the text content of the current cell "E" is merged into the target cell "D".

[0066] S202: Convert the concatenated HTML text into a table format to obtain a concatenated table of the first table and the second table.

[0067] For example, continuing with the first table shown in Table 1 and the second table shown in Table 2, the spliced ​​HTML text obtained after splicing according to the corresponding splicing categories contains the following 27 lines, corresponding to the spliced ​​table shown in Table 7. Among them, lines 2-8 are the HTML corresponding to each cell in the first row of Table 7, lines 9-14 are the HTML corresponding to each cell in the second row of Table 7, lines 15-20 are the HTML corresponding to each cell in the third row of Table 7, and lines 21-26 are the HTML corresponding to each cell in the fourth row of Table 7.

[0068] \u5e8f\u53f7 \u8bc1\u5238\u4ee3\u7801 \u8bc1\u5238\u540d\u79f0 \u6570\u91cf(\u5f20) \u516c\u5141\u4ef7\u503c(\u5143) \u5360\u57fa\u91d1\u8d44\u4ea7\u51c0\u503c\u6bd4\uff08%\uff09 1 136393 \u745e\u65b031A1 150,000.00 14,995,500.00 0.80 2 - - - - - 3 - - - - - For example, the above-mentioned spliced ​​HTML text is converted into a table format, and multiple 、 Encapsulated into a table format, the concatenated table of the first and second tables is obtained as shown in Table 7 below: Table 7 after splicing

[0069] Based on this, in order to address the problems of table offset merging errors, poor accuracy and generalization in the prior art, this application performs layout detection on the file to be processed, removes headers and footers, and other pre-processing, and then uses a table recognition model to determine the splicing category based on the HTML text of the first and last table areas in the upper and lower pages corresponding to the cross-page table, and performs merging processing according to the determined splicing category, outputs the HTML text of the spliced ​​table, and then converts the HTML of the spliced ​​table into a table format to obtain a visually spliced ​​table. In this process, tables are merged based on HTML text. Since HTML text is not affected by the position information of the cells in the table, it will not be as prone to merging errors caused by the offset of the upper and lower tables as directly identifying and merging the tables. In addition, HTML is used to represent the table structure and content information, and the contextual information of the table structure and text content is taken into account. While ensuring the merging of the structure and cell content, the accuracy and rationality of the cross-page table merging are further improved.

[0070] Figure 6 The flowchart of the method for constructing a table recognition model provided by the embodiment of the present application is shown. Figure 6 As shown in the figure, the construction process of the table recognition model specifically includes the following steps: S601: Split a sample file into multiple adjacent page groups, and extract a sample table group from each adjacent page group.

[0071] Optionally, the sample file is a file containing text and tables, and the sample file can be, for example, a paginated file in PDF image format. The sample file is divided into multiple single pages by page, and the sample file is split into multiple adjacent page groups based on two adjacent pages. Each adjacent page group can be named in the format of {MD5_1}_{pg_up1}_{pg_down1}.jpg. MD5_1 is a unique string identifier obtained by hashing the content of the sample file, pg_up1 represents the page number of the previous page in the adjacent page group, and pg_down1 represents the page number of the next page in the adjacent page group.

[0072] Optionally, for each adjacent page group, a table structure recognition model is used to extract a sample table group from the adjacent page group, where the sample table group includes the last table on the previous page and the first table on the next page in the adjacent page group. Specifically, for the previous page and the next page in the adjacent page group, OCR technology is used to identify the text content in the page to obtain the position coordinates of the text content in the page, and the table structure recognition model is used to detect the table area of ​​the page to identify which areas in the page contain tables, thereby combining the position coordinates of the text content in the page identified based on OCR technology to extract the corresponding table from the page.

[0073] S602: Generate original text corresponding to each sample table group.

[0074] Optionally, the original text is a text in HTML format, and for each table in each sample table group, the original HTML text corresponding to each sample table group is generated respectively. The original HTML text includes: the HTML text corresponding to the last table of the previous page and the HTML text corresponding to the first table of the next page. Exemplarily, the tables contained in the extracted sample table group can be converted into text in HTML format according to the HTML table syntax, and the table data in the two-dimensional array format can be converted into the corresponding HTML string. The HTML table syntax is used to define and display structured two-dimensional data in a web page, mainly through

[0080]

[0081] Labels and their nested labels (e.g. OK, Header cells, You can also merge cells across columns and rows using colspan and rowspan, thus building complex and diverse table structures.

[0075] S603: Annotate the original text corresponding to each sample table group to obtain original sample data.

[0076] Optionally, based on the labelstudio annotation platform, refer to the category index corresponding to the different splicing categories shown in Table 8 below, and annotate the original text corresponding to each sample table group to obtain the original sample data, which includes: original text, splicing category and spliced ​​text.

[0077] Table 8 Schematic diagram of splicing category marking

[0078] Optionally, for each sample table group, the original text corresponding to the sample table group must be annotated with platform assistance to generate original sample data that can be used for subsequent model training or evaluation. Specifically, according to the category indexes (labels) corresponding to the three splicing categories defined in Table 8 above, based on the table structure in the sample table group, determine whether the sample table group is suitable for splicing and the corresponding splicing category, and then use the labeling interface provided by the labelstudio annotation platform to annotate the sample table group. This annotation interface supports displaying the original text of the two tables in the sample table group and provides three category indexes for selection. Based on this annotation interface, the user labels each sample table group in combination with the judgment annotations of the three types of splicing categories to obtain the category index corresponding to each sample table group.

[0079] Optionally, based on the category index annotated by the labelstudio annotation platform, the splicing category corresponding to each sample table group can be determined, and then the original text of the sample table group can be spliced ​​according to the splicing category corresponding to the sample table group. For example, if the sample table group includes the first table table1 and the second table table2, if the splicing category corresponding to the sample table group is non-splicing, then table1 and table2 will remain unchanged. If the splicing category corresponding to the sample table group is direct splicing, then the text in table2 will be directly spliced. The elements are directly added to table1 to form the merged text html merged_tab corresponding to the merged table. Elements are structural units in HTML, a The content represents the corresponding row in the table. If the splicing category corresponding to the sample table group is merge splicing, the content of the cell td in the first row of table2 is merged into the corresponding cell in the last row of table1, and the rowspan of the merged cells is adjusted. Specifically, if the number of cell tds in the last row of table1 is the same as that in the first row of table2, and if the colspan of the cell td at the corresponding position of the last row of table1 is equal to the colspan of the cell td at the corresponding position of the first row of table2, then the adjusted rowspan is n+m-1, otherwise it is n+m, where n represents the number of cells in the last row of table1, and m represents the number of cells in the first row of table2. If the colspan of the cell td at the corresponding position of the last row of table1 is greater than 1, then the cells in the first row of table2 within the corresponding column range are not merged. On this basis, the above process is repeated from the first cell after the column range of the last row of table1 to obtain the spliced ​​table and output the spliced ​​text. S604. Train a table recognition model based on the original sample data. Optionally, the original sample data includes the original text (table1 and table2), the spliced ​​category (label is 0, 1 or 2) and the spliced ​​text (merged_table). The original sample data is assembled into the JSON format required by the following training set: data_tmplate = {"table1": " A ", "table2": " B ", "merged_table": " A B ", "label": 1 } Among them, label represents the splicing category, such as 0 for non-splicing, 1 for direct splicing, and 2 for merge splicing. A and B in the json format are examples, where A represents the actual table content in table1 and B represents the actual table content in table2. The final data format is stored as a list, and the elements in the list are the above-mentioned json format text. It should be noted that the list here stores the data of the cross-page tables in the original file to be processed (that is, the two tables with the splicing categories of direct splicing and merge splicing). The text to be processed also includes some independent tables (that is, tables with the splicing category of non-splicing, and no merge relationship with other tables). On this basis, the data of each independent table is also stored in the above list to obtain a merged data set. At this time, the tables in the merged data set are independent of each other and cannot be merged.

[0082] Optionally, data augmentation is performed on the merged dataset using various methods, including non-joining, direct joining, and combined joining, to obtain multiple augmented samples, thereby enhancing the training set. A table recognition model is then trained on the augmented training set, significantly improving its accuracy and efficiency.

[0083] Based on this, according to the table recognition model training method provided in the embodiment of the present application, by extracting adjacent page groups from sample files and based on the sample combination of the last table on the previous page and the first table on the next page, training data close to the actual cross-page table recognition application scenario is constructed, so that the model has the ability to recognize the continuity relationship of tables across multiple pages. At the same time, during the training process, by manually annotating the original text and introducing structured sample data containing splicing categories and spliced ​​text, the model's understanding of table structure changes and semantic associations is enhanced, especially with the help of data enhancement methods, such as combining and splitting independent tables and spliced ​​tables to generate more diverse samples, further expanding the diversity of training data and improving the model's adaptability to different table layouts and merging methods, thereby significantly improving its performance in identifying and integrating multi-page cross-page tables in complex documents, and effectively improving the accuracy and generalization ability of the table recognition model in processing cross-page continuous table tasks.

[0084] As a possible implementation method, the above step S603 respectively marks the original text corresponding to each sample table group to obtain original sample data, including: obtaining the splicing category corresponding to the sample table group, splicing the original text according to the splicing category, and obtaining the spliced ​​text.

[0085] The splicing categories corresponding to the sample table group are shown in Table 8 above, including non-spliceable, direct splicing, and merge splicing.

[0086] Optionally, if the table structure indicated by the first HTML text corresponding to the first table in the sample table group is different from the table structure indicated by the second HTML text corresponding to the second table, and / or, text corresponding to the table header exists in both the first HTML text and the second HTML text, then the splicing category corresponding to the sample table group is determined to be non-splicable.

[0087] For example, if the first table in the sample table group has an independent header, and the first table has a table structure of five rows and three columns, the second table in the sample table group also has an independent header, but the second table has a table structure of three rows and four columns. Accordingly, although the text corresponding to the header exists in the first HTML text corresponding to the first table and the second HTML text corresponding to the second table, the table structure indicated by the first HTML text corresponding to the first table is different from the table structure indicated by the second HTML text corresponding to the second table, so it can also be determined that the splicing category of the first HTML text corresponding to the first table and the second HTML text corresponding to the second table is non-splicable. In other words, when the first table and the second table are both independent tables, the splicing category of the first table and the second table is non-splicable.

[0088] Optionally, if the last row of the first HTML text corresponding to the first table in the sample table group matches the cells of the first row of the second HTML text corresponding to the second table, the splicing category corresponding to the sample table group is determined to be direct splicing, wherein the cell matching includes: the number of cells is the same, and the cells in the last row correspond one-to-one with the cells in the first row.

[0089] For example, if the first table in the sample table group has an independent header and the number of cells in the last row of the first table is 5, and the second table in the sample table group does not have an independent header and the number of cells in the first row of the second table is also 5, and the cells in the last row of the first table correspond one-to-one with the cells in the first row of the second table, that is, the number of columns spanned by the corresponding cells is the same, both 1. Accordingly, that is, the cells in the last row of the first HTML text corresponding to the first table match the cells in the first row of the second HTML text corresponding to the second table, then the splicing category of the first HTML text corresponding to the first table and the second HTML text corresponding to the second table is determined to be direct splicing.

[0090] Accordingly, if the splicing category corresponding to the sample table group is direct splicing, the text of each cell in the first row of the second HTML text is sequentially merged into the corresponding cell in the last row of the first HTML text to obtain and output the spliced ​​HTML text. In other words, if the splicing category of the first and second tables in the sample table group is direct splicing, it is determined that the first and second tables can be seamlessly connected, that is, the second table is directly connected to the first table to form a complete table.

[0091] Optionally, if the last row of the first HTML text corresponding to the first table in the sample table group does not match the cells of the first row of the second HTML text corresponding to the second table in the sample table group, the splicing category corresponding to the sample table group is determined to be merge splicing.

[0092] For example, if the first table in the sample table group has an independent header and the number of cells in the last row of the first table is 6, and the second table does not have an independent header and the number of cells in the first row of the second table is also 6, but there is a cell with a span of 2 rows, which occupies the last row of the first table and the first row of the second table, while the span of the remaining cells is 1, which only occupies the last row of the first table, then it is determined that the cells in the last row of the first table do not match the cells in the first row of the second table. Correspondingly, that is, the cells in the last row of the first HTML text do not match the cells in the first row of the second HTML text, then the splicing category of the first HTML text corresponding to the first table and the second HTML text corresponding to the second table is determined to be merge splicing.

[0093] Correspondingly, if the splicing category corresponding to the sample table group is merge splicing, the last row and the first row are spliced ​​according to the cell attributes of each cell in the last row of the first HTML text and the cell attributes of each cell in the first row of the second HTML text to obtain and output the spliced ​​HTML text.

[0094] For example, in the first HTML text and the second HTML text, each cell Or the header cells all have cell attributes such as rowspan and colspan. When the splicing category of the first HTML text and the second HTML text is merge splicing, the last row of the first HTML text and the first row of the second HTML text are extracted respectively, and each cell in the last row of the first HTML text and the first row of the second HTML text are parsed to obtain the cell attributes of each cell. Based on the cell attributes of each cell in the last row and the first row, a new table structure is constructed, and the spliced ​​HTML text is output.

[0095] Specifically, each cell in the first row of the second HTML text is traversed, and for the current cell traversed, the target cell corresponding to the current cell in the last row of the first HTML text is determined, and according to the cell attributes of the current cell and the cell attributes of the target cell, it is determined whether to merge the current cell into the target cell. If so, the text of the current cell is merged into the target cell, and the number of rows spanned by the target cell is adjusted. The target cell is a cell in the last row of the first HTML text that is in the target column in the table where the current cell is located. The process of determining whether to merge the current cell into the target cell includes: if the number of columns spanned by the current cell is the same as the number of columns spanned by the target cell, then determining to merge the current cell into the target cell.

[0096] Based on this, by combining HTML structural information with table splicing logic analysis, we can achieve accurate identification of cross-page table splicing categories and structured generation of the spliced ​​tables. Specifically, we use the rich semantic information such as row and column structure and cell attributes (such as rowspan and colspan) contained in the HTML text corresponding to the table to determine whether the tables on two adjacent pages can be spliced, and further subdivide them into three categories: non-splicing, direct splicing, and merged splicing, so as to more accurately reflect the complex layout and cross-page continuity relationship of tables in real documents. During the splicing process, not only the matching of the number of cells and content is considered, but also the correspondence between cell attributes is deeply analyzed to ensure that the spliced ​​tables are consistent in structure and semantically coherent. In this way, the problems of broken tables and inconsistent structures in multi-page documents are effectively solved, and the robustness and practicality of the table recognition model in actual application scenarios are improved, especially its ability to understand and integrate complex table structures is enhanced.

[0097] Figure 7 FIG2 shows a flow chart of another table recognition model training method provided by an embodiment of the present application. Figure 7 As shown, the above step S604 trains a table recognition model based on the original sample data, which specifically includes the following steps: S701, obtain independent tables from the original file, and generate texts of the independent tables.

[0098] Optionally, the independent table refers to a table that can be extracted from the original file independently, and the table has complete structure and clear boundary, that is, the table is a table that has a non-splicing splicing category in the original file, and the independent table has no merging relationship with the remaining tables in the original file. The table content of each independent table is extracted from the original file by an OCR technology, and the table content of each independent table is structured, the row and column information is retained, the table content of the independent table is converted into a uniform HTML format string, and the HTML text of each independent table is generated.

[0099] S702, combine all spliced tables in the original sample data and all independent tables into a text set.

[0100] Optionally, the original sample data includes a labeled splicing category, an original text, and a spliced text of a spliced table, and the independent table is a single table extracted from the original file. All spliced tables in the original sample data and the independent tables in the original file are combined, so that a large text set is generated based on the spliced HTML text of all spliced tables and the HTML text of all independent tables, and the text set is used as a data source for training data augmentation.

[0101] S703, split at least one augmented text in the text set to obtain at least one augmented sample data.

[0102] Optionally, the augmented text refers to a table text selected from the text set and subjected to change processing, and the purpose is to increase data diversity. Splitting refers to splitting a complete table corresponding to the augmented text into two or more sub-tables according to a certain splitting strategy, so as to generate new augmented sample data for supplementing training data and improving the generalization ability of the table recognition model. The augmented sample data includes the augmented text as the spliced text, the first split text, the second split text, and the splicing category.

[0103] Optionally, splitting at least one augmented text in the text set to obtain at least one augmented sample data includes: randomly selecting a first to-be-split text from the text set, splitting the first to-be-split text into two texts at a target action boundary in the first to-be-split text, taking the two split texts as the first split text and the second split text respectively, and determining the splicing category as direct splicing.

[0104] Exemplarily, a table table with a splicing category of direct splicing is randomly selected from a text set, and the first text to be split corresponding to the table table is obtained, and the target row tr in the first text to be split is randomly selected as the boundary for splitting. Specifically, with the target row tr as the boundary, the first text to be split is split into two texts, upper and lower, and the two texts obtained by splitting are respectively used as the first split text and the second split text. For example, the original table table with a splicing category of direct splicing is a table obtained by directly splicing a first table table1 with three rows and a second table table2 with four rows. At this time, the second row in the table table can be split as the target row, and the table table is split into a first table table1 with two rows and a second table table2 with five rows, and the HTML text corresponding to the first table table1 with two rows is used as the first split text, and the HTML text corresponding to the second table table2 with five rows is used as the second split text, and it is determined that the splicing category of the first table table1 with two rows and the second table table2 with five rows is direct splicing.

[0105] Optionally, at least one enhanced text in a text set is split to obtain at least one enhanced sample data, including: randomly selecting a second text to be split from the text set, traversing each cell in a target row of the second text to be split, and for the current cell traversed, if the content length of the current cell is greater than a preset length, splitting the content text of the current cell into two cells to obtain a first split text and the second split text, and determining the splicing category as merge splicing.

[0106] Exemplarily, a table table whose splicing category is merge splicing is randomly selected from the text set, and the second text to be split corresponding to the table table is obtained, and a target row tr is randomly selected from the second text to be split for splitting. Specifically, for each cell in the target row of the second text to be split, for the current cell traversed, if the content length of the current cell is greater than a preset length, the preset length is, for example, 5, then the content text of the current cell is split into two cells, and the number of rows spanned by the current cell is adjusted. Among them, the two cells after splitting are one in the last row of the first table table1 and the other in the first row of the second table table2.

[0107] Specifically, taking the first table shown in Table 5.1, the second table shown in Table 5.2, and the spliced ​​table shown in Table 5.3 as examples, the spliced ​​table table with the splicing category of merge and splicing is selected from the text set, and the first row of the spliced ​​table table shown in Table 5.3 is taken as the target row, and each cell in the target row is traversed to determine the content length of each cell. For example, the content length of the cell "Serial Number" is 2, the content length of the cell "Stock Code" is 4, the content length of the cell "Stock Name" is 4, the content length of the cell "Quantity (Shares)" is 3, and the content length of the cell "Fair Value (Yuan)" is 5. The content lengths of these cells are all less than or equal to the preset length of 5 and do not exceed the preset length of 5. The content length of the cell "Proportion of Net Asset Value of Fund (%)" is 10, so the content text of the cell "Proportion of Net Asset Value of Fund (%)" can be divided into two cells. It should be noted here that the original content of the cell "Proportion of net asset value of the fund (%)" was split and spliced ​​according to "Proportion of net asset value of the fund (%)" and "Proportion of value (%)". In order to achieve data enhancement here, the content text of the cell "Proportion of net asset value of the fund (%)" can be split according to the splitting method, or according to the splitting method of "Proportion of net asset value of the fund (%)" and "Proportion (%)". The content text of the cell "Proportion of net asset value of the fund (%)" is split into two cells to obtain a new first row and last row, and the HTML text corresponding to the new first row is used as the first split text, and the HTML text corresponding to the new last row is used as the second split text, and the table splicing category is determined to be merge splicing.

[0108] S704: Train a table recognition model based on the original sample data and the enhanced sample data.

[0109] Optionally, based on a training data set obtained by combining the original sample data and the enhanced sample data, the first table table, the second table table2, the spliced ​​table merged_table and the splicing category label are selected from the training data set to construct the input sequence and the target sequence respectively, and then the model is trained according to the input sequence and the output sequence to obtain a table recognition model.

[0110] Exemplarily, the format of the input sequence is: input_seq=f''[CLASS]{examples['table1'][i]}[SEP]{examples['table2'][i]}[SEP]'', where table1 represents the first HTML text, table2 represents the second HTML text, [CLS] represents the starting tag, which is used for classification tasks, and [SEP] represents a separator, which is used to distinguish the contents of different tables. Exemplarily, the format of the target sequence is: target_seq= f''[CLASS]{examples['lable1'][i]}[SEP]{examples['merged_table'][i]}'', where lable1 represents the splicing category, merged_table represents the spliced ​​table, [CLS] represents the starting position of the category label, and [SEP] represents a separator, which is used to distinguish the contents of different tables. It should be noted that for the same cross-page table, the input sequence and the target sequence exist in pairs.

[0111] For example, referring to Figure 8 As shown, the table recognition model is, for example, a T5 model, which includes an encoder (T5-Encoder), a decoder (T5-Decoder), and a classification prediction head (ClassificationHead). On this basis, an input sequence {"table1":" A ”,"table2”:" B ”}, the decoder (T5-Decoder) outputs an output sequence {"merged_table":" A B }", as well as the splicing category label and probability score output by the classification prediction head (ClassificationHead), the difference between the output sequence and the target sequence is determined based on the output sequence output by the decoder (T5-Decoder) and the splicing category label and probability score output by the classification prediction head (ClassificationHead). The model parameters of the table recognition model are continuously adjusted based on the difference between the output sequence and the target sequence, and the final table recognition model is obtained through iterative training. Among them, in addition to the T5 model with the encoder-decoder model architecture shown above, the table recognition model can also adopt language models such as Qwen, GPT, and DeepSeek. Based on this, more diverse samples are generated by combining and splitting independent tables and spliced ​​tables, thereby expanding the diversity of training data through data augmentation and improving the adaptability of the table recognition model to different table layouts and merging methods.

[0112] Based on the same inventive concept, the application also provides a table recognition device corresponding to the table recognition method. Since the table recognition device solves problems in the same principle as the table recognition method described above, the implementation of the table recognition device can refer to the implementation of the table recognition method, and the repeated parts will not be described here.

[0113] Referring to Figure 9 As shown in FIG. 9, a table recognition device 900 provided by the application is shown in the structural schematic diagram, the table recognition device 900 comprises an extraction module 901, a generation module 902 and an identification module 903, wherein: the extraction module 901 is used for acquiring adjacent first and second pages, extracting a first table from the first page, and extracting a second table from the second page, wherein the first table is the last table in the first page, and the second table is the first table in the second page; the generation module 902 is used for generating a first HTML text corresponding to the first table and a second HTML text corresponding to the second table; the identification module 903 is used for inputting the first HTML text and the second HTML text into a pre-trained table recognition model, and the table recognition model is used for splicing the first HTML text and the second HTML text according to the cell information in the first HTML text and the cell information in the second HTML text, to obtain a spliced table of the first table and the second table.

[0114] Therefore, according to the table recognition device of the application, the last table and the first table are extracted from the adjacent pages (the first page and the second page) respectively, and are converted into structured HTML format text, so that the key semantic information such as the row-column structure, the cell content and the merging relationship of the table is retained. Compared with the pure text or image form of the table, the HTML format text can more accurately describe the complex table layout, and provide reliable structure basis for subsequent splicing judgment. Then the HTML texts of the two tables are input into the pre-trained table recognition model, the table recognition model automatically analyzes the cell matching relationship and the splicing type of the two tables, and finally generates a unified spliced table. In this way, the continuity and consistency of the multi-page table in structure and content are improved, and a feasible path is provided for realizing the intelligent recognition and integration of the continuous table in the document.

[0115] In one possible implementation, the identification module 903 is specifically used to: determine the splicing category of the first HTML text and the second HTML text based on the cell information in the first HTML text and the cell information in the second HTML text, and splice the first HTML text and the second HTML text according to the splicing category to obtain and output the spliced ​​HTML text; convert the spliced ​​HTML text into a table format to obtain a spliced ​​table of the first table and the second table.

[0116] In one possible implementation, the identification module 903 is specifically configured to: determine that the splicing category is non-splicing if the table structure indicated by the first HTML text is different from the table structure indicated by the second HTML text, and / or that text corresponding to the table header exists in both the first HTML text and the second HTML text; determine that the splicing category is direct splicing if the cells of the last row of the first HTML text match the cells of the first row of the second HTML text, and the cell matching includes: the number of cells is the same, and the cells in the last row correspond one-to-one with the cells in the first row; determine that the splicing category is merge splicing if the cells of the last row of the first HTML text do not match the cells of the first row of the second HTML text.

[0117] In one possible implementation, the identification module 903 is specifically used to: if the splicing category is direct splicing, then the text of each cell in the first row of the second HTML text is merged into the corresponding cell in the last row of the first HTML text in sequence to obtain and output the spliced ​​HTML text; if the splicing category is merge splicing, then according to the cell attributes of each cell in the last row of the first HTML text and the cell attributes of each cell in the first row of the second HTML text, the last row and the first row are spliced ​​to obtain and output the spliced ​​HTML text.

[0118] In one possible implementation, the identification module 903 is specifically used to: traverse each cell in the first row of the second HTML text, and for the current cell traversed, determine the target cell corresponding to the current cell in the last row of the first HTML text, and determine whether to merge the current cell into the target cell based on the cell properties of the current cell and the cell properties of the target cell; if so, merge the text of the current cell into the target cell and adjust the number of rows spanned by the target cell.

[0119] In a possible implementation, the identification module 903 is specifically configured to: determine the target column where the current cell is located in the table; and use the cell in the target column in the last row of the first HTML text as the target cell.

[0120] In a possible implementation, the identification module 903 is specifically configured to: if the number of spanned columns of the current cell is the same as the number of spanned columns of the target cell, determine to merge the current cell into the target cell.

[0121] In one possible embodiment, the table recognition device further includes a training module, which is specifically used to: split a plurality of adjacent page groups from a sample file, and extract a sample table group from each adjacent page group, wherein the sample table group includes the last table of the previous page and the first table of the next page in the adjacent pages; generate original texts corresponding to each sample table group, wherein the original texts include: the text corresponding to the last table of the previous page and the text corresponding to the first table of the next page; mark the original texts corresponding to each sample table group to obtain original sample data, wherein the original sample data includes: original text, splicing category and spliced ​​text; and train a table recognition model based on the original sample data.

[0122] In a possible implementation, the training module is specifically configured to: obtain the splicing category corresponding to the sample table group; and perform splicing processing on the original text according to the splicing category to obtain the spliced ​​text.

[0123] In one possible implementation, the above-mentioned training module is specifically used to: obtain independent tables from the original file and generate text for each independent table; combine all spliced ​​tables in the original sample data and all independent tables into a text set; split at least one enhanced text in the text set to obtain at least one enhanced sample data, and the enhanced sample data includes: enhanced text as spliced ​​text, first split text, second split text and splicing category; and train a table recognition model based on the original sample data and the enhanced sample data.

[0124] In one possible implementation, the above-mentioned training module is specifically used to: randomly select a first text to be split from a text collection; split the first text to be split into two texts based on the target behavior in the first text to be split as the boundary, and use the two split texts as the first split text and the second split text respectively, and determine the splicing category as direct splicing.

[0125] In one possible implementation, the above-mentioned training module is specifically used to: randomly select a second text to be split from a text collection; traverse each cell in the target row of the second text to be split, and for the current cell traversed, if the content length of the current cell is greater than a preset length, split the content text of the current cell into two cells to obtain a first split text and a second split text, and determine the splicing category as merge splicing.

[0126] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference can be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0127] The embodiment of the present application also provides an electronic device 1000, such as Figure 10 1 is a schematic diagram of the structure of an electronic device 1000 provided in an embodiment of the present application, comprising: a processor 1001, a memory 1002, and optionally, a bus 1003. The memory 1002 stores machine-readable instructions executable by the processor 1001. When the electronic device 1000 is running, the processor 1001 communicates with the memory 1002 via the bus 1003. When the machine-readable instructions are executed by the processor 1001, the steps of the table recognition method described in any one of the above items are performed.

[0128] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the table recognition method described in any one of the above items are executed.

[0129] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0130] In addition, the functional units in the various embodiments of the present application can be integrated into a single processing unit, each unit can exist physically separately, or two or more units can be integrated into a single unit. If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion 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 for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in the various embodiments of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0131] The above is only a specific implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this application, which should be covered by the protection scope of the present application.

Claims

1. A table recognition method, characterized in that: include: Obtaining a first and a second adjacent page, extracting a first table from the first page, and extracting a second table from the second page, wherein the first table is the last table in the first page, and the second table is the first table in the second page; Generate a first Hypertext Markup Language HTML text corresponding to the first table and a second HTML text corresponding to the second table; The first HTML text and the second HTML text are input into a pre-trained table recognition model. The table recognition model splices the first HTML text and the second HTML text based on the cell information in the first HTML text and the cell information in the second HTML text to obtain a spliced ​​table of the first table and the second table.

2. The method according to claim 1, characterized in that The step of splicing the first HTML text and the second HTML text according to the cell information in the first HTML text and the cell information in the second HTML text to obtain a spliced ​​table of the first table and the second table includes: Determining a splicing category of the first HTML text and the second HTML text based on the cell information in the first HTML text and the cell information in the second HTML text, and splicing the first HTML text and the second HTML text based on the splicing category to obtain and output a spliced ​​HTML text; The concatenated HTML text is converted into a table format to obtain a concatenated table of the first table and the second table.

3. The method according to claim 2, characterized in that The determining, based on the cell information in the first HTML text and the cell information in the second HTML text, a splicing category of the first HTML text and the second HTML text includes: If the table structure indicated by the first HTML text is different from the table structure indicated by the second HTML text, and / or text corresponding to the table header exists in both the first HTML text and the second HTML text, determining that the splicing category is non-splicing; If the cells of the last row of the first HTML text match the cells of the first row of the second HTML text, then the splicing category is determined to be direct splicing, and the cell matching includes: the number of cells is the same, and the cells in the last row correspond to the cells in the first row one by one; If the cells of the last row of the first HTML text do not match the cells of the first row of the second HTML text, the splicing category is determined to be merge splicing.

4. The method according to claim 2, characterized in that The step of splicing the first HTML text and the second HTML text according to the splicing category to obtain and output a spliced ​​HTML text includes: If the splicing type is direct splicing, the text of each cell in the first row of the second HTML text is sequentially merged into the corresponding cell in the last row of the first HTML text to obtain and output the spliced ​​HTML text; If the splicing category is merge splicing, the last row and the first row are spliced ​​according to the cell attributes of each cell in the last row of the first HTML text and the cell attributes of each cell in the first row of the second HTML text to obtain and output the spliced ​​HTML text.

5. The method according to claim 4, characterized in that The step of splicing the last row and the first row of the second HTML text according to the cell attributes of each cell in the last row of the first HTML text and the cell attributes of each cell in the first row of the second HTML text to obtain and output the spliced ​​HTML text includes: Traverse each cell in the first row of the second HTML text, and for the current cell traversed, determine the target cell corresponding to the current cell in the last row of the first HTML text, and determine whether to merge the current cell into the target cell based on the cell attributes of the current cell and the cell attributes of the target cell. If so, merge the text of the current cell into the target cell and adjust the number of rows spanned by the target cell.

6. The method according to claim 5, characterized in that The step of determining a target cell corresponding to the current cell in the last row of the first HTML text includes: Determine the target column where the current cell is located in the table; The cell in the target column in the last row of the first HTML text is used as the target cell.

7. The method according to claim 5, characterized in that The determining whether to merge the current cell into the target cell according to the cell attributes of the current cell and the cell attributes of the target cell includes: If the number of columns spanned by the current cell is the same as the number of columns spanned by the target cell, it is determined to merge the current cell into the target cell.

8. The method according to any one of claims 1 to 7, characterized in that The process of constructing the table recognition model includes: Splitting a plurality of adjacent page groups from a sample file, and extracting a sample table group from each adjacent page group, wherein the sample table group includes the last table of the previous page and the first table of the next page among the adjacent pages; Generating original texts corresponding to each sample table group respectively, the original texts including: text corresponding to the last table on the previous page and text corresponding to the first table on the next page; Marking the original text corresponding to each sample table group respectively to obtain original sample data, wherein the original sample data includes: the original text, the splicing category and the spliced ​​text; The table recognition model is trained based on the original sample data.

9. The method according to claim 8, characterized in that The original text corresponding to each sample table group is marked to obtain original sample data, including: Obtaining the splicing category corresponding to the sample table group; The original text is spliced ​​according to the splicing category to obtain the spliced ​​text.

10. The method according to claim 8, characterized in that The step of training the table recognition model based on the original sample data includes: Obtaining independent tables from the original document and generating text for each of the independent tables; Combining all the concatenated tables and all the independent tables in the original sample data into a text set; Splitting at least one enhanced text in the text set to obtain at least one enhanced sample data, wherein the enhanced sample data includes: the enhanced text as a spliced ​​text, the first split text, the second split text, and the splicing category; The table recognition model is trained based on the original sample data and the enhanced sample data.

11. The method according to claim 10, characterized in that The step of splitting at least one enhanced text in the text set to obtain at least one enhanced sample data includes: Randomly selecting a first text to be split from the text set; The first to-be-split text is split into two texts using a target line in the first to-be-split text as a boundary. The two split texts are respectively used as the first split text and the second split text, and the splicing category is determined to be direct splicing.

12. The method according to claim 10, characterized in that The step of splitting at least one enhanced text in the text set to obtain at least one enhanced sample data includes: Randomly selecting a second text to be split from the text set; Traverse each cell in the target row of the second text to be split, and for the current cell traversed, if the content length of the current cell is greater than a preset length, split the content text of the current cell into two cells to obtain the first split text and the second split text, and determine the splicing category as merge splicing.

13. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the steps of the table recognition method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Table recognition method, model training method and device, and equipment

    CN113536874A

  • PDF (Portable Document Format) document cross-page table merging method and device and related equipment

    CN114036909A

  • PDF (Portable Document Format) file table analysis method

    CN120104577A