Table data processing method and device, equipment and storage medium
By obtaining and adjusting the attribute information of the table template to generate a target table and converting it into a table picture, the problem of insufficient table data in the existing technology is solved, and high-quality and diverse table data generation is achieved to meet the training needs of deep learning models.
Patent Information
- Application Number
- CN202411867786.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-08
AI Technical Summary
In the prior art, the tabular data used to train table recognition models is seriously insufficient, especially the Chinese tabular data set is relatively scarce, which cannot meet the growing demand for data in model training.
By obtaining the attribute information of the preset table template, generating the target table and determining its attribute information, the row and column distribution structure of the target table is the same as that of the preset table template, but with different cell sizes. The target table is then converted into a table picture and stored in association with its attribute information.
It realizes the generation of unlimited high-simulated table data based on a small number of table templates, improves the diversity and flexibility of table data, effectively solves the problem of insufficient table training data, and meets the training needs of deep learning models.
Smart Images

Figure CN119785373A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of table generation in the field of artificial intelligence, and in particular to a method, device, equipment and storage medium for processing table data. Background Art
[0002] With the development of artificial intelligence technology, model training is a key means to improve the level of artificial intelligence. Model training requires a large amount of training data, and the quality and quantity of training data will affect the training effect of the model.
[0003] At present, there is a serious shortage of table data for training table recognition models. How to process the existing table data and generate a large amount of training data is an urgent problem to be solved. Summary of the invention
[0004] The present invention provides a method, device, equipment and storage medium for processing table data.
[0005] According to a first aspect of the present disclosure, a method for processing table data is provided, comprising:
[0006] Acquire attribute information of a preset table template; wherein the preset table template is existing table data, and the attribute information represents the row and column distribution structure and cell size of the table;
[0007] Generate a target table according to the attribute information of the preset table template, and determine the attribute information of the target table; wherein the row and column distribution structure of the target table is the same as the row and column distribution structure of the preset table template, and the size of the cell of the target table is different from the size of the cell of the preset table template;
[0008] A table image corresponding to the target table is determined, and the table image and attribute information of the target table are associated and stored.
[0009] According to a second aspect of the present disclosure, there is provided a device for processing table data, comprising:
[0010] An acquisition unit, used to acquire attribute information of a preset table template; wherein the preset table template is existing table data, and the attribute information represents the row and column distribution structure and the size of the cell of the table;
[0011] A generating unit, configured to generate a target table according to the attribute information of the preset table template, and determine the attribute information of the target table; wherein the row and column distribution structure of the target table is the same as the row and column distribution structure of the preset table template, and the size of the cell of the target table is different from the size of the cell of the preset table template;
[0012] The storage unit is used to determine the table image corresponding to the target table, and store the table image and the attribute information of the target table in association.
[0013] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0014] at least one processor; and
[0015] a memory communicatively coupled to the at least one processor;
[0016] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect of the present disclosure.
[0017] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method according to the first aspect of the present disclosure.
[0018] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program, which implements the steps of the method described in the first aspect of the present disclosure when executed by a processor.
[0019] According to the technology disclosed in the present invention, the diversity and flexibility of generating table data are improved.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0022] Figure 1 It is a flowchart of a method for processing table data provided according to an embodiment of the present disclosure;
[0023] Figure 2 It is a flowchart of a method for processing table data provided according to an embodiment of the present disclosure;
[0024] Figure 3 It is a flowchart of a method for processing table data provided according to an embodiment of the present disclosure;
[0025] Figure 4 is a schematic diagram of a target table provided according to an embodiment of the present disclosure;
[0026] Figure 5is a schematic diagram of a table generation process provided according to an embodiment of the present disclosure;
[0027] Figure 6 is a structural block diagram of a table data processing device provided according to an embodiment of the present disclosure;
[0028] Figure 7 is a structural block diagram of a table data processing device provided according to an embodiment of the present disclosure;
[0029] Figure 8 is a block diagram of an electronic device for implementing the method for processing table data of an embodiment of the present disclosure;
[0030] Fig. 9 It is a block diagram of an electronic device used to implement the method for processing table data according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0032] In the field of artificial intelligence, table recognition is a crucial task, and table recognition models driven by deep learning have been widely used in many fields. However, to improve the performance of these models, they must rely on a large amount of table data for training. At present, the real table data sets suitable for training are very limited, especially Chinese table data sets, which cannot meet the growing demand for data in model training.
[0033] The current table data generation tool can randomly generate a batch of HTML (Hyper Text Markup Language) expressions. The HTML expression can represent the structure of the table to be generated, for example, it can represent the number of rows and columns of the table. It is then rendered through the browser, and a screenshot of the page with the rendered table is saved. This method can only randomly generate tables according to the preset number of table rows and columns, and cannot generate corresponding table data for specific scenarios. Therefore, in most scenarios, it cannot improve the performance of the model, but will reduce the performance of the model. In addition, the currently generated tables are all rendered through the browser. The table images are too ideal and cannot simulate the user's actual usage environment. The flexibility and diversity of table generation are poor, which affects the training effect of the model.
[0034] The present disclosure provides a method, apparatus, device and storage medium for processing tabular data, which are applied to the field of table generation in the field of artificial intelligence. Based on a small number of table templates, it is possible to generate an unlimited amount of highly simulated tabular data, thereby improving the flexibility and diversity of generated tables, thereby effectively solving the problem of insufficient table training data and meeting the training requirements of deep learning models.
[0035] It should be noted that the data in this embodiment is not targeted at a specific user and cannot reflect the personal information of a specific user. It should be noted that the data in this embodiment comes from a public data set.
[0036] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0037] In order to enable readers to more deeply understand the implementation principle of the present disclosure, the following Figure 1-Figure 9 The embodiment is further refined.
[0038] Figure 1 FIG. 1 is a flow chart of a method for processing table data according to an embodiment of the present disclosure, and the method can be executed by a table data processing device. Figure 1 As shown, the method comprises the following steps:
[0039] S101. Acquire attribute information of a preset table template; wherein the preset table template is existing table data, and the attribute information represents the row and column distribution structure and cell size of the table.
[0040] Exemplarily, one or more table templates are pre-set as preset table templates, and existing actual table data can be used as preset table templates. Different preset table templates can be set for different scenarios. For example, if a user wants to generate a table of a transcript type, an existing transcript table can be used as a preset table template.
[0041] Each table has its own attribute information, which can represent the row and column distribution structure and cell size of the table. The row and column distribution structure indicates the number of rows and columns in the table, and the cell size indicates the size of each cell in the table. The attribute information can be represented in JSON format, and the attribute information in JSON format can be stored as text data, for example, it can be stored as a .txt document. The row and column distribution structure in the attribute information can be an HTML expression.
[0042] One or more table data can be selected in advance from multiple existing table data as preset table templates, and then the attribute information of each preset table template can be obtained. For example, all existing table data can be used as preset table templates, and the attribute information of each preset table template can be stored in the same .txt format document. Each line in the document is the attribute information of a preset table template. For example, if there are 10 preset table templates, there are 10 lines of attribute information in the document, and the content in each line can represent the row and column distribution structure and cell size of a preset table template.
[0043] In this embodiment, it also includes: acquiring existing table data; randomly determining table data of a preset template sampling number from the existing table data according to a preset template sampling number, as a preset table template; wherein the preset template sampling number represents the number of preset table templates.
[0044] Specifically, all existing table data are obtained, and the existing table data may be in the form of pictures or texts, etc. The existing table data is used as a template, that is, new table data is generated based on the existing table data.
[0045] The preset table template can be determined from the existing table data according to actual needs. For example, the template sampling number can be preset, and the template sampling number can represent the number of preset table templates required. Table data with the template sampling number can be randomly selected from all the existing table data as the preset table template. For example, if the preset template sampling number is 10, 10 table data can be randomly selected from all the table data as the preset table template.
[0046] The beneficial effect of such a setting is that an appropriate number of templates can be selected according to actual needs, avoiding the situation where too many templates affect the efficiency of table generation, or too few templates affect the diversity of table generation.
[0047] In this embodiment, it also includes: determining the number of existing table data, which is the current total amount; determining the number of tables to be sampled according to the preset template sampling ratio and the current total amount; wherein the preset template sampling ratio represents the ratio of the number of preset table templates to the current total amount, and the number of tables to be sampled represents the number of preset table templates; randomly determining the table data of the number of tables to be sampled from the existing table data is the preset table template.
[0048] Specifically, multiple data sets can be preset, each data set can include different amounts of tabular data. If the amount of existing tabular data in the data set is too large, a template sampling ratio can be preset. According to the template sampling ratio, the preset table template is determined from each data set respectively, without the need to set a template sampling number for each data set.
[0049] The template sampling ratio can characterize the ratio of the number of preset table templates to the total amount of table data in the data set. That is, for each data set, the total amount of existing table data can be determined as the current total amount. According to the preset template sampling ratio and the current total amount, the number of preset table templates that need to be determined in the data set, that is, the number of tables to be sampled, is determined. According to the number of tables to be sampled, the preset table templates can be determined from the data set. For example, table data of the number of tables to be sampled can be randomly selected from the existing table data in the data set as the preset table templates. For example, if the current total amount of existing table data is 100 and the template sampling ratio is 10%, 10 table data can be randomly selected therefrom as the preset table templates.
[0050] The beneficial effect of such a setting is that by presetting the template sampling ratio, an appropriate number of preset table templates can be determined under different total amounts, without having to set the template sampling number each time, thereby effectively improving the processing efficiency of the table data.
[0051] In this embodiment, different template sampling strategies may be set, and the template sampling strategy refers to a strategy for determining a preset table template. Template sampling strategies may include full sampling, specified number sampling, and specified ratio sampling. Full sampling refers to using all existing table data as templates; specified number sampling refers to randomly selecting a specified number of tables from the existing table data as templates; specified ratio sampling refers to randomly selecting a specified ratio of tables from the existing table data as templates, wherein the specified ratio refers to the ratio of the required number of templates to the total amount of existing table data. By setting different template sampling strategies, the preset table template can be automatically determined, thereby improving the processing efficiency of table data and the diversity of table generation.
[0052] S102. Generate a target table according to the attribute information of the preset table template, and determine the attribute information of the target table; wherein the row and column distribution structure of the target table is the same as the row and column distribution structure of the preset table template, and the size of the cell of the target table is different from the size of the cell of the preset table template.
[0053] Exemplarily, according to the attribute information of the preset table template, a table similar to but not completely identical to the preset table template can be generated as the target table. Similarity can mean that the row and column distribution structure of the target table is the same as the row and column distribution structure of the preset table template, and non-completeness can mean that the size of the cell of the target table is different from the size of the cell of the preset table template. That is, the row and column distribution structure and the size of the cell of the target table can be adjusted according to the row and column distribution structure and the size of the cell of the preset table template, so as to obtain the target table.
[0054] Multiple target tables can be generated, each with its own attribute information. The number of target tables to be generated can be preset. Generally speaking, the number of target tables should be equal to or greater than the number of preset table templates. For example, if there are 10 preset table templates and 100 target tables are to be generated, 10 target tables can be generated based on the attribute information of each preset table template. The number of target tables corresponding to each preset table template can also be preset, so that each preset table template can generate a different number of target templates.
[0055] S103: Determine a table image corresponding to the target table, and associate and store the table image with attribute information of the target table.
[0056] Exemplarily, the generated target table may be data in a preset document format, for example, the target table may be located in a document in a .doc format. The target data in the document format is converted into an image, and the converted image is a table image, which can be used to represent the target table. For example, the document of the target table may be scanned, and the scanned image may be determined as a table image.
[0057] After the target table is converted into a table image, the table image and the attribute information corresponding to the target table can be associated and stored, so as to facilitate the subsequent direct acquisition of the attribute information corresponding to the table image and train the model. For example, a model for identifying a table is pre-built, and the table image can be used as training data and the attribute information can be used as a label. The table image is input into the model, and the model can output the predicted attribute information. The predicted attribute information output by the model is compared with the label to determine whether the model training is completed. In this embodiment, the training process of the model is not specifically limited.
[0058] For example, in the education industry, the table recognition model based on deep learning can automatically analyze and correct the answers of students on the answer sheet, significantly improving the efficiency of teachers analyzing students' learning situation; in the financial field, the table recognition model can automatically process documents such as financial reports with a large number of complex tables, significantly improving the analysis efficiency. The disclosed embodiment can generate almost unlimited training data for specific scenarios, which is of great significance to various application fields.
[0059] In the disclosed embodiment, an existing table can be used as a preset table template, and a target table can be generated according to the table structure and cell size of the preset table template. The generated target table may not be completely the same as the preset table template, thereby improving the flexibility and diversity of table generation. The target table is converted into a picture format to facilitate table management, and the table picture is associated with the corresponding attribute information for storage, so as to facilitate the subsequent use of the table picture and attribute information for model training. The disclosed embodiment can generate higher quality and more tables to train the model, thereby improving the training effect of the model.
[0060] Figure 2 A flowchart of a method for processing table data provided in an embodiment of the present disclosure.
[0061] In this embodiment, the attribute information includes structural information and size information, the structural information represents the row and column distribution structure of the table, and the size information represents the size of the cells in the table; generating a target table according to the attribute information of the preset table template, including: generating an initial table according to the structural information of the preset table template; wherein the row and column distribution structure of the initial table is consistent with the row and column distribution structure of the table template; adjusting the cells of the initial table according to the size information of the preset table template to obtain the target table.
[0062] This embodiment is based on the above embodiment. Figure 2 As shown, the method comprises the following steps:
[0063] S201, obtaining attribute information of a preset table template; wherein the preset table template is existing table data, and the attribute information represents the row and column distribution structure and cell size of the table.
[0064] Exemplarily, this step may refer to the above-mentioned step S101 and will not be described in detail.
[0065] S202. Generate an initial table according to the structural information of the preset table template; wherein the row and column distribution structure of the initial table is consistent with the row and column distribution structure of the table template.
[0066] Exemplarily, the attribute information may include structure information and size information. The structure information may characterize the row and column distribution structure of the table, that is, the number of rows and columns in the table. The size information may characterize the size of the cells in the table, that is, the row height and column width of the table.
[0067] Determine the structural information of the preset table template, and generate one or more initial tables according to the structural information of the preset table template, wherein the row and column distribution structure of the initial table is consistent with the row and column distribution structure of the table template. That is, the initial table has the same number of rows and columns as the number of rows and columns in the preset table template. The initial table is a blank table, and the size of the cells in the initial table can be a preset default size.
[0068] In this embodiment, the initial table may be data in a preset document format, for example, the preset document format may be .doc or .docx, etc. The structural information may be an HTML expression, and the HTML expression of the preset table template may be converted into a blank table in the preset document format as the initial table.
[0069] S203: According to the size information of the preset table template, adjust the cells of the initial table to obtain a target table.
[0070] Exemplarily, the size information of the preset table template is determined, and the cell size of the initial table is adjusted according to the size information of the preset table template, and the adjusted initial table is determined as the target table. For example, based on the size information of the preset table template, the size information can be appropriately enlarged or reduced, and the enlarged or reduced size information is used as the size information of the target table.
[0071] In this embodiment, an initial table with the same number of rows and columns is first generated according to the structural information of the preset table template, so as to generate a standard table for a specific scenario; then, according to the size information of the preset table template, the cell size of the initial table is adjusted, so that multiple target tables of different sizes can be generated in the same scenario, thereby improving the diversity and flexibility of table generation.
[0072] In this embodiment, the cells of the initial table are adjusted according to the size information of the preset table template to obtain the target table, including: according to the size information of the preset table template, based on a preset size adjustment range, the size of the cells in the initial table is adjusted to obtain the adjusted initial table; and character filling processing is performed in the cells of the adjusted initial table to obtain the target table.
[0073] Specifically, a size adjustment range is preset, and the size of the cell can be randomly adjusted within the size adjustment range to obtain an adjusted initial table. For example, the size information of the preset table template is 1 cm in width and 1 cm in height, and the preset size adjustment range is between ±0.3 mm. Then, a value can be randomly selected within the range of 0.7 to 1.3 cm as the width of the cell, and a value can be randomly selected within the range of 0.7 to 1.3 cm as the height of the cell.
[0074] The number of target tables to be generated can be preset, and the initial tables are generated according to the number, that is, a preset number of initial tables are generated. After adjusting each initial table, the width and height of each initial table can be different, thereby increasing the diversity of the tables.
[0075] After obtaining the adjusted initial table, the adjusted initial table can be filled with characters so that the cells of the table display content. For example, random text can be introduced into the table for filling, and the target table is obtained after filling. Text can be introduced according to the size of the cell, for example, the format of the characters is preset, and the format may include font, size, color, etc. According to the size of the cell and the format of the characters, the maximum number of characters that can be contained in the cell is determined, and one or more characters are filled in the cell under the number of characters to obtain the target table.
[0076] The beneficial effect of such a setting is that the size of the cell can be randomly adjusted within a certain range, and random characters can be filled into the cell to obtain a complete target table, thereby improving the efficiency and flexibility of generating table data.
[0077] In this embodiment, character filling processing is performed on the cells of the adjusted initial table to obtain a target table, including: generating a character string to be filled according to a preset character format; and adding the character string to be filled to the cells of the adjusted initial table to obtain a target table.
[0078] Specifically, a character format is preset, and the character format may include the font, size, color of the character, and may also include the language of the filled character, the character length, etc. For example, Chinese characters need to be filled, and a maximum of 8 characters are filled. According to the preset character language and within the preset character length limit, a character string to be filled is randomly generated, that is, Chinese characters within 8 characters are randomly generated.
[0079] Each cell in the initial table can correspond to its own string to be filled, and the string to be filled is added to the corresponding cell to obtain the target table. The target table is also in .doc or .docx format.
[0080] The beneficial effect of such a setting is that, based on a preset character format, random text filling is introduced into the table, which enables the generation of diversified table data while being standardized, and keeps the table structure unchanged, thereby improving the processing accuracy of table data and the diversity of the table.
[0081] S204: Determine a table image corresponding to the target table, and associate and store the table image with attribute information of the target table.
[0082] Exemplarily, this step may refer to the above-mentioned step S103 and will not be described in detail.
[0083] In the disclosed embodiment, an existing table can be used as a preset table template, and a target table can be generated according to the table structure and cell size of the preset table template. The generated target table may not be completely the same as the preset table template, thereby improving the flexibility and diversity of table generation. The target table is converted into a picture format to facilitate table management, and the table picture is associated with the corresponding attribute information for storage, so as to facilitate the subsequent use of the table picture and attribute information for model training. The disclosed embodiment can generate higher quality and more tables to train the model, thereby improving the training effect of the model.
[0084] Figure 3 A flowchart of a method for processing table data provided in an embodiment of the present disclosure.
[0085] In this embodiment, the target table exists in a document in a preset document format; determining a table image corresponding to the target table includes: converting the document containing the target table from a preset document format to an image format to obtain a document image; and extracting a table image corresponding to the target table from the document image.
[0086] This embodiment is based on the above embodiment. Figure 3 As shown, the method comprises the following steps:
[0087] S301, obtaining attribute information of a preset table template; wherein the preset table template is existing table data, and the attribute information represents the row and column distribution structure and cell size of the table.
[0088] Exemplarily, this step may refer to the above-mentioned step S101 and will not be described in detail.
[0089] S302. Generate a target table according to the attribute information of the preset table template, and determine the attribute information of the target table; wherein the row and column distribution structure of the target table is the same as the row and column distribution structure of the preset table template, and the size of the cell of the target table is different from the size of the cell of the preset table template.
[0090] Exemplarily, this step may refer to the above-mentioned step S102 and will not be described in detail.
[0091] S303: Convert the document containing the target table from a preset document format to an image format to obtain a document image.
[0092] Exemplarily, the target table is data in a preset document format, that is, each target table may exist in a document, and the document is in a preset document format, for example, it may be a .doc format or a .docx format, etc. Figure 4 A schematic diagram of the target table. Figure 4In the example, the target table is a table with 4 rows and 4 columns. The page where the target table is located is an editable document page. The page contains no other content except the target table.
[0093] In order to avoid changes in the target table due to erroneous operations such as editing the document, the document containing the target table can be converted from a preset document format to a picture format. That is, the entire document is converted, and the converted document is a picture, which is determined as a document picture. The content in the document picture is consistent with the content in the original document, and both contain the target table. In this embodiment, the format of the converted picture is not specifically limited.
[0094] In this embodiment, the document containing the target table is converted from a preset document format to an image format to obtain a document image, including: converting the document containing the target table from a preset document format to a portable document format PDF to obtain a PDF file; and taking a full-page screenshot of the PDF file to obtain a document image.
[0095] Specifically, the document format of the document where the target table is located can be converted once, and then the image format can be converted. When the target table is generated, the format of the document where the target format is located is determined to be the first document format, and the first document format can be .doc or .docx. A second document format is preset, and the second document format can be PDF (Portable Document Format). The document where the target table is located is converted from the first document format to the second document format, that is, converted to PDF format, and a document in PDF format is obtained as a PDF file. The content in the PDF file is consistent with the content in the original document, and both contain the target table.
[0096] After obtaining the PDF file, convert the PDF file into a picture format. For example, you can take a screenshot of the entire page of the PDF file to obtain a document picture. That is, the document picture is the entire page of the PDF file. The document picture can be in .png format.
[0097] The beneficial effect of this setting is that the document containing the target table is converted into a PDF file, thereby fixing the target table on the page, avoiding garbled or unclear screenshots of the document, improving the accuracy of the document image, and further improving the processing accuracy of the table data.
[0098] S304: extracting a table image corresponding to the target table from the document image, and associating and storing the table image with attribute information of the target table.
[0099] Exemplarily, after obtaining the document image, the target table can be identified from the document image, and the target table can be extracted from the document image to obtain a table image. The table image is the target table in image format, and the table image does not contain any part of the document image other than the target table. Determine the target table corresponding to each table image, obtain the attribute information corresponding to the target table, and associate the table image with the corresponding attribute information for storage, so as to facilitate the subsequent use of the table image and attribute information for model training.
[0100] In this embodiment, a table image is extracted from a document image to reduce redundant information in the document image, improve the accuracy of the table image, and enhance the effect of subsequent model training.
[0101] In this embodiment, extracting a table image corresponding to a target table from a document image includes: identifying position information of each cell from the document image; determining position information of the target table in the document image based on the position information of each cell; and cropping the target table from the document image based on the position information of the target table in the document image to obtain a table image corresponding to the target table.
[0102] Specifically, the target table includes a plurality of cells, each of which is in the shape of a rectangular frame. Each rectangular frame can be identified from the document image, and the position information of the cell can be determined, and the position information represents the coordinates of the cell in the document image. A preset image recognition model or other image recognition technology can be used to identify the cell, and the preset image recognition model can be a neural network model, which can be used to identify the rectangular frame in the image. In this embodiment, the preset image recognition model and image recognition technology are not specifically limited.
[0103] After determining the position information of each cell, the position information of the entire target table in the document image can be determined based on the position information of these cells. According to the position information of the target table in the document image, the target table is accurately cropped from the document image to obtain a table image corresponding to the target table.
[0104] The beneficial effect of such a setting is that the table position can be identified, and the target table can be separately cropped out from the document image, thereby avoiding redundant information in the table image and improving the processing accuracy of the table data.
[0105] In this embodiment, the position information of each cell is identified from the document image, including: determining the size information of the cells in the target table based on the attribute information of the target table; adding a table frame line to the document image based on the size information of the cells in the target table; and determining the position information of each cell based on the table frame line in the document image.
[0106] Specifically, after a document image is generated, the frame lines in the table may be omitted or unclear due to multiple format conversions. The frame lines of the table in the document image may be completed to improve the extraction accuracy of the table image.
[0107] For each target table, the attribute information of the target table is obtained, and the size information of the cell is obtained from the attribute information. According to the size information of the cell, the size of the rectangular frame of each cell can be determined. A table frame line is added to the document image around the characters in each cell in the target table, that is, a frame line of each cell can be added so that the frame line of each cell can surround the character content of the cell. It is also possible to first identify the frame lines of the cells in the document image through line recognition technology. If it is determined that there are cells without corresponding frame lines, the frame lines of the cells are filled.
[0108] After determining that the frame lines in the target table are complete, the position information of each cell can be identified based on the frame lines of the table in the document image. For example, the rectangular frame of each cell can be determined based on the frame lines of the table, and the coordinates of the four vertices of the rectangular frame can be determined as the position information of the cell.
[0109] The beneficial effect of such a setting is that by completing the frame lines of the target table, the accuracy of determining the cell position information can be improved, thereby improving the cropping accuracy of the table image.
[0110] Figure 5 A schematic diagram of the table generation process. Figure 5 In the method, a preset table template is first determined, and each preset table template corresponds to its own HTML expression and cell size. A random target table is generated according to the HTML expression and cell size of the preset table template. The document containing the target table is converted into an image format, and then the target table in the image format is positioned and cropped to obtain a table image. When generating the target table, the HTML expression and cell size of the target table can be determined; when positioning and cropping, the frame line of the target table can be completed, and then the position of the cell can be located, and the table image can be accurately cropped according to the position of the cell. The HTML expression, cell size, and table image of the target table are associated and stored as table training data for training the table recognition model.
[0111] In the disclosed embodiment, an existing table can be used as a preset table template, and a target table can be generated according to the table structure and cell size of the preset table template. The generated target table may not be completely the same as the preset table template, thereby improving the flexibility and diversity of table generation. The target table is converted into a picture format to facilitate table management, and the table picture is associated with the corresponding attribute information for storage, so as to facilitate the subsequent use of the table picture and attribute information for model training. The disclosed embodiment can generate higher quality and more tables to train the model, thereby improving the training effect of the model.
[0112] Figure 6 This is a structural block diagram of a table data processing device provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Figure 6 The table data processing device 600 includes: an acquisition unit 601, a generation unit 602 and a storage unit 603.
[0113] The acquisition unit 601 is used to acquire the attribute information of the preset table template; wherein the preset table template is the existing table data, and the attribute information represents the row and column distribution structure and the size of the cell of the table;
[0114] A generating unit 602 is used to generate a target table according to the attribute information of the preset table template, and determine the attribute information of the target table; wherein the row and column distribution structure of the target table is the same as the row and column distribution structure of the preset table template, and the size of the cell of the target table is different from the size of the cell of the preset table template;
[0115] The storage unit 603 is used to determine the table image corresponding to the target table, and store the table image and the attribute information of the target table in association.
[0116] Figure 7 A structural block diagram of a table data processing device provided in an embodiment of the present disclosure, such as Figure 7 As shown, the processing device 700 for table data includes an acquisition unit 701, a generation unit 702 and a storage unit 703, wherein the attribute information includes structural information and size information, the structural information represents the row and column distribution structure of the table, and the size information represents the size of the cells in the table; the generation unit 702 includes an initial generation module 7021 and a target generation module 7022.
[0117] The initial generation module 7021 is used to generate an initial table according to the structural information of the preset table template; wherein the row and column distribution structure of the initial table is consistent with the row and column distribution structure of the table template;
[0118] The target generation module 7022 is used to adjust the cells of the initial table according to the size information of the preset table template to obtain the target table.
[0119] In one example, the target generation module 7022 includes:
[0120] A size adjustment submodule, configured to adjust the size of cells in the initial table according to the size information of the preset table template and based on a preset size adjustment range, to obtain an adjusted initial table;
[0121] The character filling submodule is used to perform character filling processing in the cells of the adjusted initial table to obtain the target table.
[0122] In one example, the character padding submodule is used to:
[0123] Generate the character string to be filled according to the preset character format;
[0124] The character string to be filled is added to the cells of the adjusted initial table to obtain the target table.
[0125] In one example, the target table exists in a document in a preset document format; the storage unit 703 includes:
[0126] A format conversion module, used for converting the document containing the target table from the preset document format to a picture format to obtain a document picture;
[0127] The image extraction module is used to extract the table image corresponding to the target table from the document image.
[0128] In one example, the format conversion module includes:
[0129] A format conversion submodule, used for converting the document containing the target table from the preset document format to a portable document format PDF to obtain a PDF file;
[0130] The screenshot submodule is used to perform a full-page screenshot process on the PDF file to obtain the document image.
[0131] In one example, the image extraction module includes:
[0132] A position identification submodule, used to identify the position information of each cell from the document image;
[0133] A position determination submodule, used to determine the position information of the target table in the document image according to the position information of each cell;
[0134] The image cropping submodule is used to crop the target table from the document image according to the position information of the target table in the document image to obtain a table image corresponding to the target table.
[0135] In one example, the location identification submodule is specifically used for:
[0136] Determining size information of cells in the target table according to the attribute information of the target table;
[0137] Adding a table border to the document image according to the size information of the cells in the target table;
[0138] The position information of each cell is determined according to the table frame lines in the document image.
[0139] In one example, it also includes:
[0140] A data acquisition unit, used for acquiring existing table data;
[0141] The first determination unit is used to randomly determine the table data of the preset template sampling quantity from the existing table data according to the preset template sampling quantity, as the preset table template; wherein the preset template sampling quantity represents the quantity of the preset table templates.
[0142] In one example, it also includes:
[0143] A total amount determination unit, used to determine the amount of the existing table data as the current total amount;
[0144] A quantity determination unit, used to determine the number of tables to be sampled according to a preset template sampling ratio and the current total amount; wherein the preset template sampling ratio represents the ratio of the number of preset table templates to the current total amount, and the number of tables to be sampled represents the number of preset table templates;
[0145] The second determining unit is used to randomly determine the table data of the number of tables to be sampled from the existing table data, which is the preset table template.
[0146] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device.
[0147] Figure 8 A structural block diagram of an electronic device provided in an embodiment of the present disclosure, such as Figure 8As shown, the electronic device 800 includes: at least one processor 802; and a memory 801 communicatively connected to the at least one processor 802; wherein the memory stores instructions executable by the at least one processor 802, and the instructions are executed by the at least one processor 802 so that the at least one processor 802 can execute the table data processing method disclosed in the present invention.
[0148] The electronic device 800 further includes a receiver 803 and a transmitter 804. The receiver 803 is used to receive instructions and data sent by other devices, and the transmitter 804 is used to send instructions and data to external devices.
[0149] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0150] According to an embodiment of the present disclosure, the present disclosure also provides a computer program product, which includes: a computer program, the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the solution provided by any of the above embodiments.
[0151] Fig. 9 A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0152] like Fig. 9 As shown, the device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 804. An input / output (I / O) interface 905 is also connected to the bus 904.
[0153] A number of components in the device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0154] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as a processing method for tabular data. For example, in some embodiments, the processing method for tabular data may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the processing method for tabular data described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform the processing method for tabular data in any other appropriate manner (e.g., by means of firmware).
[0155] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0156] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0157] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0158] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0159] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0160] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain.
[0161] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0162] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for processing tabular data, comprising: Acquire attribute information of a preset table template; wherein the preset table template is existing table data, and the attribute information represents the row and column distribution structure and cell size of the table; Generate a target table according to the attribute information of the preset table template, and determine the attribute information of the target table; wherein the row and column distribution structure of the target table is the same as the row and column distribution structure of the preset table template, and the size of the cell of the target table is different from the size of the cell of the preset table template; A table image corresponding to the target table is determined, and the table image and attribute information of the target table are associated and stored.
2. The method according to claim 1, wherein: The attribute information includes structure information and size information, wherein the structure information represents the row and column distribution structure of the table, and the size information represents the size of the cells in the table; The step of generating a target table according to the attribute information of the preset table template includes: Generate an initial table according to the structural information of the preset table template; wherein the row and column distribution structure of the initial table is consistent with the row and column distribution structure of the table template; According to the size information of the preset table template, the cells of the initial table are adjusted to obtain the target table.
3. The method according to claim 2, wherein: The adjusting cells of the initial table according to the size information of the preset table template to obtain the target table includes: According to the size information of the preset table template and based on a preset size adjustment range, the size of the cells in the initial table is adjusted to obtain an adjusted initial table; Character filling processing is performed in the cells of the adjusted initial table to obtain the target table.
4. The method according to claim 3, wherein: The step of performing character filling processing on the cells of the adjusted initial table to obtain the target table includes: Generate the character string to be filled according to the preset character format; The character string to be filled is added to the cells of the adjusted initial table to obtain the target table.
5. The method according to any one of claims 1 to 4, wherein: The target table exists in a document in a preset document format; The step of determining a table image corresponding to the target table includes: Converting the document containing the target table from the preset document format to a picture format to obtain a document picture; A table image corresponding to the target table is extracted from the document image.
6. The method according to claim 5, wherein: The step of converting the document containing the target table from the preset document format to a picture format to obtain a document picture includes: Convert the document containing the target table from the preset document format to a portable document format PDF to obtain a PDF file; The PDF file is subjected to full-page screenshot processing to obtain the document image.
7. The method according to claim 5 or 6, wherein: The step of extracting a table image corresponding to the target table from the document image includes: Identify location information of each cell from the document image; Determining the position information of the target table in the document image according to the position information of each cell; According to the position information of the target table in the document picture, the target table is cropped from the document picture to obtain a table picture corresponding to the target table.
8. The method according to claim 7, wherein: The identifying the position information of each cell from the document image includes: Determining size information of cells in the target table according to the attribute information of the target table; Adding a table border to the document image according to the size information of the cells in the target table; The position information of each cell is determined according to the table frame lines in the document image.
9. The method according to any one of claims 1 to 8, further comprising: Get existing table data; According to the preset template sampling quantity, table data of the preset template sampling quantity is randomly determined from the existing table data, which is the preset table template; wherein the preset template sampling quantity represents the quantity of the preset table templates.
10. The method according to claim 9, further comprising: Determine the quantity of the existing table data as the current total quantity; Determine the number of tables to be sampled according to the preset template sampling ratio and the current total amount; wherein the preset template sampling ratio represents the ratio of the number of preset table templates to the current total amount, and the number of tables to be sampled represents the number of preset table templates; The table data of the number of tables to be sampled is randomly determined from the existing table data, which is the preset table template.
11. A device for processing tabular data, comprising: An acquisition unit, used to acquire attribute information of a preset table template; wherein the preset table template is existing table data, and the attribute information represents the row and column distribution structure and the size of the cell of the table; A generating unit, configured to generate a target table according to the attribute information of the preset table template, and determine the attribute information of the target table; wherein the row and column distribution structure of the target table is the same as the row and column distribution structure of the preset table template, and the size of the cell of the target table is different from the size of the cell of the preset table template; The storage unit is used to determine the table image corresponding to the target table, and store the table image and the attribute information of the target table in association.
12. The device according to claim 11, wherein The attribute information includes structure information and size information, wherein the structure information represents the row and column distribution structure of the table, and the size information represents the size of the cells in the table; The generating unit comprises: An initial generation module, used to generate an initial table according to the structural information of the preset table template; wherein the row and column distribution structure of the initial table is consistent with the row and column distribution structure of the table template; The target generation module is used to adjust the cells of the initial table according to the size information of the preset table template to obtain the target table.
13. The device according to claim 12, wherein: The target generation module comprises: A size adjustment submodule, configured to adjust the size of cells in the initial table according to the size information of the preset table template and based on a preset size adjustment range, to obtain an adjusted initial table; The character filling submodule is used to perform character filling processing in the cells of the adjusted initial table to obtain the target table.
14. The device according to claim 13, wherein: The character filling submodule is specifically used for: Generate the character string to be filled according to the preset character format; The character string to be filled is added to the cells of the adjusted initial table to obtain the target table.
15. The device according to any one of claims 11 to 14, wherein: The target table exists in a document in a preset document format; The storage unit comprises: A format conversion module, used for converting the document containing the target table from the preset document format to a picture format to obtain a document picture; The image extraction module is used to extract the table image corresponding to the target table from the document image.
16. The device according to claim 15, wherein: The format conversion module comprises: A format conversion submodule, used for converting the document containing the target table from the preset document format to a portable document format PDF to obtain a PDF file; The screenshot submodule is used to perform a full-page screenshot process on the PDF file to obtain the document image.
17. The device according to claim 15 or 16, wherein: The picture extraction module comprises: A position identification submodule, used to identify the position information of each cell from the document image; A position determination submodule, used to determine the position information of the target table in the document image according to the position information of each cell; The image cropping submodule is used to crop the target table from the document image according to the position information of the target table in the document image to obtain a table image corresponding to the target table.
18. The device according to claim 17, wherein: The position identification submodule is specifically used for: Determining size information of cells in the target table according to the attribute information of the target table; Adding a table border to the document image according to the size information of the cells in the target table; The position information of each cell is determined according to the table frame lines in the document image.
19. The apparatus according to any one of claims 11 to 18, further comprising: A data acquisition unit, used for acquiring existing table data; The first determination unit is used to randomly determine the table data of the preset template sampling quantity from the existing table data according to the preset template sampling quantity, as the preset table template; wherein the preset template sampling quantity represents the quantity of the preset table templates.
20. The apparatus according to claim 19, further comprising: A total amount determination unit, used to determine the amount of the existing table data as the current total amount; A quantity determination unit, used to determine the number of tables to be sampled according to a preset template sampling ratio and the current total amount; wherein the preset template sampling ratio represents the ratio of the number of preset table templates to the current total amount, and the number of tables to be sampled represents the number of preset table templates; The second determining unit is used to randomly determine the table data of the number of tables to be sampled from the existing table data, which is the preset table template.
21. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 10.
22. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-10.
23. A computer program product, wherein: The invention comprises a computer program, which implements the steps of the method according to any one of claims 1 to 10 when being executed by a processor.
Citation Information
Patent Citations
Table recognition method and device, computer device and storage medium
CN110334585A
Table reconstruction methods and apparatus, computer-readable storage media and electronic devices
CN114936542A
Table data enhancement method and device, table recognition method and device and storage medium
CN115359501A
Table type recognition model training and predicting method and device and table data recommending method and device
CN115983237A
Table generation method and generation system
CN119067085A