Cross-page table extraction method, device and equipment

By extracting features and calculating association strength for tables that span multiple pages, and merging table areas into the target format, we solved the problems of missing table headers and interrupted content continuity when processing tables that span multiple pages in large language models, and generated standardized table codes that can directly interact with the system.

CN120633615APending Publication Date: 2025-09-12INNER MONGOLIA ELECTRIC POWER SURVEY & DESIGN INST
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510748090.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-06
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

When processing cross-page tables, existing large language models have problems such as missing table headers and insufficient cross-page semantic association analysis, which leads to interrupted content continuity, and the extracted tables cannot interact directly with the system.

Method used

The method obtains the file to be processed, performs preprocessing and structure recognition, extracts feature data of the table area, calculates the association strength value, merges the cross-page table area into table data in the target format, and generates standardized structured codes.

Benefits of technology

The continuity analysis and reconstruction of cross-page tables were realized, the problems of missing table headers and interrupted content continuity were solved, and standardized table codes that can directly interact with large models were generated.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120633615A_ABST
    Figure CN120633615A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a cross-page table extraction method, device and equipment, and relates to the technical field of data processing.The method comprises the steps that a to-be-processed file is obtained, the to-be-processed file is preprocessed, and a plurality of table areas are obtained; and carrying out structure identification and feature extraction on the plurality of table regions, calculating association strength values, and merging the table regions in the to-be-selected cross-page table groups into table data in a target format according to the association strength value of the table region in each to-be-selected cross-page table group. According to the scheme, the combined table is output in the target format, so that the table can be directly used for interacting with a large model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a method, device and equipment for extracting a cross-page table. Background Art

[0002] In recent years, with the rapid development of large language models, natural language processing technology has achieved significant breakthroughs in document understanding. Through pre-training on massive amounts of text, large language models have acquired preliminary capabilities for understanding document content, such as answering questions based on document content and generating simple document summaries. However, existing large language models still face the following challenges when processing complex documents with tables (especially scanned documents):

[0003] 1. There is a lack of fine-grained awareness of the physical layout of tables (such as cell merging and row and column alignment). When handling tables that span multiple pages (common in financial statements and academic papers), the header on the second page is missing, resulting in the loss of key semantic tags in tables on subsequent pages. There is also a lack of cross-page semantic association analysis, resulting in interruptions in content continuity (such as misaligned numerical sequences).

[0004] 2. The processed document information does not directly generate standardized structured code (such as HTML), which makes it impossible to directly interact with the large language model system. Summary of the Invention

[0005] The technical problem to be solved by the present invention is to provide a method for extracting cross-page tables, which is used to solve the following problems in processing cross-page tables (common in financial statements and academic papers): the header of the second page is missing, resulting in the loss of key semantic tags in the tables on subsequent pages, lack of cross-page semantic association analysis, and interruption of content continuity (such as misalignment of numerical sequences); the extracted cross-page tables cannot directly interact with the large model system.

[0006] In order to solve the above technical problems, the technical solutions of the present invention are as follows:

[0007] In a first aspect, an embodiment of the present invention provides a method for extracting a cross-page table, comprising:

[0008] Obtaining a file to be processed, wherein the file to be processed includes a spreadsheet;

[0009] Preprocessing the file to be processed to obtain multiple table areas;

[0010] Performing structural recognition on the plurality of table areas to obtain at least one table group to be selected across pages, wherein the table group to be selected across pages includes the table areas to be merged;

[0011] Performing feature extraction on the table area in each of the to-be-selected spread-page table groups to obtain feature data corresponding to each of the to-be-selected spread-page table groups;

[0012] Determine, according to the characteristic data, the association strength value of the table area in each of the to-be-selected cross-page table groups;

[0013] According to the association strength value of the table area in each of the to-be-selected cross-page table groups, the table areas in the to-be-selected cross-page table group are merged into table data of the target format.

[0014] Furthermore, the to-be-processed file is pre-processed to obtain multiple table areas, including:

[0015] Processing the file to be processed to obtain a plurality of first images, each first image corresponding to the content of a page in the file to be processed, and the plurality of first images are continuous;

[0016] performing binarization and perspective correction processing on each first image in sequence to obtain a plurality of second images, each second image corresponding to the content of a page in the file to be processed, and the plurality of second images are continuous;

[0017] Table detection is performed on the plurality of second images to obtain a plurality of table areas.

[0018] Furthermore, structural recognition is performed on the multiple table areas to obtain at least one cross-page table group to be selected, including:

[0019] Performing structural recognition on the plurality of table areas to obtain an information list of the plurality of table areas;

[0020] At least one cross-page table group to be selected is determined according to the information list.

[0021] Furthermore, the information list includes coordinates of each table area;

[0022] Determining at least one to-be-selected cross-page table group according to the information list includes:

[0023] determining at least one image group, each image group including a plurality of consecutive second images having a table area;

[0024] For each image group, determining the coordinates of the table area in each second image in the image group and the page height of each second image according to the information list;

[0025] The coordinates of the table area of ​​each second image are compared with the page height of each second image, and the table area in the image group is determined as a cross-page table group to be selected according to the comparison result.

[0026] Furthermore, feature extraction is performed on the table area in each of the to-be-selected spread-table groups to obtain feature data corresponding to each of the to-be-selected spread-table groups, including:

