Document processing method and device, electronic equipment, storage medium and system

By performing shape analysis and splicing of tables on adjacent document pages, the problem of splitting cross-page tables is solved, achieving a complete restoration of the table structure in the document and efficient extraction of information, improving readability.

CN118551731APending Publication Date: 2024-08-27THE FOURTH PARADIGM BEIJING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310184557.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-24
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Existing document parsing tools are unable to obtain the structural information of the document in the absence of complete document source code, resulting in the splitting of cross-page tables, poor readability, and the inability to restore the original structure of the table.

Method used

By performing shape analysis on tables in adjacent document pages, matching column width ratios and column numbers, and performing table splicing to restore the relevance of cross-page tables and extract the complete table structure.

Benefits of technology

In the absence of document structure information, the association between cross-page tables was successfully restored, improving the readability of the information and ensuring the integrity of the table structure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118551731A
    Figure CN118551731A
Patent Text Reader

Abstract

The invention provides a document processing method and device, electronic equipment, a storage medium and a system. The document processing method comprises the steps of performing content detection on a to-be-processed target document; when it is detected that any two adjacent document pages contain tables, the shapes of the two tables located in the adjacent document pages respectively are analyzed, an analysis result is obtained, and the two tables comprise the previous table and the later table; and under the condition that the analysis result shows that the shape of any ith line of the previous table is matched with the shape of any jth line of the later table, splicing the two tables so as to obtain a spliced table from the target document. According to the method and the device, the problem of poor readability caused by segmentation of the cross-page tables is solved, the association between the cross-page tables can be restored, the information conveyed by the table structure is obtained, and the readability of the information is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a document processing method and device, electronic equipment, storage medium and system. Background Art

[0002] With the development of computer technology, the ways of storing and transmitting information are becoming more and more diverse. In order to facilitate the storage and processing of information, it may be necessary to further process the information in the generated documents, such as detection, recognition and extraction.

[0003] The document source code of some documents may contain all the structural information and text information of the article, and the correlation between each structural module. By interpreting the document source code, it is possible to obtain plain text information with high readability. In this case, existing document parsing tools can process the document by parsing the document source code.

[0004] In the absence of complete document source code, such document parsing tools cannot obtain the structural information of the document. When the document includes multiple pages, it is impossible to obtain information across pages. For example, if there is a table across pages, the complete table cannot be obtained, and the table is segmented, resulting in poor readability. Summary of the invention

[0005] Exemplary embodiments of the present disclosure may solve at least the above problems.

[0006] According to a first aspect of the present disclosure, a document processing method is provided, the method comprising: performing content detection on a target document to be processed, wherein the target document comprises a plurality of document pages; when it is detected that any two adjacent document pages both contain tables, analyzing shapes of two tables respectively located in the adjacent document pages to obtain an analysis result, the two tables comprising a front table and a rear table; when the analysis result indicates that the shape of any i-th row of the front table matches that of any j-th row of the rear table, splicing the two tables to obtain a spliced ​​table from the target document, wherein the i-th row is any one of m rows having the same shape as the last row of the front table, the j-th row is any one of n rows having the same shape as the first row of the rear table, and m and n are integers greater than 0.

[0007] Optionally, the shape of any i-th row of the previous table matches that of any j-th row of the subsequent table, including: the column width ratio of each column in the i-th row matches the column width ratio of each column in the j-th row, wherein the column width ratio is the ratio of the width of the column to the width of the row in which the column is located; and / or the number of columns contained in the i-th row is equal to the number of columns contained in the j-th row.

[0008] Optionally, the column width proportions matching means that a statistical value of a difference between column width proportions of each column in the two tables is less than a preset value.

[0009] Optionally, the method further comprises: performing text detection on the document content between the two tables; and executing the step of analyzing the shapes of the two tables when no text exists between the two tables.

[0010] Optionally, the analyzing the shapes of the two tables respectively located in the adjacent document pages to obtain the analysis results includes: performing cell detection on the two tables in the adjacent document pages to determine the row information and column information of each cell in each table; based on the row information and column information of each cell, analyzing the shapes of the two tables to obtain the analysis results, wherein the row information represents the row occupied by the cell, and the column information represents the column occupied by the cell.

[0011] Optionally, the splicing of the two tables includes: determining the correspondence between the columns of the previous table and the columns of the subsequent table based on the column information of the cells in the i-th row and the j-th row; updating the column information of the cells in the previous table and the subsequent table based on the correspondence; and splicing the two tables based on the updated column information.

[0012] Optionally, updating the column information of the cells in the previous table and the subsequent table based on the corresponding relationship includes: when the corresponding relationship indicates that a single column corresponds to multiple columns, updating the column information of the cells in the table where the single column is located according to the number of columns of the multiple columns.

[0013] Optionally, the column information includes the column number of the column occupied by the cell, wherein updating the column information of the cell of the table where the single column is located according to the column number of the multiple columns includes: determining all column numbers from the starting column number to the ending column number as the updated column numbers of the cells in the single column, wherein the starting column number is the column number of the single column, and the ending column number is the sum of the column number of the single column and the column number of the multiple columns minus one; for the cells in each column after the single column, determining the updated column number of the cell by the column number of the cell and the sum of the column number of the multiple columns minus one.

[0014] Optionally, the table includes a header and a body, the header is the first row of the table, and the body includes the second to last rows of the table, wherein splicing the two tables includes: performing semantic connectivity detection on the contents of each cell in the last row of the previous table and the corresponding cells in the first row of the body of the subsequent table to obtain a detection result; when the detection result indicates that there is semantic connectivity between the contents of the corresponding cells, merging the last row of the previous table and the first row of the body of the subsequent table.

[0015] Optionally, the method further includes: obtaining text blocks in the target document, wherein each text block includes one or more characters; removing invalid text blocks from the text blocks, wherein the invalid text blocks include at least one of text blocks located in pictures, text blocks belonging to headers or footers, and text blocks containing watermarks.

[0016] Optionally, the invalid text block includes a text block containing a watermark, wherein the text block containing the watermark is determined in the following manner: determining the inclination angle, text block length and text block width of each text block; clustering the text blocks according to the inclination angle, text block length and text block width, and dividing the text blocks into at least two candidate categories; and determining the text block containing the watermark from the at least two candidate categories based on the shape data of the text blocks.

[0017] Optionally, the method further includes: obtaining titles in each document page of the target document; classifying the titles according to a plurality of preset title categories; and determining the hierarchical relationship between the titles according to the title category of each title.

[0018] Optionally, determining the hierarchical relationship between titles based on the title category of each title includes: performing the following operations on each title according to the arrangement order of each title in the target document: comparing the title categories of the current title with those of each previous title in reverse order of the arrangement order of each previous title before the current title; when the current title and the previous title belong to the same title category, determining that the current title and the previous title are titles of the same level; when the current title and all previous titles do not belong to the same title category, determining that the current title is a child of the previous title of the current title.

[0019] Optionally, the i-th row is the last row of the previous table, and the j-th row is the first row of the subsequent table.

[0020] According to a second aspect of the present disclosure, a document processing device is provided, the document processing device comprising: a detection unit, configured to perform content detection on a target document to be processed, wherein the target document comprises a plurality of document pages; an analysis unit, configured to analyze shapes of two tables respectively located in the adjacent document pages to obtain an analysis result when it is detected that any two adjacent document pages both contain tables, the two tables comprising a front table and a rear table; a splicing unit, configured to splice the two tables to obtain a spliced ​​table from the target document when the analysis result indicates that the shape of any i-th row of the front table matches that of any j-th row of the rear table, wherein the i-th row is any one of m rows having the same shape as the last row of the front table, the j-th row is any one of n rows having the same shape as the first row of the rear table, and m and n are integers greater than 0.

[0021] According to a third aspect of the present disclosure, an information extractor is provided, comprising: an information extraction device, the information extraction device being used to extract information from a document; and a document processing device according to an exemplary embodiment of the present disclosure, the document processing device being used to process a document extracted by the information extraction device.

[0022] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor, wherein the processor executable instructions, when executed by the processor, cause the processor to execute the document processing method according to the exemplary embodiment of the present disclosure.

[0023] According to a fifth aspect of the present disclosure, a computer-readable storage medium storing instructions is provided, which, when executed by at least one computing device, prompts the at least one computing device to execute the document processing method according to the exemplary embodiments of the present disclosure.

[0024] According to a sixth aspect of the present disclosure, a system is provided comprising at least one computing device and at least one storage device storing instructions, wherein when the instructions are executed by the at least one computing device, the at least one computing device is prompted to execute the document processing method according to the exemplary embodiment of the present disclosure.

