Method and device for identifying valid table cells in document

By identifying and filtering table line shape elements and sub-regions in electronic documents, the problem of identifying effective cells in special-shaped tables is solved, and efficient deconstruction and identification of table regions in electronic documents are achieved.

CN118537877APending Publication Date: 2024-08-23ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410664071.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

It is difficult for existing technology to effectively identify valid cells in special-shaped tables in electronic documents, resulting in limited processing efficiency.

Method used

By identifying the table area in the document, the table line shape elements are obtained. The table line shape element recognition model trained by the artificial intelligence algorithm is used, combined with the binary map and connected domain solution, to filter out the sub-regions divided by the table line shape elements, and based on The shape and positional relationship of the sub-area are used to determine whether it is a valid cell.

Benefits of technology

Accurately identify valid cells in table areas including non-full-border tables, improving the efficiency and accuracy of electronic document processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537877A
    Figure CN118537877A
Patent Text Reader

Abstract

The invention discloses a method and device for identifying effective table cells in a document, and the method comprises the steps: obtaining table line-shaped elements in a to-be-identified document, recognizing sub-regions divided by the table line-shaped elements, and carrying out the preliminary positioning of the effective table cells in the table regions; according to the method, each sub-region is identified according to the shape of each sub-region and the position relationship between the sub-region and the table region, the table region can be deconstructed, and the functional independence and integrity of the sub-region are judged according to information such as the shape and the position of the sub-region, so that whether the sub-region belongs to an effective cell or not is accurately judged; through the above judgment process from coarse to fine, the effective cells in the table areas including special-shaped tables such as non-full-frame tables can be identified. The method is widely applied to the technical field of computer document processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer document processing, in particular to a method and device for identifying valid cells of a table in a document. Background Art

[0002] In the process of processing electronic documents, it is usually necessary to process the tables in the documents. Generally speaking, a table has a border on the outside of the whole, and there are multiple table lines inside the table, which divide the cells inside the table. These table lines are also the borders of the cells. Cells can be filled with various types of content, such as text, pictures, and even tables. Cells are the basic components of tables. Identifying cells in a table is conducive to content extraction and other processing tasks.

[0003] If a part of a table has the properties of a cell (for example, it can accommodate at least part of the information to be displayed in the table, can be distinguished from other parts, and can be edited independently), then regardless of whether this part is divided by table lines, this part actually functions as a cell and can be called a valid cell. For regular tables such as full-border tables (tables with complete external borders), it is relatively easy to identify valid cells because of their simple structure. However, due to the personal habits of the author of the electronic document and the complexity of the information to be expressed by the table, electronic documents usually contain special-shaped tables such as embedded tables and non-full-border tables (tables with partial or complete external borders missing), and it is difficult to identify valid cells in these tables.

[0004] For example, a part of an embedded table also contains an internal table, and this part can actually be distinguished from other parts and is independently editable. It can be recognized as a valid cell in the embedded table as a whole. However, due to the structural complexity of the embedded table, current related technologies may mistakenly recognize this part as an internal table with a border rather than a cell in the embedded table. The recognized embedded table loses its integrity, which limits the efficiency of content recognition, content extraction, and content classification of electronic documents. Summary of the invention

[0005] In view of the technical problems that it is difficult to identify valid cells in tables, especially irregular tables, when identifying table areas in document pages, resulting in limited processing efficiency of electronic documents, the purpose of the present invention is to provide a method and device for identifying valid cells in tables in documents.

[0006] In one aspect, an embodiment of the present invention includes a method for identifying valid cells in a table in a document, and the method for identifying valid cells in a table in a document includes the following steps:

[0007] Identify the table area in the document to be identified;

[0008] Acquire a plurality of table line shape elements located in the table area;

[0009] In the table area, identifying at least one sub-area divided by each of the table line shape elements;

[0010] The sub-regions are screened according to their shapes and their positional relationship with the table region, and the screened sub-regions are identified as valid cells.

[0011] Further, the obtaining of the table line shape element located in the table area includes:

[0012] Acquire at least one of a text document element, a path document element, and a picture document element located in the table area from the document to be identified;

[0013] When the text document element is acquired, content detection is performed on the text document element, and when it is detected that the text document element contains preset characters, the text document element is determined to be a table line shape element;

[0014] When the path document element is acquired, the path document element is parsed for instructions and bounding box is extracted, and when a straight line drawing instruction is parsed but a curve line drawing instruction is not parsed, and the aspect ratio or height-to-width ratio of the extracted bounding box is greater than a first ratio threshold, the path document element is determined to be a table line shape element;

[0015] When the picture-type document element is obtained and grayscaled, pixel detection is performed on the boundary of the picture-type document element. If continuous pixels with non-second pixel values ​​are detected on any boundary, and the ratio of the continuous length to the length of the boundary is greater than the second ratio threshold, the picture-type document element is determined to be a table line shape element.

[0016] Further, the obtaining of the table line shape element located in the table area includes:

[0017] Acquire a trained table line shape element recognition model; the table line shape element recognition model is obtained by training table line feature samples using an artificial intelligence algorithm;

[0018] Rendering the document to be identified into image data;

[0019] The image data is input into the table line shape element recognition model to perform table line shape element recognition to obtain table line shape elements.

[0020] Furthermore, in the table area, identifying at least one sub-area divided by each of the table line shape elements includes:

[0021] Creating a binary image; the size of the binary image is proportional to the size of the document to be identified;

[0022] Mapping the table area in the document to be identified to the binary image;

[0023] The pixel value of the portion of the binary image mapped by the table line shape element is set as a first pixel value, and the pixel value of the portion not mapped by the table line shape element is set as a second pixel value;

[0024] Solving the connected domain of the binary image to determine at least one connected domain in the binary image; the pixel value of the connected domain is the second pixel value;

[0025] A document region in the document to be identified mapped by each connected domain is identified as one of the sub-regions.

[0026] Furthermore, before solving the connected domain of the binary graph, identifying at least one sub-region divided by each of the table line shape elements in the table region further comprises:

[0027] A closing operation is performed on the binary image.

[0028] Further, the filtering of each sub-region according to the shape of each sub-region and the positional relationship between each sub-region and the table region, and identifying the filtered sub-region as a valid cell, includes:

[0029] At least one round of the first processing process is executed in sequence until no valid cells are identified in any round of the first processing process, and the execution of the first processing process is terminated; any round of the first processing process includes the following steps:

[0030] In the case where the first processing process in this round is the first processing process in the first round, a table border is detected from the table area identified in the document to be identified; in the case where the first processing process in this round is not the first processing process in the first round, a table border is detected from the table area updated by the previous first processing process;

[0031] In the case where at least one edge line of any of the sub-regions overlaps with the detected table border, and the shape of the sub-region is a convex figure, identifying the sub-region as a valid cell;

[0032] The sub-regions belonging to valid cells are deleted from the table region to obtain the table region updated by the first processing process in this round.

[0033] Furthermore, the table valid cell identification method also includes:

[0034] If no valid cell is identified in any round of the first processing, terminating the execution of the first processing;

[0035] The sub-region that is not identified as a valid cell after executing all of the first processing processes is identified as an invalid cell.

[0036] Further, the filtering of each sub-region according to the shape of each sub-region and the positional relationship between each sub-region and the table region, and identifying the filtered sub-region as a valid cell, includes:

[0037] At least one round of the second processing process is performed in sequence until no non-convex sub-region is detected from the table region in any round of the second processing process, and the second processing process is terminated; any round of the second processing process includes the following steps:

[0038] In the case where the second processing process in this round is the second processing process in the first round, the convexity of the shape of each sub-region in the table region is detected, and the non-convex edge line is obtained from the detected non-convex sub-region; in the case where the second processing process in this round is not the second processing process in the first round, the non-convex edge line updated in the previous second processing process is obtained; wherein the non-convex sub-region is a sub-region with a non-convex figure shape, and the non-convex edge line is the edge line of the non-convex part of the non-convex figure;

[0039] Merging the sub-regions connected by the acquired non-convex edge lines to obtain a merged sub-region, deleting the non-convex edge lines inside the merged sub-region, and detecting the concavity and convexity of the shape of the merged sub-region;

[0040] When the shape of the merged sub-region is a convex figure, the merged sub-region is identified as a valid cell; when the shape of the merged sub-region is not a convex figure, the non-convex edge line of the edge of the merged sub-region is obtained as the non-convex edge line after update in this round of the second processing process.

[0041] Furthermore, the table valid cell identification method also includes:

[0042] The sub-region that is not identified as a valid cell after executing all of the second processing processes is identified as an invalid cell.

[0043] Furthermore, the table valid cell identification method also includes:

[0044] During any round of the second processing,

[0045] After deleting the non-convex edge lines inside the merged sub-region, the table line shape elements corresponding to the deleted non-convex edge lines are identified as table contents.

[0046] Further, the sequentially executing at least one round of the second processing process includes:

[0047] In case of executing a first process, detecting execution of the first process;

[0048] After the last round of the first processing process is executed, the first round of the second processing process is started;

