Table recognition method and device and computer device
By acquiring raster and vector graphics from PDF documents and using a table structure prediction model to train and generate sample documents, the problem of poor prediction performance caused by the complexity of Chinese financial table structures is solved, and accurate identification and prediction of complex tables are achieved.
Patent Information
- Application Number
- CN202311092117.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-29
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-08-29
AI Technical Summary
Existing technologies have poor prediction performance when parsing table structures in PDF documents, especially Chinese financial tables. This is because the table structures are complex, varied, and inconsistent, which affects the accuracy of the model.
By acquiring raster and vector graphics from documents, a table-structure prediction model is trained to generate sample documents. The model is then iteratively adjusted by combining layout recognition and text position information to improve prediction accuracy.
It achieves accurate identification of complex tables, improves the accuracy of table structure prediction models, and can quickly generate a large number of consistent labeled sample documents.
Smart Images

Figure CN116994276B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data processing technology, and in particular to a table recognition method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] PDF documents often contain rich tabular information. While table areas can be detected during PDF page parsing, parsing the table structure, such as rows, columns, headers, and empty cells, is extremely difficult. Related technologies predict table areas and analyze the information to obtain structural information, then construct the table structure using this predicted information. However, these methods are less effective at predicting complex tables. This is because Chinese financial tables are structurally complex, often containing incomplete tables, tables with missing lines, and frequently nested headers. Furthermore, table styles are highly varied, with numerous background colors. Even with the same data, different companies may present tables with vastly different styles. All these complexities affect the model's predictions. Summary of the Invention
[0003] Therefore, it is necessary to provide a table recognition method, apparatus, computer device, computer-readable storage medium, and computer program product that is compatible with various forms to address the above-mentioned technical problems.
[0004] Firstly, this application provides a table recognition method. The method includes:
[0005] Get the document containing the table range;
[0006] The document is input into a preset table structure prediction model, which outputs the table structure in the document. The table structure prediction model is obtained by training on the correspondence between sample documents and sample table structures. The sample document is obtained by extracting raster graphics and vector graphics corresponding to the table areas in the initial sample document; determining the sample table structure corresponding to the raster graphics; parsing the text and corresponding position information from the vector graphics; and generating the sample document based on the sample table structure, the text, and the corresponding position information.
[0007] In one embodiment, the training method of the table structure prediction model includes:
[0008] Obtain a sample document set, which includes the sample documents and the corresponding sample table structure;
[0009] Construct an initial table structure prediction model, which includes training parameters;
[0010] The sample document is input into the initial table structure prediction model to obtain the prediction result;
[0011] Based on the difference between the prediction results and the sample table structure, the initial table structure prediction model is iteratively adjusted to obtain the table structure prediction model.
[0012] In one embodiment, the raster graphic includes a table area and a non-table area, and determining the sample table structure corresponding to the raster graphic includes:
[0013] The grid graphic is input into a preset layout recognition model, and a grid graphic with a recognition box is output, wherein the recognition box is used to identify the table area of the grid graphic;
[0014] The non-table areas in the grid graphic with the recognition frame are cropped to obtain the processed grid graphic;
[0015] The table structure is marked in the processed raster graphic to obtain the sample table structure.
[0016] In one embodiment, generating the sample document based on the sample table structure, the text, and the corresponding location information includes:
[0017] Edit the constituent elements of the sample table structure to obtain a derived sample table structure;
[0018] Edit the text to obtain derived text;
[0019] Based on the location information, the text and the derived text are merged into the corresponding sample table structure to obtain a sample document; wherein the location information of the text is the same as the location information of the derived text corresponding to the text.
[0020] In one embodiment, outputting the table structure in the document includes:
[0021] Output table cells of various preset categories;
[0022] The initial table lines are obtained based on the table row area and table column area in the table unit;
[0023] Based on the position information of the text, the initial table lines are corrected to obtain table lines; wherein, the horizontal and vertical lines in the table lines constitute the borders of the cells;
[0024] Based on the cell combination area in the table cell of the preset category, the table cells are merged to obtain the table structure in the document.
[0025] In one embodiment, the method further includes:
[0026] Based on the position information of the text, the text is added to the table structure to obtain a table structure with text.
[0027] Secondly, this application also provides a form recognition device. The device includes:
[0028] The retrieval module is used to retrieve documents that contain table regions;
[0029] The generation module is used to input the document into a preset table structure prediction model and output the table structure in the document. The table structure prediction model is obtained by training on the correspondence between sample documents and sample table structures. The sample document is obtained by extracting raster graphics and vector graphics corresponding to the table areas in the initial sample document; determining the sample table structure corresponding to the raster graphics; parsing the text and corresponding position information from the vector graphics; and generating the sample document based on the sample table structure, the text, and the corresponding position information.
[0030] In one embodiment, the generation module further includes:
[0031] The acquisition submodule is used to acquire a sample document set, which includes the sample documents and the corresponding sample table structure;
[0032] A construction submodule is used to construct an initial table structure prediction model, which includes training parameters.
[0033] The prediction submodule is used to input the sample document into the initial table structure prediction model to obtain the prediction result;
[0034] The first generation submodule is used to iteratively adjust the initial table structure prediction model based on the difference between the prediction result and the sample table structure to obtain the table structure prediction model.
[0035] In one embodiment, the generation module includes:
[0036] The second generation submodule is used to input the raster graphic into a preset layout recognition model and output a raster graphic with a recognition box, wherein the recognition box is used to identify the table area of the raster graphic;
[0037] The cropping submodule is used to crop the non-table areas in the grid graphic with the recognition box to obtain the processed grid graphic.
[0038] The annotation submodule is used to annotate the table structure in the processed raster graphic to obtain the sample table structure.
[0039] In one embodiment, the generation module includes:
[0040] The first derivative submodule is used to edit the constituent elements in the sample table structure to obtain a derived sample table structure.
[0041] The second derivative submodule is used to edit the text to obtain derived text;
[0042] The sample generation submodule is used to merge the text and the derived text into the corresponding sample table structure according to the location information to obtain a sample document; wherein the location information of the text is the same as the location information of the derived text corresponding to the text.
[0043] In one embodiment, the generation module includes:
[0044] The output submodule is used to output table cells of various preset categories;
[0045] The table line submodule is used to obtain the initial table lines based on the table row area and table column area in the table unit;
[0046] The cell submodule is used to correct the initial table lines based on the position information of the text to obtain table lines; wherein, the horizontal and vertical lines in the table lines constitute the border of the cell;
[0047] The table structure submodule is used to merge the table cells according to the cell combination area in the table cells of the preset category to obtain the table structure in the document.
[0048] In one embodiment, the device further includes:
[0049] An integration module is used to add the text to the table structure based on the text's location information, thereby obtaining a table structure with text.
[0050] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the table recognition method as described in any one of the embodiments of this disclosure.
[0051] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the table recognition method as described in any one of the embodiments of this disclosure.
[0052] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the table recognition method as described in any of the embodiments of this disclosure.
[0053] The aforementioned table recognition method, apparatus, computer equipment, storage medium, and computer program product extract raster and vector graphics corresponding to table areas in an initial sample document; determine the sample table structure corresponding to the raster graphics; parse text and corresponding positional information from the vector graphics; and generate the sample document based on the sample table structure, the text, and the corresponding positional information. This method can quickly and accurately generate a large number of sample documents. Using these sample documents to train a table structure prediction model can improve the accuracy of the model and achieve relatively accurate prediction results even for tables with complex structures. Attached Figure Description
[0054] Figure 1 This is a flowchart illustrating a table recognition method in one embodiment.
[0055] Figure 2 This is a schematic diagram of the training process for a table structure prediction model in one embodiment.
[0056] Figure 3 This is a flowchart illustrating the process of determining the sample table structure in one embodiment.
[0057] Figure 4 This is an example of a table image passed to a table annotation platform.
[0058] Figure 5 This is a training data image after being processed by a table annotation platform in one embodiment.
[0059] Figure 6 This is a schematic diagram of the process for generating sample documents in one embodiment.
[0060] Figure 7 This is a schematic diagram of the process for generating a table structure in one embodiment.
[0061] Figure 8 This is a schematic diagram of the table recognition process in one embodiment.
[0062] Figure 9 This is a flowchart illustrating a table prediction model in one embodiment.
[0063] Figure 10 This is a schematic diagram of a table recognition device in one embodiment.
[0064] Figure 11 This is a schematic diagram of a table structure prediction model training device in one embodiment.
[0065] Figure 12 This is a schematic diagram of a data processing apparatus in one embodiment.
[0066] Figure 13 This is a schematic diagram of a sample generation device in one embodiment.
[0067] Figure 14 This is a schematic diagram of an integrated table structure device in one embodiment.
[0068] Figure 15 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0069] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0070] In one embodiment, such as Figure 1 As shown, a table recognition method is provided, which can be applied to a terminal or server, including the following steps:
[0071] Step S1: Obtain the document containing the table area.
[0072] Optionally, the table area may include an area composed of tables, and the document may include PDF files, Word files, image documents, web pages, etc.
[0073] Step S3: Input the document into a preset table structure prediction model and output the table structure in the document. The table structure prediction model is obtained by training on the correspondence between sample documents and sample table structures. The sample document is obtained by extracting the raster graphics and vector graphics corresponding to the table areas in the initial sample document; determining the sample table structure corresponding to the raster graphics; parsing the text and corresponding position information from the vector graphics; and generating the sample document based on the sample table structure, the text, and the corresponding position information.
[0074] In this embodiment of the disclosure, the table structure prediction model can predict table cells in an input document. These table cells may include: table row areas, table column areas, merged cell areas, a special cell area for an entire row, and header row numbers, etc. Further, the table structure is obtained after correcting and merging the table cells. In another exemplary embodiment, the table structure prediction model may further include: inputting the document into the table structure prediction model to directly obtain a model of the table structure.
[0075] The table structure can be the inner and outer borders of a table in a document, and can include an empty table without text. The sample document can be used to train a table structure prediction model, and can include documents containing both table structure and text. The sample table structure can be the annotated table structure corresponding to the sample document; for example, a document may contain a table structure with embedded text. This table structure can be a lineless table structure or a lined table structure. For lineless table structures, lines need to be annotated and the text removed to obtain the sample table structure; for lined table structures, the text needs to be removed to obtain the sample table structure.
[0076] Optionally, the table structure prediction model can be obtained by training the correspondence between sample documents and sample table structures. The table structure prediction model can be obtained by deep learning training on artificial intelligence models such as neural networks, linear regression, logistic regression, and random forests.
[0077] Optionally, the raster graphic corresponding to the table area includes an image of the table area, and the raster graphic may include images in formats such as jpg, jpeg, bmp, and png.
[0078] Optionally, the vector graphics may include images in formats such as SVG, CDR, AI, and DWG. These vector graphics are images described using geometric shapes and mathematical formulas, and can be scaled infinitely without distortion.
[0079] In one exemplary embodiment, a PDF document containing table areas can be obtained, the PDF document can be input into a table structure prediction model, and an empty table without text can be output from the table areas of the PDF document.
[0080] In one exemplary embodiment, the svglib library in Python can be used to convert each page of a PDF file into SVG format. In another exemplary embodiment, the "SVG Chatcher" plugin can be installed in a web browser to capture SVG graphics in a selected area. In yet another exemplary embodiment, SuperVectorizer on a Mac can be used to convert the PDF into SVG.
[0081] In the above table recognition method, the text and corresponding position information of the table are determined by the vector graphics corresponding to the table area of the sample document, and the table structure is determined by the raster graphics of the table. By providing the table structure, text and corresponding position information, a large number of sample documents with consistent annotation methods can be generated quickly and accurately. The table structure prediction model can be trained using the sample documents, which can improve the accuracy of table structure prediction and achieve relatively accurate prediction results even for complex tables.
[0082] In one embodiment, such as Figure 2 The aforementioned step S3 includes:
[0083] Step S301: Obtain a sample document set, which includes the sample documents and the corresponding sample table structure.
[0084] Step S302: Construct an initial table structure prediction model, which includes training parameters.
[0085] Step S303: Input the sample document into the initial table structure prediction model to obtain the prediction result.
[0086] Step S304: Based on the difference between the prediction result and the sample table structure, the initial table structure prediction model is iteratively adjusted to obtain the table structure prediction model.
[0087] The initial table structure prediction model in step S302 may include models whose accuracy cannot be guaranteed after training with data. The prediction result in step S303 may include the table predicted by the model after the initial table structure prediction model, consisting of all cells in the table area of the document. These cells include merged cells, entire rows of special cells, table cells, etc. The difference between the prediction result and the sample table structure in step S304 can be represented as the difference in the table lines between the prediction result and the sample table structure. This difference may include missing table lines, differences in the position of table lines, etc. The table structure prediction model can be obtained through continuous training with sample documents and sample table structures, and iteratively updated in subsequent recognition processes.
[0088] In one exemplary embodiment, the initial table structure prediction model can be iteratively adjusted by comparing the differences between the initial table structure prediction model and the sample table structure. In another exemplary embodiment, the initial table structure prediction model can be iteratively adjusted by comparing the differences between the initial table structure prediction model's multiple prediction results for a single sample document.
[0089] In one exemplary embodiment, images containing tables can be labeled to form samples, and a table structure prediction model can be obtained by training the samples. Table images not used for training are input into the initial table structure prediction model for prediction. The prediction results are compared with the corresponding labeled table structures, and the initial table structure prediction model is iteratively adjusted to obtain the table structure prediction model.
[0090] In one exemplary embodiment, a PDF document can be parsed into a raster image. Training samples are formed by annotating the raster images. An initial table structure prediction model is trained using a portion of the training samples. Table images not used for training are then input into the initial table structure prediction model for prediction. The prediction results are compared with the annotated samples to identify deficiencies in the model prediction. The initial table structure prediction model is then iteratively adjusted to obtain a new table structure prediction model.
[0091] In one exemplary embodiment, the table image to be predicted can be used to perform a table structure prediction model. After obtaining the prediction result, the prediction result is reviewed, erroneous prediction results are corrected, and the reviewed result is input into the table structure prediction model. The model training is triggered periodically to iteratively improve the accuracy of the model.
[0092] In this embodiment, an initial table structure prediction model is constructed using sample documents. This initial table structure prediction model is then used to predict the sample documents. The initial table structure prediction model is continuously iterated and adjusted to obtain a table structure prediction model. This process enables the training of the table structure prediction model, allowing it to be continuously updated in subsequent predictions. This improves the accuracy of the table structure prediction model and is also very effective in handling the recognition needs of complex table situations.
[0093] In one embodiment, such as Figure 3 The aforementioned step S3 includes:
[0094] Step S311: Input the grid graphic into a preset layout recognition model and output a grid graphic with a recognition frame, wherein the recognition frame is used to identify the table area of the grid graphic;
[0095] Step S312: Crop the non-table areas in the grid graphic with the recognition frame to obtain the processed grid graphic;
[0096] Step S313: Mark the table structure in the processed raster graphic to obtain the sample table structure.
[0097] In step S311, the layout recognition model can take a raster image as input, predict and label the table areas within the raster image, and output a raster image with recognition boxes. The processed raster image in step S312 can contain only the image of the table areas. The cropping can be done by cropping the table areas based on the recognition boxes predicted by the layout recognition model, resulting in a raster image containing only the table areas. The labeled table structure in step S313 can include information such as horizontal table lines, vertical table lines, cell merging, and header row numbers.
[0098] In one exemplary embodiment, a raster graphic of a document can be input into a layout recognition model for prediction, and a raster image with a table recognition frame can be output. The table area in the table recognition frame of the raster image can be cropped to obtain a table image, wherein the table image is an image containing only the table area, including: wired tables and wireless tables.
[0099] In one exemplary embodiment, a table annotation platform can be constructed, which can annotate incoming table images, such as... Figure 4 As shown, the image is labeled with information such as table horizontal lines, table vertical lines, cell merging, and table row numbers. The table image is then processed into the training data format for the table structure prediction model, such as... Figure 5 As shown, the platform can also be used to determine whether the model results are correct and make corrections when reviewing table data.
[0100] In this embodiment, a layout recognition model is used to predict the table in the raster graphic, cropping it to obtain a table image, and then labeling the table image to form a sample table structure. This ensures that the image input to the table structure prediction model contains only the table area, without other content as interference information. At the same time, the model can ignore the prediction of table detection, reducing the difficulty of model prediction and improving the accuracy of the table structure prediction model.
[0101] In one embodiment, such as Figure 6 The aforementioned step S3 includes:
[0102] Step S321: Edit the constituent elements of the sample table structure to obtain a derived sample table structure;
[0103] Step S322: Edit the text to obtain derived text;
[0104] Step S323: Based on the location information, merge the text and the derived text into the corresponding sample table structure to obtain a sample document; wherein the location information of the text is the same as the location information of the derived text corresponding to the text.
[0105] In step S321, the constituent elements of the table structure can include various cell types that constitute the table structure. These constituent elements may include: table lines, special cells that merge entire rows of cells, header rows, etc. The derived sample table structure can include a large number of derived complete table structures obtained after editing. The derived text in step S322 refers to a large number of new derived texts obtained after editing the original text. The position information in step S323 refers to the position information of the text within the table image. The sample document can include: a sample document after merging text with the derived table structure, a sample document after merging derived text with the table structure, and a sample document after merging derived text with the derived table structure, etc.
[0106] Optionally, editing the constituent elements in step S321 may include: adding or deleting table lines, merging and splitting cells, adding or deleting header rows, etc. Editing the text in step S322 may include: replacing text content, changing font, adding or deleting text, empty text, etc.
[0107] In one exemplary embodiment, a derived sample table structure can be generated by adding or deleting table lines and header rows in the table structure. Based on the derived sample table structure, text and corresponding position information are added, deleted, and replaced to form derived text. The derived sample table structure is then merged with the derived text to obtain a derived sample document.
[0108] In one exemplary embodiment, multiple derived texts can be generated using derived sample table structures, corresponding texts, and location information. These multiple derived texts are then cross-substituted to form multiple derived texts. The cross-substitution includes: exchanging texts among multiple derived texts, filling empty text boxes in multiple derived texts, and deleting text from derived texts.
[0109] In this embodiment, by editing the table structure, text, and corresponding position information, a large number of sample documents with uniform annotation format can be generated. This method can also produce accurate samples for tables with complex structures, which can be used to train the table structure prediction model to improve the accuracy of the table structure prediction model.
[0110] In one embodiment, such as Figure 7 The aforementioned step S3 includes:
[0111] Step S331: Output table cells of various preset categories;
[0112] Step S332: Obtain the initial table lines based on the table row area and table column area in the table unit;
[0113] Step S333: Correct the initial table lines according to the position information of the text to obtain table lines; wherein, the horizontal and vertical lines in the table lines constitute the borders of the cells;
[0114] Step S334: Merge the table cells according to the cell combination area in the table cells of the preset category to obtain the table structure in the document.
[0115] The table units in step S331 may include: table row areas, table column areas, merged cell areas, special areas of an entire row, and table header areas. The initial table line correction in step S333 can be achieved by comparing text and corresponding position information to determine if there is text overlap with table lines. If so, the overlapping table lines are corrected based on the position of the overlapping text. The cell borders and the initial table structure are obtained by the intersection of table lines. The cell combination area in step S334 may include: merged cell areas, special row areas of an entire row, and table header row areas. The merging process calculates the intersection of the cell combination area and the cells to determine the cell combinations in the initial table structure and merges them. Cell combinations may include: merged cells, special cells of an entire row, and table header row cells. The table structure in the document may include all inner and outer borders of the table and may contain all cells of the table, wherein the cells may include: merged cells, special cells of an entire row, and table header cells.
[0116] In one exemplary embodiment, the initial table lines can be determined by table row areas and table column areas. If two adjacent table row areas intersect, the horizontal center line of the intersection is taken as a horizontal table line. If two adjacent table row areas do not intersect, the horizontal center line of the blank area between the two adjacent table row areas is taken as a horizontal table line. If two adjacent table column areas intersect, the vertical center line of the intersection is taken as a vertical table line. If two adjacent table row areas do not intersect, the vertical center line of the blank area between the two adjacent table row areas is taken as a vertical table line, thus forming the initial table lines.
[0117] In one exemplary embodiment, table lines can be obtained by processing table row areas and table column areas. The table lines are then corrected based on the text's position frame to determine their final shape. For example, when a table line overlaps the text, it needs to be corrected. The horizontal table lines are adjusted vertically to minimize this overlap, and the area containing the horizontal line is set as the adjusted horizontal line. Similarly, the vertical table lines are adjusted horizontally to minimize this overlap, and the area containing the vertical line is set as the adjusted vertical line. The initial cell is then determined by the intersection of the horizontal and vertical table lines. The intersection of the merged cell area and the initial cell is calculated. For example, the merged cell area overlaps with the initial cell, and the overlapping portion is determined as the merged cell. These overlapping cells are then merged sequentially to obtain the merged cell information. In another exemplary embodiment, the intersection of a whole row of special table areas with the initial cell is calculated to obtain special row cell information. In another exemplary embodiment, the intersection of the header row area with the initial cell is calculated to obtain header row cell information. The table structure is determined based on the cell information, the merged cell information, the special row cell information, and the header cell information.
[0118] In this embodiment, the table structure in the document is obtained by analyzing and processing the table cells, making the table structure more accurate, avoiding errors caused by cell recognition, and improving the accuracy of table structure recognition.
[0119] In one embodiment, step S3 includes:
[0120] Step S5: Based on the position information of the text, add the text to the table structure to obtain a table structure with text.
[0121] In one exemplary embodiment, after obtaining the table structure with text, the erroneous prediction results can be manually reviewed and corrected. The corrected formal table data can then be used for table model training, and model training can be triggered periodically to iteratively improve the model's accuracy.
[0122] In one exemplary embodiment, after obtaining the table structure with text, the table's structural information such as tr and td can be constructed based on the horizontal and vertical overlap information of the cell position boxes, thereby constructing the table's HTML format.
[0123] In this embodiment, by matching the positional relationship between cells and text, the table structure and text are mapped one-to-one, resulting in a table identical to the one in the table image. Through step-by-step analysis of cells and text, the model can focus on the text content of the table without worrying about the content, thus reducing the prediction difficulty and improving the accuracy of table recognition.
[0124] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0125] In one exemplary embodiment, the table recognition method may be as follows: Figure 8 The flowchart is as follows:
[0126] The input electronic PDF is decomposed into JPG images and SVG images;
[0127] The JPG image is input into the layout recognition model to predict the table area and crop the table area to obtain the table image. The SVG image is then parsed to obtain the text and the corresponding position information.
[0128] The table image is input into the table structure prediction model for prediction;
[0129] The prediction results of the table structure prediction model can be manually reviewed to correct erroneous predictions, and the reviewed results can be sent to the post-processing module.
[0130] The results of the table structure prediction model, the text, and the corresponding location information are sent to the post-processing module. The post-processing module performs an intersection analysis on the results of the table structure prediction model and processes them to obtain the table structure. Based on the location information, the table structure is matched one-to-one with the text to finally obtain a table with text.
[0131] In one exemplary embodiment, the table structure prediction model in the table recognition method can be as follows: Figure 9 The flowchart is used for training:
[0132] The input electronic PDF is decomposed into JPG images and SVG images;
[0133] The JPG image is input into the layout recognition model to predict the table area and crop the table area to obtain the table image. The SVG image is then parsed to obtain the text and the corresponding position information.
[0134] The table image is annotated with its table structure to obtain a sample table structure;
[0135] Based on the location information, the sample table structure and text are matched one-to-one to obtain a sample document. At the same time, the sample table structure, text, and corresponding positional relationships are edited to obtain a derived sample table structure, derived text, and corresponding positional information. Based on the location information, the sample table structure and the derived sample table structure are matched one-to-one with the text and corresponding positional relationships to obtain a derived sample document.
[0136] The sample documents and the derived sample documents are input into the table recognition model for training.
[0137] Based on the same inventive concept, this application also provides a table recognition device for implementing the table recognition method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more table recognition device embodiments provided below can be found in the limitations of the table recognition method described above, and will not be repeated here.
[0138] In one embodiment, a form recognition device 10 is provided, such as... Figure 10 As shown, it includes: an acquisition module 100 and a generation module 200, wherein:
[0139] The retrieval module is used to retrieve documents that contain table regions;
[0140] A generation module is used to input the document into a preset table structure prediction model and output the table structure in the document. The table structure prediction model is obtained through training on the correspondence between sample documents and sample table structures. The sample document is obtained by extracting raster graphics and vector graphics corresponding to table areas in the initial sample document; determining the sample table structure corresponding to the raster graphics; parsing text and corresponding position information from the vector graphics; and generating the sample document based on the sample table structure, the text, and the corresponding position information.
[0141] In one embodiment, a table structure prediction model training device 20 is provided, such as... Figure 11As shown, it includes: an acquisition submodule 201, a construction submodule 202, a prediction submodule 203, a first generation submodule 204, and a table annotation module 205, wherein:
[0142] The acquisition submodule is used to acquire a sample document set, which includes the sample documents and the corresponding sample table structure;
[0143] A construction submodule is used to construct an initial table structure prediction model, which includes training parameters.
[0144] The prediction submodule is used to input the sample document into the initial table structure prediction model to obtain the prediction result;
[0145] The first generation submodule is used to iteratively adjust the initial table structure prediction model based on the difference between the prediction result and the sample table structure to obtain the table structure prediction model.
[0146] In one embodiment, a sample form extraction device 30 is provided, such as... Figure 12 As shown, it includes: a second generation submodule 211, a cropping submodule 212, and an annotation submodule 213, wherein:
[0147] The second generation submodule is used to input the raster graphic into a preset layout recognition model and output a raster graphic with a recognition box, wherein the recognition box is used to identify the table area of the raster graphic;
[0148] The cropping submodule is used to crop the non-table areas in the grid graphic with the recognition box to obtain the processed grid graphic.
[0149] The annotation submodule is used to annotate the table structure in the processed raster graphic to obtain the sample table structure.
[0150] In one embodiment, a sample generation device 40 is provided, such as... Figure 13 As shown, it includes: a first derivative submodule 221, a second derivative submodule 222, and a sample generation submodule 223, wherein:
[0151] The first derivative submodule is used to edit the constituent elements in the sample table structure to obtain a derived sample table structure.
[0152] The second derivative submodule is used to edit the text to obtain derived text;
[0153] The sample generation submodule is used to merge the text and the derived text into the corresponding sample table structure according to the location information to obtain a sample document; wherein the location information of the text is the same as the location information of the derived text corresponding to the text.
[0154] In one embodiment, an integrated table structure device 50 is provided, such as Figure 14 As shown, it includes: output submodule 231, table line module 232, cell submodule 233, and table structure submodule 234, wherein:
[0155] The output submodule is used to output table cells of various preset categories;
[0156] The table line submodule is used to obtain the initial table lines based on the table row area and table column area in the table unit;
[0157] The cell submodule is used to correct the initial table lines based on the position information of the text to obtain table lines; wherein, the horizontal and vertical lines in the table lines constitute the border of the cell;
[0158] The table structure submodule is used to merge the table cells according to the cell combination area in the table cells of the preset category to obtain the table structure in the document.
[0159] In one embodiment, a table recognition device is provided, comprising: an integration submodule, wherein:
[0160] The integration submodule is used to add the text to the table structure according to the position information of the text, so as to obtain a table structure with text.
[0161] Each module in the aforementioned table recognition device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0162] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 15As shown, the computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a table recognition method. The display unit is used to form a visually visible image and can be a display screen, projection device, or virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0163] Those skilled in the art will understand that Figure 15 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0164] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0165] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0166] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A table recognition method, characterized in that, The method includes: Get the document containing the table range; The document is input into a preset table structure prediction model, which outputs the table structure in the document. The table structure prediction model is trained using the correspondence between sample documents and sample table structures. The sample document is obtained by extracting raster and vector graphics corresponding to table areas in the initial sample document. The raster graphics are input into a preset layout recognition model, which outputs raster graphics with recognition boxes, which are used to identify the table areas of the raster graphics. Non-table areas in the raster graphics with recognition boxes are cropped to obtain processed raster graphics. The table structure is marked in the processed raster graphics to obtain a sample table structure. Text and corresponding position information are parsed from the vector graphics, and the constituent elements of the sample table structure are edited to obtain a derived sample table structure. Editing the constituent elements includes at least one of the following: adding or deleting table lines, merging and splitting cells, and adding or deleting header rows. The text is edited to obtain... The process involves: obtaining derived text; editing the text, including at least one of the following: replacing text content, changing font, adding or deleting text, and creating empty text; merging the text and the derived text into a corresponding sample table structure based on position information to obtain a sample document; wherein the position information of the text is the same as the position information of the derived text corresponding to the text; the raster graphic includes table areas and non-table areas; the processed raster graphic includes wired tables and non-wireless tables; and training the table structure prediction model, including: acquiring a set of sample documents, the set of sample documents including the sample documents and corresponding sample table structures; constructing an initial table structure prediction model, the initial table structure prediction model including training parameters; inputting the sample document into the initial table structure prediction model to obtain a prediction result; and iteratively adjusting the initial table structure prediction model based on the difference between the prediction result and the sample table structure to obtain a table structure prediction model.
2. The method according to claim 1, characterized in that, The step of outputting the table structure in the document includes: Output table cells of various preset categories; The initial table lines are obtained based on the table row area and table column area in the table unit; Based on the position information of the text, the initial table lines are corrected to obtain table lines; wherein, the horizontal and vertical lines in the table lines constitute the borders of the cells; Based on the cell combination area in the table cell of the preset category, the table cells are merged to obtain the table structure in the document.
3. The method according to claim 1, characterized in that, Also includes: Based on the position information of the text, the text is added to the table structure to obtain a table structure with text.
4. A form recognition device, characterized in that, The device includes: The retrieval module is used to retrieve documents that contain table regions; A generation module is used to input the document into a preset table structure prediction model and output the table structure in the document. The table structure prediction model is obtained through training on the correspondence between sample documents and sample table structures. The sample document is obtained by extracting raster graphics and vector graphics corresponding to table areas in the initial sample document; inputting the raster graphics into a preset layout recognition model and outputting raster graphics with recognition boxes, the recognition boxes being used to identify the table areas of the raster graphics; cropping the non-table areas in the raster graphics with recognition boxes to obtain a processed raster graphics; marking the table structure in the processed raster graphics to obtain a sample table structure; parsing the text and corresponding position information from the vector graphics, and editing the constituent elements in the sample table structure to obtain a derived sample table structure; editing the constituent elements includes at least one of the following: adding or deleting table lines, merging and splitting cells, adding or deleting header rows; and editing the text. The process involves: first, obtaining derived text; then, editing the text, including at least one of the following: replacing text content, changing font, adding or deleting text, and creating empty text; merging the text and the derived text into a corresponding sample table structure based on position information to obtain a sample document; wherein the position information of the text is the same as the position information of the derived text; the raster graphic includes table areas and non-table areas; the processed raster graphic includes wired tables and non-wireless tables; and training the table structure prediction model, including: obtaining a set of sample documents, the set of sample documents including the sample documents and corresponding sample table structures; constructing an initial table structure prediction model, the initial table structure prediction model including training parameters; inputting the sample documents into the initial table structure prediction model to obtain prediction results; and iteratively adjusting the initial table structure prediction model based on the difference between the prediction results and the sample table structures to obtain a table structure prediction model.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.
7. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
PDF document table extraction method, device and equipment and computer readable storage medium
CN110390269A
Table identification method and system based on structural unit, terminal and medium
CN114529773A