[0027] For each to-be-selected spread-page table group, calculating the maximum offset of the table area in the to-be-selected spread-page table group in the x-direction, and obtaining corresponding first feature data;

[0028] Calculating a sentence vector for the content in the table area of ​​the to-be-selected cross-page table group, and determining second feature data based on the sentence vector;

[0029] A digital sequence of content in a table area in the to-be-selected cross-page table group is detected, and third feature data is determined according to the digital sequence.

[0030] Furthermore, determining the association strength value of the table area in each of the to-be-selected cross-page table groups according to the characteristic data includes:

[0031] For each of the to-be-selected spread-page table groups, performing weighted summation on the first feature data, the second feature data, and the third feature data according to a preset weight, to obtain a correlation strength value of the table area in each of the to-be-selected spread-page table groups;

[0032] Merging the table areas in the to-be-selected spread-page table group into table data in a target format according to the association strength values ​​of the table areas in each to-be-selected spread-page table group includes:

[0033] Each of the association strength values ​​is compared with a preset value. If the association strength value is greater than the preset value, the table areas in the to-be-selected cross-page table group corresponding to the association strength value are merged into table data in a target format.

[0034] Furthermore, the method further comprises:

[0035] A page-spanning identifier in the to-be-processed file is identified, and the page-spanning tables contained in the to-be-processed file are merged into table data in a target format according to the page-spanning identifier.

[0036] Furthermore, merging the table areas in the to-be-selected spread-page table group into table data in a target format includes:

[0037] Perform semantic mapping on the table area in the selected cross-page table group to obtain table data in the target format.

[0038] In a second aspect, an embodiment of the present invention further provides a device for extracting a cross-page table, comprising:

[0039] An acquisition module is used to acquire a file to be processed, wherein the file to be processed includes a cross-page table;

[0040] A first processing module is used to pre-process the file to be processed to obtain multiple table areas;

[0041] A second processing module is configured to perform structural recognition on the plurality of table areas to obtain at least one table group to be selected across pages, wherein the table group to be selected across pages includes the table areas to be merged;

[0042] A third processing module is used to extract features from the table area in each of the to-be-selected spread-page table groups to obtain feature data corresponding to each of the to-be-selected spread-page table groups;

[0043] A fourth processing module is configured to determine, based on the feature data, a correlation strength value of a table region in each of the to-be-selected cross-page table groups;

[0044] The fifth processing module is configured to merge the table areas in the to-be-selected spread-page table group into table data in a target format according to the association strength values ​​of the table areas in each to-be-selected spread-page table group.

[0045] In a third aspect, an embodiment of the present invention further provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the cross-page table extraction method as described in the first aspect are implemented.

[0046] The above solution of the present invention includes at least the following beneficial effects:

[0047] The above solution of the present invention pre-processes the file to be processed to retain the information of the original image to the greatest extent. Structural recognition, feature extraction, and calculation of correlation strength values ​​are performed on the multiple table areas to achieve continuity analysis and reconstruction of cross-page tables. This solves the problems of missing headers and interrupted content continuity by merging the table areas in the selected cross-page table group into table data in the target format and generating standardized table code that can be used for direct interaction with large models. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 It is a schematic flow chart of an embodiment of the present invention;

[0049] Figure 2 、 3 , 4, and 5 are schematic diagrams of pages containing a table that spans two pages;

[0050] Figure 6 、 7 It is a schematic diagram of the coordinates of two consecutive spread tables;

[0051] Figure 8 is a flow chart of another embodiment;

[0052] Figure 9 is a schematic diagram of an apparatus according to an embodiment of the present invention;

[0053] Figure 10It is a schematic structural diagram of an electronic device embodiment of the present invention. DETAILED DESCRIPTION

[0054] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0055] like Figure 1 As shown, an embodiment of the present invention provides an embodiment of a method for extracting a cross-page table, comprising:

[0056] Step 11, obtaining a file to be processed, wherein the file to be processed includes a cross-page table;

[0057] Step 12: pre-processing the file to be processed to obtain multiple table areas;

[0058] Step 13: performing structural recognition on the plurality of table areas to obtain at least one table group to be selected across pages, wherein the table group to be selected across pages includes the table area to be merged;

[0059] Step 14: extracting features from the table area in each of the to-be-selected spread-page table groups to obtain feature data corresponding to each of the to-be-selected spread-page table groups;

[0060] Step 15, determining the association strength value of the table area in each of the to-be-selected cross-page table groups according to the feature data;

[0061] Step 16: Merge the table areas in the to-be-selected spread-page table group into table data in a target format according to the association strength values ​​of the table areas in each to-be-selected spread-page table group.

[0062] As an example, the file to be processed may be obtained by receiving user input; because files containing cross-page tables are common in financial statements and academic papers, the file to be processed may also be obtained from a related file library.

[0063] In this embodiment, when obtaining the file to be processed, it is necessary to determine the file format of the file to be processed. If the file to be processed is in PDF format, the PyPDF2 tool can be used to read the pages in the file to be processed as input. PyPDF2 is a pure Python PDF tool library that can be used to read, split, merge, crop and convert PDF files. If the file to be processed is in image format, the Pillow library can be used to directly read the image of the file to be processed. The Pillow library is Python's most popular image processing library and is a friendly branch of the Python Imaging Library (PIL). It provides a wide range of image processing functions and supports multiple image formats. If the file to be processed is in other formats, the file to be processed can be scanned first to obtain the file to be processed in PDF format or image format.