[0049] Wherein, any round of the first processing process includes the following steps:

[0050] In the case where the first processing process in this round is the first processing process in the first round, a table border is detected from the table area identified in the document to be identified; in the case where the first processing process in this round is not the first processing process in the first round, a table border is detected from the table area updated by the previous first processing process;

[0051] In the case where at least one edge line of any of the sub-regions overlaps with the detected table border, and the shape of the sub-region is a convex figure, identifying the sub-region as a valid cell;

[0052] The sub-regions belonging to valid cells are deleted from the table region to obtain the table region updated by the first processing process in this round.

[0053] Furthermore, the table valid cell identification method further includes:

[0054] Detecting the position of the edge of the sub-region belonging to the valid cell;

[0055] In the case where a table line shape element is detected, the detected table line shape element is identified as a table line.

[0056] Furthermore, the table valid cell identification method further includes:

[0057] Detecting the position of the edge of the sub-region belonging to the invalid cell;

[0058] When a table line shape element is detected and the detected table line shape element is not recognized as a table line, the detected table line shape element is recognized as table annotation information.

[0059] On the other hand, an embodiment of the present invention further includes a device for identifying valid cells in a table in a document, the device for identifying valid cells in a table including:

[0060] A table area recognition module is used to recognize the table area in the document to be recognized;

[0061] An element acquisition module, used for acquiring a plurality of table line shape elements located in the table area;

[0062] A sub-region identification module, used for identifying at least one sub-region divided by each of the table line shape elements in the table region;

[0063] The sub-region screening module is used to screen each of the sub-regions according to their shapes and their positional relationship with the table area, and identify the screened sub-regions as valid cells.

[0064] Furthermore, when acquiring the table line shape element located in the table area, the element acquisition module is specifically used to:

[0065] Acquire at least one of a text document element, a path document element, and a picture document element located in the table area from the document to be identified;

[0066] When the text document element is acquired, content detection is performed on the text document element, and when it is detected that the text document element contains preset characters, the text document element is determined to be a table line shape element;

[0067] When the path document element is acquired, the path document element is parsed for instructions and bounding box is extracted, and when a straight line drawing instruction is parsed but a curve line drawing instruction is not parsed, and the aspect ratio or height-to-width ratio of the extracted bounding box is greater than a first ratio threshold, the path document element is determined to be a table line shape element;

[0068] When the picture-type document element is obtained and grayscaled, pixel detection is performed on the boundary of the picture-type document element. If continuous pixels with non-second pixel values ​​are detected on any boundary, and the ratio of the continuous length to the length of the boundary is greater than the second ratio threshold, the picture-type document element is determined to be a table line shape element.

[0069] Furthermore, when acquiring the table line shape element located in the table area, the element acquisition module is specifically used to:

[0070] Acquire a trained table line shape element recognition model; the table line shape element recognition model is obtained by training table line feature samples using an artificial intelligence algorithm;

[0071] Rendering the document to be identified into image data;

[0072] The image data is input into the table line shape element recognition model to perform table line shape element recognition, and a table line shape element recognition result is obtained and output.

[0073] Further, when the sub-region identification module identifies at least one sub-region divided by each of the table line shape elements from the table region, it is specifically used to:

[0074] Creating a binary image; the size of the binary image is proportional to the size of the document to be identified;

[0075] Mapping the table area in the document to be identified to the binary image;

[0076] The pixel value of the portion of the binary image mapped by the table line shape element is set as a first pixel value, and the pixel value of the portion not mapped by the table line shape element is set as a second pixel value;

[0077] Solving the connected domain of the binary image to determine at least one connected domain in the binary image; the pixel value of the connected domain is the second pixel value;

[0078] A document region in the document to be identified mapped by each connected domain is identified as one of the sub-regions.

[0079] Furthermore, before solving the connected domain of the binary graph, the sub-region identification module is further used to:

[0080] A closing operation is performed on the binary image.

[0081] Furthermore, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically used to:

[0082] At least one round of the first processing process is executed in sequence until no valid cells are identified in any round of the first processing process, and the execution of the first processing process is terminated; any round of the first processing process includes the following steps:

[0083] In the case where the first processing process in this round is the first processing process in the first round, a table border is detected from the table area identified in the document to be identified; in the case where the first processing process in this round is not the first processing process in the first round, a table border is detected from the table area updated by the last first processing process;

[0084] If at least one edge line of any of the sub-regions overlaps with the detected table border, and the shape of the sub-region is a convex figure, the sub-region is identified as a valid cell;

[0085] The sub-regions belonging to valid cells are deleted from the table region to obtain the table region updated by the first processing process in this round.

[0086] Furthermore, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically used to:

[0087] If no valid cell is identified in any round of the first processing, terminating the execution of the first processing;

[0088] The sub-region that is not identified as a valid cell after executing all of the first processing processes is identified as an invalid cell.

[0089] Furthermore, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically used to:

[0090] At least one round of the second processing process is performed in sequence until no non-convex sub-region is detected from the table region in any round of the second processing process, and the second processing process is terminated; any round of the second processing process includes the following steps:

[0091] In the case where the second processing process in this round is the second processing process in the first round, the convexity of the shape of each sub-region in the table region is detected, and the non-convex edge line is obtained from the detected non-convex sub-region; in the case where the second processing process in this round is not the second processing process in the first round, the non-convex edge line updated in the previous second processing process is obtained; wherein the non-convex sub-region is a sub-region with a non-convex figure shape, and the non-convex edge line is the edge line of the non-convex part of the non-convex figure;

[0092] Merging the sub-regions connected by the acquired non-convex edge lines to obtain a merged sub-region, deleting the non-convex edge lines inside the merged sub-region, and detecting the concavity and convexity of the shape of the merged sub-region;

[0093] When the shape of the merged sub-region is a convex figure, the merged sub-region is identified as a valid cell. When the shape of the merged sub-region is not a convex figure, the non-convex edge line of the edge of the merged sub-region is obtained as the non-convex edge line after update in this round of the second processing process.

[0094] Furthermore, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically used to:

[0095] The sub-region that is not identified as a valid cell after executing all of the second processing processes is identified as an invalid cell.

[0096] Furthermore, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically used to:

[0097] During any round of the second processing,

[0098] After deleting the non-convex edge lines inside the merged sub-region, the table line shape elements corresponding to the deleted non-convex edge lines are identified as table contents.

[0099] Furthermore, when the sub-region screening module sequentially performs at least one round of the second processing process, it is specifically used to:

[0100] In case of executing a first process, detecting execution of the first process;

[0101] After the last round of the first processing process is executed, the first round of the second processing process is started;

[0102] Wherein, any round of the first processing process includes the following steps:

[0103] In the case where the first processing process in this round is the first processing process in the first round, a table border is detected from the table area identified in the document to be identified; in the case where the first processing process in this round is not the first processing process in the first round, a table border is detected from the table area updated by the last first processing process;

[0104] If at least one edge line of any of the sub-regions overlaps with the detected table border, and the shape of the sub-region is a convex figure, the sub-region is identified as a valid cell;

[0105] The sub-regions belonging to valid cells are deleted from the table region to obtain the table region updated by the first processing process in this round.

[0106] Furthermore, the table valid cell identification device further includes:

[0107] A valid cell detection module, used to detect the position of the edge line of the sub-region belonging to the valid cell;

[0108] The table line recognition module is used to recognize the detected table line shape element as a table line when a table line shape element is detected.

[0109] Furthermore, the table valid cell identification device further includes:

[0110] An invalid cell detection module, used to detect the position of the edge line of the sub-region belonging to the invalid cell;

[0111] The table annotation information recognition module is used to recognize the detected table line shape element as table annotation information when a table line shape element is detected and the detected table line shape element is not recognized as a table line.

[0112] The beneficial effects of the present invention are as follows: the method and device for identifying valid cells in a table in a document in the embodiment can preliminarily locate valid cells in a table area by acquiring table line shape elements in a document to be identified and identifying sub-areas divided by each table line shape element; by identifying each sub-area according to its shape and positional relationship with the table area, the table area can be deconstructed, and the functional independence and integrity of the sub-area can be judged according to information such as the shape and position of the sub-area, thereby accurately judging whether the sub-area belongs to a valid cell; through the above-mentioned judgment process from coarse to fine, valid cells in a table area including special-shaped tables such as non-full-border tables can be identified. BRIEF DESCRIPTION OF THE DRAWINGS

[0113] Figure 1 A schematic diagram of the steps of a method for identifying valid cells in a table in a document in an embodiment;

[0114] FIG. 2( a ), FIG. 2( b ) and FIG. 2( c ) are schematic diagrams of sub-regions divided by table line shape elements in an embodiment;

[0115] Figure 3 Schematic diagram of the principle of step 3 in the embodiment;

[0116] Figure 4 It is a schematic flow chart of the first processing process in the embodiment;

[0117] Figure 5 This is an example diagram of the first processing process in the embodiment;

[0118] Figure 6 Schematic diagram of the second process in the embodiment;

