Table processing method, device, apparatus, and computer storage medium
By obtaining the coordinate information and tilt angle of the cells, and using trigonometric functions to calculate the theoretical vertical coordinate of the cells, the problem of inaccurate recognition of tilted tables is solved, and accurate calibration and sorting of tables are achieved.
Patent Information
- Application Number
- CN202310075971.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-07
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2043-02-07
AI Technical Summary
Existing technologies have the problem of inaccurate cell sorting when identifying tilted tables, resulting in disordered row order in the calibrated table.
By obtaining the cell's coordinate information and tilt angle, the theoretical vertical coordinate of the cell is calculated using trigonometric functions. This determines whether the cells are in the same row, and they are then sorted vertically and horizontally before being filled with content to calibrate the table.
It achieves accurate calibration of tables at any tilt angle, avoiding recognition errors caused by pixel differences and inconsistent row heights, and obtains a standard sorted table.
Smart Images

Figure CN116978043B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of computer data processing, in particular to a table processing method, device and equipment and computer storage medium. BACKGROUND
[0002] A table is a common document object, and most table documents in daily work are transmitted and saved in the form of PDF or pictures. Application of table recognition technology can recognize a table in the form of PDF or pictures as a preset text structure, thereby reducing table processing time and storage cost.
[0003] Currently, wired table structure recognition generally determines a cell area by using table lines, that is, a cell is positioned by detecting the coordinates of the intersection points of horizontal and vertical lines, and then the cell is rearranged according to the coordinates to restore the original structure of the table. In general, whether the cells belong to the same row is determined according to the relationship between the distance between the cells and a fixed threshold.
[0004] The inventor found that when the table is inclined, the existing method of determining the relative positions of cells left and right and above and below according to the coordinates of the intersection points of horizontal and vertical lines cannot accurately determine the relative positions of cells left and right and above and below. Moreover, the method of determining whether the cells belong to the same row according to a fixed threshold has poor effect on files with different pixels and large differences in table row height, and a too small threshold value will incorrectly split a row into multiple rows, and a too large threshold value will combine multiple rows into one row. Therefore, the existing algorithm for table recognition by sorting cells has the problem of inaccurate recognition of inclined tables. SUMMARY
[0005] In view of the above problems, embodiments of the present application provide a table processing method, device, equipment and computer storage medium to solve the problem of inaccurate recognition of inclined tables in the prior art.
[0006] According to an aspect of an embodiment of the present application, a table processing method is provided, which comprises:
[0007] recognizing a target table in target data to obtain cell information; the target table is a wired table with inclination; the cell information includes the content, coordinate information and inclination angle of a plurality of cells;
[0008] determining whether each two cells are located in the same row according to the coordinate information and inclination angle of the two cells, regarding all cells located in the same row as a target row, and obtaining a plurality of target rows;
[0009] vertically sorting the target rows and horizontally sorting the cells in the target rows according to the coordinate information, to obtain a sorted table;
[0010] Fill the content of each cell into the sorted table respectively to obtain a calibrated table corresponding to the target table.
[0011] In an optional manner, the coordinate information comprises a horizontal coordinate and a vertical coordinate; the two cells comprise a first cell and a second cell; and the method further comprises:
[0012] determining a theoretical vertical coordinate of the second cell according to the horizontal coordinate and the vertical coordinate of the first cell, the horizontal coordinate of the second cell, and the tilt angle;
[0013] determining whether the first cell and the second cell are located in the same row according to a coordinate deviation between the theoretical vertical coordinate and the vertical coordinate of the second cell;
[0014] regarding all the cells located in the same row as a target row to obtain a plurality of target rows.
[0015] In an optional manner, the method further comprises:
[0016] determining a coordinate relative relationship between the first cell and the second cell according to the tilt angle and a preset trigonometric function;
[0017] determining a theoretical vertical coordinate of the second cell according to the horizontal coordinate and the vertical coordinate of the first cell, the horizontal coordinate of the second cell, and the coordinate relative relationship.
[0018] In an optional manner, the coordinate relative relationship comprises a ratio relationship between a horizontal coordinate distance between the first cell and the second cell and a vertical coordinate distance between the first cell and the second cell; and the method further comprises:
[0019] determining a vertical coordinate distance according to a distance between the horizontal coordinate of the first cell and the horizontal coordinate of the second cell and the ratio relationship;
[0020] determining a theoretical vertical coordinate of the second cell according to the vertical coordinate of the first cell and the vertical coordinate distance.
[0021] In an optional manner, the method further comprises:
[0022] determining that the first cell and the second cell are located in the same row when the coordinate deviation is less than or equal to a preset error threshold; and the error threshold is used to represent an influence of a table line thickness of the target table on cell coordinate identification.
[0023] In an optional manner, the method further comprises:
[0024] synchronize the tilt angle of each of the cells according to an average value of the tilt angles of all the cells.
[0025] In an alternative way, the coordinate information comprises a horizontal coordinate and a vertical coordinate of the cell; the method further comprises:
[0026] horizontally sorting each of the cells according to an order of the horizontal coordinates of all the cells in the target row;
[0027] vertically sorting the target rows according to an order of the vertical coordinates of the first cells of all the target rows, to obtain a sorted table.
[0028] According to another aspect of the embodiments of the present application, a table processing apparatus is provided, comprising:
[0029] a recognizing module, configured to recognize a target table in target data to obtain cell information; the target table is a wired table with tilt; the cell information comprises content, coordinate information and a tilt angle of a plurality of cells;
[0030] a determining module, configured to determine whether each two of the cells are in the same row according to the coordinate information and the tilt angle of the two cells, and to obtain a plurality of target rows by taking all the cells in the same row as a target row;
[0031] a sorting module, configured to vertically sort the target rows and horizontally sort the cells in the target rows according to the coordinate information, to obtain a sorted table;
[0032] a filling module, configured to fill the content of each cell into the sorted table respectively, to obtain a calibrated table corresponding to the target table.
[0033] According to another aspect of the embodiments of the present application, a table processing device is provided, comprising:
[0034] a processor, a memory, a communication interface and a communication bus, the processor, the memory and the communication interface complete communication with each other through the communication bus;
[0035] the memory is configured to store at least one executable instruction, and the executable instruction causes the processor to perform the operations of the table processing method according to any one of the preceding embodiments.
[0036] According to a further aspect of the embodiments of the present application, a computer readable storage medium is provided, in which at least one executable instruction is stored, and the executable instruction causes a table processing device to perform the operations of the table processing method according to any one of the preceding aspects.
[0037] The embodiments of the present application obtain cell information by identifying a target table in target data; the target table is a wired table with inclination; the cell information includes content, coordinate information and inclination angle of a plurality of cells; whether two cells are located in the same row is determined according to the coordinate information and inclination angle of the two cells; all cells located in the same row are taken as a target row, and a plurality of target rows are obtained; the target rows are sorted in the vertical direction and the cells in the target rows are sorted in the horizontal direction according to the coordinate information, and a sorted table is obtained; and the content of each cell is filled into the sorted table, and a calibrated table corresponding to the target table is obtained. Thus, unlike the prior art which determines whether cells in the same row according to whether the direct distance of the vertical coordinates of the cells is less than a fixed threshold, the embodiments of the present application optimize the cell sorting algorithm, and reasonably calculate and infer whether other cells belong to the same row according to the inclination angle information of the cells. The embodiments of the present application are applicable to any inclined table, and do not need to manually adjust the threshold parameter according to the pixel, row height difference of the table document, thereby achieving accurate correction of the wired table with inclination.
[0038] The above description is only a summary of the technical solutions of the embodiments of the present application, in order to more clearly understand the technical means of the embodiments of the present application, and to be implemented according to the content of the specification, and in order to make the above and other purposes, features and advantages of the embodiments of the present application more obvious and easy to understand, the specific embodiments of the present application are described below. BRIEF DESCRIPTION OF DRAWINGS
[0039] The accompanying drawings are only used to show the embodiments, and are not considered as limitations of the present application. Moreover, the same reference signs are used to represent the same parts throughout the drawings. In the drawings:
[0040] Figure 1 A schematic diagram of a target table in the table processing method provided by the embodiments of the present application is shown;
[0041] Figure 2 A flowchart of the table processing method provided by the embodiments of the present application is shown;
[0042] Figure 3 A structure diagram of the table processing device provided by the embodiments of the present application is shown;
[0043] Figure 4A schematic diagram of the structure of the table processing device provided in an embodiment of the present invention is shown. Detailed Implementation
[0044] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0045] Before describing the embodiments of the present invention, the prior art and its problems will be further explained.
[0046] Tables are a common document object, and in daily work, most table documents are in PDF or similar formats. Figure 1 The images shown are transmitted and saved. Applying table recognition technology can reduce table processing time. Currently, wired table structure recognition typically uses table lines to determine cell areas, locates cells by detecting the intersections of horizontal and vertical lines, and then rearranges the cells based on a rule-based sorting algorithm to restore the original table structure, thus obtaining the row and column distribution and logical structure of the table document.
[0047] like Figure 1 As shown, the tables identified from the table document may be skewed. Therefore, it is necessary to calibrate the tables included in the table document, that is, to calibrate the tables to eliminate skewness, and the content of each row and column cell in the calibrated table must be consistent with the corresponding cell content in the table document.
[0048] Existing algorithms for rearranging cells to calibrate tables typically sort cells directly based on their coordinates (which could be the coordinates of the cell's vertex, such as the top-left corner, or the center point). The algorithms sort cells by their top-left corner y-coordinates from top to bottom and their x-coordinates from left to right. If the x-coordinate of the current cell is greater than the x-coordinate of the previous cell and the distance between the current and previous cell y-coordinates is less than a certain fixed threshold (e.g., 35-30 pixels), then the current and previous cells are considered to be in the same row; otherwise, they are considered to be in different rows.
[0049] like Figure 1 The top-left corner coordinates of the cell containing "1" are (40, 400), and the top-left corner coordinates of the cell containing "2" are (217, 330). The difference between the top-left ordinates of these two cells is 400 - 330 = 70, which exceeds the aforementioned fixed threshold. Therefore, the existing table processing method will separate the cell containing "1" and the cell containing "2" into different rows. Clearly, due to the table's tilt, this will cause the row order of the calibrated cells to be disordered.
[0050] Using existing methods Figure 1The calibrated table can be found in Table 1. (Combined with...) Figure 1 As can be seen from Table 1, the content of Table 1 is consistent with... Figure 1 The information in the tables is completely different.
[0051] 5 10 4 9 3 15 2 8 14 1 7 13 6 12 11
[0052] Table 1
[0053] Therefore, the existing method of calibrating tables by directly judging the distance between cell coordinates based on a fixed threshold has the problem of low calibration accuracy for tables with tilt angles.
[0054] Figure 2 A flowchart of a table processing method provided in an embodiment of the present invention is shown. This method is executed by a computer processing device. The computer processing device may include a mobile phone, a laptop computer, etc. Figure 2 As shown, the method includes the following steps:
[0055] Step 10: Identify the target table in the target data to obtain cell information; the target table is a line table with a tilt; the cell information includes the content, coordinate information and tilt angle of multiple cells.
[0056] The target data can be in the form of PDF or images, or other formats where the tables within the data cannot be directly edited. The target table is divided into multiple cells using lines. For example... Figure 2 The target table shown can be a 3x5 slanted table, consisting of three rows, each row containing five cells, with the cells separated by lines. It should be noted that... Figure 2 The rows in the table are not uniform in height, while the target table can have uniform or non-uniform row heights.
[0057] The content of a cell is the information contained within it, such as... Figure 2 The numbers included in cells such as "1", "2", and "16". The cell's coordinate information is used for positioning that cell and can be used with positioning tools.
[0058] The horizontal and vertical coordinates of the points are represented, wherein the positioning points can be the vertices or the center points of the cells. It should be noted that the coordinate information of the plurality of cells corresponds to consistent positioning points, i.e., the coordinate information of the center point of the cell is selected as the coordinate information of the cell. There is no case that one cell selects the center point coordinate as the coordinate information, and another cell selects the top-left vertex coordinate as the coordinate information. Specifically, the top-left vertex of the table can be taken as the origin, and the horizontal direction and the vertical direction of the target document can be taken as the coordinate axes to establish a coordinate system. The coordinates of the selected positioning points in the coordinate system are the coordinates of the cells. It can be easily understood that the target document is used to display the target table, and the target document does not exist in the inclination. The target table exists in the inclination relative to the horizontal and vertical directions of the target document in the document.
[0059] The inclination angle can be calculated according to the coordinate information of the cell by using the inverse trigonometric function. For example, assuming that the coordinates of the top-left vertex, the top-right vertex, the bottom-right vertex and the bottom-left vertex of the cell cell i are ((x i1 ,y i1 ), (x i2 ,y i2 ), (x i3 ,y i3 ), (x i4 ,y i4 )), the inclination angle of the cell cell i is
[0060]
[0061] Step 20: determining whether the two cells are located in the same row according to the coordinate information and the inclination angle of each two cells, taking all the cells located in the same row as a target row, and obtaining a plurality of target rows.
[0062] The coordinate information includes the x-coordinate and y-coordinate; the two cells include a first cell and a second cell. For any two cells in a plurality of cells, the line connecting the positioning points of the two cells can be regarded as the hypotenuse of a right triangle. It is easy to see that the vertical side of the triangle represents the y-coordinate distance between the first cell and the second cell, and the horizontal side of the triangle represents the x-coordinate distance between the first cell and the second cell. According to the Pythagorean theorem, when the angle between the hypotenuse and the horizontal side of the right triangle is determined, its horizontal and vertical sides satisfy a specific numerical relationship. Furthermore, the angle between the hypotenuse and the horizontal side of the triangle formed by connecting the positioning points of any two cells in the same row is the tilt angle of that cell, i.e., the tilt angle of the target document. The angle between the hypotenuse and the horizontal side of the triangle formed by connecting the positioning points of cells in different rows will obviously be greater than the tilt angle.
[0063] Therefore, the first cell of any two cells can be used as the row positioning reference. The theoretical distance between the first and second cells in the vertical direction can be determined based on the horizontal distance and tilt angle between the second and first cells. From this theoretical distance, the second cell can be estimated.
[0064] The theoretical ordinate of the first cell is determined, and then compared with the actual ordinate of the second cell to determine whether the second cell is in the same row as the first cell.
[0065] It should be noted that, generally, the tilt angle of each cell in the target table should be consistent, so the tilt angle of any cell can be used for calculations in subsequent steps. However, considering that there may be errors in the recognition of the coordinate information of each cell, there may be inconsistencies in the tilt angles of the cells. Therefore, to facilitate calculation and improve the accuracy of the cell tilt angles, the tilt angles of each cell can be synchronized based on the average tilt of all cells. Therefore, step 20 also includes:
[0066] Step 200: Synchronize the tilt angle of each cell based on the average tilt angle of all cells.
[0067] The average tilt angle of all cells is expressed as Where n is the total number of cells, θ i For cell i The tilt angle is θ. Therefore, θ can be regarded as the tilt angle of the entire target table. By synchronizing the tilt angle of each cell to θ, the problem of large deviations in cell tilt angles caused by errors in the recognition of some cell coordinates is avoided, which would affect the accuracy of cell row positioning.
[0068] In addition, taking the average of the tilt angles of all the cells as the tilt angle of the target document can also avoid the existing inaccuracy of determining the tilt angle of the target table only according to the top coordinates of the target table, thereby reducing the influence of cell coordinate recognition errors on table calibration.
[0069] The tilt angle of the target document is further taken as the basis for judging the ratio relationship between the horizontal and vertical coordinate distances of the cells in the same row, that is, step 20 further includes:
[0070] Step 201: determining the theoretical vertical coordinate of the second cell according to the horizontal coordinate of the first cell, the horizontal coordinate of the second cell, and the tilt angle.
[0071] The theoretical vertical coordinate is used to represent the vertical coordinate that the second cell should have when the first cell and the second cell are in the same row. First, the ratio of the vertical coordinate distance and the horizontal coordinate distance between the first cell and the second cell can be determined by using a trigonometric function and the tilt angle. Then, the theoretical vertical coordinate distance between the first cell and the second cell can be determined according to the ratio and the horizontal coordinate distance between the first cell and the second cell. Finally, the theoretical vertical coordinate of the other cell can be obtained by combining the vertical coordinate of one of the two cells on the basis of the theoretical vertical coordinate.
[0072] Therefore, specifically, step 201 further includes:
[0073] Step 2012: determining the coordinate relative relationship between the first cell and the second cell according to the tilt angle and a preset trigonometric function.
[0074] The trigonometric function can be any one of tangent, sine, and cosine. The coordinate relative relationship is used to represent the relative position relationship between the first cell and the second cell, and specifically can be the ratio of the vertical coordinate distance and the horizontal coordinate distance between the first cell and the second cell. Optionally, for the convenience of calculation, the trigonometric function can be preferably a tangent function.
[0075] Step 2013: determining the theoretical vertical coordinate according to the horizontal coordinate of the first cell, the vertical coordinate of the first cell, the horizontal coordinate of the second cell, and the coordinate relative relationship.
[0076] The coordinate relative relationship includes a ratio relationship between a horizontal coordinate distance between the first cell and the second cell and a vertical coordinate distance between the first cell and the second cell. The horizontal coordinate distance between the first cell and the second cell is determined according to the horizontal coordinate of the first cell and the horizontal coordinate of the second cell. The vertical coordinate distance is determined according to the ratio relationship and the horizontal coordinate distance. The theoretical vertical coordinate of the second cell is obtained by translating the vertical coordinate of the first cell by the vertical coordinate distance.
[0077] Therefore, step 2013 further includes step 210: determining a vertical coordinate distance according to the distance between the horizontal coordinate of the first cell and the horizontal coordinate of the second cell and the ratio relationship.
[0078] Specifically, the ratio relationship can be a ratio of the horizontal coordinate distance between the first cell and the second cell to the vertical coordinate distance of both the first cell and the second cell. When the inclination angle is 45°, the ratio is 1, that is, the line connecting the positioning points of the first cell and the second cell is an isosceles right triangle. At this time, the horizontal coordinate distance between the first cell and the second cell and the quotient of the ratio can be determined as the vertical coordinate distance according to the tangent function of the triangle.
[0079] Step 211: determining the theoretical vertical coordinate according to the vertical coordinate of the second cell and the vertical coordinate distance.
[0080] Specifically, the theoretical vertical coordinate is obtained by adding or subtracting the vertical coordinate distance to the vertical coordinate of the first cell. When the horizontal coordinate of the second cell is greater than the horizontal coordinate of the first cell, the vertical coordinate distance is subtracted from the vertical coordinate of the first cell to obtain the theoretical vertical coordinate of the second cell. Correspondingly, when the horizontal coordinate of the second cell is less than the horizontal coordinate of the first cell, the vertical coordinate distance is added to the vertical coordinate of the first cell to obtain the theoretical vertical coordinate of the first cell.
[0081] Step 202: determining whether the first cell and the second cell are located in the same row according to a coordinate deviation between the theoretical vertical coordinate and the vertical coordinate of the second cell.
[0082] It is easy to understand that, when the assumption is true, i.e. the first cell and the second cell are located in the same row, the angle between the line connecting the positioning points in the first cell and the second cell and the horizontal coordinate axis direction is close to the inclination angle, and when the first cell and the second cell are not located in the same row, the difference between the angle between the line connecting the positioning points in the first cell and the second cell and the horizontal coordinate axis direction and the inclination angle will be obviously larger, and the specific difference is affected by the line thickness of the divided cell and the row height of the cell. Therefore, the coordinate deviation between the theoretical vertical coordinate of the second cell obtained by reasoning according to the foregoing assumption and the vertical coordinate of the second cell actually identified can be used to determine whether the first cell and the second cell are located in the same row. If the coordinate deviation is large, it indicates that the assumption between the first cell and the second cell is not met, i.e. they are not located in the same row.
[0083] Specifically, step 202 further includes:
[0084] Step 2021: When the coordinate deviation is less than or equal to a preset error threshold, it is determined that the first cell and the second cell are located in the same row; the error threshold is used to represent the influence of the table line thickness of the target table on cell coordinate identification.
[0085] Specifically, the error threshold can be small, such as 10 pixels, etc. The error threshold can be adaptively determined according to the accuracy of cell coordinate identification. Correspondingly, when the coordinate deviation is greater than the preset error threshold, it is determined that the first cell and the second cell are located in different rows.
[0086] It should be noted that the error threshold in the embodiment of the application is to avoid the influence of the table line thickness on the cell coordinate identification, and is generally set to be small, which is different from the fixed threshold for directly measuring the distance between the vertical coordinates of two cells in the prior art.
[0087] Step 203: All cells located in the same row are taken as a target row, and a plurality of target rows are obtained.
[0088] In order to improve the accuracy of cell positioning, a cell can be selected as a positioning reference in all cells, and it is determined whether the other remaining cells and the positioning reference are in the same row according to the foregoing steps, so as to obtain the cells in the same row as the positioning reference, obtain a target row, and repeat the above process for the remaining unpositioned cells until the target rows of all cells are determined.
[0089] Step 30: The target rows are respectively sorted in the vertical direction and the cells in the target rows are sorted in the horizontal direction according to the coordinate information, and a sorted table is obtained.
[0090] The horizontal sorting of the cells in each target row can be performed first, and the cells are arranged from left to right according to the ascending order of the horizontal coordinates of the cells in the target row. Then, when sorting the target rows vertically, the target rows are arranged from top to bottom according to the ascending order of the vertical coordinates of the first cells in the target rows, so that the sorted table is horizontal and vertical, i.e., there is no tilt.
[0091] Therefore, step 30 further comprises: step 301: for each target row, sorting the cells in the target row horizontally according to the order of the horizontal coordinates of all the cells in the target row.
[0092] Specifically, the cells are arranged from left to right into a row parallel to the horizontal edge of the target document according to the ascending order of the horizontal coordinates of all the cells in the target row, so that a target row sorted in a row is obtained.
[0093] Step 302: sorting the target rows vertically according to the order of the vertical coordinates of the first cells of all the target rows, so that the sorted table is obtained.
[0094] Specifically, all the target rows are sorted vertically according to the descending order of the horizontal coordinates of the first cells of all the target rows, so that a sorted table is obtained.
[0095] In another embodiment of the present application, the determination of the plurality of target rows can also be performed according to the following process:
[0096] Let set C = {cell1, cell2,..., cell n}, and table set T = {}.
[0097] Randomly select and delete a cell cell i from C, and let C = {cell1, cell2,..., cell n}-cell i Let row set R = {cell i}.
[0098] Iterate through set C, and take out a cell cell j . According to cell i , calculate the vertical coordinate of the positioning point (such as the top-left corner endpoint) of cell j in theory, denoted as
[0099] Calculate the difference between the theoretical vertical coordinate j of the positioning point of cell j and the real vertical coordinate y j1 obtained by the actual table recognition of cell i . When d is small (usually less than 10 pixels), the cell i and the cell j belong to the same row.
[0100] The cell cell j is added to the set R, and the cell cell j is deleted from the set C.
[0101] The above process is repeated until the set C is empty.
[0102] Finally, the set R is sorted according to the left-top horizontal coordinates of the cells from small to large, and the sorted row set is added to the table set T, T = T + R. The table set T is sorted according to the vertical coordinates of the first cell of each row set in the set T from small to large, and the table structure is restored according to the set T to obtain the sorted table.
[0103] Step 40: Fill the contents of each cell into the sorted table respectively to obtain the calibrated table corresponding to the target table.
[0104] Finally, fill the contents of each cell into the calibrated table to obtain the sorted table
[0105] As in the previous embodiment, the table deflection angle θ = -22.08° is calculated, and the table in the table set T is calibrated according to the foregoing steps. Figure 2 The calibrated table after calibration can refer to Table 2.
[0106] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[0107] Table 2
[0108] As shown in Table 2, the calibrated table of the embodiment of the present application does not have the problems such as inclination, misplacement, or inconsistency of row height and column width, and the table form is more standard, which is convenient for subsequent direct identification and editing of the table.
[0109] The embodiment of the present application obtains cell information by recognizing a target table in target data; the target table is a wired table with inclination; the cell information includes the content, coordinate information and inclination angle of multiple cells; whether two cells are located in the same row is determined according to the coordinate information and inclination angle of the two cells; all cells located in the same row are taken as a target row, and multiple target rows are obtained; the target rows are respectively sorted in the longitudinal direction and the cells in the target rows are respectively sorted in the horizontal direction according to the coordinate information, and a sorted table is obtained; the content corresponding to each cell is respectively filled into the sorted table, and a calibrated table corresponding to the target table is obtained. Thus, unlike the prior art which determines whether cells in the same row according to whether the direct distance of the longitudinal coordinates of the cells is less than a certain fixed threshold, the embodiment of the present application optimizes the cell sorting algorithm, reasonably calculates and reasons whether other cells belong to the same row through the inclination angle information of the cells. The embodiment of the present application is applicable to tables with any inclination angle, and does not need to manually adjust the threshold parameter according to the pixel, row height difference of the table document, thereby realizing accurate correction of the wired table with inclination.
[0110] Figure 3 The structure schematic diagram of the table processing device provided by the embodiment of the present application is shown. As shown in the figure, Figure 3 The device 50 includes an identification module 501, a determination module 502, a sorting module 503 and a filling module 504. The identification module 501 is configured to recognize a target table in target data to obtain cell information; the target table is a wired table with inclination; the cell information includes the content, coordinate information and inclination angle of multiple cells.
[0111] The determination module 502 is configured to determine whether two cells are located in the same row according to the coordinate information and inclination angle of the two cells, take all cells located in the same row as a target row, and obtain multiple target rows.
[0112] The sorting module 503 is configured to sort the target rows in the longitudinal direction and sort the cells in the target rows in the horizontal direction according to the coordinate information, and obtain a sorted table.
[0113] The filling module 504 is configured to fill the content corresponding to each cell into the sorted table, and obtain a calibrated table corresponding to the target table.
[0114] The operation process of the table processing device provided by the embodiment of the present application is substantially the same as the foregoing method embodiment, and will not be described in detail.
[0115] The table processing device provided in this invention identifies a target table in target data to obtain cell information. The target table is a wired table with a tilt. The cell information includes the content, coordinate information, and tilt angle of multiple cells. Based on the coordinate information and tilt angle of every two cells, it determines whether two cells are in the same row. All cells in the same row are considered as one target row, resulting in multiple target rows. The target rows are then vertically sorted, and the cells within each target row are horizontally sorted according to the coordinate information to obtain a sorted table. The content corresponding to each cell is then filled into the sorted table to obtain a calibrated table corresponding to the target table. This differs from the prior art, which determines whether cells are in the same row based on whether the direct distance between their vertical coordinates is less than a fixed threshold. This latter method has the problem of misidentifying tilted wired tables. This invention optimizes the cell sorting algorithm by reasonably calculating and inferring whether other cells belong to the same row based on the cell tilt angle information. It is applicable to tables with any tilt angle and eliminates the need to manually adjust threshold parameters based on differences in table document pixels and row height, thereby achieving accurate correction of tilted wired tables.
[0116] Figure 4 The diagram shows a structural schematic of a table processing device provided in an embodiment of the present invention. The specific embodiments of the present invention do not limit the specific implementation of the table processing device.
[0117] like Figure 4 As shown, the table processing device may include: a processor 602, a communications interface 604, a memory 606, and a communications bus 608.
[0118] The processor 602, communication interface 604, and memory 606 communicate with each other via communication bus 608. Communication interface 604 is used to communicate with other network elements such as clients or other servers. The processor 602 executes program 610, specifically performing the relevant steps described above in the table processing method embodiment.
[0119] Specifically, program 610 may include program code, which includes computer-executable instructions.
[0120] The processor 602 can be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to perform the embodiments of the present application. The table processing device includes one or more processors, which can be the same type of processor, such as one or more CPUs; or can be different types of processors, such as one or more CPUs and one or more ASICs.
[0121] The memory 606 is used to store programs 610. The memory 606 can include a high-speed RAM memory, and can also include a non-volatile memory, such as at least one disk memory.
[0122] The programs 610 can be specifically called by the processor 602 to make the table processing device perform the following operations:
[0123] Identifying a target table in target data to obtain cell information; the target table is a wired table with inclination; the cell information includes the content, coordinate information and inclination angle of a plurality of cells;
[0124] Determining whether each two cells are located in the same row according to the coordinate information and inclination angle of the two cells, regarding all cells located in the same row as a target row, and obtaining a plurality of target rows;
[0125] Respectively performing longitudinal sorting on the target rows and performing horizontal sorting on the cells in the target rows according to the coordinate information, and obtaining a sorted table;
[0126] Filling the content corresponding to each cell into the sorted table respectively, and obtaining a calibrated table corresponding to the target table.
[0127] The operation process of the table processing device provided by the embodiments of the present application is substantially the same as the foregoing method embodiments, and will not be described again.
[0128] The table processing device provided by the embodiments of the present application identifies the target table in the target data, and determines whether each two cells are located in the same row according to the coordinate information and inclination angle of the two cells.
[0129] The cell information is obtained; the target table is a wired table with inclination; the cell information includes contents, coordinate information and inclination angles of a plurality of cells; whether two cells are located in the same row is determined according to the coordinate information and the inclination angles of the two cells, all the cells located in the same row are taken as a target row, and a plurality of target rows are obtained; the target rows are respectively sorted in the longitudinal direction and the cells in the target rows are respectively sorted in the horizontal direction according to the coordinate information, and a sorted table is obtained; and the contents corresponding to the cells are respectively filled into the sorted table, and a calibrated table corresponding to the target table is obtained. Therefore, compared with the prior art in which whether cells in the same row are determined according to whether the direct distance of the longitudinal coordinates of the cells is less than a certain fixed threshold, the present embodiment optimizes the cell sorting algorithm, reasonably calculates and reasons whether other cells belong to the same row through the inclination angle information of the cells, is applicable to tables with any inclination angle, does not need to manually adjust the threshold parameter according to the pixel and row height difference of the table document, and thus accurate correction of the wired table with inclination is realized.
[0130] The embodiment of the present application provides a computer readable storage medium, the storage medium stores at least one executable instruction, the executable instruction is executed on a table processing device, and the table processing device executes the table processing method in any method embodiment.
[0131] The executable instruction can be specifically used for causing the table processing device to execute the following operations:
[0132] The target table in the target data is identified to obtain cell information; the target table is a wired table with inclination; the cell information includes contents, coordinate information and inclination angles of a plurality of cells;
[0133] Whether two cells are located in the same row is determined according to the coordinate information and the inclination angles of the two cells, all the cells located in the same row are taken as a target row, and a plurality of target rows are obtained;
[0134] The target rows are respectively sorted in the longitudinal direction and the cells in the target rows are respectively sorted in the horizontal direction according to the coordinate information, and a sorted table is obtained;
[0135] The contents corresponding to the cells are respectively filled into the sorted table, and a calibrated table corresponding to the target table is obtained.
[0136] The executable instruction stored in the computer storage medium provided by the embodiment of the present application has substantially the same operation process as the foregoing method embodiment, and details are not repeated.
[0137] The executable instructions stored in the computer storage medium provided in this embodiment of the invention are processed by the target data.
[0138] The target table is identified to obtain cell information; the target table is a wired table with a tilt; the cell information includes the content, coordinate information, and tilt angle of multiple cells; based on the coordinate information and tilt angle of every two cells, it is determined whether the two cells are in the same row, and all cells in the same row are considered as a target row, resulting in multiple target rows; based on the coordinate information, the target rows are sorted vertically and the cells within the target rows are sorted horizontally to obtain a sorted table; the content corresponding to each cell is filled into the sorted table to obtain a calibrated table corresponding to the target table. This differs from the existing technology that determines whether cells are in the same row based on whether the direct distance between the vertical coordinates of the cells is less than a certain fixed threshold, which has the problem of misidentification for tilted wired tables. This embodiment of the invention optimizes the cell sorting algorithm, reasonably calculating and inferring whether other cells belong to the same row based on the cell tilt angle information. It is applicable to tables with any tilt angle, eliminating the need to manually adjust threshold parameters based on differences in table document pixels and row height, thereby achieving accurate correction for tilted wired tables.
[0139] This invention provides a table processing apparatus for executing the above-described table processing method.
[0140] This invention provides a computer program that can be invoked by a processor to cause a table processing device to execute the table processing method in any of the above method embodiments.
[0141] This invention provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions that, when executed on a computer, cause the computer to perform the table processing method in any of the above method embodiments.
[0142] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of the present invention are not directed to any particular programming language. It should be understood that the content of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0143] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the application can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been described in detail in order not to obscure the understanding of this description.
[0144] Similarly, it is to be understood that the phraseology or terminology employed herein, and not otherwise specifically defined, is for the purpose of description without resort to limit the claimed application. Unless specifically identified, the use of
[0145] In the above description of exemplary embodiments of the application, various features of the embodiments of the present application are sometimes grouped together. However, this should not be interpreted as intending that any of the claimed application require more features than are explicitly recited in each claim. Moreover, while the above description has been presented in the context of the embodiments of the present application, it should be appreciated that individual aspects of the present application are not limited to that context. Accordingly, many modifications can be made by those skilled in the art, without departing from the spirit and scope of the claimed application.
[0146] Those skilled in the art will appreciate that modules in the apparatuses herein can be adapted and placed in one or more apparatuses other than the one in which they are described. Modules or units or components in the embodiments can be combined into one module or unit or component, and can be divided into a plurality of sub-modules or sub-units or sub-components. Any combination of all the features disclosed in the specification (including the accompanying claims, abstract and drawings), and any method or process or steps of any method or process so disclosed, can be made unless specifically stated otherwise. Each feature disclosed in the description (including the accompanying claims, abstract and drawings) can be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
[0147] It is noted that the foregoing examples have been provided merely for the purpose of explanation and are in no way to be construed as limiting of the present application. While the application has been described with reference to preferred embodiments, it is understood that the words that have been used herein are words of description, and that changes can be made within the scope and spirit of the application. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word comprising does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The application can be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the system claims enumerating several means, several of these means can be embodied by one and the same item of hardware. The use of the words first, second, third, etc. do not imply any order. The terms first, second, third, etc. are to be understood as names. The steps of any method claims herein do not have to be performed in order. The above-described embodiments of the application are merely possible examples of implementations, and are intended to provide an overall insight into the application, and do not purport to be exhaustive or to limit the scope of the application to the precise forms disclosed.
Claims
1. A form processing method characterized by, The method comprises: identifying a target table in target data to obtain cell information; the target table is a wired table with inclination; the cell information comprises contents, coordinate information and inclination angles of multiple cells; determining whether two cells are located in the same row according to the coordinate information and inclination angles of the two cells, taking all cells located in the same row as a target row to obtain multiple target rows; the coordinate information comprises horizontal coordinates and vertical coordinates; the two cells comprise a first cell and a second cell; the determination of whether the two cells are located in the same row according to the coordinate information and inclination angles of the two cells to obtain multiple target rows comprises: determining a theoretical vertical coordinate of the second cell according to the horizontal coordinate, vertical coordinate of the first cell, horizontal coordinate of the second cell and inclination angle; determining whether the first cell and the second cell are located in the same row according to a coordinate deviation between the theoretical vertical coordinate and the vertical coordinate of the second cell; taking all cells located in the same row as a target row to obtain multiple target rows; wherein the determination of the theoretical vertical coordinate of the second cell according to the horizontal coordinate, vertical coordinate of the first cell, horizontal coordinate of the second cell and inclination angle comprises: determining a coordinate relative relationship between the first cell and the second cell according to the inclination angle and a preset trigonometric function; determining the theoretical vertical coordinate of the second cell according to the horizontal coordinate, vertical coordinate of the first cell, horizontal coordinate of the second cell and the coordinate relative relationship; vertically sorting the target rows and horizontally sorting cells in the target rows according to the coordinate information to obtain a sorted table; filling the contents of each cell into the sorted table to obtain a calibrated table corresponding to the target table.
2. The method of claim 1, wherein, The coordinate relative relationship comprises a ratio relationship between a horizontal coordinate distance between the first cell and the second cell and a vertical coordinate distance between the first cell and the second cell; The determination of the theoretical vertical coordinate of the second cell according to the horizontal coordinate, vertical coordinate of the first cell, horizontal coordinate of the second cell and the coordinate relative relationship comprises: determining a vertical coordinate distance according to the distance between the horizontal coordinate of the first cell and the horizontal coordinate of the second cell and the ratio relationship; determining the theoretical vertical coordinate of the second cell according to the vertical coordinate of the first cell and the vertical coordinate distance. The determination of whether the first cell and the second cell are located in the same row according to the coordinate deviation between the theoretical vertical coordinate and the vertical coordinate of the second cell comprises:
3. The method of claim 1, wherein, when the coordinate deviation is less than or equal to a preset error threshold, determining that the first cell and the second cell are located in the same row; the error threshold is used to represent an influence of table line thickness of the target table on cell coordinate identification. 4. The method of claim 1, wherein, Before determining the theoretical vertical coordinate of the second cell according to the horizontal coordinate of the first cell and the horizontal coordinate of the second cell and the tilt angle of the second cell, comprising: Synchronizing the tilt angle of each cell according to the average of the tilt angles of all the cells.
5. The method of claim 1, wherein, The coordinate information comprises horizontal coordinates and vertical coordinates of the cells; and the sorting the target rows and the cells in the target rows according to the coordinate information respectively to obtain a sorted table, comprising: For each target row, sorting the cells in the target row horizontally according to the order of the horizontal coordinates of all the cells in the target row; Sorting the target rows vertically according to the order of the vertical coordinates of the first cells of all the target rows to obtain the sorted table.
6. A table processing apparatus characterized by comprising: The device comprises: A recognition module configured to recognize a target table in target data to obtain cell information; The target table is a wired table with tilt; and the cell information comprises contents, coordinate information and a tilt angle of a plurality of cells; A determination module configured to determine whether two cells are in the same row according to the coordinate information and the tilt angle of the two cells, and take all the cells in the same row as a target row to obtain a plurality of target rows; the coordinate information comprises horizontal coordinates and vertical coordinates; the two cells comprise a first cell and a second cell; the determination whether the two cells are in the same row according to the coordinate information and the tilt angle of the two cells to obtain a plurality of target rows comprises: determining a theoretical vertical coordinate of the second cell according to the horizontal coordinate of the first cell, the vertical coordinate of the first cell, the horizontal coordinate of the second cell and the tilt angle of the second cell; determining whether the first cell and the second cell are in the same row according to a coordinate deviation between the theoretical vertical coordinate and the vertical coordinate of the second cell; taking all the cells in the same row as a target row to obtain a plurality of target rows; wherein the determination of the theoretical vertical coordinate of the second cell according to the horizontal coordinate of the first cell, the vertical coordinate of the first cell, the horizontal coordinate of the second cell and the tilt angle of the second cell comprises: determining a coordinate relative relationship between the first cell and the second cell according to the tilt angle and a preset trigonometric function; and determining the theoretical vertical coordinate of the second cell according to the horizontal coordinate of the first cell, the vertical coordinate of the first cell, the horizontal coordinate of the second cell and the coordinate relative relationship; A sorting module configured to sort the target rows and the cells in the target rows according to the coordinate information respectively to obtain a sorted table; A filling module configured to fill the contents of each cell into the sorted table respectively to obtain a calibrated table corresponding to the target table.
7. A table processing device characterized by comprising: Comprising: a processor, a memory, a communication interface, and a communication bus, which are used for communication among each other through the communication bus; the memory is used for storing at least one executable instruction, which makes the processor execute the operations of the table processing method according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, the storage medium stores at least one executable instruction, which, when executed on the table processing device, makes the table processing device execute the operations of the table processing method according to any one of claims 1-5.
Citation Information
Patent Citations
Method and device for identifying table in picture, readable medium and electronic equipment
CN110956087A
Table extraction method and device, computer equipment and storage medium
CN114283435A