Table header recognition method and device, and electronic device
By using feature matrix to process the n rows of data in the table processing, dynamically determine the table header position, the problem caused by changes in the table header position in traditional methods is solved, and more flexible and fault-tolerant data processing is achieved.
Patent Information
- Application Number
- CN202210325871.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-30
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2042-03-30
AI Technical Summary
When processing tables, traditional methods require fixed row numbers to set table header rows, which causes the data table header to be inconsistent with the code settings when users modify templates or add hidden rows, resulting in failure in import or data errors.
By reading the first n rows of data of the current table, processing the data matrix using the first feature matrix and the second feature matrix, determining the position group of predicted table headers, including the left corner point and the right corner point position, dynamically adjusting the value of n to increase the range of the data matrix until the target position of the table header is determined.
It realizes intelligent identification of the position of the table header, improves the flexibility and fault tolerance of the system, and solves the problems caused by changes in the position of the data content.
Smart Images

Figure CN114708599B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of data recognition, and in particular to a table header recognition method and device, and an electronic device. Background Art
[0002] Usually, the template of a table (for example, Excel) specifies a row as the data column header, and the following rows as data. The computer program will convert the read data into a data object based on the information in the data header, and then hand it over to the specific business logic for processing. Because the Excel template may not be the first row according to business needs, the data header row may not be the first row. The traditional method requires setting a fixed row number in the code for reading. If the user modifies the template or adds a hidden row to the template, the header row in the data table will be inconsistent with the code setting, resulting in import failure; or the user adds some comments outside the table area, which will affect the system reading, read more or less data columns, and cause data errors. Summary of the invention
[0003] In order to solve the above technical problems, the present disclosure is proposed. The embodiments of the present disclosure provide a table header recognition method and device, and an electronic device.
[0004] According to one aspect of an embodiment of the present disclosure, a table header recognition method is provided, including:
[0005] Read the content in the current table to obtain the original data matrix corresponding to the data of the first n rows of the current table; wherein n is an odd number greater than 1;
[0006] The original data matrix is processed by a first characteristic matrix and a second characteristic matrix to determine m first prediction position groups corresponding to the prediction table header; wherein each of the first prediction position groups includes a first left corner point position and a first right corner point position, and m is an integer greater than or equal to zero;
[0007] In response to the number of data rows included in the current table being greater than n+2, increasing the value of n at least once, and determining at least one set of second prediction position groups with a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n; wherein each set of the second prediction position groups includes at least one second left corner point position and at least one second right corner point position;
[0008] Based on the m first prediction position groups and / or at least one second prediction position group, a target position of a table header corresponding to the current table is determined.
[0009] Optionally, the step of reading the content in the current table to obtain the original data matrix corresponding to the data of the first n rows of the current table includes:
[0010] Read the data in the current table row by row to obtain the original data of the first n rows of the current table;
[0011] The n rows of original data are coded and converted to obtain an original data matrix.
[0012] Optionally, the processing the original data matrix by using the first characteristic matrix and the second characteristic matrix to determine the m first prediction position groups corresponding to the prediction table header includes:
[0013] Convolve and calculate the original data matrix with the first feature matrix and the second feature matrix respectively to obtain a first determination matrix and a second determination matrix; wherein the first feature matrix and the second feature matrix are both n*n matrices;
[0014] Determine at least one first left corner point position of the prediction table header based on the position with the largest value in the first determination matrix;
[0015] Determine at least one first right corner point position of the prediction table header based on the position with the largest value in the second determination matrix;
[0016] The m first predicted position groups are determined based on the at least one first left corner point position and the at least one first right corner point position.
[0017] Optionally, the convolving and calculating the original data matrix with the first feature matrix and the second feature matrix respectively to obtain a first determination matrix and a second determination matrix includes:
[0018] Fill and expand the original data matrix according to the sizes of the first characteristic matrix and the second characteristic matrix to obtain an expanded matrix;
[0019] The first feature matrix and the second feature matrix are respectively used as convolution kernels to perform convolution and calculation with the expansion matrix to obtain a first determination matrix and a second determination matrix.
[0020] Optionally, determining the m first predicted position groups based on the at least one first left corner point position and the at least one first right corner point position comprises:
[0021] Determine the row where each first left corner point position in the at least one first left corner point position is located, and determine the row where each first right corner point position in the at least one first right corner point position is located;
[0022] The first left corner point position and the first right corner point position that are in the same row are determined as the first predicted position group to obtain the m first predicted position groups.
[0023] Optionally, it also includes:
[0024] In response to the number of data rows included in the current table being less than n+2, determining whether m is zero;
[0025] When m is zero, the first row in the current table is used as the target position;
[0026] When m is not zero, a first prediction position group with the smallest number of rows is determined from the at least one first prediction position group as the target position.
[0027] Optionally, determining a target position of a table header corresponding to the current table based on the m first prediction position groups and / or at least one second prediction position group includes:
[0028] Determine whether the column difference value corresponding to each of the m first prediction position groups is less than n+2; wherein the column difference value is the difference between the column number where the first right corner point position is located and the column number where the first left corner point position is located in the first prediction position group;
[0029] In response to the column difference corresponding to each of the first prediction position groups being less than n+2, determining a target position of a table header corresponding to the current table based on the at least one second prediction position group;
[0030] In response to the column difference corresponding to each of the first prediction position groups being greater than n+2, a target position of a table header corresponding to the current table is determined based on the at least one first prediction position group and at least one second prediction position group.
[0031] Optionally, determining a target position of a table header corresponding to the current table based on the at least one set of second predicted position groups includes:
[0032] Determine whether at least one second left corner point position in each group of the second predicted position groups has a second left corner point position with overlapping positions in other second predicted position groups; and determine whether at least one second right corner point position has a second right corner point position with overlapping positions in other second predicted position groups;
[0033] In response to the existence of position overlap, determining a target position of a table header corresponding to the current table based on the second left corner point position and the second right corner point position that overlap;
[0034] In response to the absence of position overlap, a target position of the table header corresponding to the current table is determined based on the second left corner point position and the second right corner point position corresponding to the new data matrix with the largest n value.
[0035] Optionally, determining a target position of a table header corresponding to the current table based on the at least one first prediction position group and the at least one second prediction position group includes:
[0036] Determine whether at least one first left corner point position of the at least one first predicted position group has a second left corner point position with overlapping positions in the at least one second predicted position group; and determine whether at least one first right corner point position has a second right corner point position with overlapping positions in the at least one second predicted position group;
[0037] In response to the existence of position overlap, determining a target position of a table header corresponding to the current table based on the first left corner point position and the first right corner point position that overlap;
[0038] In response to the absence of position overlap, a target position of the table header corresponding to the current table is determined based on the second left corner point position and the second right corner point position corresponding to the new data matrix with the largest n value.
[0039] Optionally, increasing the value of n at least once, and determining at least one second predicted position group with a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n, comprises:
[0040] Add 2 to the value of n, continue reading the content in the current table, and obtain a new data matrix corresponding to the data of the first n rows of the current table;
[0041] Processing the new data matrix by using the new first characteristic matrix and the new second characteristic matrix to determine at least one second prediction position corresponding to the prediction table header;
[0042] In response to the number of data rows included in the current table being greater than n+2, iteratively executing the above steps until the number of times the value of n is increased reaches a set number of times, thereby obtaining the at least one second predicted position group;
[0043] In response to the number of data rows included in the current table being less than n+2, the at least one set of second predicted position groups is obtained.
[0044] According to another aspect of an embodiment of the present disclosure, a table header recognition device is provided, comprising:
[0045] A data reading module is used to read the content in the current table and obtain the original data matrix corresponding to the data of the first n rows of the current table; wherein n is an odd number greater than 1;
[0046] A table header prediction module, used to process the original data matrix through a first feature matrix and a second feature matrix to determine m first prediction position groups corresponding to the prediction table header; wherein each of the first prediction position groups includes a first left corner point position and a first right corner point position, and m is an integer greater than or equal to zero;
[0047] an iterative prediction module, configured to, in response to the number of data rows included in the current table being greater than n+2, increase the value of n at least once, and determine at least one set of second prediction position groups with a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n; wherein each set of the second prediction position groups includes at least one second left corner point position and at least one second right corner point position;
[0048] The first position determination module is used to determine a target position of a table header corresponding to the current table based on the m first predicted position groups and / or at least one second predicted position group.
[0049] Optionally, the data reading module is specifically used to read the data in the current table row by row to obtain the original data of the first n rows of the current table; and perform encoding conversion on the original data of the n rows to obtain the original data matrix.
[0050] Optionally, the table header prediction module includes:
[0051] A convolution calculation unit, used for convolving and calculating the original data matrix with the first feature matrix and the second feature matrix respectively, to obtain a first determination matrix and a second determination matrix; wherein the first feature matrix and the second feature matrix are both n*n matrices;
[0052] A left corner point prediction unit, used to determine at least one first left corner point position of the prediction table header based on the position with the largest value in the first decision matrix;
[0053] A right corner point prediction unit, used to determine at least one first right corner point position of the prediction table header based on the position with the largest value in the second determination matrix;
[0054] A position prediction unit is used to determine the m first predicted position groups based on the at least one first left corner point position and the at least one first right corner point position.
[0055] Optionally, the convolution calculation unit is specifically used to fill and expand the original data matrix according to the size of the first feature matrix and the second feature matrix to obtain an extended matrix; and perform convolution and calculation with the extended matrix using the first feature matrix and the second feature matrix as convolution kernels to obtain a first determination matrix and a second determination matrix.
[0056] Optionally, the position prediction unit is specifically used to determine the row where each first left corner point position among the at least one first left corner point position is located, and to determine the row where each first right corner point position among the at least one first right corner point position is located; the first left corner point position and the first right corner point position that are in the same row are determined as the first predicted position group, to obtain the m first predicted position groups.
[0057] Optionally, the device further comprises:
[0058] A second position determination module is used to determine whether m is zero in response to the number of data rows included in the current table being less than n+2; when m is zero, taking the first row in the current table as the target position; when m is not zero, determining the first predicted position group with the smallest number of rows from the at least one first predicted position group as the target position.
[0059] Optionally, the first position determination module is specifically used to determine whether the column difference corresponding to each of the m first prediction position groups is less than n+2; wherein the column difference is the difference between the column number where the first right corner point position is located and the column number where the first left corner point position is located in the first prediction position group; in response to the column difference corresponding to each of the first prediction position groups being less than n+2, based on the at least one group of second prediction position groups, the target position of the table header corresponding to the current table is determined; in response to the column difference corresponding to each of the first prediction position groups being greater than n+2, based on the at least one first prediction position group and at least one group of second prediction position groups, the target position of the table header corresponding to the current table is determined.
[0060] Optionally, when determining the target position of the table header corresponding to the current table based on the at least one group of second predicted position groups, the first position determination module is used to determine whether at least one second left corner point position in each group of the second predicted position groups has an overlapping second left corner point position in other second predicted position groups; and determine whether at least one second right corner point position has an overlapping second right corner point position in other second predicted position groups; in response to the existence of position overlap, determining the target position of the table header corresponding to the current table based on the overlapping second left corner point position and second right corner point position; in response to the absence of position overlap, determining the target position of the table header corresponding to the current table based on the second left corner point position and second right corner point position corresponding to the new data matrix with the largest n value.
[0061] Optionally, when determining the target position of the table header corresponding to the current table based on the at least one first predicted position group and the at least one second predicted position group, the first position determination module is used to determine whether there is a second left corner point position with overlapping positions in at least one first left corner point position of the at least one first predicted position group in the at least one second predicted position group; and determine whether there is a second right corner point position with overlapping positions in the at least one second predicted position group; in response to the existence of positional overlap, determine the target position of the table header corresponding to the current table based on the first left corner point position and the first right corner point position with overlapping positions; in response to the absence of positional overlap, determine the target position of the table header corresponding to the current table based on the second left corner point position and the second right corner point position corresponding to the new data matrix with the largest n value.
[0062] Optionally, the iterative prediction module is specifically used to add 2 to the value of n, continue to read the contents of the current table, and obtain a new data matrix corresponding to the data of the first n rows of the current table; process the new data matrix through the new first feature matrix and the new second feature matrix to determine at least one second prediction position corresponding to the prediction table header; in response to the number of data rows included in the current table being greater than n+2, iteratively perform the above steps until the number of times the value of n is increased reaches a set number of times, and obtain the at least one group of second prediction position groups; in response to the number of data rows included in the current table being less than n+2, obtain the at least one group of second prediction position groups.
[0063] According to another aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the table header recognition method described in any of the above embodiments.
[0064] According to another aspect of the embodiments of the present disclosure, an electronic device is provided, the electronic device comprising:
[0065] processor;
[0066] a memory for storing instructions executable by the processor;
[0067] The processor is used to read the executable instructions from the memory and execute the instructions to implement the table header recognition method described in any one of the above embodiments.
[0068] Based on the above embodiments of the present disclosure, a table header recognition method, device, and electronic device are provided. The content in the current table is read to obtain the original data matrix corresponding to the data of the first n rows of the current table; wherein n is an odd number greater than 1; the original data matrix is processed by a first feature matrix and a second feature matrix to determine m first prediction position groups corresponding to the prediction header; wherein each of the first prediction position groups includes a first left corner point position and a first right corner point position, and m is an integer greater than or equal to zero; in response to the number of data rows included in the current table being greater than n+2, the value of n is increased at least once, and at least one group of second prediction position groups is determined by a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n; wherein each group of the second prediction position groups includes at least one second left corner point position and at least one second right corner point position; based on the m first prediction position groups and / or at least one group of second prediction position groups, the target position of the header corresponding to the current table is determined; the embodiment of the present disclosure proposes a method of intelligently identifying data header rows using feature matrices based on specific data content, which provides more flexibility and fault tolerance and solves the problem caused by changes in data content position.
[0069] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The above and other purposes, features and advantages of the present disclosure will become more apparent by describing the embodiments of the present disclosure in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. In the drawings, the same reference numerals generally represent the same components or steps.
[0071] Figure 1 It is a flowchart of a table header recognition method provided by an exemplary embodiment of the present disclosure.
[0072] Figure 2a This disclosure Figure 1 A schematic flow chart of step 102 in the embodiment shown.
[0073] Figure 2b It is a schematic diagram of part of the contents of a current table in an optional example of a table header recognition method provided by an exemplary embodiment of the present disclosure.
[0074] Figure 2c yes Figure 2b A schematic diagram of the original data matrix obtained by encoding and converting the tabular data in the illustrated embodiment.
[0075] Figure 3 This disclosure Figure 1A schematic flow chart of step 104 in the illustrated embodiment.
[0076] Figure 4 This disclosure Figure 1 A schematic flow chart of step 108 in the illustrated embodiment.
[0077] Figure 5 This disclosure Figure 1 A schematic flow chart of step 106 in the illustrated embodiment.
[0078] Figure 6 It is a structural schematic diagram of a table header recognition device provided by an exemplary embodiment of the present disclosure.
[0079] Figure 7 is a structural diagram of an electronic device provided by an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0080] Below, the exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described here.
[0081] It should be noted that the relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless specifically stated otherwise.
[0082] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present disclosure are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.
[0083] It should also be understood that in the embodiments of the present disclosure, “plurality” may refer to two or more than two, and “at least one” may refer to one, two, or more than two.
[0084] It should also be understood that any component, data or structure mentioned in the embodiments of the present disclosure can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.
[0085] In addition, the term "and / or" in this disclosure is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this disclosure generally indicates that the previous and next associated objects are in an "or" relationship. The data referred to in this disclosure may include unstructured data such as text, images, and videos, and may also be structured data.
[0086] It should also be understood that the description of the various embodiments in the present disclosure focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.
[0087] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0088] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0089] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0090] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0091] The disclosed embodiments can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.
[0092] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0093] Exemplary Methods
[0094] Figure 1 FIG. 1 is a flow chart of a table header recognition method provided by an exemplary embodiment of the present disclosure. This embodiment can be applied to electronic devices, such as Figure 1 As shown, the following steps are included:
[0095] Step 102, read the content in the current table to obtain the original data matrix corresponding to the data of the first n rows of the current table.
[0096] Here, n is an odd number greater than 1, for example, 3, 5, 7, etc.
[0097] In this embodiment, the current table can be a table file (such as an Excel file) including arbitrary data content; when processing the data in the current table, it can be read and processed at the same time without reading all the data at one time. When processing n rows of data, n rows can be read for processing, saving memory space.
[0098] In this article, Excel files are mostly used as table files for explanation. People skilled in the art should understand that other table files, such as Numbers files in Mac OS and Kingsoft Excel files, also fall within the scope of application of the present invention.
[0099] Step 104: Process the original data matrix using the first characteristic matrix and the second characteristic matrix to determine m first prediction position groups corresponding to the prediction table header.
[0100] Each first predicted position group includes a first left corner point position and a first right corner point position, and m is an integer greater than or equal to zero.
[0101] In one embodiment, the first feature matrix is used to identify the position of the upper left corner in an area with the same shape as the first feature matrix in the data of the first n rows of the current table, and the second feature matrix is used to identify the position of the upper right corner in an area with the same shape as the second feature matrix in the data of the first n rows of the current table.
[0102] Step 106, in response to the number of data rows included in the current table being greater than n+2, increasing the value of n at least once, and determining at least one second prediction position group with a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n.
[0103] Each group of second predicted position groups includes at least one second left corner point position and at least one second right corner point position.
[0104] In this embodiment, since the data is partially read and partially processed, and the header row may not be in the first n rows, it is necessary to expand the data processing range and recognize other rows in the current table by increasing the value of n.
[0105] Step 108: Determine a target position of a table header corresponding to the current table based on the m first prediction position groups and / or at least one second prediction position group.
[0106] The above embodiments of the present disclosure provide a table header recognition method and device, storage medium, and electronic device, which read the content in the current table to obtain the original data matrix corresponding to the data of the first n rows of the current table; wherein n is an odd number greater than 1; the original data matrix is processed by a first feature matrix and a second feature matrix to determine m first prediction position groups corresponding to the prediction header; wherein each of the first prediction position groups includes a first left corner point position and a first right corner point position, and m is an integer greater than or equal to zero; in response to the number of data rows included in the current table being greater than n+2, the value of n is increased at least once, and at least one group of second prediction position groups is determined by a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n; wherein each group of the second prediction position groups includes at least one second left corner point position and at least one second right corner point position; based on the m first prediction position groups and / or at least one group of second prediction position groups, a target position of the header corresponding to the current table is determined; the embodiments of the present disclosure propose a method of intelligently identifying data header rows using feature matrices based on specific data content, which provides more flexibility and fault tolerance and solves the problem caused by changes in data content position.
[0107] like Figure 2a As shown in the above Figure 1 Based on the illustrated embodiment, step 102 may include the following steps:
[0108] Step 1021, read the data in the current table row by row to obtain the original data of the first n rows of the current table.
[0109] In this embodiment, the data in the current table can be read in SAX mode to achieve row-by-row reading. The current table content is read from top to bottom in sequence and cannot be read twice, so a cache result is required to store the Excel part content used for judgment.
[0110] Optionally, the process of data reading cache may include: when intelligent judgment is turned off, conventional reading is to read Excel content row by row, and when the current row number is equal to the set data column header row (for example, when the nth row has not been read), the data object attribute structure is set (the entire row content is used as the data column, excluding blank cells); when the current row number is greater than the set data column header row (that is, when n rows of data are read), it is used as data content, converted into a data object, and used as original data.
[0111] When smart judgment is turned on, the judgment content size is set (default 128), and Excel content is accepted row by row and placed in the cache. When the number of cached rows is equal to the set judgment content size (that is, when n rows of data are read) or when the end of Excel is read, the Excel content that has been read is recognized for the header, and the row number of the predicted table header is returned. The data of the row number of the data column header row in the cache is set as the data object attribute structure (the data within the left and right boundaries of the judgment content range is used as the data column, and most of the other content that is not the column header information can be excluded). The data in the cache that is larger than the row number of the data column header row is continued to be processed as the data content. If there is still unread content in Excel, the remaining Excel content is continued to be read and processed as the data content.
[0112] Step 1022, performing encoding conversion on the n rows of original data to obtain an original data matrix.
[0113] In this embodiment, the data content in the table is transformed into a two-dimensional matrix through a transformation function. Optionally, the transformation function here adopts the simplest form to meet most scenarios; for example, an example transformation function is: transforming an empty cell to 0 and a non-empty cell to 1. Figure 2b After encoding the contents of the table shown in Figure 2c The two-dimensional matrix shown is used as the original data matrix; or, another example is transformed as follows: according to the character length of the text or value in the cell, it is transformed into a corresponding value, and the longer the character length, the larger the value obtained after the transformation; this embodiment reads the contents of the first n rows of Excel content, and converts them into a two-dimensional matrix according to the transformation function, converting the problem of identifying the row number of the data column header into the problem of identifying the position of a rectangle containing the data column header and the data content, thereby realizing automatic identification of the header position without manual participation and saving manpower.
[0114] like Figure 3 As shown in the above Figure 1 Based on the illustrated embodiment, step 104 may include the following steps:
[0115] Step 1041, convolve and calculate the original data matrix with the first characteristic matrix and the second characteristic matrix respectively to obtain the first determination matrix and the second determination matrix.
[0116] The first characteristic matrix and the second characteristic matrix are both n*n matrices.
[0117] Optionally, assuming that the size of the first feature matrix is size*size, the process of determining the first feature matrix for identifying the upper left corner of the rectangle may include: setting the flag flag to size / 2 and rounding it, looping the rows and columns (the serial number starts from 0), the row number +1 is less than or equal to flag, or the column number +1 is less than or equal to flag, then the current matrix position value is set to -1, otherwise it is set to 1, and the process can be implemented by the following pseudo code:
[0118]
[0119] After the above processing, when size = 3, the size of the first feature matrix is 3*3, and the first feature matrix can be obtained as The first characteristic matrix determines that the more similar the shape of the data matrix is to the first characteristic matrix, the larger the position value of the convolution sum with the first characteristic matrix in the upper left corner.
[0120] Optionally, assuming that the size of the second feature matrix is size*size, the process of determining the second feature matrix for identifying the upper right corner of the rectangle may include: setting the flag flag to size / 2 and rounding it, looping the rows and columns (the serial number starts from 0), the row number + 1 is less than or equal to flag or the column number is greater than flag, then the current matrix position value is set to -1, otherwise it is set to 1, and the process can be implemented by the following pseudo code:
[0121]
[0122]
[0123] After the above processing, when size = 3, the size of the second characteristic matrix is 3*3, and the second characteristic matrix can be obtained as The second characteristic matrix determines that the more similar the shape of the data matrix is to the second characteristic matrix, the larger the position value of the convolution sum with the second characteristic matrix in the upper right corner.
[0124] Step 1042: Determine at least one first left corner point position of the prediction table header based on the position with the largest value in the first determination matrix.
[0125] Optionally, the first determination matrix has the same size as the original data matrix, and there may be at least one position with the largest value in the first determination matrix, that is, there are multiple maximum values. In this case, the positions corresponding to the multiple maximum values are all used as at least one first left corner point position in the original data matrix.
[0126] Step 1043: Determine at least one first right corner point position of the prediction table header based on the position with the largest value in the second determination matrix.
[0127] Optionally, the second determination matrix has the same size as the original data matrix, and there may be at least one position with the largest value in the second determination matrix, that is, there are multiple maximum values. In this case, the positions corresponding to the multiple maximum values are all used as at least one first right corner point position in the original data matrix.
[0128] Step 1044: Determine m first predicted position groups based on at least one first left corner point position and at least one first right corner point position.
[0129] Optionally, step 1044 may further include: determining a row where each first left corner point position in at least one first left corner point position is located, and determining a row where each first right corner point position in at least one first right corner point position is located;
[0130] The first left corner point position and the first right corner point position of the same row as the row are determined as a first prediction position group, and m first prediction position groups are obtained.
[0131] Since the ultimate goal of this embodiment is to determine the row where the header is located in the current table, and the header is usually a row, the left corner point position and the right corner point position corresponding to the row where the header is located must be in the same row. In this embodiment, among the at least one first upper left corner point position and the at least one first upper right corner point position determined by the judgment matrix, there may be a first upper left corner point position and a first upper right corner point position in the same row, and there may also be a first upper left corner point position and a first upper right corner point position that are not in the same row. In this embodiment, the first upper left corner point position and the first upper right corner point position in the same row are determined as a first predicted position group. When all the first upper left corner point positions and the first upper right corner point positions are not in the same row, the value of m is zero, that is, no predicted header is obtained based on the current value of n, and it can be considered that the header is not in the first n rows of data in the current table.
[0132] Optionally, step 1041 proposed in the above embodiment may include:
[0133] The original data matrix is filled and expanded according to the sizes of the first characteristic matrix and the second characteristic matrix to obtain an expanded matrix.
[0134] In this embodiment, before convolution and calculation are performed on the original data matrix, in order to avoid data omission, the original data matrix needs to be padded so that the judgment matrix calculated later is of the same size as the original data matrix; wherein the padding is to fill a set number of circles of 0s around the original data matrix, and the value k of the set number of circles is an integer value obtained by dividing the number of rows (or columns) of the first judgment matrix (or the second judgment matrix) by 2. For example, if the number of rows of the first judgment matrix is 3, a circle of 0s is added around the original data matrix, that is, a row of 0s is added above the original data matrix, a row of 0s is added below the original data matrix, a column of 0s is added on the left, and a column of 0s is added on the right.
[0135] The first characteristic matrix and the second characteristic matrix are respectively used as convolution kernels and expansion matrices to perform convolution and calculation to obtain a first determination matrix and a second determination matrix.
[0136] In this embodiment, the first characteristic matrix and the second characteristic matrix are used respectively to perform convolution and calculation on the extended matrix with a step size of 1 to determine which current position's shape is most matched with the characteristic matrix (the first characteristic matrix or the second characteristic matrix). After the convolution and calculation, the first determination matrix and the second determination matrix are obtained. Since the sizes of the first determination matrix and the second determination matrix are the same as the original data matrix, the position of the left corner point of the predicted header in the original data matrix can be determined based on the maximum value position in the first determination matrix, and the position of the upper right corner point of the predicted header in the original data matrix can be determined based on the maximum value position in the second determination matrix, thereby realizing the prediction of the header position of the original data matrix.
[0137] In some optional embodiments, the method provided in this embodiment further includes:
[0138] In response to the number of data rows included in the current table being less than n+2, determining whether m is zero;
[0139] When m is zero, the first row in the current table is used as the target position;
[0140] When m is not zero, a first prediction position group with the smallest number of rows is determined from at least one first prediction position group as the target position.
[0141] In this embodiment, the data in the current table is insufficient to support the next increase in the value of n. For example, when n=5, and the total number of rows corresponding to the content in the current table is 5 rows; at this time, there is no need to continue to increase the value of n to continue to calculate the new predicted position, but the target position is determined by the currently obtained m first predicted position groups, and when m=0, it can be considered that the first predicted position group is not obtained based on the current value of n, and the default first row is used as the table header; and when there is at least one first predicted position group, since the table header is usually at a higher position, this embodiment uses the first predicted position group with the smallest number of rows as the target position, thereby improving the credibility of the determined table header position.
[0142] like Figure 4 As shown in the above Figure 1 Based on the illustrated embodiment, step 108 may include the following steps:
[0143] Step 1081 , determining whether the column difference corresponding to each of the m first prediction position groups is less than n+2; if so, executing step 1082 , otherwise, executing step 1083 .
[0144] The column difference is the difference between the column number where the first right corner point is located and the column number where the first left corner point is located in the first predicted position group.
[0145] Step 1082: Determine a target position of a table header corresponding to the current table based on at least one second predicted position group.
[0146] Step 1083: Determine a target position of a table header corresponding to the current table based on at least one first prediction position group and at least one second prediction position group.
[0147] Among them, when the column difference is equal to n+2, step 1083 or step 1082 can be executed, which can be determined according to the actual application scenario.
[0148] This embodiment shows that if the distance between the first right corner point position and the first left corner point position in the predicted position obtained by a single prediction is less than the size of the feature matrix of the next round, it means that the data in the predicted position is not in a whole row, and usually the number of columns corresponding to the header row is the maximum number of columns in the table data. Therefore, it means that the predicted position is inaccurate. The predicted position obtained in the current round does not participate in the next round of calculation, thereby improving the accuracy of the target position provided by this embodiment.
[0149] Optionally, step 1082 may include:
[0150] Determine whether at least one second left corner point position in each group of second predicted position groups has a second left corner point position with overlapping positions in other second predicted position groups; and determine whether at least one second right corner point position has a second right corner point position with overlapping positions in other second predicted position groups;
[0151] In response to the existence of position overlap, determining a target position of a table header corresponding to the current table based on the second left corner point position and the second right corner point position of the overlapped positions;
[0152] In response to the absence of position overlap, a target position of the table header corresponding to the current table is determined based on the second left corner point position and the second right corner point position corresponding to the new data matrix with the largest n value.
[0153] In this embodiment, when the prediction of the table header position of each round is relatively accurate, the obtained predicted position should be overlapping. Therefore, when there are overlapping left and right corner positions, this embodiment uses the overlapping position as the target position. When there is no overlapping position, since the maximum round (n has the largest value) covers the most content of the current table data, the target position is determined by the predicted position of the maximum round, avoiding the problem of the table header being missed when it is in the later rows.
[0154] Optionally, step 1083 may include:
[0155] Determine whether at least one first left corner point position of at least one first predicted position group has a second left corner point position with overlapping position in at least one second predicted position group; and determine whether at least one first right corner point position has a second right corner point position with overlapping position in at least one second predicted position group;
[0156] In response to the existence of position overlap, determining a target position of a table header corresponding to the current table based on the first left corner point position and the first right corner point position of the overlap;
[0157] In response to the absence of position overlap, a target position of the table header corresponding to the current table is determined based on the second left corner point position and the second right corner point position corresponding to the new data matrix with the largest value of n.
[0158] In this embodiment, the first predicted position group can also be regarded as a second predicted position group. At this time, the process of determining the target position is similar to the process of step 1082 in the above embodiment, which can be understood with reference to the above embodiment and will not be repeated here.
[0159] like Figure 5 As shown in the above Figure 1 Based on the illustrated embodiment, step 106 may include the following steps:
[0160] Step 1061, add 2 to the value of n, continue reading the content in the current table, and obtain a new data matrix corresponding to the data of the first n rows of the current table.
[0161] Step 1062: Process the new data matrix using the new first characteristic matrix and the new second characteristic matrix to determine at least one second prediction position corresponding to the prediction table header.
[0162] Step 1063, determine whether the number of times the value of n is increased reaches a set number of times, if yes, obtain at least one group of second predicted position groups, and end; otherwise, execute step 1064.
[0163] In this embodiment, if the total number of rounds exceeds the set number, the next round of calculation is stopped. Optionally, the set number can be set to a value such as 3, 4, 5, etc. The specific value of the set number can be set according to the actual application scenario.
[0164] Step 1064, determine whether the number of data rows included in the current table is less than n+2, if so, execute step 1065; otherwise, return to execute step 1061.
[0165] Step 1065, obtaining at least one set of second predicted position groups.
[0166] The value of n in this embodiment is increased gradually, and each time the value of n is increased by 2, and the header prediction is performed with the increased value of n, to achieve multiple rounds of header position prediction. The conditions for ending the iteration include that the number of data rows in the current table has been processed, or the number of iterations reaches the set number; at this time, the second predicted position group of all predicted headers is obtained; through multiple rounds of prediction, the header of any row in the table content can be accurately identified, avoiding the problem of inaccurate results caused by only identifying the number of rows in the earlier position, and improving the accuracy of the target position.
[0167] In an optional example, the feature matrix size is set to 3*3 in the first round, and the original data matrix is convolved and calculated with the first feature matrix and the second feature matrix to obtain the first judgment matrix and the second judgment matrix. The position with the largest value in the first judgment matrix is most likely to be the position of the upper left corner of the table header, and the position with the largest value in the second judgment matrix is most likely to be the position of the upper right corner of the table header. If the current predicted upper left corner position and the upper right corner position of the data matrix are in the same row, then this row becomes the candidate predicted data column header row. When multiple rows have the same score, the feature matrix size is expanded, and the height and width are increased by 2 (5*5 in the second round), and matched again until the unique highest score predicted data column header row is matched. Some special cases will also end early and directly return the most likely result under the current conditions; characteristic cases may include: 1. If the last row of Excel has been read and the total number of rows is not enough to continue to expand the feature matrix size; 2. The data width of multiple predicted data column header rows currently pending is not enough to continue to expand the matrix size.
[0168] Any table header recognition method provided in the embodiments of the present disclosure may be executed by any appropriate device with data processing capabilities, including but not limited to: a terminal device and a server, etc. Alternatively, any table header recognition method provided in the embodiments of the present disclosure may be executed by a processor, such as the processor executing any table header recognition method mentioned in the embodiments of the present disclosure by calling corresponding instructions stored in a memory. This will not be described in detail below.
[0169] Exemplary Devices
[0170] Figure 6 FIG. 1 is a schematic diagram of a structure of a table header recognition device provided by an exemplary embodiment of the present disclosure. Figure 6 As shown, the device provided in this embodiment includes:
[0171] The data reading module 61 is used to read the content in the current table and obtain the original data matrix corresponding to the data of the first n rows of the current table; wherein n is an odd number greater than 1;
[0172] A table header prediction module 62 is used to process the original data matrix through the first characteristic matrix and the second characteristic matrix to determine m first prediction position groups corresponding to the prediction table header; wherein each first prediction position group includes a first left corner point position and a first right corner point position, and m is an integer greater than or equal to zero;
[0173] The iterative prediction module 63 is used to, in response to the number of data rows included in the current table being greater than n+2, increase the value of n at least once, and determine at least one set of second prediction position groups with a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n; wherein each set of second prediction position groups includes at least one second left corner point position and at least one second right corner point position;
[0174] The first position determination module 64 is configured to determine a target position of a table header corresponding to a current table based on the m first predicted position groups and / or at least one second predicted position group.
[0175] Optionally, the data reading module 61 is specifically used to read the data in the current table row by row to obtain the original data of the first n rows of the current table; and perform encoding conversion on the original data of the n rows to obtain the original data matrix.
[0176] Optionally, the header prediction module 62 includes:
[0177] A convolution calculation unit, used to convolve and calculate the original data matrix with the first characteristic matrix and the second characteristic matrix respectively, to obtain a first determination matrix and a second determination matrix; wherein the first characteristic matrix and the second characteristic matrix are both n*n matrices;
[0178] A left corner point prediction unit, used to determine at least one first left corner point position of the prediction table header based on the position with the largest value in the first determination matrix;
[0179] A right corner point prediction unit, used to determine at least one first right corner point position of the prediction table header based on the position with the largest value in the second determination matrix;
[0180] A position prediction unit is used to determine m first predicted position groups based on at least one first left corner point position and at least one first right corner point position.
[0181] Optionally, the convolution calculation unit is specifically used to fill and expand the original data matrix according to the size of the first characteristic matrix and the second characteristic matrix to obtain an extended matrix; and perform convolution and calculation with the extended matrix using the first characteristic matrix and the second characteristic matrix as convolution kernels respectively to obtain a first determination matrix and a second determination matrix.
[0182] Optionally, the position prediction unit is specifically used to determine the row where each first left corner point position in at least one first left corner point position is located, and to determine the row where each first right corner point position in at least one first right corner point position is located; the first left corner point position and the first right corner point position that are in the same row are determined as a first predicted position group, to obtain m first predicted position groups.
[0183] Optionally, the device provided in this embodiment further includes:
[0184] The second position determination module is used to determine whether m is zero in response to the number of data rows included in the current table being less than n+2; when m is zero, the first row in the current table is used as the target position; when m is not zero, the first predicted position group with the smallest number of rows is determined from at least one first predicted position group as the target position.
[0185] Optionally, the first position determination module 64 is specifically used to determine whether the column difference corresponding to each first prediction position group in the m first prediction position groups is less than n+2; wherein the column difference is the difference between the column number where the first right corner point position is located and the column number where the first left corner point position is located in the first prediction position group; in response to the column difference corresponding to each first prediction position group being less than n+2, based on at least one group of second prediction position groups, determine the target position of the table header corresponding to the current table; in response to the column difference corresponding to each first prediction position group being greater than n+2, based on at least one first prediction position group and at least one group of second prediction position groups, determine the target position of the table header corresponding to the current table.
[0186] Optionally, when determining the target position of the table header corresponding to the current table based on at least one group of second predicted position groups, the first position determination module 64 is used to determine whether at least one second left corner point position in each group of second predicted position groups has an overlapping second left corner point position in other second predicted position groups; and determine whether at least one second right corner point position has an overlapping second right corner point position in other second predicted position groups; in response to the existence of overlap, determining the target position of the table header corresponding to the current table based on the overlapping second left corner point position and second right corner point position; in response to the absence of overlap, determining the target position of the table header corresponding to the current table based on the second left corner point position and second right corner point position corresponding to the new data matrix with the largest n value.
[0187] Optionally, when determining the target position of the table header corresponding to the current table based on at least one first predicted position group and at least one second predicted position group, the first position determination module 64 is used to determine whether there is a second left corner point position with overlapping positions in at least one first left corner point position of at least one first predicted position group in at least one second predicted position group; and determine whether there is a second right corner point position with overlapping positions in at least one first right corner point position in at least one second predicted position group; in response to the existence of position overlap, determine the target position of the table header corresponding to the current table based on the first left corner point position and the first right corner point position with overlapping positions; in response to the absence of position overlap, determine the target position of the table header corresponding to the current table based on the second left corner point position and the second right corner point position corresponding to the new data matrix with the largest n value.
[0188] Optionally, the iterative prediction module 63 is specifically used to add 2 to the value of n, continue to read the content in the current table, and obtain a new data matrix corresponding to the data of the first n rows of the current table; process the new data matrix through the new first characteristic matrix and the new second characteristic matrix to determine at least one second prediction position corresponding to the prediction table header; in response to the number of data rows included in the current table being greater than n+2, iteratively execute the above steps until the number of times the value of n is increased reaches a set number of times, and obtain at least one group of second prediction position groups; in response to the number of data rows included in the current table being less than n+2, obtain at least one group of second prediction position groups.
[0189] Exemplary Electronic Devices
[0190] Below, reference Figure 7 The electronic device according to the embodiment of the present disclosure is described. The electronic device may be any one or both of the first device 100 and the second device 200, or a stand-alone device independent of them, and the stand-alone device may communicate with the first device and the second device to receive the collected input signals from them.
[0191] Figure 7 A block diagram of an electronic device according to an embodiment of the present disclosure is illustrated.
[0192] like Figure 7 As shown, the electronic device 70 includes one or more processors 71 and a memory 72 .
[0193] The processor 71 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 70 to perform desired functions.
[0194] The memory 72 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 71 may run the program instructions to implement the table header recognition method of each embodiment of the present disclosure described above and / or other desired functions. Various contents such as input signals, signal components, noise components, etc. may also be stored in the computer-readable storage medium.
[0195] In one example, the electronic device 70 may further include: an input device 73 and an output device 74, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0196] For example, when the electronic device is the first device 100 or the second device 200, the input device 73 may be the microphone or microphone array described above, for capturing input signals from a sound source. When the electronic device is a stand-alone device, the input device 73 may be a communication network connector, for receiving collected input signals from the first device 100 and the second device 200.
[0197] In addition, the input device 73 may also include, for example, a keyboard, a mouse, and the like.
[0198] The output device 74 can output various information to the outside, including the determined distance information, direction information, etc. The output device 74 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0199] Of course, to simplify, Figure 7 Only some of the components related to the present disclosure in the electronic device 70 are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device 70 may also include any other appropriate components.
[0200] Exemplary computer program products and computer-readable storage media
[0201] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the table header recognition method according to various embodiments of the present disclosure described in the above-mentioned "Exemplary Method" section of this specification.
[0202] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0203] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enables the processor to execute the steps of the table header recognition method according to various embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.
[0204] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable 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 above.
[0205] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0206] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0207] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0208] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
[0209] It should also be noted that in the apparatus, device and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0210] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0211] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A table header recognition method, characterized in that: include: Read the content in the current table to obtain the original data matrix corresponding to the data of the first n rows of the current table; wherein n is an odd number greater than 1; The original data matrix is processed by a first feature matrix and a second feature matrix to determine m first prediction position groups corresponding to the prediction table header; wherein each of the first prediction position groups includes a first left corner point position and a first right corner point position, and m is an integer greater than or equal to zero; the first feature matrix is used to identify the position of the upper left corner in an area having the same shape as the first feature matrix in the data of the first n rows of the current table, and the second feature matrix is used to identify the position of the upper right corner in an area having the same shape as the second feature matrix in the data of the first n rows of the current table; In response to the number of data rows included in the current table being greater than n+2, increasing the value of n at least once, and determining at least one set of second prediction position groups with a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n; wherein each set of the second prediction position groups includes at least one second left corner point position and at least one second right corner point position; Determine a target position of a table header corresponding to the current table based on the m first prediction position groups and / or at least one second prediction position group; The step of reading the content in the current table to obtain the original data matrix corresponding to the data in the first n rows of the current table includes: Read the data in the current table row by row to obtain the original data of the first n rows of the current table; Performing encoding conversion on the n rows of original data to obtain an original data matrix; The processing of the original data matrix by using the first characteristic matrix and the second characteristic matrix to determine the m first prediction position groups corresponding to the prediction table header includes: Convolve and calculate the original data matrix with the first feature matrix and the second feature matrix respectively to obtain a first determination matrix and a second determination matrix; wherein the first feature matrix and the second feature matrix are both n*n matrices; Determine at least one first left corner point position of the prediction table header based on the position with the largest value in the first determination matrix; Determine at least one first right corner point position of the prediction table header based on the position with the largest value in the second determination matrix; The m first predicted position groups are determined based on the at least one first left corner point position and the at least one first right corner point position.
2. The method according to claim 1, characterized in that The convolution and calculation of the original data matrix with the first feature matrix and the second feature matrix to obtain a first determination matrix and a second determination matrix comprises: Fill and expand the original data matrix according to the sizes of the first characteristic matrix and the second characteristic matrix to obtain an expanded matrix; The first feature matrix and the second feature matrix are respectively used as convolution kernels to perform convolution and calculation with the expansion matrix to obtain a first determination matrix and a second determination matrix.
3. The method according to claim 1, characterized in that The determining the m first predicted position groups based on the at least one first left corner point position and the at least one first right corner point position comprises: Determine the row where each first left corner point position in the at least one first left corner point position is located, and determine the row where each first right corner point position in the at least one first right corner point position is located; The first left corner point position and the first right corner point position that are in the same row are determined as the first predicted position group to obtain the m first predicted position groups.
4. The method according to any one of claims 1 to 3, characterized in that: Also includes: In response to the number of data rows included in the current table being less than n+2, determining whether m is zero; When m is zero, the first row in the current table is used as the target position; When m is not zero, a first prediction position group with the smallest number of rows is determined from the at least one first prediction position group as the target position.
5. The method according to any one of claims 1 to 3, characterized in that: The determining, based on the m first prediction position groups and / or at least one second prediction position group, a target position of a table header corresponding to the current table includes: Determine whether the column difference value corresponding to each of the m first prediction position groups is less than n+2; wherein the column difference value is the difference between the column number where the first right corner point position is located and the column number where the first left corner point position is located in the first prediction position group; In response to the column difference corresponding to each of the first prediction position groups being less than n+2, determining a target position of a table header corresponding to the current table based on the at least one second prediction position group; In response to the column difference corresponding to each of the first prediction position groups being greater than n+2, a target position of a table header corresponding to the current table is determined based on the at least one first prediction position group and at least one second prediction position group.
6. The method according to claim 5, characterized in that The determining, based on the at least one set of second predicted position groups, a target position of a table header corresponding to the current table includes: Determine whether at least one second left corner point position in each group of the second predicted position groups has a second left corner point position with overlapping positions in other second predicted position groups; and determine whether at least one second right corner point position has a second right corner point position with overlapping positions in other second predicted position groups; In response to the existence of position overlap, determining a target position of a table header corresponding to the current table based on the second left corner point position and the second right corner point position that overlap; In response to the absence of position overlap, a target position of the table header corresponding to the current table is determined based on the second left corner point position and the second right corner point position corresponding to the new data matrix with the largest n value.
7. A table header recognition device, characterized in that: include: A data reading module is used to read the content in the current table and obtain the original data matrix corresponding to the data of the first n rows of the current table; wherein n is an odd number greater than 1; A table header prediction module, used for processing the original data matrix through a first feature matrix and a second feature matrix to determine m first prediction position groups corresponding to the prediction table header; wherein each of the first prediction position groups includes a first left corner point position and a first right corner point position, and m is an integer greater than or equal to zero; the first feature matrix is used to identify the position of the upper left corner in the area with the same shape as the first feature matrix in the data of the first n rows of the current table, and the second feature matrix is used to identify the position of the upper right corner in the area with the same shape as the second feature matrix in the data of the first n rows of the current table; an iterative prediction module, configured to, in response to the number of data rows included in the current table being greater than n+2, increase the value of n at least once, and determine at least one set of second prediction position groups with a new data matrix, a new first feature matrix, and a new second feature matrix corresponding to the increased n; wherein each set of the second prediction position groups includes at least one second left corner point position and at least one second right corner point position; A first position determination module, configured to determine a target position of a table header corresponding to the current table based on the m first predicted position groups and / or at least one second predicted position group; The data reading module is specifically used to read the data in the current table row by row to obtain the original data of the first n rows of the current table; and perform encoding conversion on the original data of the n rows to obtain the original data matrix; The table header prediction module includes: A convolution calculation unit, used for convolving and calculating the original data matrix with the first feature matrix and the second feature matrix respectively, to obtain a first determination matrix and a second determination matrix; wherein the first feature matrix and the second feature matrix are both n*n matrices; A left corner point prediction unit, used to determine at least one first left corner point position of the prediction table header based on the position with the largest value in the first decision matrix; A right corner point prediction unit, used to determine at least one first right corner point position of the prediction table header based on the position with the largest value in the second determination matrix; A position prediction unit is used to determine the m first predicted position groups based on the at least one first left corner point position and the at least one first right corner point position.
8. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the table header recognition method described in any one of claims 1-6 above.
Citation Information
Patent Citations
Information identifying method of format picture, electronic device and readable storage medium
CN107862303A
Automatic webpage table data extraction method and device
CN107992625A