[0119] Figure 7 This is an example diagram of the second processing process in the embodiment;

[0120] Figure 8 A schematic diagram of a complex table that can be identified by a valid cell identification method for a table in a document;

[0121] Fig. 9 A schematic diagram of an embedded table that can be identified by a valid cell identification method for a table in a document;

[0122] Fig.10 A schematic diagram of a table with non-aligned lines that can be identified by a valid cell identification method for a table in a document;

[0123] Fig.11 It is a structural schematic diagram of a device for identifying valid cells of a table in a document in an embodiment;

[0124] Fig.12 is a schematic diagram of the structure of a computer device in an embodiment;

[0125] Fig.13 Schematic diagram of the working principle of the computer-readable storage medium in the embodiment. DETAILED DESCRIPTION

[0126] In the method for identifying valid table cells in this embodiment, the object to be identified is the document to be identified, which can be either a layout document or a streaming document. At the data level, documents of various formats include at least one of the basic elements of the type of vector line drawings, text, pictures, etc. These basic elements are collectively referred to as document elements.

[0127] Taking PDF (Portable Document Format) documents as an example, its technical specifications specify various types of document elements, including:

[0128] Vector line graphic element (path element) Path: Each vector line graphic element Path usually includes vector line operation instructions [such as MoveTo (move but not draw), LineTo (move and draw a straight line), BezierTo (move and draw a Bezier curve)], vector line coordinates [such as StartPoint (coordinates before moving), EndPoint (coordinates after moving)], vector line color, vector line external bounding box [in the form of BBox (Bounding Box) coordinates], etc.;

[0129] Text element Text: Each text element Text usually includes text Unicode, character code CharCode and external bounding box BBox coordinates;

[0130] Image element Image: Each image element Image usually contains RGB color information, external bounding box BBox coordinates and other contents.

[0131] In documents of other formats, various document elements may have other names, but they can be classified into vector line drawing elements, text elements, image elements, etc. according to their actual content. This embodiment mainly takes the document to be identified in PDF format as an example. The table area identification method of this application can also be applied to other document formats similar to PDF, such as OFD format, CAJ format, XML format, HTML format, etc., and only needs to be adaptively modified.

[0132] The meanings of some terms used in this embodiment are as follows:

[0133] Table lines: Table lines are the lines used to separate rows and columns in a table. They are used to define the borders of a table and the separators between cells, making the table clearer and easier to read. Table lines can be horizontal lines, used to separate rows; they can also be vertical lines, used to separate columns; they can also be intersecting horizontal and vertical lines, forming the borders of cells;

[0134] Cell: A cell is the smallest unit in a table, used to store data or display content. It is located at the intersection of a table and is formed by the intersection of rows and columns;

[0135] Full border table: A full border table is a table format that has lines around the table with all borders complete;

[0136] Half-border table: A half-border table is another form of table representation, which only has part of the table lines, usually including at least the top and bottom edges of the border. For example, a double-line table (a table consisting of only two horizontal or vertical lines) and a three-line table (a table consisting of only three horizontal or vertical lines) are both half-border tables. There are also tables that lack up to three border lines.

[0137] Borderless table: A table with four border lines missing;

[0138] Non-full-border table: a table with incomplete borders, i.e. a table with missing parts or even all of the borders, which can be used as a general term for semi-border tables and borderless tables;

[0139] Embedded table: refers to nesting a table in another table; in the structure of embedded table, a table cell can contain another complete table;

[0140] Closing operation: It is a morphological operation in image processing, usually used to remove small holes and breaks in binary images, making the objects in the image more connected and complete; the closing operation is to first perform an expansion operation and then an erosion operation, which can fill and connect small holes and cracks in the original image; the closing operation can be achieved through structural elements of different sizes and shapes, and can be performed multiple times to better fill the holes and breaks in the image.

[0141] In this embodiment, refer to Figure 1 ,The method for identifying valid cells of a table in a document includes the following steps:

[0142] S1. Identify the table area in the document to be identified;

[0143] S2. Get multiple table line shape elements located in the table area;

[0144] S3. In the table area, identifying at least one sub-area divided by each table line shape element;

[0145] S4. Screen each sub-region according to its shape and its positional relationship with the table region, and identify the screened sub-region as a valid cell.

[0146] Steps S1-S4 can be executed by a computer. For example, a computer code can be obtained by programming through computer programming technology, and the computer code can be input into a computer device so that the computer device executes steps S1-S4. The computer code can be integrated into application software such as a document reader and a document editor, and steps S1-S4 are executed when the computer device runs the application software such as a document reader and a document editor, so that the table area recognition effect achieved by the computer device executing steps S1-S4 becomes one of the functions of the application software such as a document reader and a document editor.

[0147] The computer device can download the document to be identified through the Internet, or connect to a mobile device such as a mobile phone, a tablet computer, a removable hard disk, etc., and read the document to be identified from the mobile device for the computer device to execute steps S1-S4.

[0148] In step S1, the table area in the document to be identified can be directly determined based on the table area marked by the data of the document to be identified, or the table area can be identified from the document to be identified using a valid table cell recognition technology in the document.

[0149] In step S2, the document to be recognized is parsed to obtain all document elements in the document to be recognized, and then table line shape elements are filtered out from all document elements. The table line shape elements in step S2 refer to some specific document elements in the document to be recognized. After these document elements are rendered and displayed, the display effects can be used to represent table lines. Specifically, the table line shape elements may be document elements of types such as vector line graph elements Path, text elements Text, image elements Image, or other types of document elements. For example, in the document to be recognized, a specific vector line graph element Path can be used to depict a horizontal or vertical straight line to represent the border or the table line dividing cells internally. Such a vector line graph element Path belongs to the table line shape elements in step S1. However, due to personal habits of the editor of the document to be recognized or limitations of the document editing software's functions, multiple text characters "-" (dash) or "——" (double dash) or Chinese character "一" and other text elements Text may be used. When these text elements Text are displayed, their display effect is a horizontal straight line, which can achieve the visual effect of a table line. Similarly, when text characters "|" or Arabic numeral character "1" and other text elements Text are displayed, their display effect is a vertical straight line, which can also achieve the visual effect of a table line. Such text elements Text belong to the table line shape elements in step S2. There may also be some image elements Image in the document to be recognized, and the content of these image elements Image is the table line. Therefore, when these image elements Image are displayed, they achieve the effect of displaying the table line. Such image elements Image belong to the table line shape elements in step S2.

[0150] Since the table line shape elements obtained in step S2 may specifically be basic types such as vector line graph elements Path, text elements Text, image elements Image, etc., each table line shape element determines the shape and position of the area in the document to be recognized through the coordinates of its circumscribed bounding box BBox. Therefore, in step S3, it is possible to recognize at least one sub-region into which the table line shape elements divide the interior of the table region. For example, referring to Fig. 2(a), the table line shape elements A1 and B1 divide the interior of the table region into sub-regions R1, R2, and R3; referring to Fig. 2(b), the table line shape elements A2 and B2 divide the interior of the table region into sub-regions R4, R5, and R6; referring to Fig. 2(c), the table line shape elements A3, B3, and C3 divide the interior of the table region into sub-regions R7, R8, and R9.

[0151] In step S4, according to the shapes of the sub-regions and the positional relationships between the sub-regions and the table region, the sub-regions are filtered, and the filtered sub-regions are recognized as valid cells.

[0152] Specifically, in step S4, the sub-areas in each table area are screened by using "having a specific shape and having a specific positional relationship with the table area" as the screening condition. For any table area, the screening result may be that some or all of the sub-areas are screened out, or no sub-areas are screened out. For any table area, when at least one sub-area is screened out, the table area is identified as a table as a whole, and the sub-areas screened out from the table area are identified as valid cells in the table.

[0153] In this embodiment, when executing step S2, that is, the step of acquiring a plurality of table line shape elements located in the table area, the following steps may be specifically performed:

[0154] S201A. Obtain multiple document elements from the document to be identified; wherein the document element is at least one of a text document element, a path document element, and a picture document element;

[0155] S202A. When a text document element is obtained, the content of the text document element is detected, and when it is detected that it contains preset characters, the text document element is determined to be a table line shape element;

[0156] S203A. When a path-type document element is obtained, the path-type document element is subjected to instruction parsing and bounding box extraction. When a straight line drawing instruction is parsed but a curve drawing instruction is not parsed, and the aspect ratio or height-to-width ratio of the extracted bounding box is greater than the first ratio threshold, the path-type document element is determined as a table line shape element;

[0157] S204A. When a picture-type document element is obtained and rendered and grayed out, pixel detection is performed on the boundary of the picture-type document element. When continuous pixels with non-second pixel values ​​are detected on any boundary, and the ratio of the continuous length to the length of the boundary is greater than the second ratio threshold, the boundary of the picture-type document element is determined as a table line shape element.

[0158] Steps S201A-S204A are the first execution mode of step S2.

[0159] In step S201A, from all the document elements obtained from the document to be identified, some or all types of document elements such as text document elements Text, path document elements Path, and image document elements Image are screened out.