[0064] The file to be processed is pre-processed to obtain multiple table areas in order to detect and locate the positions of all tables in the file to be processed. The tables identified here include tables that span pages and tables that do not span pages. Therefore, after determining the position of each table, two rounds of screening are required to select the tables that span pages:

[0065] In the first round of screening, the structure of each table is identified to identify the tables that may span pages, that is, to obtain a group of tables to be selected that span pages. Each group of tables to be selected that span pages includes multiple table areas to be merged.

[0066] In the second round of screening, it is necessary to extract features from the table areas in the to-be-selected cross-page table group, and then determine the association strength values ​​of the table areas. The table areas in the to-be-selected cross-page table group are merged based on the association strength values.

[0067] Because the output of existing table recognition models (such as Table-Transformer) is a set of cell scores, labels, boxes, and row-column relationships, it does not directly generate standardized structured code (such as HTML). Direct interaction with large model systems is not possible. Therefore, when merging table areas in a group of tables to be selected across multiple pages, this embodiment merges the table areas in the W3C standard HTML code format.

[0068] In an optional embodiment of the present invention, step 12 includes:

[0069] Step 121: Process the file to be processed to obtain a plurality of first images, each of which corresponds to the content of a page in the file to be processed, and the plurality of first images are continuous;

[0070] Step 122 , performing binarization and perspective correction processing on each first image in sequence to obtain a plurality of second images, each second image corresponding to the content of a page in the file to be processed, and the plurality of second images are continuous;

[0071] Step 123 : Perform table detection on the plurality of second images to obtain a plurality of table areas.

[0072] In this embodiment, the to-be-processed file is processed to obtain a plurality of first images in order to uniformly convert the to-be-processed file into a continuous image format. For this process, reference may be made to the relevant description of the above embodiment.

[0073] As an example, for each first image, a local adaptive binarization algorithm can be used to perform binarization processing: the threshold of each area in the first image is dynamically calculated through a sliding window (128×128 pixels):

[0074]

[0075] Where T(x, y) is the enhanced pixel value (or adjusted parameter). μ is the local mean (usually the average pixel value within a neighborhood window), σ is the local standard deviation (a measure of contrast or variation within the neighborhood window), k = 0.5 controls the enhancement strength (k greater than 0 indicates enhanced contrast), and R = 128 is the dynamic range. The local adaptive binarization algorithm effectively suppresses background noise and maximizes the preservation of low-contrast areas. Using the adaptive binarization algorithm for binarization maximizes the preservation of the original image information.

[0076] The goal of perspective correction is to restore an obliquely shot image to its normal view by calculating the perspective transformation matrix. For example, perspective correction can be performed using OpenCV or automatic document boundary detection.

[0077] As an example, we use the Table-Transformer-Detection module to perform table detection on a source file that has been binarized and perspective corrected. The output of this algorithm is the position of the table in the image (i.e., the coordinates of the four vertices of each table area).

[0078] In this embodiment, by imaging, binarizing and perspective correcting the file to be processed, the position information of each table area in the file to be processed is obtained, and the accurate positioning of the table area is achieved, preparing for the next step of screening cross-page tables.

[0079] In an optional embodiment of the present invention, step 13 includes:

[0080] Step 131, performing structural recognition on the plurality of table areas to obtain an information list of the plurality of table areas;

[0081] Step 132: Determine at least one cross-page table group to be selected according to the information list.

[0082] As an example, a Table-Transformer-Structure-Recognition algorithm may be used to perform structural recognition on the multiple table areas to obtain an information list of the multiple table areas, including row information, column information, and merged cell information of the recognized tables.

[0083] In an optional embodiment of the present invention, the information list includes the coordinates of each table area, and step 132 includes:

[0084] Step 1321: determining at least one image group, each image group including a plurality of consecutive second images having a table area;

[0085] Step 1322 , for each image group, determining the coordinates of the table area in each second image in the image group and the page height of each second image according to the information list;

[0086] Step 1323 : Compare the coordinates of the table area of ​​each second image with the page height of each second image, and determine the table area in the image group as a cross-page table group to be selected based on the comparison result.

[0087] As an example, the information list may include coordinates of four vertices of each table area, or coordinates of two vertices on a diagonal line of the table area.

[0088] As an example, take the case where there are two consecutive images with table areas in the image group, such as Figure 2 、 3 As shown, Figure 2 、 3 The pages in are two consecutive pages (page 1 is the first page, page 2 is the second page):

[0089] Then in step 1322, for each image group, the coordinates of the table area in each second image in the image group and the page height of each second image are determined according to the information list, that is: the coordinate values ​​a1 of the two bottom vertices of the table area of ​​the first image in the y-axis direction and the page height b1 of the entire image of the first image are determined; the coordinate values ​​c1 of the two bottom vertices of the table area of ​​the second image in the y-axis direction and the page height d1 of the entire image of the first image are determined.

[0090] Taking the above example, if there are two consecutive images with table areas in the image group:

[0091] Then, in step 1323, the coordinates of the table area of ​​each second image are compared with the page height of each second image, and the table area in the image group is determined as the cross-page table group to be selected according to the comparison result, that is:

[0092] Comparison threshold of the first image: set 90% of b1 as the first threshold;

[0093] Comparison threshold for the second image: set 10% of d1 as the second threshold;

[0094] If a1 is greater than the first threshold and c1 is less than the second threshold, the two table areas corresponding to a1 and c1 in the image group are determined as the cross-page table group to be selected.

[0095] As an example, there are two consecutive images with table areas in the image group, and the first image has two table areas, such as Figure 3 、 4 As shown, Figure 4 The page in is the first of two consecutive pages, and the page has two table areas. Figure 3 The page in is the second of two consecutive pages and contains a table area:

[0096] Then in step 1322, for each image group, the coordinates of the table area in each second image in the image group and the page height of each second image are determined according to the information list, that is: the coordinate values ​​a1 and a2 of the two bottom vertices of the two table areas in the y-axis direction and the page height b1 of the entire image of the first image are determined respectively; the coordinate value c1 of the two bottom vertices of the table area of ​​the second image in the y-axis direction and the page height d1 of the entire image of the first image are determined.

[0097] Then, in step 1323, the coordinates of the table area of ​​each second image are compared with the page height of each second image, and the table area in the image group is determined as the cross-page table group to be selected according to the comparison result, that is:

[0098] Comparison threshold of the first image: set 90% of b1 as the first threshold;

[0099] Comparison threshold for the second image: set 10% of d1 as the second threshold;

[0100] If a1 is greater than a first threshold and c1 is less than a second threshold, the two table areas corresponding to a1 and c1 are determined as a table group to be selected for a spread. If a2 is greater than the first threshold and c1 is less than a second threshold, the two table areas corresponding to a2 and c1 are determined as a table group to be selected for a spread. Otherwise, the table group does not constitute a table group to be selected for a spread.

[0101] As an example, there are three consecutive images with table areas in the image group, and the first image has two table areas, such as Figure 3 、 4 ,5, Figure 3 、 4 The pages in ,5 are three consecutive pages. Among them, Figure 4 The page in is the first page, and there are two table areas on the page. Figure 3 The page in the figure is the second page, which contains a table area. Figure 5 The page in the figure is the third page, which contains a table area:

[0102] Then in step 1322, for each image group, the coordinates of the table area in each second image in the image group and the page height of each second image are determined according to the information list, that is: the coordinate values ​​a1 and a2 of the two bottom vertices of the two table areas in the y-axis direction and the page height b1 of the entire image of the first image are determined respectively; the coordinate value c1 of the two bottom vertices of the table area of ​​the second image in the y-axis direction and the page height d1 of the entire image of the first image are determined; the coordinate value e1 of the two bottom vertices of the table area of ​​the third image in the y-axis direction and the page height f1 of the entire image of the first image are determined.

[0103] Then, in step 1323, the coordinates of the table area of ​​each second image are compared with the page height of each second image, and the table area in the image group is determined as the cross-page table group to be selected according to the comparison result, that is:

[0104] Comparison threshold of the first image: set 90% of b1 as the first threshold;

[0105] Comparison threshold for the second image: 10% of d1 is set as the second threshold, and 90% of d1 is set as the third threshold;

[0106] Comparison threshold for the third image: Set 10% of f1 as the fourth threshold

[0107] If a1 is greater than the first threshold and c1 is less than the second threshold, the two table areas corresponding to a1 and c1 are determined as the cross-page table group to be selected; and if c1 is greater than the third threshold and e1 is less than the fourth threshold, the two table areas corresponding to c1 and e1 are determined as the cross-page table group to be selected, that is, the three table areas corresponding to a1, c1 and e1 are determined as the cross-page table group to be selected.

[0108] If a2 is greater than the first threshold and c1 is less than the second threshold, the two table areas corresponding to a2 and c1 are determined as the cross-page table group to be selected; and if c1 is greater than the third threshold and e1 is less than the fourth threshold, the two table areas corresponding to c1 and e1 are determined as the cross-page table group to be selected, that is, the three table areas corresponding to a2, c1 and e1 are determined as the cross-page table group to be selected.

[0109] If only the condition that a2 is greater than the first threshold and c1 is less than the second threshold is satisfied, the two table areas corresponding to a2 and c1 are determined as the cross-page table group to be selected.

[0110] If only the condition that c1 is greater than the third threshold and e1 is less than the fourth threshold is satisfied, the two table areas corresponding to c1 and e1 are determined as the to-be-selected cross-page table group.

[0111] Otherwise, it does not constitute a table group to be selected across pages.

[0112] In some embodiments, if there are n consecutive images with table areas in the image group, the comparison is performed referring to the above comparison process.

[0113] In an optional embodiment of the present invention, step 14 includes:

[0114] Step 141 , for each to-be-selected spread-page table group, calculate the maximum offset of the table area in the to-be-selected spread-page table group in the x-direction to obtain corresponding first feature data;

[0115] Step 142 , calculating a sentence vector of the content in the table area of ​​the to-be-selected cross-page table group, and determining second feature data based on the sentence vector;

[0116] Step 143 : Detect the digital sequence of the content in the table area of ​​the to-be-selected cross-page table group, and determine the third characteristic data according to the digital sequence.