[0025] According to the exemplary embodiments of the present disclosure, the document processing method and apparatus, electronic device, storage medium and system can perform shape analysis on two tables located on adjacent document pages, and when the column width ratios of adjacent rows of the two tables match, the tables can be spliced ​​together, so that the spliced ​​complete table can be extracted. In the absence of document structure information, the association between tables across pages can be restored, the information conveyed by the table structure can be obtained, and the readability of the information can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] These and / or other aspects and advantages of the present disclosure will become clear and more easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0027] Figure 1 is a flowchart illustrating a document processing method according to an exemplary embodiment of the present disclosure.

[0028] Figure 2 is a flowchart illustrating a step of analyzing a table shape in a document processing method according to an exemplary embodiment of the present disclosure.

[0029] Figure 3 is a structural diagram illustrating a detected table in a document processing method according to an exemplary embodiment of the present disclosure.

[0030] Figure 4A and Figure 4B is a schematic diagram illustrating an example of two adjacent tables in a document processing method according to an exemplary embodiment of the present disclosure.

[0031] Figure 5 Detailed description is a flowchart illustrating steps of concatenating tables in a document processing method according to an exemplary embodiment of the present disclosure.

[0032] Figure 6 is a diagram showing an exemplary embodiment according to the present disclosure Figure 4A and Figure 4B Schematic diagram of the table after the two tables are spliced ​​together.

[0033] Figure 7 is a flowchart illustrating steps of updating column information in a document processing method according to an exemplary embodiment of the present disclosure.

[0034] Figure 8 Detailed description is a flowchart illustrating steps of merging cells across pages in a document processing method according to an exemplary embodiment of the present disclosure.

[0035] Fig. 9 is a schematic diagram showing a result of content detection on a target document in a document processing method according to an exemplary embodiment of the present disclosure.

[0036] Fig.10 is a flowchart illustrating steps of processing a text block in a document processing method according to an exemplary embodiment of the present disclosure.

[0037] Fig.11 Detailed description is a flowchart illustrating steps of determining a watermark text block in a document processing method according to an exemplary embodiment of the present disclosure.

[0038] Fig.12Detailed description is a flowchart illustrating steps of determining a hierarchical relationship of titles in a document processing method according to an exemplary embodiment of the present disclosure.

[0039] Fig.13 is a block diagram illustrating a document processing apparatus according to an exemplary embodiment of the present disclosure.

[0040] Fig.14 is a block diagram illustrating an information extractor according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0041] The following description with reference to the accompanying drawings is provided to assist in a comprehensive understanding of the embodiments of the present disclosure as defined by the claims and their equivalents. Various specific details are included to assist in understanding, but these details are considered to be exemplary only. Therefore, one of ordinary skill in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. In addition, descriptions of well-known functions and structures are omitted for clarity and brevity.

[0042] It should be noted that the phrase "at least one of the items" in the present disclosure includes three types of parallel situations: "any one of the items", "a combination of any number of the items", and "all of the items". For example, "including at least one of A and B" includes the following three parallel situations: (1) including A; (2) including B; (3) including A and B. Another example is "executing at least one of step 1 and step 2" which means the following three parallel situations: (1) executing step 1; (2) executing step 2; (3) executing step 1 and step 2.

[0043] The following describes a document processing method, a document processing device, an information extractor, an electronic device, a computer-readable storage medium storing instructions, and a system including at least one computing device and at least one storage device storing instructions according to exemplary embodiments of the present disclosure with reference to the accompanying drawings.

[0044] Among the relevant document processing technologies, the processing of structured information and data management are relatively mature, but a large part of the information still exists in an unstructured form, and the information cannot be quickly obtained, resulting in a large amount of data waste. Most of the automated management of document data also remains at the level of editable documents with complete file source codes, such as word documents, editable PDF documents, etc., while for non-editable documents or documents with incomplete file source codes, such as scanned documents, photographed documents, etc., the file source codes of this type of documents do not contain any valid text information. The image text extraction technology and layout-related technologies of existing document parsing tools can only obtain the text in a single-page document and independent article elements. Information such as table structure, document chapter hierarchy structure, reading order, etc. cannot be restored, resulting in serious information loss, reading difficulties, data labeling difficulties and other subsequent problems.

[0045] For example, because existing document processing technologies cannot obtain the structural information of document content, the following problems may occur in the process of processing cross-page tables in documents: First, the overall shape and size of tables on two adjacent pages of scanned or photographed files may have large deviations, which makes subsequent processing of the table difficult; second, when a single table spans multiple pages, if there are complex merged cells in the table, it is difficult to determine the correspondence of the columns of tables on different pages; third, when cells span across pages, the continuity of the content between tables on different pages is destroyed; fourth, there are repeated table headers after spanning pages, which is not easy to read. Due to the above problems, it may be difficult to obtain a complete table from a document, and existing solutions can only handle the cross-page merged layout of simple tables in printed documents, but cannot truly restore the original structure of the table.

[0046] In addition, the above problem exists not only in cross-page tables in scanned or photographed documents, but also in the situation where the structural relationship between tables is lost in some editable documents.

[0047] In addition, for non-editable documents such as scanned copies or photographed images, although the image processing technology in the field of computer vision can be used to extract document elements such as text information, titles, tables, etc. in the image, for cross-page information, the elements in different pages are completely independent, cannot be connected, and have no hierarchical relationship. The information across pages is completely unrelated. In addition to the problem of the above-mentioned cross-page tables being segmented, there will also be the problem of losing the chapter hierarchy throughout the article, which will also lead to poor readability and loss of important information originally conveyed by the document structure.

[0048] In view of the above, in a first aspect, an exemplary embodiment of the present disclosure proposes a document processing method to solve at least one of the problems in the related art. The document processing method can be executed by a computing device with computing and analysis functions, and the computing device can be a terminal device or a server, wherein the terminal device can be a tablet computer, a laptop computer, a digital assistant, a wearable device, etc.; the server can be an independent server, a server cluster, a cloud computing platform or a virtualization center.

[0049] Figure 1 is a flowchart illustrating a document processing method according to an exemplary embodiment of the present disclosure. Figure 1 As shown, the document processing method may include the following steps:

[0050] In step S110, content detection may be performed on the target document for extracting information.

[0051] Here, the target document may include multiple document pages. As an example, the target document may be electronic information stored in a digital form, which may include but not limited to documents, letters, reports, drawings and other file types, and the format of the target document may be arbitrary, for example, it may be but not limited to text document formats such as doc, docx, txt, portable document formats such as pdf, table document formats such as xls, picture formats such as jpg, png, hypertext markup language such as html, etc. The present disclosure does not impose any special restrictions on the format, content, and type of the target document.

[0052] It should be noted that the document processing method according to the present disclosure is not only applicable to the processing of non-editable documents such as scanned copies or photographed pictures, but also applicable to the processing of editable documents that have lost the structural relationship between tables.

[0053] In this step, the target document may be subjected to content detection, for example, each document page may be subjected to table detection to determine whether there is a cross-page table in the document. Here, the table detection may be performed based on information extracted from the target document, and the process of extracting information from the target document will be described in detail below.

[0054] Here, a cross-page table may refer to a complete table that is typeset on at least two document pages. For example, if the table has a large number of rows and cannot be fully displayed in the current document page, part of the table will be displayed in the next document page. In some cases, a cross-page table may be an extra-long table that spans more than two pages.

[0055] In addition, the form of the table described in the exemplary embodiments of the present disclosure may be arbitrary. For example, the table in different document pages may have repeated headers or may not have repeated headers. In addition, the merging of cells in tables in different document pages may be different, for example, the number of columns merged by the merged cells in each table is different. In addition, there may be cells that span pages, for example, the content of a cell is only partially displayed in the current page, while the other part is displayed in the next page.

[0056] In step S120, when it is detected that any two adjacent document pages both contain tables, shapes of the two tables respectively located in the adjacent document pages may be analyzed to obtain an analysis result.

[0057] In this step, the shapes of the tables on two adjacent document pages may be analyzed to determine whether the two tables need to be spliced ​​in the subsequent step. Here, the two tables may include a front table and a back table.

[0058] Here, the shape of the table may include but is not limited to the number of columns in any row of the table, the width of each column, the proportion of the column width in the entire row, and the like.

[0059] As an example, Figure 2 As shown, the shapes of the two tables can be analyzed in the following way to obtain the analysis results:

[0060] In step S210, cell detection may be performed on two tables in adjacent document pages to determine row information and column information of each cell in each table.

[0061] Here, the row information of the cell represents the row occupied by the cell, and the column information of the cell represents the column occupied by the cell.

[0062] In this step, an existing table detection model algorithm such as that in the PaddleOCR suite can be used to obtain the table structure on each document page to represent the table in the form of coordinates.