[0160] If the text - type document element Text is filtered out in step S201A, in step S202A, for the text - type document element Text, directly detect whether the text Unicode or character code CharCode, etc. contains preset characters in the form of a straight - line segment, such as a dash "-", an em - dash "——", "|", the Chinese character "一", or the Arabic numeral "1". Determine the text - type document element Text with the above - mentioned preset characters as a table - line - shaped element and store it in LineGroup.

[0161] If the path - type document element Path is filtered out in step S201A, in step S203A, perform instruction parsing and bounding - box extraction on the path - type document element Path. For a path - type document element Path, if the BezierTo instruction (curve - drawing instruction) is parsed, it indicates that the path - type document element Path corresponds to a curve, and such a path - type document element Path will not be a table line, so bounding - box extraction may not be performed; if the LineTo instruction (straight - line - drawing instruction) is parsed and the BezierTo instruction is not parsed, it indicates that the path - type document element Path depicts a straight - line - related graphic (such as a rectangle or a line segment). Then, perform bounding - box extraction on the path - type document element Path to obtain its circumscribed - bounding - box coordinates BBox. For the path - type document element Path depicting a horizontal straight line, the aspect ratio BBox.Width / BBox.Height can be calculated based on its circumscribed - bounding - box coordinates BBox. For the path - type document element Path depicting a vertical straight line, the aspect ratio BBox.Height / BBox.Width can be calculated based on its circumscribed - bounding - box coordinates BBox. The first ratio threshold can be set to 5. When the aspect ratio BBox.Width / BBox.Height is greater than 5 (i.e., BBox.Width>5*BBox.Height) or the aspect ratio BBox.Height / BBox.Width is greater than 5 (i.e., BBox.Height>5*BBox.Width), it can be considered that the path - type document element Path is used to depict a sufficiently slender rectangle, that is, the path - type document element Path depicts a straight line. Therefore, determine such a path - type document element Path as a table - line - shaped element.

[0162] For the path - type document element Path depicting a horizontal straight line, other judgment conditions can also be set. For example, when the following conditions are met simultaneously, determine the path - type document element Path as a table - line - shaped element and store it in LineGroup:

[0163] BBox.Width>5*BBox.Height and BBox.Height<5.25

[0164] |Path.StartPoint.y-Path.EndPoint.y|<0.1

[0165] For a path-type document element Path that depicts a vertical straight line, other judgment conditions may be set. For example, when the following conditions are met at the same time, the path-type document element Path is determined as a table line shape element and stored in LineGroup:

[0166] BBox.Height>5*BBox.Width and BBox.Width<5.25

[0167] |Path.StartPoint.x-Path.EndPoint.x|<0.1

[0168] If step S201A is executed to filter out the picture-type document element Image, in step S204A, after rendering and grayscale processing are performed on the picture-type document element Image, the pixel values ​​of each pixel in the picture-type document element Image are respectively the first pixel value (0, indicating pure black), the second pixel value (255, indicating pure white) or a pixel value between the first pixel value and the second pixel value; pixel detection is performed on the boundary of the picture-type document element Image, and for a picture-type document element Image, if it is detected that there are continuous pixels with non-second pixel values ​​(i.e., non-255) on any boundary thereof, and the ratio of the continuous length to the length of the boundary is greater than the second ratio threshold, then this edge of the picture-type document element Image is determined as a table line shape element.

[0169] In step S204A, for example, a picture-type document element Image has a length of H and a width of W, Pixel(x,y) represents the pixel value of the yth row and xth column in the picture-type document element Image, and the value range is 0 to 255. The second proportional threshold (indicating the minimum allowed line length, which can be set between 0 and 1) is set to 0.5. If there is a continuous x value range i to j, such that Pixel(x,0) is less than 255 (or less than 200 or other smaller values, indicating that the color of Pixel(x,0) is dark enough), and ji>H*0.5 (indicating that Pixel(x,0) is long enough), then the edge of Pixel(x,0) is determined as a table line shape element, and the coordinates of the edge of Pixel(x,0) (Image.left, Image.top+i, Image.left+linewidth, Image.top+j) are stored in LineGroup to represent the corresponding table line shape element. Among them, linewidth is the line width, which can be a fixed value such as 1 or 0, and Image.left and Image.top are the coordinates of the external bounding box corresponding to the Image element of this image document element.

[0170] By executing steps S201A-S204A, table line shape elements belonging to various document element types can be identified from the document to be identified and stored in LineGroup, that is, LineGroup is a collection of various table line shape elements.

[0171] In this embodiment, when executing step S2, that is, the step of obtaining the table line shape element in the document to be identified, the following steps may be specifically performed:

[0172] S201B obtains the trained table line shape element recognition model;

[0173] S202B. Rendering the document to be identified into image data;

[0174] S203B. Input the image data into a table line shape element recognition model to perform table line shape element recognition, and obtain a plurality of table line shape element recognition results.

[0175] Steps S201B-S203B are a second execution method of step S2.

[0176] In step S201B, table line feature samples can be extracted from documents in known table areas based on methods such as manual annotation, data synthesis, and document conversion to HTML, and artificial intelligence algorithm training can be performed on table line shape element recognition models based on target detection networks such as Faster-RCNN, Yolov4, CenterNet, and FCOS to learn table line features.

[0177] In step S202B, after the document to be identified is rendered into image data, it is used as input data of the table line shape element recognition model. In step S203B, the table line shape element recognition model identifies the document to be identified in the form of image data, thereby outputting the table line shape element recognition result.

[0178] By executing steps S201B-S203B, the advantages of high efficiency and accuracy of artificial intelligence technology can be utilized to quickly extract table line shape elements from the document to be identified, achieving the same effect as steps S201A-S204A.

[0179] In this embodiment, when executing step S3, that is, the step of identifying at least one sub-region divided by each table line shape element in the table region, the following steps may be specifically performed:

[0180] S301. Create a binary image;

[0181] S302. Mapping the table area in the document to be identified to a binary image;

[0182] S303. Set the pixel value of the portion of the binary image mapped by the table line shape element as the first pixel value, and set the pixel value of the portion not mapped by the table line shape element as the second pixel value;

[0183] S304. Solve the connected domain of the binary image to determine at least one connected domain in the binary image; the pixel value of the connected domain is the second pixel value;

[0184] S305. Mapping the binary graph after the connected domain solution back to the document to be identified;

[0185] S306. Identify the document region in the document to be identified that is mapped by each connected domain as a sub-region.

[0186] The principle of steps S301-S306 is as follows Figure 3 shown.

[0187] Reference Figure 3 In step S301, a binary image proportional to the size of the document to be identified is created. Specifically, the size of the binary image can be determined by scaling the size of the document to be identified according to a certain ratio Ratio. For example, if the size of the document to be identified is 1280×720, it can be scaled by 0.5 times to determine the size of the binary image to be 640×360. Generally, the smaller the Ratio, the faster the subsequent processing speed, but the accuracy will be affected. The Ratio can be set to around 0.2.

[0188] In step S301, the initial pixel value of each point in the binary image may be set to the second pixel value 255 (pure white).

[0189] In step S302, the coordinates corresponding to each table line shape element stored in the LineGroup in the document to be recognized are calculated according to the Ratio and mapped to the corresponding points in the binary image.

[0190] In step S303, the pixel value of the pixel point mapped in the binary image is set to the first pixel value 0 (pure black), and the pixel value of the part not mapped in the binary image is still the second pixel value 255 (pure white). The pixel value settings of each point in the binary image in step S301 and step S303 are not unique. For example, when executing step S301, the initial pixel value of each point in the binary image is set to the first pixel value 0 (pure black), and when executing step S303, the pixel value of the pixel point mapped in the binary image is set to the second pixel value 255 (pure white). When executing steps S301 and S303, the initial pixel value of each point in the binary image and the pixel value of the pixel point mapped can also be set to other values ​​respectively, preferably so that a large difference (for example, more than 50) is maintained between them.

[0191] In step S304, the binary graph is solved for connected domains. Specifically, a connected domain solving algorithm such as a depth-first traversal algorithm may be used. The connected domain solving algorithm first dilates and then erodes the binary graph, thereby determining connected domains where each pixel value in the binary graph is the second pixel value 255.

[0192] In step S305, the coordinates of each connected domain in the binary image are divided by Ratio and then mapped back to the document to be identified. Each connected domain in the binary image with a pixel value of the second pixel value 255 is mapped to the coordinates in the document to be identified, and a corresponding sub-region in the corresponding table region in the document to be identified can be determined.

[0193] In this embodiment, after executing steps S301-S303 and before executing step S304, a closing operation may be performed on the binary graph to repair small gaps in the binary graph caused by loss of mapping accuracy, which is conducive to more accurately calculating the connected domain in the binary graph.

[0194] In this embodiment, by executing steps S301 - S305 , the binary graph and connected domain solving algorithm can be applied to quickly identify sub-regions such as R1 - R9 in the table region of the document to be identified.