[0117] As an example, for each cross-page table group to be selected, the maximum offset of the table area of ​​adjacent pages in the cross-page table group to be selected in the x-direction is calculated, that is: for the table area in the cross-page table group to be selected, BERT is used to calculate the x-coordinate offset (pixel level) of the corresponding column of the adjacent page, and the x-coordinate offset of each column is obtained, and the inverse of the maximum value (max_offset) is selected as the first feature data: 1 / (1+max_offset).

[0118] Reference Attachment Figure 6 、 7 , Figure 6 is the table on the first page, Figure 7 The table is on the second page. The first and second pages are adjacent pages of a continuous page. The table on the first and second pages is a spanning table area. The x-coordinate offset of the corresponding columns of the adjacent pages is x 11 and x 21 The difference 1,x 12 and x 22 The difference 2,x 13 and x 23 The difference 3,x 14 and x 24 The difference 4 is selected, and a maximum value is selected from the four differences as the maximum offset max_offset to obtain the first feature data 1 / (1+max_offset).

[0119] BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained language model based on the Transformer architecture. It simultaneously learns contextual information through a bidirectional Transformer to obtain sentence vectors.

[0120] As an example, BERT is used to extract the sentence vectors of the last / beginning paragraphs corresponding to each column in the table area of ​​adjacent pages in the selected cross-page table group, calculate the cosine similarity, and select the largest cosine similarity as the second feature data.

[0121] Reference Attachment Figure 6 、 7 Calculate sentence vector 1 for "column alignment" and sentence vector 2 for "semantic relevance." Obtain cosine similarity 1 based on sentence vectors 1 and 2. Calculate sentence vector 3 for "For two tables, calculate the x-coordinate offset (pixel level) of corresponding columns on adjacent pages, taking the maximum value (max_offset) as the penalty term: 1 / (1+max_offset)." and sentence vector 4 for "Use BERT to extract sentence vectors for each cell at the end / beginning of adjacent pages and calculate the cosine similarity, the largest of which." Obtain cosine similarity 2 based on sentence vectors 3 and 4. Calculate sentence vector 5 for "40%" and sentence vector 6 for "20%." Obtain cosine similarity 3 based on sentence vectors 5 and 6. Select the largest cosine similarity among cosine similarity 1, cosine similarity 2, and cosine similarity 3 as the second feature data.

[0122] As an example, the difference consistency (such as arithmetic progression / proportional progression) of the number sequences (such as amount, number) in the table area of ​​adjacent pages in the selected cross-page table group is detected. If the difference consistency is met, full marks (1 point) will be awarded, otherwise 0 points will be awarded.

[0123] As an example, there is a number sequence 40% and 20%. 40% and 20% satisfy arithmetic progression (or geometric ratio) and the difference consistency is scored full marks (1 point).

[0124] Reference Attachment Figure 3 、 4 5. If the three table areas corresponding to a1, c1 and e1 are determined to be the cross-page table group to be selected, the first feature data, second feature data and third feature data of the table areas corresponding to the adjacent pages a1 and c1 are extracted, and the first feature data, second feature data and third feature data of the table areas corresponding to the adjacent pages c1 and e1 are extracted.

[0125] In an optional embodiment of the present invention, step 15 includes:

[0126] Step 151 : For each to-be-selected spread-page table group, perform weighted summation on the first feature data, the second feature data, and the third feature data according to preset weights to obtain a correlation strength value of the table area in each to-be-selected spread-page table group.

[0127] As an example, the weights of the first feature data, the second feature data, and the third feature data are 0.4, 0.2, and 0.4, respectively.

[0128] Take the above as an example, refer to the attached Figure 3 、 4 5. According to the preset weights, the first feature data, the second feature data, and the third feature data of the table area corresponding to the adjacent pages a1 and c1 are weighted and summed to obtain A. The first feature data, the second feature data, and the third feature data of the table area corresponding to the adjacent pages c1 and e1 are weighted and summed to obtain B.

[0129] In some embodiments, the number and types of features extracted can be modified or adjusted as needed.

[0130] In an optional embodiment of the present invention, step 16 includes: comparing each association strength value with a preset value; if the association strength value is greater than the preset value, merging the table areas in the selected cross-page table group corresponding to the association strength value into table data in the target format.

[0131] As an example, the preset value is 0.93. The preset value can be adjusted as needed.

[0132] As an example, refer to the attached Figure 3 、 45. If only A is greater than the preset value, the table areas corresponding to a1 and c1 are merged into the table data in the target format; if only B is greater than the preset value, the table areas corresponding to c1 and e1 are merged into the table data in the target format; if A is greater than the preset value and B is greater than the preset value, the table areas corresponding to a1, c1 and e1 are merged into the table data in the target format.

[0133] As an example, merging table areas in the selected spread table group corresponding to the association strength values ​​can refer to: obtaining the coordinates of the corresponding table areas, aligning the coordinates of the lower left and lower right endpoints of the previous table with the coordinates of the upper left and upper right endpoints of the next table through translation and scaling. After aligning, the results are output in the target format.

[0134] In an optional embodiment of the present invention, step 16 further includes: merging the table areas in the to-be-selected cross-page table group and performing semantic mapping to obtain table data in a target format.

[0135] As an example, the steps of semantic mapping can be referred to:

[0136] A) Generate a standard table skeleton:

[0137]

[0138]

[0139]