[0063] Specifically, in the table detection model algorithm, the rectangular area completely surrounded by horizontal and vertical lines can be obtained according to the intersection of the lines to confirm the location information of each cell. The text in the rectangular area can be the content of the table (for example, Figure 3 (the content enclosed by the dotted line).

[0064] In the case of determining the horizontal and vertical lines and the intersections between the lines, the position of each cell is saved based on the position information of the four vertices of the cell, for example, Figure 3The position coordinates of the four vertices of the cell X1 can be [(x1, y1), (x2, y1), (x2, y2), (x1, y2)]. When the position coordinates are determined, the row information and column information of the cell can be confirmed. For example, the column of the cell can be determined according to the values ​​of x1 and x2, and the row of the cell can be determined according to the values ​​of y1 and y2.

[0065] Figure 3 An example structure of a table according to an exemplary embodiment of the present disclosure is shown. Figure 3 As shown, the table may include one or more rows (e.g., row 1, row 2, and row 3) and one or more columns (e.g., column 1, column 2, column 3, and column 4), each row and each column may include one or more cells, a cell may include a single cell and a merged cell, and a merged cell may be a cell occupying multiple rows and / or multiple columns. Here, rows and columns are divided according to the minimum cell to ensure that each cell occupies at least one row and at least one column. For example, in Figure 3 There are four columns and three rows in total. Cell X1 can occupy the 1st row and the 1st and 2nd columns, and cell X2 can occupy the 1st row and the 3rd column.

[0066] As an example, when a table includes merged cells, for the merged cells, the merge information of the merged cells also needs to be saved.

[0067] For example, at Figure 3 The cell X1 at the upper left corner of the table may be a merged cell, which may be obtained by horizontal merging. Specifically, it may be considered that the merged cell X1 is obtained by merging two horizontally adjacent single cells (i.e., the cell in the first column and the first row and the cell in the second column and the first row). For another example, the cell X3 at the lower right corner of the table may be a merged cell, which may be obtained by horizontal merging and vertical merging. Specifically, it may be considered that the merged cell X3 is obtained by merging four horizontally and vertically adjacent single cells (i.e., the cell in the second row of the third column, the cell in the third row of the third column, the cell in the second row of the fourth column, and the cell in the third row of the fourth column).

[0068] In addition to the position coordinates of the four vertices of the cell, the merging information of the merged cells also needs to be determined. The merging of cells can be described using the representation of {[row1, row2), [col1, col2)} to describe the coverage of each cell. Here, the brackets [row1, row2) indicate that the cell starts from row1 (occupies row1) and ends at row2 (does not occupy row2), and the brackets [col1, col2) indicate that the cell starts from column col1 (occupies column col1) and ends at column col2 (does not occupy column col2).

[0069] Specifically, in the case of column merging, the horizontal coordinates of each vertex of all cells (i.e., the above-mentioned x position) can be normalized and calculated to confirm the dividing lines of the complete columns of the entire table, and the situation of each cell covering the dividing line of the column can be checked to determine the information of the merged column of the cell, for example, Figure 3 The four vertices of cell X1 cover a column dividing line L1 in the horizontal coordinate (i.e., the direction of the row), that is, its merge information can be expressed as [(0,1), (0,2)], where (0,1) means that the row occupied by the cell is the 1st row, and (0,2) means that the columns occupied by the cell are the 1st and 2nd columns. Similarly, in the case of row merging, the ordinates of each vertex of all cells (i.e., the above-mentioned y position) can be normalized and calculated to confirm the dividing line of the complete row of the entire table, and to check whether each cell covers the dividing line of the row, so as to determine the information of the merged row of the cell.

[0070] It should be noted that the representation of rows, columns and cells in a table is not limited to the above examples, as long as the structure of the table can be represented. For example, the merge information of cells can also be represented as: [(row1, row2, col1, col2)].

[0071] Return to reference Figure 2 In step S220, the shapes of the two tables can be analyzed based on the row information and column information of each cell to obtain an analysis result.

[0072] Here, analyzing the shapes of the two tables may include analyzing whether the shapes of any i-th row of the preceding table and any j-th row of the succeeding table match, where the i-th row may be any one of m rows having the same shape as the last row (last row) of the preceding table, and the j-th row may be any one of n rows having the same shape as the first row (first row) of the succeeding table, where m and n are integers greater than 0. For example, the i-th row may be the last row of the preceding table, and the j-th row may be the first row of the succeeding table.

[0073] As an example, shape matching of any i-th row in the previous table with any j-th row in the subsequent table may include: the column width ratio of each column in the i-th row matches the column width ratio of each column in the j-th row; and / or, the number of columns contained in the i-th row is equal to the number of columns contained in the j-th row.

[0074] Here, the column width ratio may be a ratio of the width of a column to the width of a row where the column is located.

[0075] For a table that spans multiple pages, although the tables on different pages originally belong to the same complete table, due to problems such as scanning, shooting, or separate editing of document pages, the tables on different pages have the same number of columns, but the widths of the columns may be different. In this regard, according to an exemplary embodiment of the present disclosure, it is possible to determine whether two tables belong to the same table by using the column width ratio method proposed in the above two aspects.

[0076] Specifically, if tables on different pages originally belong to the same table, although the size of the table may change due to scanning, photography or individual editing of document pages, the width of each column in the table should remain unchanged as a percentage of the entire row.

[0077] As an example, matching column width ratios may mean that a statistical value of a difference between column width ratios of each column in two tables is less than a preset value.

[0078] For example, when the number of columns in the i-th row of the previous table and the j-th row of the subsequent table is the same, the statistical value r of the difference between the column width proportions can be determined by the following expression:

[0079]

[0080] Among them, W1 is the width of the previous table, which can be considered as the width of the i-th row; W2 is the width of the following table, which can be considered as the width of the j-th row; w1 p is the width of the pth cell in the i-th row of the previous table; w2 p is the width of the pth cell in the jth row of the following table; P is the total number of cells in the ith row (or the jth row), and p is an integer greater than 0 and less than or equal to P.

[0081] The statistical value r can represent the difference percentage of the column width ratio of the corresponding columns of the two tables. When the above statistical value r is less than a preset value (for example, 0.05), it can be determined that the shapes of the two tables match, and the subsequent splicing operation can be continued; otherwise, it can be determined that the shapes of the two tables do not match, and there is no need to splice. Here, the preset value can be adjusted according to actual needs. In this way, according to an exemplary embodiment of the present disclosure, it is possible to determine whether two tables belong to the same table by comparing the column width ratios, so that even if the tables on different pages have the same number of columns but the widths of the columns may be different, it is possible to accurately identify whether the two tables belong to the same complete table, providing a more accurate judgment for table splicing.

[0082] In the above expressions, the width of each row, the width of each cell, and the number of cells can be determined based on the row information and column information of each cell in the table.

[0083] Specifically, the row structure information of the i-th row in the previous table and the j-th row in the subsequent table can be determined based on the row information and column information of each cell. Here, the row structure information may include but is not limited to the position information of each cell in the row and the merge information of the cells, and the position information of the cells may include the horizontal coordinate information of the left and right boundaries of the cells and the leftmost column occupied by each cell.

[0084] As an example, the position information of a cell can be expressed as: [the leftmost column occupied by the cell, [the horizontal coordinate position of the left border of the cell, the horizontal coordinate position of the right border of the cell], and the merge information of a cell can be expressed as: [(row1, row2, col1, col2)] or {[row1, row2), [col1, col2)}, where the cell starts from row1 (occupies row1) and ends at row2 (does not occupy row2), and starts from column col1 (occupies column col1) and ends at column col2 (does not occupy col2). Here, the difference between the horizontal coordinate position of the right border and the horizontal coordinate position of the left border of the cell is the width of the column, and the sum of the widths of the columns is the width of the row.

[0085] Figure 4A and Figure 4B shows an example of two adjacent tables. Assume that the i-th row is the last row of the previous table and the j-th row is the first row of the next table. Figure 4A Taking the previous table shown as an example, Figure 4A The row structure information of the last row of the table may include the position information of each cell in the last row and the merge information of the cells in the last row, where, assuming that the columns in the table are numbered starting from 0 according to integers greater than 0, that is, the column number of the first column of the table is 0, the column number of the second column of the table is 1, and so on, the position information of the five cells in the last row are [0, [49.0, 134.0]], [1, [134.0, 327.0]], [3, [327.0, 447.0]], [4, [447.0, 803.0]] and [5, [803.0, 1565.0]], and the merge information of the cells in the last row is [(6, 7, 1, 3)], that is, (6, 7) indicates that the row occupied by the merged cell is the 7th row, and (1, 3) indicates that the columns occupied by the merged cell are the 2nd and 3rd columns.

[0086] Similarly, Figure 4AThe row structure information of the first row (first row) of the previous table may include the position information of each cell in the first row and the merge information of the cells in the first row, wherein the position information of the five cells in the first row are [0, [49.0, 134.0]], [1, [134.0, 327.0]], [3, [327.0, 447.0]], [4, [447.0, 803.0]] and [5, [803.0, 1565.0]], respectively, and the merge information of the cells in the first row is [(0, 1, 1, 3)], that is, (0, 1) indicates that the row occupied by the merged cell is the first row, and (1, 3) indicates that the columns occupied by the merged cell are the second and third columns. Figure 4A In a similar way, we can also determine Figure 4B The row structure information of the first and last rows in the will not be repeated here.

[0087] When two tables enter the current merge judgment, the table information of the i-th row and the j-th row of the two tables can be obtained respectively, and then the shapes of the tables are analyzed, and the statistical value of the difference between the column width proportions is calculated.

[0088] Although the above expression gives an example of calculating the statistical value r of the difference between column width proportions, it is not limited to this, and the statistical value can also be determined by other statistical methods. For example, the mode, median, variance, etc. of the difference between column width proportions can be calculated, and the corresponding preset value mentioned above can be determined according to the form of the statistical value.

[0089] According to an exemplary embodiment of the present disclosure, whether the two tables need to be spliced ​​can be determined by analyzing whether the shapes of the two tables match. In this way, incorrect processing of the tables can be avoided, and two irrelevant tables can be spliced ​​together to improve the accuracy of table splicing.

[0090] It is described above that whether the shapes of two tables match is analyzed to determine whether the two tables need to be spliced. In addition, as an example, whether there is no text between the two tables can also be analyzed to determine whether the two tables need to be spliced.

[0091] Specifically, before performing table shape analysis, text detection may be performed on the document content between the two tables; when no text exists between the two tables, the step of analyzing the shapes of the two tables is performed.

[0092] As an example, for a document including multiple document pages, the table of the current page can be obtained one by one according to the arrangement order of the document pages. If there is no table on the current page, the judgment of the next page is directly entered. If there is a table on the current page, it is judged whether there are words before and after the table on the current page.

[0093] If there is no text after the table on the current page, the table may be a cross-page table and the table can be put into a backward merge state; if there is other text after the table on the current page, it can be considered that the table has ended on the current page and the table can be saved as an independent table.

[0094] If there is no text before the table on the current page, the table may be a cross-page table. Determine whether there is a table on the previous page to be merged backwards. If so, perform the steps of analyzing the shapes of the two tables. If not, save it as an independent table.

[0095] In addition, as an example, the above step of performing text detection on the document content between two tables may be performed after the step of eliminating invalid text, which will be described in detail below.

[0096] As described above, whether the tables should be spliced ​​can be determined from two aspects: whether the table shapes match and whether there is text between the tables. This can ensure that when processing tables in adjacent pages, the cross-page tables that need to be spliced ​​are accurately found, and non-cross-page tables will not be misoperated, further improving the accuracy of table splicing.

[0097] return Figure 1 In step S130, when the analysis result indicates that the shapes of any i-th row of the previous table match those of any j-th row of the subsequent table, the two tables may be concatenated to obtain a concatenated table from the target document.

[0098] As an example, Figure 5 As shown, joining two tables may include the following steps:

[0099] In step S510, the correspondence between each column of the previous table and each column of the subsequent table may be determined based on the column information of each cell in the i-th row and the j-th row.

[0100] Different tables may have different merged cell situations. Therefore, even if the number of columns is the same, two tables may have different merged cell situations in different columns. It is necessary to clarify the correspondence between the columns. By determining this correspondence, you can avoid splicing errors caused by different merge structures of internal cells in tables on different pages during the splicing process, and ensure that the table content is aligned in the column direction after splicing.

[0101] by Figure 4A and Figure 4B Taking the two tables shown as an example, since the columns of the two tables are one-to-one corresponding, the correspondence between the cells in the i-th row and the j-th row can be determined based on the columns occupied by the cells in the i-th row of the previous table and the j-th row of the subsequent table.

[0102] For example, the correspondence between the columns of the two tables can be expressed by ([column information of the cell in the i-th row], [column information of the cell in the j-th row]). Figure 4A and Figure 4B In the two tables shown, Figure 4A The column information of each cell in the i-th row (for example, the last row) of the previous table is: [[0], [1, 2], [3], [4], [5]], Figure 4B The column information of each cell in the jth row (for example, the first row) of the subsequent table is: [[0], [1], [2], [3, 4], [5]], where the first column is numbered 0, the second column is numbered 1, the third column is numbered 2, and so on, the sixth column is numbered 5. In this way, the corresponding relationship between the columns can be obtained as follows: [([0], [0]), ([1, 2], [1]), ([3], [2]), ([4], [3, 4]), ([5], [5])], where ([1, 2], [1]) means that the second and third columns of the previous table correspond to the second column of the subsequent table, and ([4], [3, 4]) means that the fifth column of the previous table corresponds to the fourth and fifth columns of the subsequent table.

[0103] In step S520, column information of cells in the previous table and the next table may be updated based on the corresponding relationship.

[0104] In this step, when the correspondence relationship indicates that a single column corresponds to a single column, the columns of the previous table and the subsequent table can correspond one to one. For example, the column information of each cell in the i-th row (for example, the last row) of the previous table is: [[0], [1], [2], [3], [4]], and the column information of each cell in the j-th row (for example, the first row) of the subsequent table is: [[0], [1], [2], [3], [4]], so the correspondence relationship can be: [([0], [0]), ([1], [1]), ([2], [2]), ([3], [3]), ([4], [4])], in which case the column information of the two tables can keep the current numbering.

[0105] In the case where the corresponding relationship indicates that a single column corresponds to multiple columns, the column information of the cell of the table where the single column is located may be updated according to the number of the multiple columns.

[0106] Specifically, Figure 4A and Figure 4B Taking the two tables shown in the figure as an example, the corresponding relationship between the columns is: [([0],[0]),([1,2],[1]),([3],[2]),([4],[3,4]),([5],[5])], which means that although Figure 4AThe total number of columns in the previous table and Figure 4B The total number of columns in the subsequent tables is 6, but there are merged columns, so the above correspondence is not a one-to-one correspondence. In this case, Figure 6 As shown, after the two tables are joined, the total number of columns of the table will become 7, so the column information of the cells needs to be updated, for example, the columns need to be renumbered.

[0107] As an example, Figure 7 As shown, in the example where the column information includes the column number of the column occupied by the cell, the column information of the cell of the table where the single column is located can be updated in the following manner:

[0108] In step S710 , all column numbers from the start column number to the end column number may be determined as updated column numbers of cells in a single column.

[0109] Here, the starting column number may be the column number of a single column, and the ending column number may be the sum of the column number of the single column and the number of columns of the multiple columns minus one.

[0110] by Figure 4A and Figure 4B Taking the two tables shown as examples, the correspondence between their columns is: [([0],[0]),([1,2],[1]),([3],[2]),([4],[3,4]),([5],[5])], where for the correspondence ([1,2],[1]), the multiple columns 2 and 3 of the previous table correspond to the single column 2 of the subsequent table, so the column number of the 2nd column of the subsequent table can be updated.

[0111] Specifically, the starting column number can be the column number 1 of the second column, and the ending column number can be the sum of the column number 1 of the single column and the column number 2 of the multiple columns minus one, which is 2. In other words, all column numbers from 1 to 3 can be determined as the updated column numbers of the cells in the single column, that is, the updated column number of the second column of the single column in the subsequent table is [1,2].

[0112] In step S720, for cells in each column after the single column, the sum of the column number of the cell and the number of columns of the multiple columns minus one may be determined as the updated column number of the cell.

[0113] For the columns after a single column, for example, still taking the above example, the columns after the second column of the single column in the latter table are the third to sixth columns, which are numbered [2], [3], [4], and [5] respectively. In this way, the number of each column can be added to the number of columns 2 and then subtracted by one, and the updated numbers of the third to sixth columns are obtained as [3], [3], [5], and [6] respectively.

[0114] Here, the process of the above steps S510 to S520 can be performed column by column according to the direction of the rows of the table (for example, from left to right). Figure 4A and Figure 4B Taking the two tables shown as examples, the correspondence between their columns is: [([0],[0]),([1,2],[1]),([3],[2]),([4],[3,4]),([5],[5])]. From left to right, the above steps can be performed for the correspondence ([1,2],[1]) to update the column information of each cell in the subsequent table. Then, based on the updated column information, the above steps can be performed for the correspondence between a single column and multiple columns to update the column information of each cell in the previous table.

[0115] Specifically, for the corresponding relationship ([1,2],[1]), after the above steps S510 to S520, the column information of each column in the subsequent table has been updated, and the corresponding relationship of each column is updated to: [([0],[0]),([1,2],[1,2]),([3],[3]),([4],[4,5]),([5],[6])]. In this case, for the corresponding relationship ([4],[4,5 ])Execute the process from step S510 to step S520, thereby updating the column information of each column in the previous table, and further updating the correspondence of each column to: [([0],[0]),([1,2],[1,2]),([3],[3]),([4,5],[4,5]),([6],[6])], so far, the column information of each column in the previous table completely corresponds to the column information of each column in the subsequent table, that is, each column is in a one-to-one correspondence.

[0116] Here, by updating the cell information of the table where the single column is located, the single columns of both the previous table and the subsequent table can be taken into consideration. For example, the column information of the corresponding single column cells of the subsequent table can be updated based on the multiple columns of the previous table, or the column information of the corresponding single column cells of the previous table can be updated based on the multiple columns of the subsequent table, thereby ensuring the consistency of the column information representation methods of the previous and next tables, so that a complete table structured information can be formed after splicing.

[0117] Return to reference Figure 5 In step S530, the two tables may be joined based on the updated column information.

[0118] In this step, since the column information of the two tables has been updated, each column is in a one-to-one correspondence, so the column information of the two tables can be spliced. In this case, it is sufficient to further update the row information.

[0119] Specifically, the row information of all cells in the subsequent table can be updated based on the number of rows in the previous table. For example, the row information can include the row number of the row occupied by the cell, and the row number can be numbered according to integers starting from 0, that is, the row number of the first row is 0, the row number of the second row is 1, and so on. When splicing two tables, the row number of each row in the subsequent table can be updated to the sum of the row number and the number of rows in the previous table.

[0120] by Figure 4A and Figure 4B For example, Figure 4A The rows in the previous table are numbered [0], [1], [2], [3], [4], [5], and [6], for a total of 7 rows; Figure 4B The row numbers of the subsequent table are [0], [1], [2], [3], [4], [5], [6] and [7], for a total of 8 rows. When joining two tables, the row numbers of the subsequent table can be updated to [7], [8], [9],

[10] ,

[11] ,

[12] ,

[13] and

[14] respectively. In this way, the row information of the two tables can be joined.

[0121] In addition to updating the column and row information of each cell as above, you can also update the merged information of merged cells. For example, before the tables are joined, Figure 4B The cells in the second column of the latter table are single cells, and their column information is [1]. After splicing, their column information is updated from a single column to multiple columns, that is, the column information is [1,2]. Therefore, all cells in this column are merged cells, and the merged information of these merged cells updated due to table splicing can be stored.

[0122] After the above splicing process, Figure 4A Taking the previous table shown as an example, Figure 4A The position information of the five cells in the last row of the table are updated to [0, [49.0, 134.0]], [1, [134.0, 327.0]], [3, [327.0, 447.0]], [4, [447.0, 803.0]], and [6, [803.0, 1565.0]], and the merged information of the cells in the last row is [(6, 7, 1, 3), (6, 7, 4, 6)].

[0123] Similarly, Figure 4AThe position information of the five cells in the first row of the previous table are [0, [49.0, 134.0]], [1, [134.0, 327.0]], [3, [327.0, 447.0]], [4, [447.0, 803.0]], and [6, [803.0, 1565.0]], and the merged information of the cells in the first row is [(0, 1, 1, 3), (0, 1, 4, 6)]. Figure 4A In a similar way, we can also determine Figure 4B The position information and merge information of the updated cells in the first row and the last row will not be repeated here.

[0124] In addition, as an example, a table may include a header and a body, the header may be the first row of the table, and the body includes the second to last rows of the table. If the first rows of the two tables are completely identical, they may be considered duplicate headers, and the first row of data in the subsequent table may be removed. Here, the operation of removing the first row of data in the subsequent table may be performed before or after the splicing process. If it is performed after the splicing process, the row information of each cell in the body of the subsequent table may be updated in response to the removal of the first row of data in the subsequent table, for example, the row number of each cell may be reduced by one.

[0125] In addition, as an example, a cross-page table may also have cross-page cells, that is, the content of the cells in the last row of the previous table is not fully displayed, but is displayed in the first row of the table body of the next table. Figure 4A and Figure 4B For example, the content of the cell in the 7th row and 6th column of the previous table is not fully displayed, and part of its content is displayed in the cell in the 2nd row and 6th column of the next table. For such cross-page cells, they can be merged when splicing tables. For example, the merged rows are as follows Figure 6 as shown in .

[0126] As an example, for the first row of the subsequent table after removing the duplicate headers (i.e., the first row of the table body), if the content of the first cell is empty and more than half of the cells in the row are empty, then the cells in the row are judged to be cross-page cells in the previous table, and the row can be directly merged with the last row of the previous table.

[0127] If the first cell content is not empty or less than half of the cells in the row are empty, it is necessary to determine whether there is semantic connectivity between the contents of the corresponding cells based on semantics, so as to determine whether there are cross-page cells.

[0128] For this case, Figure 8 As shown, the step of splicing two tables may also include:

[0129] In step S810, semantic connectivity detection may be performed on the contents of each cell in the last row of the preceding table and the corresponding cells in the first row of the table body of the succeeding table to obtain a detection result.

[0130] In step S820, when the detection result indicates that there is semantic connectivity between the contents of corresponding cells, the last row of the preceding table and the first row of the table body of the succeeding table may be merged.

[0131] As an example, an N-Gram language model can be pre-trained for semantic connectivity detection. For example, documents commonly used in news or business scenarios can be collected as training data. By training a large amount of text data, each word in the training data is annotated with semantic continuity. For example, the unigam, bigram, and trigram in the training data can be annotated, and then the N-Gram language model can be trained. The trained N-Gram language model can be used as a dictionary for word segmentation to predict the probability that the input word segmentation is continuous semantics.

[0132] When the tables are concatenated, the last two words of the text in each cell of the last row of the previous table and the first word of the text in the corresponding cell of the first row in the table body of the subsequent table can be combined into a tri-gram segmentation, and the tri-gram segmentation is placed in the trained N-Gram language model to output a probability value, which can be determined by the combination of different weights of the tri-gram segmentation being a unigram segmentation, a bigram segmentation, and a tri-gram segmentation. For example, the probability of the tri-gram segmentation being a unigram segmentation, the probability of being a bigram segmentation, and the probability of being a trigram segmentation can be weighted according to the preset weights, and then the sum of the three weighted probabilities is used as the final probability value. This probability value can be compared with a preset probability threshold. If it is higher than or equal to the probability threshold, it can be considered that there is a semantic connection between the text in each cell of the last row of the previous table and the text in the corresponding cell of the first row in the table body of the subsequent table; if it is lower than the probability threshold, it is considered that there is no semantic connection between the two texts.

[0133] However, the method of determining semantic connectivity is not limited to the above examples, and may also be determined based on other methods, for example, based on other semantic models such as NPLM, Word2vec, etc., or the binary word segmentation may be placed in a trained model to predict the probability.

[0134] The detection result indicates that there is semantic connectivity between the contents of corresponding cells, which can mean that: the number of columns with semantic connectivity accounts for more than half of the total number of columns. In this case, it can be determined that the cells in the last row of the previous table and the corresponding cells in the first row of the table body of the subsequent table are cross-page cells, and these two rows of cells can be merged. After the two cells are merged, the row information of the cells in other rows of the subsequent table can be updated, for example, the row number can be reduced by one. In this way, the cell contents that are divided into different pages in the cross-page table can be integrated, and the contents of the same cell can be merged to improve the readability of the spliced ​​table.

[0135] The above describes the process of splicing two tables. When the target document includes multiple document pages, the splicing of two tables on adjacent pages can be performed in sequence from front to back in the order of the document pages. The spliced ​​table can be used as the front table and spliced ​​with the rear table in the next document page according to the above splicing process.

[0136] For example, the first row of information of the table on the previous page can be used as the first row of information of the current table, the last row of information of the table on the current page can be used as the last row of information of the current table, and the spliced ​​table can be used as the table on the current page to enter the backward merging state.

[0137] According to the document processing method disclosed in the present invention, a complete table obtained by splicing can be extracted for a target document including multiple document pages. In the absence of document structure information, the relationship between cross-page tables can be restored, the information conveyed by the table structure can be obtained, and the readability of the information can be improved.

[0138] The above describes the splicing solution for cross-page tables in the target document. In addition to cross-page tables, the target document can also include other article elements such as text, title, header, footer, etc. The processing solution for other article elements will be further given below.

[0139] As mentioned above Figure 1 In step S110, the target document may be subjected to content detection. In addition to the above table, the information extracted from the target document may also include but is not limited to title, picture, picture title, table title, header, footer, annotation, etc.

[0140] According to an exemplary embodiment of the present disclosure, invalid text may also be removed from the text extracted from the target document.

[0141] Specifically, if all identified text blocks are treated as the article body of the target document, some invalid text blocks that do not belong to the article body may be introduced, causing the meaning of the article to change and affecting the reading effect.

[0142] As an example, Fig.10 As shown, the document processing method may further include the following steps:

[0143] In step S1010, a text block in a target document may be obtained.

[0144] Here, each text block may include one or more characters. For example, all text blocks extracted from the target document may be obtained.

[0145] In step S1020, invalid text blocks may be removed from the text blocks.

[0146] Invalid text blocks may refer to non-text blocks. By removing invalid text blocks, it is possible to avoid non-text content from interfering with reading or being inserted into the text to cause information confusion. Here, invalid text blocks may include at least one of text blocks located in pictures, text blocks belonging to headers or footers, and text blocks containing watermarks.

[0147] Specifically, for the text block in the picture, in the content detection of step S110, the element of type picture and the position information of the picture element have been obtained. By confirming whether the position of any text block is included in the picture element, it is determined whether the text block is a text block in the picture. If the position of the text block is within the range of the picture, the text block is removed from the text list as an invalid text block. For example, Fig. 9 The text block "SYSTEM" in the image element detected in .

[0148] For the text block belonging to the header or footer, in the content detection of step S110, the elements of the type of header and footer and the corresponding position information have been obtained. By confirming whether the position of the text block coincides with the position of the header and footer, when the proportion of the coincidence between any text block and the position of the header or footer is greater than the preset proportion, the text block can be considered to be a header or footer, and the text block is removed from the text list as an invalid text block.

[0149] For a text block containing a watermark, Fig.11 As shown, the text block containing the watermark can be determined in the following way:

[0150] In step S1110 , the inclination angle, text block length, and text block width of each text block may be determined.

[0151] For example, the inclination angle, length and width of the text block may be determined according to the coordinate information of the four vertices of each text block detected in step S110 .

[0152] In step S1120, the text blocks may be clustered according to the inclination angle, the length of the text blocks, and the width of the text blocks, and the text blocks may be divided into at least two candidate categories.

[0153] In a document, the features of a watermark are more prominent than those of the main text. A watermark may have a regular shape and repeated text content. Therefore, in this step, all text blocks may be clustered first. A text block with a stronger category feature is more likely to be a watermark text block.

[0154] Here, based on the characteristics of the watermark having a regular shape and repeated text content, the text blocks can be clustered according to the tilt angle, text block length and text block width, and at least two candidate categories of text blocks can be clustered. For example, text blocks with the same tilt angle, text block length and text block width can be selected as one candidate category, and the remaining text blocks can be selected as another candidate category.

[0155] However, the present disclosure is not limited to this, and the clustering method can also be adjusted according to actual needs. For example, a text block with a larger inclination angle can be used as a candidate category, and / or a text block with a smaller length can be used as a candidate category, etc., and the number of candidate categories can be increased according to actual needs.

[0156] In step S1130, a text block containing a watermark may be determined from at least two candidate categories based on the shape data of the text block.

[0157] As described above, the features of the watermark are more prominent than the main text, so in this step, a watermark text block having the watermark shape features can be determined from the candidate categories.

[0158] As an example, step S1030 may include any one or more of the following examples:

[0159] In one example, from at least two candidate categories, a text block whose text edit distance statistic value is less than a preset statistic value is determined as a text block containing a watermark, wherein the text edit distance statistic value is obtained by counting the text edit distance between every two text blocks in the candidate category.

[0160] Specifically, the text contents of multiple watermarks in the same document page are generally the same, such as the name of the document author, the company logo, etc. Therefore, the text edit distance of each candidate category text block can be calculated for each two characters, and the statistical value of the edit distance of each candidate category text block can be calculated. Here, the statistical value can be, for example, but not limited to, the average value, the maximum value, the minimum value, etc.

[0161] Here, the text edit distance refers to a quantitative measurement of the degree of difference between two strings (for example, two Chinese characters or two English words), which is measured by calculating the minimum number of times it takes to transform one string into another. The closer the two strings are, the smaller the text edit distance between them; the greater the difference between the two strings, the larger the text edit distance between them.

[0162] When the text edit distance statistic of a candidate category is less than the preset statistic, it can be considered that the edit distance between the text blocks of the candidate category is small, so that the text block of the candidate category can be determined as a text block containing a watermark. Here, the preset statistic can be set according to actual needs.

[0163] In one example, the difference between the average tilt angle of the text blocks in the candidate category and the average tilt angle of the text blocks in any other candidate category is greater than a preset angle.

[0164] Specifically, in a document, in order not to interfere with the display of the main text, the watermark generally has a certain tilt angle to distinguish it from the horizontally written main text. Therefore, by comparing the average tilt angles of the text blocks between the candidate categories, when the average tilt angle of a candidate category is greater than the average tilt angle of another candidate category by a preset angle, the text block of the candidate category can be considered to be a text block containing a watermark. Here, the preset angle can be set according to actual needs, for example, it can be but not limited to 30 degrees.

[0165] In one example, the number of text blocks in the candidate category is less than the number of text blocks in any other candidate category.

[0166] Specifically, in a single-page document, the amount of text used as a watermark is generally less than the amount of text in the main text. Therefore, the number of text blocks in each candidate category can be compared, and the text blocks in the candidate category with fewer text blocks can be determined as the text blocks containing the watermark.

[0167] When text blocks containing watermarks are determined, these text blocks can be removed from the text block list to prevent the watermark text blocks from interfering with the processing of the main text.

[0168] In addition, according to an exemplary embodiment of the present disclosure, the hierarchical relationship between titles may also be determined based on the titles extracted from the target document.

[0169] As an example, Fig.12 As shown, the document processing method according to the embodiment of the present disclosure may also include the following steps:

[0170] In step S1210, the title of each document page of the target document may be obtained.

[0171] For example, the title text block extracted from the target document can be obtained.

[0172] In step S1220, the titles can be classified according to multiple preset title categories.

[0173] The title categories can be preset according to actual needs. For example, the title categories can be divided into: "one", "(one)", "1.", "1.1", "1.1.1", "(1)", "1)", "a", "a)", where each category can use the starting label of the category as the category mark, and based on this category mark, regular expressions can be used to classify each title text block.

[0174] For example, the category mark "one" corresponds to one type of title, and the category mark "(one)" corresponds to two types of titles; or, as will be described below Fig. 9 As shown, the category mark "1." corresponds to one type of title, and the category mark "1.1" corresponds to two types of titles. There can be a subordinate relationship between titles at all levels. For example, a two - type title can be a sub - level of a one - type title, and a three - type title can be a sub - level of a two - type title, and so on. Taking Fig. 9 as an example, the two - type title "1.1 Specific Requirements" is a sub - level of the one - type title "1 Usage Requirements", and it is the specific content of the one - type title "1 Usage Requirements".

[0175] However, the way of dividing title categories is not limited to the above method, and the category mark of each category can also be set according to actual needs. For example, it can also be "Ⅰ", "Ⅱ", etc.

[0176] In step S1230, the hierarchical relationship between each title can be determined according to the title category of each title.

[0177] As an example, in this step, the following operations can be performed on each title according to the arrangement order of the titles in the target document:

[0178] Compare the title category of the current title with the title categories of each previous title in the reverse order of the arrangement order of each previous title before the current title;

[0179] In the case where the current title and the previous title belong to the same title category, determine that the current title and the previous title are titles at the same level;

[0180] In the case where the current title does not belong to the same title category as all previous titles, determine that the current title is a sub - level of the previous title of the current title.

[0181] Specifically, the above judgment can be performed on each title after the first title that appears in the entire target document to determine the hierarchical relationship between each title.

[0182] It is possible to determine one by one whether the current title and the previous title are of the same title category. If they are of the same title category, it is determined that the current title and the previous title belong to the same level of chapters; if they are not of the same category, it is determined whether the current title and the previous title's upper level title are of the same title category.

[0183] For example, Fig. 9 For example, the second-category title "1.2 System composition and function" and its previous title "1.1 Specific requirements" belong to the same title category, so both belong to the same level chapters, that is, both are sub-levels of the first-category title "1 Usage requirements".

[0184] If the current title and the previous title's upper level title are of the same category, it means that the current level chapter has been completed by the previous title, and the current title returns to the upper level title to continue numbering; if the current title and the previous title's upper level title are not of the same title category, continue to compare to the upper level until a title belonging to the same title category is found.

[0185] For example, still Fig. 9 For example, if the title "1.3 System Improvement" appears after the title "1.2.2 Function", the title "1.3 System Improvement" and its previous title "1.2.2 Function" do not belong to the same category. You can continue to compare the title "1.3 System Improvement" with the previous title "1.2.2 Function" of the previous level title "1.2 System Composition and Function" to determine that the two belong to the same title category. This means that the current level chapter of "1.2 System Composition and Function" has been completed in the previous title "1.2.2 Function". The current title "1.3 System Improvement" returns to the previous level title to continue numbering, that is, continues to number after "1.2 System Composition and Function".

[0186] If the current title and all previous titles are not in the same title category, and the current title is the starting number of a title in a certain title category, then the current title is determined to be a sub-level starting title of the previous level title.

[0187] For example, still Fig. 9 For example, the title "1.1 Specific Requirements" and the title before it do not belong to the same title category, so it can be determined that the title "1.1 Specific Requirements" is a child of its previous title "1 Usage Requirements".

[0188] According to an exemplary embodiment of the present disclosure, all titles in the target document can be traversed in the above-mentioned manner to determine the hierarchical relationship between the titles. In this way, based on the existing document detection technology, further information reorganization can be performed on the basis of the article element detection results, so as to restore the association between the upper and lower pages of the document and enhance the readability of the plain text after text recognition, thereby reducing the difficulty of subsequent text processing.

[0189] Based on the above exemplary embodiments, the steps of text extraction, article element extraction, irrelevant information removal, chapter structure restoration, and cross-page table merging can be performed on the target document, and after execution, different text category labels can be marked on each text block. Category labels include, but are not limited to, chapter titles, tables, table titles, pictures, picture titles, text (text blocks not detected by the target detection model are considered text), comments, etc., among which headers, footers, and comments will affect the readability of the article, and this part of information can be stored independently of the article. In addition, relationship labels can also be marked on text blocks, and relationship labels include, but are not limited to, text block order, upper and lower hierarchical relationships, etc. In this way, structured storage of the target document can be achieved, and all text block information can be converted into the required display form or storage form for use according to the usage scenario.

[0190] According to the document processing method of the exemplary embodiment of the present disclosure, a more complete way of extracting text information and document structure can be proposed for non-editable documents. The method can merge cross-page tables, and can also perform text extraction, article element extraction, irrelevant information elimination and chapter structure restoration. In this way, the text information, position information, and a series of features of article elements extracted by the existing visual model can be fully combined to restore the association relationship of each article element in the document, thereby retaining all the information of the document as much as possible, while removing invalid information such as watermarks, headers and footers to prevent reading interference caused by them.

[0191] The process of extracting information from a target document will be described in detail below. This process can be performed in the information extraction device described below.

[0192] As an example, the target document to be processed may be a PDF file, which may be converted into a picture format, for example, the PDF file may be segmented into multiple pictures according to the document pages. Existing document detection technology may be used to detect article elements of the target document and determine the positions of the article elements on each document page. Although the target document is described as a PDF file here, it is not limited thereto, and the target document may also be in other formats, for example, a picture format.

[0193] Here, you can choose object detection and text recognition models in packages such as PaddleOCR to perform object detection and text recognition on the target document.

[0194] Taking the PaddleOCR suite as an example, this series of models can have text recognition and document element detection functions. The text recognition function of the OCR model can be used to identify all the text information in each document page of the target document, and take the text block as the detection target, and return the text information of all the text blocks in the document page and the coordinate information of the four vertices of the text block.

[0195] You can set detection targets according to actual needs, such as titles, pictures, picture titles, tables, table titles, headers, footers, comments, etc., and train the target detection model in the PaddleDetection suite based on the detection targets. After recognizing the text information, you can input the text information and coordinate information of the recognized text block into the trained detection model, and use the model to classify each text block in the document page and determine the element type to which each text block belongs. For example, Fig. 9 As shown, each text block can be identified, and the element type of each text block can be detected. For example, the text blocks of each element type in the target document can be extracted according to the overlap between the document element position information of the element type and the text block, so as to perform the document processing method described above.

[0196] It should be noted that, although the PaddleDetection kit is used as an example here, the exemplary embodiments of the present disclosure are not limited to this, and models of other frameworks can also be used for content detection. For example, the technology of obtaining and restoring the article layout in scanned documents can be used with the help of computer vision technology.

[0197] In a second aspect, an exemplary embodiment of the present disclosure provides a document processing device, such as Fig.13 As shown, the document processing device includes a detection unit 1310 , an analysis unit 1320 and a splicing unit 1330 .

[0198] The detection unit 1310 is used to perform content detection on a target document to be processed, wherein the target document includes a plurality of document pages.

[0199] The analyzing unit 1320 is used to analyze the shapes of two tables respectively located in the adjacent document pages when it is detected that any two adjacent document pages both contain tables, and obtain an analysis result, where the two tables include a front table and a back table.

[0200] The splicing unit 1330 is used to splice the two tables when the analysis result indicates that the shape of any i-th row of the previous table matches that of any j-th row of the subsequent table, so as to obtain a spliced ​​table from the target document, wherein the i-th row is any one of the m rows having the same shape as the last row of the previous table, the j-th row is any one of the n rows having the same shape as the first row of the subsequent table, and m and n are integers greater than 0.

[0201] As an example, the shape of any i-th row in the previous table matches that of any j-th row in the subsequent table, including: the column width ratio of each column in the i-th row matches the column width ratio of each column in the j-th row, wherein the column width ratio is the ratio of the width of the column to the width of the row in which the column is located; and / or the number of columns contained in the i-th row is equal to the number of columns contained in the j-th row.

[0202] As an example, matching column width ratios means that a statistical value of a difference between column width ratios of each column in two tables is less than a preset value.

[0203] As an example, the document processing apparatus further includes: a text detection unit for performing text detection on the document content between the two tables; and a shape analysis unit for executing the step of analyzing the shapes of the two tables when no text exists between the two tables.

[0204] As an example, the analysis unit 1320 is also used to: perform cell detection on two tables in adjacent document pages to determine the row information and column information of each cell in each table; based on the row information and column information of each cell, analyze the shapes of the two tables to obtain analysis results, wherein the row information represents the row occupied by the cell, and the column information represents the column occupied by the cell.

[0205] As an example, the splicing unit 1330 is also used to: determine the correspondence between the columns of the previous table and the columns of the subsequent table based on the column information of each cell in the i-th row and the j-th row; based on the correspondence, update the column information of the cells in the previous table and the subsequent table; and splice the two tables based on the updated column information.

[0206] As an example, the splicing unit 1330 is further configured to: when the correspondence relationship indicates that a single column corresponds to multiple columns, update the column information of the cell of the table where the single column is located according to the number of the multiple columns.

[0207] As an example, the column information includes the column number of the column occupied by the cell, wherein the splicing unit 1330 is also used to: determine all column numbers from the starting column number to the ending column number as updated column numbers of the cells in the single column, wherein the starting column number is the column number of the single column, and the ending column number is the sum of the column number of the single column and the number of columns of multiple columns minus one; for the cells in each column after the single column, the column number of the cell and the sum of the number of columns of multiple columns minus one is determined as the updated column number of the cell.

[0208] As an example, a table includes a header and a body, the header is the first row of the table, and the body includes the second to last rows of the table, wherein the splicing unit 1330 is also used to: perform semantic connectivity detection on the contents of each cell in the last row of the previous table and the corresponding cell in the first row of the body of the subsequent table to obtain a detection result; when the detection result indicates that there is semantic connectivity between the contents of the corresponding cells, merge the last row of the previous table and the first row of the body of the subsequent table.

[0209] As an example, the document processing device also includes: a text block extraction unit, used to extract text blocks in the target document, wherein each text block includes one or more characters; and a removal unit, used to remove invalid text blocks from the text blocks, wherein the invalid text blocks include at least one of text blocks located in pictures, text blocks belonging to headers or footers, and text blocks containing watermarks.

[0210] As an example, an invalid text block includes a text block containing a watermark, wherein the text block containing the watermark is determined in the following manner: determining the inclination angle, text block length and text block width of each text block; clustering the text blocks according to the inclination angle, text block length and text block width, and dividing the text blocks into at least two candidate categories; and determining the text block containing the watermark from at least two candidate categories based on the shape data of the text blocks.

[0211] As an example, the document processing device also includes: a title extraction unit, used to extract the title in each document page of the target document; a classification unit, used to classify the titles according to multiple preset title categories; and a hierarchy determination unit, used to determine the hierarchical relationship between the titles based on the title category of each title.

[0212] As an example, the hierarchy determination unit is also used to: perform the following operations on each title according to the arrangement order of each title in the target document: compare the title categories of the current title with those of the previous titles in reverse order of the arrangement order of the previous titles before the current title; when the current title and the previous title belong to the same title category, determine that the current title and the previous title are titles of the same level; when the current title and all previous titles do not belong to the same title category, determine that the current title is a child of the previous title of the current title.

[0213] As an example, the i-th row is the last row in the former table, and the j-th row is the first row in the latter table.

[0214] Regarding the device in the above embodiment, the specific manner in which each unit performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.

[0215] In a third aspect, an exemplary embodiment of the present disclosure provides an information extractor, such as Fig.14 As shown, the information extractor 1400 may include an information extracting device 1410 and a document processing device 1420 .

[0216] The information extraction device 1410 is used to extract information from a document, for example, it can execute the above-mentioned process of extracting information from a target document.

[0217] The document processing device 1420 may be a document processing device according to an exemplary embodiment of the present disclosure, and the document processing device is used to process the document extracted by the information extracting device 1410 .

[0218] Fig.13 and Fig.14 Each unit in the document processing device and information extractor shown may be configured as software, hardware, firmware, or any combination of the above items to perform a specific function. For example, each unit may correspond to a dedicated integrated circuit, or may correspond to a pure software code, or may correspond to a module that combines software and hardware. In addition, one or more functions implemented by each unit may also be uniformly executed by components in a physical entity device (e.g., a processor, a client, or a server, etc.).

[0219] In addition, refer to Figures 1 to 12 The document processing method described can be implemented by a program (or instruction) recorded on a computer-readable storage medium. For example, according to an exemplary embodiment of the present disclosure, a computer-readable storage medium storing instructions can be provided, wherein when the instructions are executed by at least one computing device, the at least one computing device is prompted to perform the document processing method according to the present disclosure.

[0220] The computer program in the computer-readable storage medium can be run in an environment deployed in a computer device such as a client, a host, an agent device, a server, etc. It should be noted that the computer program can also be used to perform additional steps in addition to the above steps or perform more specific processing when performing the above steps. The contents of these additional steps and further processing have been described in reference to Figures 1 to 12 It is mentioned in the description of the related method, so it will not be repeated here to avoid repetition.

[0221] It should be noted that the various units in the document processing device and the information extractor according to the exemplary embodiment of the present disclosure can completely rely on the operation of the computer program to realize the corresponding functions, that is, each unit corresponds to each step in the functional architecture of the computer program, so that the entire system is called through a special software package (for example, lib library) to realize the corresponding function.

[0222] on the other hand, Fig.13 and Fig.14 The various units shown may also be implemented by hardware, software, firmware, middleware, microcode, or any combination thereof. When implemented by software, firmware, middleware, or microcode, the program code or code segment for performing the corresponding operation may be stored in a computer-readable medium such as a storage medium, so that the processor may perform the corresponding operation by reading and running the corresponding program code or code segment.

[0223] For example, the exemplary embodiments of the present disclosure may also be implemented as a computing device, which includes a storage component and a processor, wherein a computer executable instruction set is stored in the storage component, and when the computer executable instruction set is executed by the processor, a document processing method according to the exemplary embodiments of the present disclosure is executed.

[0224] Specifically, the computing device can be deployed in a server or client, or can be deployed on a node device in a distributed network environment. In addition, the computing device can be a PC, a tablet device, a personal digital assistant, a smart phone, a web application, or other device capable of executing the above instruction set.

[0225] Here, the computing device is not necessarily a single computing device, but may also be any device or circuit collection that can execute the above instructions (or instruction sets) individually or jointly. The computing device may also be part of an integrated control system or system manager, or may be configured as a portable electronic device that is interconnected with a local or remote (e.g., via wireless transmission) interface.

[0226] In a computing device, a processor may include a central processing unit (CPU), a graphics processing unit (GPU), a programmable logic device, a dedicated processor system, a microcontroller, or a microprocessor. By way of example and not limitation, a processor may also include an analog processor, a digital processor, a microprocessor, a multi-core processor, a processor array, a network processor, etc.

[0227] According to the document processing method of the exemplary embodiment of the present disclosure, some operations described may be implemented by software, some operations may be implemented by hardware, and further, these operations may be implemented by a combination of software and hardware.

[0228] The processor may execute instructions or codes stored in one of the storage components, which may also store data. Instructions and data may also be sent and received over a network via a network interface device, which may employ any known transmission protocol.

[0229] The storage component may be integrated with the processor, for example, RAM or flash memory is arranged within an integrated circuit microprocessor, etc. In addition, the storage component may include a separate device, such as an external disk drive, a storage array, or any other storage device that can be used by a database system. The storage component and the processor may be operatively coupled, or may communicate with each other, such as through an I / O port, a network connection, etc., so that the processor can read files stored in the storage component.

[0230] In addition, the computing device may also include a video display (such as a liquid crystal display) and a user interaction interface (such as a keyboard, a mouse, a touch input device, etc.) All components of the computing device may be connected to each other via a bus and / or a network.

[0231] The document processing method according to the exemplary embodiment of the present disclosure can be described as various interconnected or coupled functional blocks or functional diagrams. However, these functional blocks or functional diagrams can be equally integrated into a single logical device or operate according to non-precise boundaries.

[0232] Therefore, refer to Figures 1 to 12 The document processing method described may be implemented by a system including at least one computing device and at least one storage device storing instructions.

[0233] According to an exemplary embodiment of the present disclosure, at least one computing device is a computing device for executing a document processing method according to an exemplary embodiment of the present disclosure, and a computer executable instruction set is stored in the storage device. When the computer executable instruction set is executed by the at least one computing device, the execution reference Figures 1 to 12 The document processing method described.

[0234] The above describes various exemplary embodiments of the present disclosure, and it should be understood that the above description is only exemplary and not exhaustive, and the present disclosure is not limited to the disclosed exemplary embodiments. Without departing from the scope and spirit of the present disclosure, many modifications and changes are obvious to those of ordinary skill in the art. Therefore, the scope of protection of the present disclosure should be based on the scope of the claims.

Claims

1. A document processing method, characterized in that: The method comprises: Performing content detection on a target document to be processed, wherein the target document includes a plurality of document pages; When it is detected that any two adjacent document pages both contain tables, analyzing shapes of two tables respectively located in the adjacent document pages to obtain analysis results, wherein the two tables include a front table and a rear table; When the analysis result indicates that the shape of any i-th row of the previous table matches that of any j-th row of the subsequent table, the two tables are spliced ​​to obtain a spliced ​​table from the target document, wherein the i-th row is any one of the m rows having the same shape as the last row of the previous table, and the j-th row is any one of the n rows having the same shape as the first row of the subsequent table, and m and n are integers greater than 0.

2. The document processing method according to claim 1, characterized in that: The shape of any i-th row of the preceding table matches that of any j-th row of the succeeding table, including: The column width ratio of each column in the i-th row matches the column width ratio of each column in the j-th row, wherein the column width ratio is the ratio of the width of a column to the width of the row where the column is located; and / or, The number of columns included in the i-th row is equal to the number of columns included in the j-th row.

3. The document processing method according to claim 2, characterized in that: The column width proportions match means that a statistical value of a difference between the column width proportions of each column in the two tables is less than a preset value.

4. The document processing method according to claim 1, characterized in that: The method further comprises: Performing text detection on the document content between the two tables; In the case where there is no text between the two tables, a step of analyzing the shapes of the two tables is performed.

5. The document processing method according to any one of claims 1 to 4, characterized in that: The analyzing the shapes of the two tables respectively located in the adjacent document pages to obtain the analysis results includes: Performing cell detection on the two tables in the adjacent document pages to determine row information and column information of each cell in each table; Based on the row information and column information of each cell, the shapes of the two tables are analyzed to obtain analysis results, The row information represents the row occupied by the cell, and the column information represents the column occupied by the cell.

6. A document processing device, characterized in that: The document processing device comprises: A detection unit, configured to perform content detection on a target document to be processed, wherein the target document includes a plurality of document pages; An analyzing unit, configured to analyze shapes of two tables respectively located in the adjacent document pages to obtain an analysis result when it is detected that both of the two adjacent document pages contain tables, wherein the two tables include a front table and a rear table; A splicing unit is used to splice the two tables when the analysis result indicates that the shape of any i-th row of the previous table matches that of any j-th row of the subsequent table, so as to obtain a spliced ​​table from the target document, wherein the i-th row is any one of the m rows having the same shape as the last row of the previous table, and the j-th row is any one of the n rows having the same shape as the first row of the subsequent table, and m and n are integers greater than 0.

7. An information extractor, characterized in that The information extractor comprises: An information extraction device, the information extraction device is used to extract information from a document; The document processing apparatus according to claim 6, wherein the document processing apparatus is used to process the document extracted by the information extracting apparatus.

8. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor, Wherein, when the processor executable instructions are executed by the processor, the processor is prompted to execute the document processing method according to any one of claims 1 to 5.

9. A computer-readable storage medium storing instructions, characterized in that: When the instructions are executed by at least one computing device, the at least one computing device is prompted to execute the document processing method according to any one of claims 1 to 5.

10. A system comprising at least one computing device and at least one storage device storing instructions, characterized in that: When the instructions are executed by the at least one computing device, the at least one computing device is prompted to perform the document processing method according to any one of claims 1 to 5.