[0195] After identifying sub-regions R1-R9, the information (edge ​​coordinates) of these sub-regions can be stored in Contours. The i-th sub-region can be represented by Contours(i). At the same time, the information of each table region (edge ​​coordinates of all 4 edges) is stored in Canvas.

[0196] In this embodiment, when executing step S4, that is, screening each sub-region according to its shape and the positional relationship with the table area, and identifying the screened sub-region as a valid cell, multiple rounds of first processing processes can be executed in sequence. Except for the first round of first processing processes, each round of first processing processes is based on the execution result of the previous round of first processing processes, and continues to perform corresponding processing until no valid cells are identified in a certain round of first processing processes, and the execution of all first processing processes is terminated, that is, the subsequent first processing processes are no longer executed.

[0197] In this embodiment, refer to Figure 4 , any round of the first processing process includes the following steps:

[0198] S401A. In the case where the first processing process in this round is the first processing process in the first round, a table border is detected from the table area identified in the document to be identified, and conversely, a table border is detected from the table area updated from the previous first processing process;

[0199] S402A. If at least one edge of any sub-region overlaps with the detected table border and the shape of the sub-region is a convex figure, the sub-region is identified as a valid cell;

[0200] S403A. Delete the sub-areas belonging to the valid cells from the table area, thereby obtaining the table area updated by the first processing process of this round.

[0201] Reference Figure 4In step S401A, if the current process is the first round of the first processing, then the table border Canvas of the table area identified from the document to be identified is obtained; if the current process is not the first round of the first processing (for example, the second round, the fifth round of the first processing, etc.), then the table border Canvas updated by the previous round of the first processing is obtained; step S402A is executed to traverse all the sub-areas in the table area corresponding to the table border Canvas, for example, for the i-th sub-area Contours(i), it is determined whether the sub-area Contours(i) has at least one edge line that is consistent with the table border Canvas. If the corresponding edge in as coincides, if not, then the sub-region Contours(i) is not determined as a valid cell, and i=i+1 is set, that is, the i+1th sub-region Contours(i+1) is determined; if there is at least one edge in the sub-region Contours(i) that coincides with the corresponding edge in the table border Canvas, then it is determined whether the shape of the sub-region Contours(i) is a convex figure. If it is a convex figure, then the sub-region Contours(i) can be determined as a valid cell. If it is not a convex figure, then the sub-region Contours(i) is not determined as a valid cell.

[0202] In step S402A, the mathematical definition of a convex figure is: for a figure F and any two points A and B in F, if all points on the line segment AB are always in the figure F, then the figure F is called a convex figure. The rule for determining a convex figure is: for a polygonal figure F, if any side of the polygon F is extended to a straight line, and the remaining sides of the polygon F are on the same side of the straight line, then the polygonal figure F is determined to be a convex polygon. Therefore, when executing step S402A, the sub-region Contours(i) can be processed as follows: detect the boundary of the sub-region Contours(i), traverse each boundary of the sub-region Contours(i), extend one boundary to a straight line, and determine whether the other boundaries are on the same side of the straight line; if there is any boundary extended to a straight line, the other boundaries are on the same side of the straight line, then the sub-region Contours(i) can be determined to be a convex figure, otherwise, if there is no boundary extended to a straight line, the other boundaries are on the same side of the straight line, then the sub-region Contours(i) can be determined to be a non-convex figure.

[0203] If in step S402A, the sub-region Contours(i) is determined to be a valid cell, then when executing step S403A, the sub-region Contours(i) is deleted from the table area corresponding to the table border Canvas, and the remaining area is used as the new table area. The table border Canvas also changes, thereby updating the table border Canvas. Figure 4The updated table border Canvas is called when the next round of the first processing process executes step S401A.

[0204] Figure 4 An example of steps S401A-S403A shown in FIG. Figure 5 See Figure 5 A table area of ​​the document to be identified corresponds to the table border Canvas1, and the table line shape elements therein are identified to divide the table area into sub-areas R10, R11, R12, R13 and R14. Steps S401A-S403A are performed on the table area.

[0205] In the first round of the first processing, step S401A is executed to obtain the current table border Canvas1; step S402A is executed to first judge the sub-region R10, and it can be detected that there is an edge in the sub-region R10 (the edge on its left side) that coincides with an edge of the current table border Canvas1 (the edge on its left side), that is, an edge of the current table border Canvas1 is also an edge in the sub-region R10, so the concavity and convexity of the sub-region R10 can be further judged, and it can be detected that the shape of the sub-region R10 is a rectangle (convex figure), so that it can be determined that the sub-region R10 belongs to a valid cell in this table area; refer to Figure 5 After deleting sub-region R10 from the table area corresponding to the current table border Canvas1, sub-regions R11, R12, R13 and R14 remain, forming a new table border Canvas2, thereby completing the update of the table border and executing the first processing process of the second round.

[0206] In the second round of the first processing, execute step S401A to obtain the current table border Canvas2; execute step S402A to first judge the sub-region R11. No edge of the sub-region R11 overlaps with the edge in the table border Canvas2, so the sub-region R11 is not identified as a valid cell, and then judge the sub-region R12. Based on the same principle, no edge of the sub-regions R12, R13 and R14 overlaps with the edge in the table border Canvas2, so the sub-regions R12, R13 and R14 are not identified as valid cells. Since no valid cells are identified in the second round of the first processing, the execution of the first processing is terminated, that is, the second round of the first processing is ended, and the third round of the first processing and other subsequent first processing processes are no longer executed.

[0207] Therefore, for Figure 5After executing two rounds of the first processing process, the table area shown has traversed all sub-areas, and only the sub-area R10 is identified as a valid cell. For sub-areas R11, R12, R13 and R14, since they are not identified as valid cells after all the rounds of the first processing process, sub-areas R11, R12, R13 and R14 can be identified as invalid cells.

[0208] By executing steps S401A-S403A, sub-regions meeting the conditions can be screened out according to the characteristics of the shape of the valid cells and the positional relationship between the valid cells and the table area, so that the valid cells can be efficiently identified.

[0209] In this embodiment, when executing step S4, that is, screening each sub-region according to its shape and the positional relationship with the table area, and identifying the screened sub-region as a valid cell, multiple rounds of the second processing process can be executed in sequence. Except for the first round of the second processing process, each round of the second processing process is based on the execution result of the previous round of the second processing process, and continues to perform corresponding processing until no non-convex sub-region is detected from the table area in a certain round of the second processing process, and the execution of all the second processing processes is terminated, that is, the subsequent second processing processes are no longer executed.

[0210] In this embodiment, refer to Figure 6 , any round of the second processing process includes the following steps:

[0211] S401B. When the second processing process in this round is the second processing process in the first round, detect the convexity of the shape of each sub-region in the table region, obtain the non-convex edge line from the detected non-convex sub-region, and when the second processing process in this round is not the second processing process in the first round, obtain the non-convex edge line updated by the second processing process in the previous round;

[0212] S402B. Merging the sub-regions connected by the acquired non-convex edge lines to obtain a merged sub-region, deleting the non-convex edge lines inside the merged sub-region, and detecting the concavity of the shape of the merged sub-region;

[0213] S403B. When the shape of the merged sub-region is a convex figure, the merged sub-region is identified as a valid cell. When the shape of the merged sub-region is not a convex figure, the non-convex edge line of the edge of the merged sub-region is obtained as the non-convex edge line after update in this round of the second processing process.

[0214] Figure 6 An example of steps S401B-S403B is shown in FIG. Figure 7 shown.

[0215] Figure 7Part (a) is a table area of ​​the document to be recognized, and this table area is divided into sub-areas such as R11, R12, R13 and R14 by various table line shape elements.

[0216] When executing the second processing of the first round, step S401B is used to detect the convexity of sub-regions R11, R12, R13 and R14, where sub-regions R11, R13 and R14 are all rectangular (convex shapes), while sub-region R12 is an irregular shape, and sub-region R12 is a non-convex shape. For a non-convex shape, if one of the edges is extended into a straight line, the other edges cannot be on the same side of the straight line, then the edge in the non-convex shape is called a non-convex edge line. Therefore, Figure 7 In part (a), the boundary between the non-convex sub-region R12 and the sub-region R11 and the boundary between the non-convex sub-region R12 and the sub-region R13 are both non-convex edge lines of the non-convex sub-region R12.

[0217] When executing the second processing of the first round, execute step S402B, for the non-convex edge line "the boundary between the non-convex sub-region R12 and the sub-region R11", merge the two sub-regions R11 and R12 connected by this non-convex edge line to obtain a merged sub-region (R11+R12), delete the non-convex edge line inside the merged sub-region (R11+R12), and form Figure 7 The concavity and convexity of the shape of the combined sub-region (R11+R12) are detected.

[0218] Reference Figure 7 In part (b) of FIG. 1 , the merged sub-region (R11+R12) is a non-convex figure. Therefore, in step S403B of the first round of the second processing, the merged sub-region (R11+R12) is not identified as a valid cell. Instead, the non-convex edge line of the edge of the merged sub-region (R11+R12), that is, the boundary line between the merged sub-region (R11+R12) and the sub-region R13, is obtained as the non-convex edge line after the update of the second processing of this round. The first round of the second processing is completed.