[0140] <tbody id=”simple_table”>

[0141] B) Get all data columns:

[0142] Traverse the output of the Table-Transformer-Structure-Recognition algorithm, and for each data item whose label is a table column, record its starting and ending positions to form a column position list.

[0143] C) Insert data rows

[0144] Traverse the output of the Table-Transformer-Structure-Recognition algorithm. For each data item labeled as a table row, insert a pair of tr tags into the standard table skeleton. Use the column position list to split the image area of ​​the data item into cell blocks. Record the four vertex positions of each cell in the table and insert them into the tr tag corresponding to the data item as a td tag pair. That is, in the format of (x_min, xmax.y_min, y_max)

[0145] D) Cell merging

[0146] Traverse the output of the Table-Transformer-Structure-Recognition algorithm (this algorithm can recognize merged cells that span rows or columns in the table area). For each data item labeled "tablespanning cell" (i.e., merged cells that span rows or columns), if the vertex coordinates of the spanning cell are within the position range of the table area, add the rowspan and colspan attributes to the frontmost table and delete the remaining cells within the position range.

[0147] For example, as shown in Table 1, there is a merged cell in the table (that is, the cell where data 18 is located). The target format of the table data is:

[0148]

[0149] <!--Table header cell tag-->

[0150] Name

[0151] age

[0152]

[0153]

[0154] <! --Table normal cell tag-->Tom

[0155] 18

[0156]

[0157]

[0158] <!--Table normal cell tag-->

[0159] Jerry

[0160]

[0161] Table 1 Example of a table (continued)

[0162]

[0163] Perform semantic mapping on the table area in the selected cross-page table group to obtain HTML table code that complies with W3C standards (including

[0198]

[0199]

[0200]

[0201]

[0202]

[0203]

[0204]

[0205] Figure 9

[0206]

[0207]

[0208]

[0209]

[0210]

[0211]

[0212]

[0213]

[0214]

[0215]

[0216]

[0217]

[0218]

[0219]

[0220]

[0221]

[0222]

[0223]

[0224]

[0225]

[0226]

[0227]

[0228]

[0229]

[0230]

[0231]

[0232]

[0233]

[0234]

[0235]

[0236] Figure 10 Figure 10

[0237]

[0238]

[0239] , , Tags), the output results can be directly used for database import or large model input without secondary development.

[0164] In an optional embodiment of the present invention, the method further includes: identifying a cross-page identifier in the file to be processed, and merging the cross-page tables contained in the file to be processed into table data in a target format according to the cross-page identifier.

[0165] As an example, some tables that span multiple pages are marked with a "continued table" logo in the header (such as Table 1). Identify the explicit span logo in the document (such as "continued table"). If the corresponding text is recognized, it is determined that the table spans multiple pages.

[0166] refer to Figure 8 , Figure 8 This is a flow chart of another embodiment of the present invention.

[0167] 1) Read the scanned file

[0168] Supports multi-format document input (PDF / image, etc.). For a specified file, if it is an image format input, it can be directly read using the Pillow library. For PDF files, use PyPDF2 (converted to image) to read the page in the file as input.

[0169] 2) Binarization

[0170] For the image data read in step 1), a local adaptive binarization algorithm is used for binarization processing, and the threshold of each area is dynamically calculated through a sliding window (128×128 pixels):

[0171]

[0172] Where T(x,y) is the enhanced pixel value (or adjusted parameter). μ is the local mean (usually the average pixel value within a neighborhood window), σ is the local standard deviation (a measure of contrast or variation within the neighborhood window), k = 0.5 controls the enhancement strength (k greater than 0 indicates enhanced contrast), and R = 128 is the dynamic range. The local adaptive binarization algorithm effectively suppresses background noise and maximizes the preservation of low-contrast areas.

[0173] Each page is processed by sliding to obtain a binarized image, and then the binarized image is subjected to perspective correction.

[0174] 3) Table detection

[0175] Table-Transformer-Detection (Table Detection Module) is used to detect tables in the binarized and perspective-corrected source file. The output of this algorithm is the location of the table in the image (i.e., the coordinates of the four vertices of the table). If the table does not exist, an empty list is returned.

[0176] 4) Table structure recognition

[0177] For areas in the file where tables are identified, the Table-Transformer-Structure-Recognition algorithm is applied. The output is a table information list, which includes elements such as cell score row and column probabilities, labels, and the locations of the four vertices of the area. Labels include table, row, column, and merged cells (data representation).

[0178] 5) Joint reasoning system for cross-page tables (i.e., corresponding to steps 13 and 14 for selecting the cross-page table group to be selected)

[0179] a) Cross-page candidate detection

[0180] For two consecutive pages, if the bottom coordinate of the table on the first page is greater than 90% of the height of the first page, and the top coordinate of the table on the second page is less than 10% of the height of the second page, the two tables are classified as a table to be selected for a spread.

[0181] b) Table Continuous Scoring Model

[0182] For the selected cross-page tables, the correlation strength between the two tables is quantified through multi-dimensional features. When the weighted total score is greater than 0.93, they are determined to be the same cross-page table.

[0183] c) Page mark detector

[0184] Identify explicit page-spread identifiers in the document (such as "continued table"). If the corresponding text is recognized, it is determined that the table spans pages.

[0185] d) Table merging