[0219] Since no valid cells are identified after executing steps S401B-S403B in the first round of the second processing, the next round, ie, the second round of the second processing, is executed.

[0220] In the second round of the second processing, the updated non-convex edge line obtained in step S401B is Figure 7Execute step S402B to merge the sub-regions connected by the non-convex edge lines [i.e., the merged sub-regions (R11+R12) and sub-region R13] to obtain the merged sub-region (R11+R12+R13), delete the non-convex edge lines inside the merged sub-region (R11+R12+R13), and form Figure 7 For each sub-region shown in part (c), the concavity and convexity of the shape of the combined sub-region (R11+R12+R13) are detected.

[0221] Reference Figure 7 In part (c) of FIG. 1 , the merged sub-region (R11+R12+R13) is a non-convex figure. Therefore, in step S403B of the second round of the second processing process, the merged sub-region (R11+R12+R13) is not identified as a valid cell. Instead, the non-convex edge line of the edge of the merged sub-region (R11+R12+R13), that is, the boundary line between the merged sub-region (R11+R12+R13) and the sub-region R14, is obtained as the non-convex edge line after the update of the second round of the second processing process. The second round of the second processing process is completed.

[0222] Since no valid cells are identified after executing steps S401B-S403B in the second round of the second processing procedure, the next round, i.e., the third round of the second processing procedure, is executed.

[0223] In the third round of the second processing, the updated non-convex edge line obtained in step S401B is Figure 7 Execute step S402B to merge the subregions connected by the non-convex edge lines [i.e., the merged subregion (R11+R12+R13) and subregion R14] to obtain the merged subregion (R11+R12+R13+R14), delete the non-convex edge lines inside the merged subregion (R11+R12+R13+R14), and form Figure 7 For each sub-region shown in part (d) of FIG. 1 , the concavity and convexity of the shape of the combined sub-region (R11+R12+R13+R14) are detected.

[0224] Reference Figure 7 In part (d) of FIG. 5 , the merged sub-region (R11+R12+R13+R14) is a convex figure, so in step S403B of the second processing process of the third round, the merged sub-region (R11+R12+R13+R14) is identified as a valid cell.

[0225] In this embodiment, after executing three rounds of the second processing process, the merged sub-region (R11+R12+R13+R14) is identified as a valid cell, that is, Figure 7 Each sub-area in the table area shown is identified as a valid cell, so there are no invalid cells in the table area.

[0226] Reference Figure 7 For non-convex sub-regions in the table area, after executing several rounds of the second processing process to merge the sub-regions, there will eventually be no non-convex sub-regions in the table area, so that a new second processing process cannot be executed, or there may not be non-convex sub-regions in the table area at the beginning, so a new round of the second processing process cannot be executed. Therefore, the end condition of all the second processing processes can be set to "no non-convex sub-regions are detected from the table area". That is, if the situation of "no non-convex sub-regions are detected from the table area" occurs, then a new round of the second processing process will not be executed, thereby terminating the execution of all the second processing processes.

[0227] If there are still sub-regions that are not identified as valid cells after all rounds of the second processing process are executed, then these sub-regions that are not identified as valid cells can be identified as invalid cells.

[0228] In this embodiment, after S402B is executed in any round of the second processing, the table line shape element corresponding to the deleted non-convex edge line can be identified as the table content. Figure 7 In part (d), the dotted lines indicate the locations of the non-convex edge lines deleted in the second processing process. These deleted non-convex edge lines can be identified as the table contents in the valid cell (R11+R12+R13+R14).

[0229] By executing steps S401B-S403B, sub-regions that meet the conditions can be screened out according to the characteristics of the shape of the valid cells and the positional relationship between the valid cells and the table area, so that the valid cells can be efficiently identified.

[0230] In this embodiment, when executing step S4, only steps S401A-S403A or only steps S401B-S403B may be executed, or multiple rounds of the first processing process S401A-S403A may be executed first, and then multiple rounds of the second processing process S401B-S403B may be executed for each sub-region that is not identified as a valid cell, thereby helping to improve the ability to identify valid cells.

[0231] In this embodiment, the method for identifying valid cells in a table further includes the following steps:

[0232] S5. Detecting the position of the edge of the sub-region belonging to the valid cell, and in the case where a table line shape element is detected, identifying the detected table line shape element as a table line;

[0233] S6. Detect the position of the border of the sub-area belonging to the invalid cell, and if a table line shape element is detected and the detected table line shape element is not recognized as a table line, recognize the detected table line shape element as table annotation information.

[0234] After executing steps S1 to S4, valid cells and invalid cells in the table area can be identified from the document to be identified.

[0235] For the sub-region identified as a valid cell, step S5 is executed to detect the position of the edge line of the sub-region. If a table line shape element is detected, the detected table line shape element is identified as a table line.

[0236] For the sub-region identified as an invalid cell, step S6 is executed to detect the position of the edge of the sub-region. If a table line shape element is detected, it is determined whether the detected table line shape element is identified as a table line of some valid cells. If the detected table line shape element is identified as a table line, the detected table line shape element is identified as the table annotation information of the invalid cell. The table annotation information is information that annotates the table and serves as a separator between different tables.

[0237] By executing steps S5-S6, it is possible to process the table line shape elements located at the edge positions of the valid cells and invalid cells on the basis of identifying the valid cells and invalid cells, and identify these table line shape elements as table lines or table annotation information, thereby realizing the recognition and classification of the table line shape elements in the document to be identified, thereby improving the readability of the document to be identified.

[0238] In this embodiment, Figure 8 The method for identifying valid cells in a table execution document of a complex form shown in the figure can be performed by executing the first processing process S401A-S403A, firstly identifying the sub-area R21 as one of the valid cells through step S402A, deleting the valid cell R21 from the table area, and then judging the remaining sub-areas (R15+R16+R17+R18+R19+R20), and executing the first processing process S401A-S403A can no longer identify the valid cells therein. However, executing the second processing process S401B-S403B on the remaining sub-areas (R15+R16+R17+R18+R19+R20) can detect that R15, R16, R17, R18, R19 and R20 are valid cells respectively.

[0239] In this embodiment, Fig. 9The method for identifying valid cells in a table in an embedded table execution document shown in the figure can be performed by executing the second processing process S401B-S403B, and the non-convex sub-region R22 is identified in step S401B, and the non-convex edge line is determined to be the boundary between the non-convex sub-region R22 and the sub-regions R23, R24, R25, and R26, and then step S402B is performed to merge the sub-regions R22, R23, R24, R25, and R26 connected by the non-convex edge line to obtain a merged sub-region (R22+R23+R24+R25+R26), and the merged sub-region (R22+R23+R24+R25+R26) is a rectangle (convex figure), so that the merged sub-region (R22+R23+R24+R25+R26) is identified as a valid cell. Based on the same principle, the second processing process S401B-S403B can be performed to Figure 8 The merged sub-region (R70+R28+R29+R30+R31) in the table is identified as a valid cell. Therefore, the table valid cell identification method in this embodiment can accurately identify the valid cells in the embedded table.

[0240] In this embodiment, Fig.10 The method for identifying valid cells of a table in a document with a table having non-aligned lines shown in the figure can be performed by executing the second processing process S401B-S403B, identifying the non-convex sub-region R32 and the non-convex edge line L32 therein through step S401B, merging the sub-region R32 connected by the non-convex edge line through step S402B, that is, merging the sub-region R32 with itself, and the obtained merged sub-region is the sub-region R32 itself, and after deleting the non-convex edge line L32 inside the merged sub-region R32, detecting the convexity of the shape of the merged sub-region R32, and the merged sub-region R32 after deleting the non-convex edge line L32 is a rectangle (convex figure), so that the merged sub-region R32 is identified as a valid cell, and on this basis, the non-convex edge line L32 can be identified as the table content in this valid cell, rather than as a table line.

[0241] comprehensive Figure 8 , Fig. 9 and Fig.10 As shown in the example, the table valid cells in this embodiment can identify valid cells in table areas of various forms, such as complex tables, embedded tables, and tables with non-aligned lines, and has a strong valid cell recognition capability.

[0242] In this embodiment, the valid cell recognition device of the table in the document can be run to execute the valid cell recognition method of the table in the document. Specifically, corresponding to the above method embodiment, as Fig.11 As shown, the effective cell identification device of the table in the document includes:

[0243] A table area recognition module is used to recognize the table area in the document to be recognized;

[0244] An element acquisition module, used for acquiring a table line shape element located in the table area; the table line shape element is a document element in the document to be identified, whose display effect represents a table line;

[0245] A sub-region identification module, used for identifying at least one sub-region divided by each of the table line shape elements in the table region;

[0246] The sub-region screening module is used to screen each of the sub-regions according to their shapes and their positional relationship with the table area, and identify the screened sub-regions as valid cells.