[0186] If either step b) of the table continuity scoring model or step c) of the page break detector determines that the table spans pages, the table merging step is performed. This involves translating and scaling the table so that the lower left and lower right endpoints of the previous table coincide with the upper left and upper right endpoints of the next table.

[0187] The cross-page table joint reasoning system simultaneously analyzes the overlap between the table area at the bottom of the current page and the top of the next page. It quantifies the probability of cross-page association based on column alignment, table header similarity, and content semantic relevance. For cells with a cross-page association probability greater than a threshold, the two cells are merged.

[0188] 6) Convert the overlapped table in step 5) into W3C standard HTML code

[0189] A) Generate a standard table skeleton:

[0190]

[0191]

[0192]

[0193] <tbody id=”simple_table”>

[0194] B) Get all data columns:

[0195] Traverse the output of the Table-Transformer-Structure-Recognition algorithm, and for each data item whose label is a table column, record its starting and ending positions to form a column position list.

[0196] C) Insert data rows

[0197] Traverse the output of the Table-Transformer-Structure-Recognition algorithm. For each data item labeled as a table row, insert a pair of tr tags into the standard table skeleton. Use the column position list to split the image area of ​​the data item into cell blocks. Record the four vertex positions of each cell in the table and insert them into the tr tag corresponding to the data item in the form of a td tag pair. (x_min,xmax.y_min,y_max) Format D) Cell merging and traversal of the output result of the Table-Transformer-Structure-Recognition (table structure recognition) algorithm, for each data item whose label is a table spanning cell. If its vertex coordinates are within the position range of the data item. Then add rowspan and colspan attributes to the frontmost table, and delete the remaining cells within the position range. In this embodiment, by adapting the three major technologies of binarization algorithm, cross-page semantic association, and structured output mapping, the core pain points of Table-Transformer in industrial scenarios are solved: 1. Applicability expansion: supports high-precision parsing of curved surfaces, tilts, cross-pages, and low-quality documents. 2. Process efficiency revolution: full process automation, comprehensive improvement of processing speed. 3. Downstream compatibility: direct output of standard HTML, seamless connection between database and front-end system. It is a structural schematic diagram of an embodiment of a cross-page table extraction device of the present invention. The device includes: an acquisition module 91 for acquiring a file to be processed, wherein the file to be processed includes a cross-page table; a first processing module 92 for preprocessing the file to be processed to obtain multiple table areas; a second processing module 93 for performing structural recognition on the multiple table areas to obtain at least one to-be-selected cross-page table group, wherein the to-be-selected cross-page table group includes a table area to be merged; a third processing module 94 for performing feature extraction on the table area in each to-be-selected cross-page table group to obtain feature data corresponding to each to-be-selected cross-page table group; a fourth processing module 95 for determining, based on the feature data, an association strength value of the table area in each to-be-selected cross-page table group; and a fifth processing module 96 for merging the table areas in the to-be-selected cross-page table group into table data of a target format based on the association strength value of the table area in each to-be-selected cross-page table group. Optionally, the first processing module 92 is further configured to: process the file to be processed to obtain a plurality of first images, each first image corresponding to the content of a page in the file to be processed, and the plurality of first images are continuous; perform binarization and perspective correction processing on each first image in sequence to obtain a plurality of second images, each second image corresponding to the content of a page in the file to be processed, and the plurality of second images are continuous; perform table detection on the plurality of second images to obtain a plurality of table areas. Optionally, the second processing module 93 is further configured to: perform structural recognition on the plurality of table areas to obtain an information list of the plurality of table areas; and determine at least one to-be-selected cross-page table group based on the information list.Optionally, the information list includes the coordinates of each table area; the second processing module 93 is further used to: determine at least one image group, each image group including a plurality of consecutive second images having table areas; for each image group, determine the coordinates of the table area in each second image in the image group and the page height of each second image according to the information list; compare the coordinates of the table area in each second image with the page height of each second image, and determine the table area in the image group as a to-be-selected cross-page table group based on the comparison result. Optionally, the third processing module 94 is further used to: for each to-be-selected cross-page table group, calculate the maximum offset of the table area in the to-be-selected cross-page table group in the x-direction to obtain corresponding first feature data; calculate the sentence vector of the content in the table area in the to-be-selected cross-page table group, and determine second feature data based on the sentence vector; detect the digital sequence of the content in the table area in the to-be-selected cross-page table group, and determine third feature data based on the digital sequence. Optionally, the fourth processing module 95 is also used to: for each to-be-selected cross-page table group, perform weighted summation on the first feature data, the second feature data, and the third feature data according to a preset weight, to obtain an association strength value of the table area in each to-be-selected cross-page table group; based on the association strength value of the table area in each to-be-selected cross-page table group, merge the table areas in the to-be-selected cross-page table group into table data in a target format, including: comparing each association strength value with a preset value, and if the association strength value is greater than the preset value, merging the table areas in the to-be-selected cross-page table group corresponding to the association strength value into table data in a target format. Optionally, the device also includes a sixth processing module, which is used to: identify the cross-page identifier in the to-be-processed file, and merge the cross-page tables contained in the to-be-processed file into table data in a target format according to the cross-page identifier. Optionally, the fifth processing module 96 is also used to: perform semantic mapping on the table areas in the to-be-selected cross-page table group to obtain table data in a target format. An example of a physical structure diagram of an electronic device is shown. As shown, the electronic device may include: a processor (processor) 1010, a communication interface (Communications Interface) 1020, a memory (memory) 1030 and a communication bus 1040, wherein the processor 1010, the communication interface 1020, and the memory 1030 communicate with each other via the communication bus 1040. The processor 1010 can call the logic instructions in the memory 1030 to execute a cross-page table extraction method as described above. In addition, the logic instructions in the memory 1030 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product.Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment 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 disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk. The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment. A person of ordinary skill in the art can understand and implement the present invention without inventive effort. The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A method for extracting a cross-page table, characterized in that: include: Obtaining a file to be processed, wherein the file to be processed includes a spreadsheet; Preprocessing the file to be processed to obtain multiple table areas; Performing structural recognition on the plurality of table areas to obtain at least one table group to be selected across pages, wherein the table group to be selected across pages includes the table areas to be merged; Performing feature extraction on the table area in each of the to-be-selected spread-page table groups to obtain feature data corresponding to each of the to-be-selected spread-page table groups; Determine, according to the characteristic data, the association strength value of the table area in each of the to-be-selected cross-page table groups; According to the association strength values ​​of the table areas in each of the to-be-selected spread-page table groups, the table areas in the to-be-selected spread-page table group are merged into table data in a target format.