[0247] In an optional implementation, when acquiring the table line shape element located in the table area, the element acquisition module is specifically used to:

[0248] Acquire a plurality of document elements located in the table area from the document to be identified, wherein the document element is at least one of a text document element, a path document element, and a picture document element;

[0249] When the text document element is acquired, content detection is performed on the text document element, and when it is detected that the text document element contains preset characters, the text document element is determined to be a table line shape element;

[0250] When the path document element is acquired, the path document element is parsed for instructions and bounding box is extracted, and when a straight line drawing instruction is parsed but a curve line drawing instruction is not parsed, and the aspect ratio or height-to-width ratio of the extracted bounding box is greater than a first ratio threshold, the path document element is determined to be a table line shape element;

[0251] When the picture-type document element is obtained and grayscaled, pixel detection is performed on the boundary of the picture-type document element. If continuous pixels with non-second pixel values ​​are detected on any boundary, and the ratio of the continuous length to the length of the boundary is greater than the second ratio threshold, the picture-type document element is determined to be a table line shape element.

[0252] In an optional implementation, when acquiring the table line shape element located in the table area, the element acquisition module is specifically used to:

[0253] Acquire a trained table line shape element recognition model; the table line shape element recognition model is obtained by training table line feature samples using an artificial intelligence algorithm;

[0254] Rendering the document to be identified into image data;

[0255] The image data is input into the table line shape element recognition model to perform table line shape element recognition, and a table line shape element recognition result is obtained and output.

[0256] In an optional implementation manner, when the sub-region identification module identifies at least one sub-region divided by each of the table line shape elements from the table region, it is specifically configured to:

[0257] Creating a binary image; the size of the binary image is proportional to the size of the document to be identified;

[0258] Mapping the table area in the document to be identified to the binary image;

[0259] The pixel value of the portion of the binary image mapped by the table line shape element is set as a first pixel value, and the pixel value of the portion not mapped by the table line shape element is set as a second pixel value;

[0260] Solving the connected domain of the binary image to determine at least one connected domain in the binary image; the pixel value of the connected domain is the second pixel value;

[0261] Mapping the binary graph after the connected domain solution back to the document to be identified;

[0262] A document region in the document to be identified mapped by each connected domain is identified as one of the sub-regions.

[0263] In an optional implementation, the sub-region identification module is further used, before solving the connected domain of the binary graph, to:

[0264] A closing operation is performed on the binary image.

[0265] In an optional implementation, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically configured to:

[0266] At least one round of the first processing process is executed in sequence until no valid cells are identified in any round of the first processing process, and the execution of the first processing process is terminated; any round of the first processing process includes the following steps:

[0267] In the case where the first processing process of this round is the first processing process of the first round, a table border is detected from the table area identified in the document to be identified, and conversely, a table border is detected from the table area updated in the previous first processing process;

[0268] If at least one edge of any of the sub-regions overlaps with the table border and the shape of the sub-region is a convex figure, the sub-region is identified as a valid cell;

[0269] The sub-area belonging to the valid cell is deleted from the table area, thereby updating the table area.

[0270] In an optional implementation, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically configured to:

[0271] If no valid cell is identified in any round of the first processing, terminating the execution of the first processing;

[0272] The sub-region that is not identified as a valid cell after executing all of the first processing processes is identified as an invalid cell.

[0273] In an optional implementation, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically configured to:

[0274] At least one round of the second processing process is performed in sequence until no non-convex sub-region is detected from the table region in any round of the second processing process, and the second processing process is terminated; any round of the second processing process includes the following steps:

[0275] In the case where the second processing process in this round is the second processing process in the first round, the convexity of the shape of each sub-region in the table region is detected, and the non-convex edge line is determined from the detected non-convex sub-region, and conversely, the non-convex edge line updated in the previous second processing process is obtained; wherein the non-convex sub-region is a sub-region with a non-convex figure shape, and the non-convex edge line is the edge line of the non-convex part of the non-convex figure;

[0276] Merging the sub-regions connected by the non-convex edge lines to obtain a merged sub-region, deleting the non-convex edge lines inside the merged sub-region, and detecting the concavity and convexity of the shape of the merged sub-region;

[0277] When the shape of the merged sub-region is a convex figure, the merged sub-region is identified as a valid cell, otherwise, the non-convex edge line of the edge of the merged sub-region is obtained as the non-convex edge line after update in the second processing process of this round.

[0278] In an optional implementation, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically configured to:

[0279] The sub-region that is not identified as a valid cell after executing all of the second processing processes is identified as an invalid cell.

[0280] In an optional implementation, when the sub-region screening module screens each sub-region according to its shape and its positional relationship with the table region and identifies the screened sub-region as a valid cell, it is specifically configured to:

[0281] During any round of the second processing,

[0282] After deleting the non-convex edge lines inside the merged sub-region, the table line shape elements corresponding to the deleted non-convex edge lines are identified as table contents.

[0283] In an optional implementation, when the sub-region screening module sequentially performs at least one round of the second processing process, it is specifically used to:

[0284] In case of executing a first process, detecting execution of the first process;

[0285] After the last round of the first processing process is executed, the first round of the second processing process is started;

[0286] Wherein, any round of the first processing process includes the following steps:

[0287] In the case where the first processing process of this round is the first processing process of the first round, a table border is detected from the table area identified in the document to be identified, and conversely, a table border is detected from the table area updated in the previous first processing process;

[0288] If at least one edge of any of the sub-regions overlaps with the table border and the shape of the sub-region is a convex figure, the sub-region is identified as a valid cell;

[0289] The sub-area belonging to the valid cell is deleted from the table area, thereby updating the table area.

[0290] In an optional embodiment, the table valid cell identification device further includes:

[0291] A valid cell detection module, used to detect the position of the edge line of the sub-region belonging to the valid cell;

[0292] The table line recognition module is used to recognize the detected table line shape element as a table line when a table line shape element is detected.

[0293] In an optional embodiment, the table valid cell identification device further includes:

[0294] An invalid cell detection module, used to detect the position of the edge line of the sub-region belonging to the invalid cell;

[0295] The table annotation information recognition module is used to recognize the detected table line shape element as table annotation information when a table line shape element is detected and the detected table line shape element is not recognized as a table line.

[0296] By running the device for identifying valid cells in a table in a document, the same technical effect as the method for identifying valid cells in a table in a document in the embodiment can be achieved.

[0297] In this embodiment, the computer is programmed to execute Figure 1 and storing such a computer program in a Fig.12 The memory 1201 of the computer device shown, or Fig.13 The computer program stored in the memory 1201 or the computer readable storage medium 1301 can be Fig.12 The processor 1202 or Fig.13 The processor 1302 in the processor reads it and obtains the execution Figure 1 The processor executes these instructions and can execute Figure 1 The steps S1-S4 in the document are to execute the method for identifying valid cells in the table in the document.

[0298] because Fig.12 The computer device and Fig.13 The computer-readable storage media shown can enable the processor to execute the method for identifying valid cells in a table in a document, so Fig.12 The computer device and Fig.13 The computer-readable storage media shown can achieve the same technical effect as the method for identifying valid cells in a table in a document in the embodiment.

[0299] It should be noted that, unless otherwise specified, the singular forms of "a" and "the" used in this disclosure are also intended to include plural forms, unless the context clearly indicates other meanings. In addition, unless otherwise defined, all technical and scientific terms used in this embodiment have the same meaning as those generally understood by those skilled in the art. The terms used in the present embodiment specification are only for describing specific embodiments, not for limiting the present invention. The term "and / or" used in this embodiment includes any combination of one or more related listed items.

[0300] It should be understood that, although the term first, second, third etc. may be adopted to describe various elements in the present disclosure, these elements should not be limited to these terms. These terms are only used to distinguish the same type of elements from each other. For example, without departing from the scope of the present disclosure, the first element may also be referred to as the second element, and similarly, the second element may also be referred to as the first element. The use of any and all examples or exemplary language ("for example", "such as" etc.) provided by the present embodiment is only intended to better illustrate embodiments of the present invention, and unless otherwise required, the scope of the present invention will not be limited.

[0301] It should be appreciated that embodiments of the present invention may be implemented or enforced by computer hardware, a combination of hardware and software, or by computer instructions stored in a non-transitory computer-readable memory. The method may be implemented in a computer program using standard programming techniques - including a non-transitory computer-readable storage medium configured with a computer program, wherein the storage medium so configured causes the computer to operate in a specific and predefined manner - according to the methods and drawings described in the specific embodiments. Each program may be implemented in a high-level procedural or object-oriented programming language to communicate with a computer system. However, if desired, the program may be implemented in assembly or machine language. In any case, the language may be a compiled or interpreted language. In addition, the program may be run on a programmed dedicated integrated circuit for this purpose.

[0302] In addition, the operations of the process described in this embodiment may be performed in any suitable order, unless otherwise indicated in this embodiment or otherwise clearly contradicted by the context. The process described in this embodiment (or variations and / or combinations thereof) may be performed under the control of one or more computer systems configured with executable instructions, and may be implemented as a code (e.g., executable instructions, one or more computer programs, or one or more applications) executed on one or more processors in common, by hardware or a combination thereof. A computer program includes a plurality of instructions that may be executed by one or more processors.