2. The method according to claim 1, characterized in that The file to be processed is pre-processed to obtain multiple table areas, including: Processing the file to be processed to obtain a plurality of first images, each first image corresponding to the content of a page in the file to be processed, and the plurality of first images are continuous; performing binarization and perspective correction processing on each first image in sequence to obtain a plurality of second images, each second image corresponding to the content of a page in the file to be processed, and the plurality of second images are continuous; Table detection is performed on the plurality of second images to obtain a plurality of table areas.

3. The method according to claim 2, characterized in that Performing structural recognition on the multiple table areas to obtain at least one cross-page table group to be selected includes: Performing structural recognition on the plurality of table areas to obtain an information list of the plurality of table areas; At least one cross-page table group to be selected is determined according to the information list.

4. The method according to claim 3, characterized in that The information list includes the coordinates of each table area; Determining at least one to-be-selected cross-page table group according to the information list includes: determining at least one image group, each image group including a plurality of consecutive second images having a table area; For each image group, determining the coordinates of the table area in each second image in the image group and the page height of each second image according to the information list; The coordinates of the table area of ​​each second image are compared with the page height of each second image, and the table area in the image group is determined as a cross-page table group to be selected according to the comparison result.

5. The method according to claim 1, characterized in that Perform feature extraction on the table area in each of the to-be-selected spread-page table groups to obtain feature data corresponding to each of the to-be-selected spread-page table groups, including: For each to-be-selected spread-page table group, calculating the maximum offset of the table area in the to-be-selected spread-page table group in the x-direction, and obtaining corresponding first feature data; Calculating a sentence vector for the content in the table area of ​​the to-be-selected cross-page table group, and determining second feature data based on the sentence vector; A digital sequence of content in a table area in the to-be-selected cross-page table group is detected, and third feature data is determined according to the digital sequence.

6. The method according to claim 5, characterized in that Determining, according to the characteristic data, the association strength value of the table area in each to-be-selected cross-page table group includes: For each of the to-be-selected spread-page table groups, performing weighted summation on the first feature data, the second feature data, and the third feature data according to a preset weight, to obtain a correlation strength value of the table area in each of the to-be-selected spread-page table groups; Merging the table areas in the to-be-selected spread-page table group into table data in a target format according to the association strength values ​​of the table areas in each to-be-selected spread-page table group includes: Each of the association strength values ​​is compared with a preset value. If the association strength value is greater than the preset value, the table areas in the to-be-selected cross-page table group corresponding to the association strength value are merged into table data in a target format.

7. The method according to claim 1, characterized in that The method further comprises: A page-spanning identifier in the to-be-processed file is identified, and the page-spanning tables contained in the to-be-processed file are merged into table data in a target format according to the page-spanning identifier.

8. The method according to claim 1, characterized in that Merge the table areas in the selected spread table group into table data of the target format, including: The table areas in the selected cross-page table group are merged and semantic mapping is performed to obtain table data in the target format.

9. A device for extracting a cross-page table, characterized in that: include: An acquisition module is used to acquire a file to be processed, wherein the file to be processed includes a cross-page table; A first processing module is used to pre-process the file to be processed to obtain multiple table areas; A second processing module is configured to perform structural recognition on the plurality of table areas to obtain at least one table group to be selected across pages, wherein the table group to be selected across pages includes the table areas to be merged; A third processing module is used to extract features from the table area in each of the to-be-selected spread-page table groups to obtain feature data corresponding to each of the to-be-selected spread-page table groups; A fourth processing module is configured to determine, based on the feature data, a correlation strength value of a table region in each of the to-be-selected cross-page table groups; The fifth processing module is configured to merge the table areas in the to-be-selected spread-page table group into table data in a target format according to the association strength values ​​of the table areas in each to-be-selected spread-page table group.

10. An electronic device, characterized in that: include: processor, memory, and bus, wherein, The processor and the memory communicate with each other via the bus; The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the steps of the cross-page table extraction method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Contract detail extraction and classification method and system

    CN121435939A