[0303] Further, the method can be implemented in any type of computing platform that is operably connected to a suitable computer, including but not limited to a personal computer, a minicomputer, a mainframe, a workstation, a network or distributed computing environment, a separate or integrated computer platform, or in communication with a charged particle tool or other imaging device, etc. Various aspects of the present invention can be implemented in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into a computing platform, such as a hard disk, an optical read and / or write storage medium, a RAM, a ROM, etc., so that it can be read by a programmable computer, and when the storage medium or device is read by the computer, it can be used to configure and operate the computer to perform the process described herein. In addition, the machine-readable code, or part thereof, can be transmitted via a wired or wireless network. When such media includes instructions or programs that implement the above steps in conjunction with a microprocessor or other data processor, the invention of this embodiment includes these and other different types of non-transitory computer-readable storage media. When programmed according to the methods and techniques of the present invention, the present invention also includes the computer itself.

[0304] The above are only preferred embodiments of the present invention. The present invention is not limited to the above embodiments. As long as the technical effects of the present invention are achieved by the same means, any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention. Within the scope of protection of the present invention, its technical solutions and / or implementation methods may have various modifications and changes.

Claims

1. A method for identifying valid cells in a table in a document. It is characterized in that The table valid cell identification method comprises: Identify the table area in the document to be identified; Acquire a plurality of table line shape elements located in the table area; In the table area, identifying at least one sub-area divided by each of the table line shape elements; The sub-regions are screened according to their shapes and their positional relationship with the table region, and the screened sub-regions are identified as valid cells.

2. The method for identifying valid cells in a table according to claim 1, It is characterized in that The acquiring of a plurality of table line shape elements located in the table area comprises: Acquire a plurality of document elements located in the table area from the document to be identified, wherein the document element is at least one of a text document element, a path document element, and a picture document element; When the text document element is acquired, content detection is performed on the text document element, and when it is detected that the text document element contains preset characters, the text document element is determined to be a table line shape element; When the path document element is acquired, the path document element is parsed for instructions and bounding box is extracted, and when a straight line drawing instruction is parsed but a curve line drawing instruction is not parsed, and the aspect ratio or height-to-width ratio of the extracted bounding box is greater than a first ratio threshold, the path document element is determined to be a table line shape element; When the picture-type document element is obtained and grayscaled, pixel detection is performed on the boundary of the picture-type document element. If continuous pixels with non-second pixel values ​​are detected on any boundary, and the ratio of the continuous length to the length of the boundary is greater than the second ratio threshold, the picture-type document element is determined to be a table line shape element.

3. The method for identifying valid cells in a table according to claim 1, It is characterized in that The acquiring of a plurality of table line shape elements located in the table area comprises: Acquire a trained table line shape element recognition model; the table line shape element recognition model is obtained by training table line feature samples using an artificial intelligence algorithm; Rendering the document to be identified into image data; The image data is input into the table line shape element recognition model to perform table line shape element recognition to obtain a plurality of table line shape elements.

4. The method for identifying valid cells in a table according to claim 1, It is characterized in that In the table area, identifying at least one sub-area divided by each of the table line shape elements, comprises: Creating a binary image; the size of the binary image is proportional to the size of the document to be identified; Mapping the table area in the document to be identified to the binary image; The pixel value of the portion of the binary image mapped by the table line shape element is set as a first pixel value, and the pixel value of the portion not mapped by the table line shape element is set as a second pixel value; Solving the connected domain of the binary image to determine at least one connected domain in the binary image; the pixel value of the connected domain is the second pixel value; A document region in the document to be identified mapped by each connected domain is identified as one of the sub-regions.

5. The method for identifying valid cells in a table according to claim 4, It is characterized in that Before solving the connected domain of the binary graph, identifying at least one sub-region divided by each of the table line shape elements in the table region further includes: A closing operation is performed on the binary image.

6. The method for identifying valid cells in a table according to claim 1, It is characterized in that The step of screening each of the sub-regions according to the shape of each of the sub-regions and the positional relationship between each of the sub-regions and the table region, and identifying the screened sub-regions as valid cells, includes: At least one round of the first processing process is executed in sequence until no valid cells are identified in any round of the first processing process, and the execution of the first processing process is terminated; any round of the first processing process includes the following steps: In the case where the first processing process in this round is the first processing process in the first round, a table border is detected from the table area identified in the document to be identified; in the case where the first processing process in this round is not the first processing process in the first round, a table border is detected from the table area updated by the previous first processing process; In the case where at least one edge line of any of the sub-regions overlaps with the detected table border, and the shape of the sub-region is a convex figure, identifying the sub-region as a valid cell; The sub-regions belonging to valid cells are deleted from the table region to obtain the table region updated by the first processing process in this round.

7. The method for identifying valid cells in a table according to claim 6, It is characterized in that The table valid cell identification method also includes: If no valid cell is identified in any round of the first processing, terminating the execution of the first processing; The sub-region that is not identified as a valid cell after executing all of the first processing processes is identified as an invalid cell.

8. The method for identifying valid cells in a table according to any one of claims 1 to 7, It is characterized in that The step of screening each of the sub-regions according to the shape of each of the sub-regions and the positional relationship between each of the sub-regions and the table region, and identifying the screened sub-regions as valid cells, includes: At least one round of the second processing process is performed in sequence until no non-convex sub-region is detected from the table region in any round of the second processing process, and the second processing process is terminated; any round of the second processing process includes the following steps: In the case where the second processing process in this round is the second processing process in the first round, the convexity of the shape of each sub-region in the table region is detected, and the non-convex edge line is obtained from the detected non-convex sub-region; in the case where the second processing process in this round is not the second processing process in the first round, the non-convex edge line updated in the previous second processing process is obtained; wherein the non-convex sub-region is a sub-region with a non-convex figure shape, and the non-convex edge line is the edge line of the non-convex part of the non-convex figure; Merging the sub-regions connected by the acquired non-convex edge lines to obtain a merged sub-region, deleting the non-convex edge lines inside the merged sub-region, and detecting the concavity and convexity of the shape of the merged sub-region; When the shape of the merged sub-region is a convex figure, the merged sub-region is identified as a valid cell; when the shape of the merged sub-region is not a convex figure, the non-convex edge line of the edge of the merged sub-region is obtained as the non-convex edge line after update in this round of the second processing process.

9. The method for identifying valid cells in a table according to claim 8, It is characterized in that The table valid cell identification method also includes: The sub-region that is not identified as a valid cell after executing all of the second processing processes is identified as an invalid cell.

10. The method for identifying valid cells in a table according to claim 8, It is characterized in that The table valid cell identification method also includes: During any round of the second processing, After deleting the non-convex edge lines inside the merged sub-region, the table line shape elements corresponding to the deleted non-convex edge lines are identified as table contents.

11. The method for identifying valid cells in a table according to any one of claims 8 to 10, It is characterized in that The sequentially executing at least one round of the second processing process includes: In case of executing a first process, detecting execution of the first process; After the last round of the first processing process is executed, the first round of the second processing process is started; Wherein, any round of the first processing process includes the following steps: In the case where the first processing process in this round is the first processing process in the first round, a table border is detected from the table area identified in the document to be identified; in the case where the first processing process in this round is not the first processing process in the first round, a table border is detected from the table area updated by the previous first processing process; In the case where at least one edge line of any of the sub-regions overlaps with the detected table border, and the shape of the sub-region is a convex figure, identifying the sub-region as a valid cell; The sub-regions belonging to valid cells are deleted from the table region to obtain the table region updated by the first processing process in this round.

12. The method for identifying valid cells in a table according to claim 9, It is characterized in that The table valid cell identification method further includes: Detecting the position of the edge of the sub-region belonging to the valid cell; In the case where a table line shape element is detected, the detected table line shape element is identified as a table line.

13. The method for identifying valid cells in a table according to claim 12, It is characterized in that The table valid cell identification method further includes: Detecting the position of the edge of the sub-region belonging to the invalid cell; When a table line shape element is detected and the detected table line shape element is not recognized as a table line, the detected table line shape element is recognized as table annotation information.

14. A device for identifying valid cells in a table in a document, It is characterized in that The table valid cell identification device comprises: a table area identification module, which is used to identify the table area in the document to be identified; An element acquisition module, used for acquiring a plurality of table line shape elements located in the table area; A sub-region identification module, used for identifying at least one sub-region divided by each of the table line shape elements in the table region; The sub-region screening module is used to screen each of the sub-regions according to their shapes and their positional relationship with the table area, and identify the screened sub-regions as valid cells.

Citation Information

Patent Citations

  • System and method for extracting tables for PDF document

    CN110516208A

  • Picture table recognition method and device, electronic equipment and storage medium

    CN111860502A

  • Table extraction and identification method and system based on deep learning

    CN115661848A

  • Bulk acoustic resonator

    KR102642901B1