Method and device for extracting cross-page table in target document and electronic equipment

Through optical character recognition and parsing XML technology to identify and extract span tables, the problem of insufficient accuracy and low efficiency of span table extraction in the existing technology is solved, and higher extraction accuracy and efficiency are achieved, and it is suitable for complex table scenarios.

CN119091453APending Publication Date: 2024-12-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411198640.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

When identifying and extracting span page tables, the algorithm is complex and easily affected by factors such as table layout, text overlap, image quality, etc., resulting in insufficient extraction and low efficiency.

Method used

The target adjacent table is identified through optical character recognition technology, and the table attribute information is extracted in combination with parsing XML technology, the table is merged, and the table is limited to no other page elements between the table elements, improving the recognition accuracy and extraction efficiency.

Benefits of technology

It improves the accuracy and efficiency of the extraction of spreadsheets, reduces the complexity of extraction, applies to complex table scenarios, avoids XML parsing of non-span tables, and improves the accuracy of knowledge Q&A in large model customer service.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119091453A_ABST
    Figure CN119091453A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for extracting a cross-page table in a target document and electronic equipment. The method comprises the following steps: converting a plurality of pages in a target document into a plurality of pictures arranged according to a target sequence; performing adjacency identification on tables in the plurality of pictures based on an optical character identification technology to obtain a target adjacent table; the target adjacent table comprises a first table in the first picture and a second table in the second picture; performing table attribute identification on a first table and the second table in a target adjacent page of the target document based on an extensible markup language analysis technology to obtain first table attribute information corresponding to the first table and second table attribute information corresponding to the second table; and according to the first table attribute information and the second table attribute information, merging the first table and the second table to obtain a target merged table corresponding to the target adjacent table. According to the technical scheme provided by the invention, the extraction accuracy and extraction efficiency of the cross-page table can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device and electronic device for extracting a cross-page table in a target document. Background Art

[0002] With the widespread application of big data, interactions such as data query are becoming more and more abundant, such as Q&A based on big model customer service for data query. Data query is generally performed on the data in the table in the document. In related technologies, document intelligent OCR is generally used to extract table data. However, the algorithm for identifying and extracting table data in documents based on OCR is complex and easily affected by the quality of document images. In addition, when there are tables spanning multiple pages in a document, although document intelligent OCR can analyze the layout and content of the table and merge the cross-page tables into a complete table as much as possible. However, identifying and extracting cross-page tables based on OCR requires high algorithm complexity and is easily affected by some other table factors (such as complex table layout, text overlap, image quality, etc.), which often requires manual adjustment, and the merging of cross-page tables is not accurate enough and the efficiency is low. Summary of the invention

[0003] The present application provides a method, device and electronic device for extracting a cross-page table in a target document, which can improve the accuracy and efficiency of extracting a cross-page table. The technical solution of the present application is as follows:

[0004] According to a first aspect of an embodiment of the present application, a method for extracting a cross-page table in a target document is provided, comprising:

[0005] Converting multiple pages in the target document into multiple images arranged in a target order; the target order refers to the order in which the multiple pages are arranged in the target document;

[0006] Based on the optical character recognition technology, the tables in the multiple images are identified for adjacency to obtain target adjacent tables; the target adjacent tables include a first table in a first image and a second table in a second image, the first image and the second image are adjacent in the target sequence arrangement, the first table is at the bottom of the first image, the second table is at the top of the second image, and no other page elements except table elements are included between the first table and the second table;

[0007] Based on the extensible markup language parsing technology, table attributes of the first table and the second table in the target adjacent page of the target document are identified to obtain first table attribute information corresponding to the first table and second table attribute information corresponding to the second table; the target adjacent page is a first page corresponding to the first picture and a second page corresponding to the second picture;

[0008] The first table and the second table are merged according to the first table attribute information and the second table attribute information to obtain a target merged table corresponding to the target adjacent table.

[0009] According to a second aspect of an embodiment of the present application, a device for extracting a cross-page table in a target document is provided, wherein the target document is a document based on an extensible markup language; the device comprises:

[0010] An image conversion module is used to convert multiple pages in the target document into multiple images arranged in a target order; the target order refers to the page arrangement order of the multiple pages in the target document;

[0011] an adjacent table recognition module, configured to perform adjacency recognition on tables in the plurality of images based on an optical character recognition technology to obtain a target adjacent table; the target adjacent table comprises a first table in a first image and a second table in a second image, the first image and the second image are adjacent in the target sequence arrangement, the first table is at the bottom of the first image, the second table is at the top of the second image, and no other page elements except table elements are included between the first table and the second table;

[0012] a table attribute recognition module, configured to perform table attribute recognition on the first table and the second table in a target adjacent page of the target document based on parsing extensible markup language technology, and obtain first table attribute information corresponding to the first table and second table attribute information corresponding to the second table; the target adjacent page is a first page corresponding to the first picture and a second page corresponding to the second picture;

[0013] The target merged table acquisition module is used to merge the first table and the second table according to the first table attribute information and the second table attribute information to obtain a target merged table corresponding to the target adjacent table.

[0014] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement a method as described in any one of the above-mentioned first aspects.

[0015] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any method described in the first aspect of the embodiment of the present application.

[0016] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, comprising computer instructions, which, when executed by a processor, enable a computer to execute any one of the methods described in the first aspect of the embodiment of the present application.

[0017] The technical solution provided by the embodiments of the present application brings at least the following beneficial effects:

[0018] By using OCR technology to identify target adjacent tables in multiple pages of a target document, and extracting table attribute information from target adjacent pages of a target document based on XML parsing technology, the recognition accuracy of target adjacent tables can be improved based on the recognition accuracy of table positions by OCR, and the extraction accuracy of table attribute information can be improved. Moreover, the recognition and extraction of table attribute information will not be affected by the complexity of table layout, text overlap, image quality, etc., so that the extraction of table attribute information can be effectively applied to complex table scenarios, such as cross-page table scenarios. By limiting the target adjacent table to include a first table in a first image and a second table in a second image, the first image and the second image are adjacent in the target sequence arrangement, the first table is at the bottom of the first image, the second table is at the top of the second image, and no other page elements except table elements are included between the first table and the second table, the scenario in which the first table and the second table are cross-page tables is characterized, and according to more accurate first table attribute information and second table attribute information, a target merged table corresponding to the target adjacent table is obtained by merging, the extraction accuracy and efficiency of the cross-page table can be improved, and the extraction complexity of the cross-page table can be effectively reduced.

[0019] In addition, first, the target adjacent table is obtained by performing table adjacency recognition based on OCR, and then the table attributes of the table in the target adjacent page corresponding to the target adjacent table are recognized based on the XML parsing technology, so that the XML parsing technology can only target the target adjacent page, avoiding XML parsing of non-cross-page table pages, and further improving the extraction efficiency of cross-page tables.

[0020] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application, and do not constitute an improper limitation on the present application.

[0022] Figure 1 It is a schematic diagram of an application environment according to an exemplary embodiment.

[0023] Figure 2 The present invention is a flowchart showing a method for extracting a cross-page table in a target document according to an exemplary embodiment.

[0024] Figure 3 The present invention is a flowchart of a method for extracting a cross-page table in a target document according to an exemplary embodiment.

[0025] Figure 4 It is a schematic diagram showing a cross-page table according to an exemplary embodiment.

[0026] Figure 5 The figure is a schematic diagram showing a method of extracting a cross-page table based on OCR according to an exemplary embodiment.

[0027] Figure 6 The diagram is a schematic diagram showing a method of extracting a cross-page table based on OCR combined with parsing an XML file according to an exemplary embodiment.

[0028] Figure 7 It is a schematic diagram of an interface display of a cross-page table extracted based on OCR combined with parsing of XML files and used for question and answer in large-model customer service according to an exemplary embodiment.

[0029] Figure 8 The present invention is a block diagram of a device for extracting a cross-page table in a target document according to an exemplary embodiment.

[0030] Fig. 9 The invention is a block diagram of an electronic device for extracting a cross-page table in a target document according to an exemplary embodiment.

[0031] Fig.10 The invention is a block diagram of an electronic device for extracting a cross-page table in a target document based on an exemplary embodiment. DETAILED DESCRIPTION

[0032] Various exemplary embodiments, features and aspects of the present application will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0033] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0034] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0035] In addition, in order to better illustrate the present application, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present application can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present application.

[0036] See also Figure 1 , Figure 1 A schematic diagram of an application system provided according to an embodiment of the present application is shown. The application system can be used in the method for extracting a cross-page table in a target document of the present application. Figure 1 As shown, the application system may at least include a server 01 and a terminal 02 .

[0037] In an embodiment of the present application, the server 01 can be used to extract cross-page tables in the target document. The server 01 may include an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0038] In the embodiment of the present application, the terminal 02 can be used for the relevant display of the cross-page table extraction in the target document. The terminal 02 may include physical devices such as smart phones, desktop computers, tablet computers, laptops, smart speakers, digital assistants, augmented reality (AR) / virtual reality (VR) devices, smart wearable devices, etc. The physical device may also include software running in the physical device, such as an application program. The operating system running on the terminal 02 in the embodiment of the present application may include but is not limited to Android system, IOS system, Linux, Windows, etc.

[0039] In addition, it should be noted that Figure 1 What is shown is only one application environment of the method for extracting a cross-page table in a target document provided by the present application.

[0040] In the embodiments of this specification, the terminal 02 and the server 01 may be directly or indirectly connected via wired or wireless communication, which is not limited in this application.

[0041] It should be noted that in the specific implementation of this application, user-related data is involved. When the following embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0042] Before introducing the method embodiments provided in the present application, a brief introduction is first given to the application scenarios, relevant terms or nouns that may be involved in the method embodiments of the present application to facilitate understanding by technicians in the field of the present application.

[0043] Word document: is a common document format used to store text, images, tables, charts, etc. Word documents usually have a file extension of .doc or .docx. .doc is an old version of the Word document format, while .docx is a new version of the Word document format based on XML, which is also the basis for this application to combine OCR and parse XML files (engineering parsing) to extract cross-page tables.

[0044] Unioffice software library: Unioffice is a Go language library for processing Office documents (such as docx, Xlsx, and Pptx). It provides a set of powerful APIs that enable developers to read, create, and edit Office documents. In the embodiments of this specification, when using the XML parsing technology, it can be implemented by calling the Unioffice software library.

[0045] XML, Extensible Markup Language, is a markup language for storing and transmitting data. It uses tags to define the structure and content of data and is self-descriptive. XML files consist of tags, elements, attributes, and text. Each element is surrounded by a start tag and an end tag, and other elements, attributes, or text can be contained between the start tag and the end tag. Attributes provide additional information about elements.

[0046] Spread-page tables: Spread-page tables are when the table content in a document exceeds one page and the table is automatically split to the next page. Usually part of the table is displayed at the bottom of the current page, and the remaining part continues to be displayed at the top of the next page to maintain the integrity and continuity of the table. Spread-page tables are very useful when dealing with large amounts of data or when more space is needed to display the table content. It allows the table to be split across multiple pages to better fit the layout and page limits of the document.

[0047] Big model customer service: Big model customer service refers to a way of providing customer service and support by using large-scale machine learning models and natural language processing technology. By using big model customer service, enterprises can automatically and intelligently handle a large number of customer inquiries and questions, and provide fast, accurate and personalized responses. Big model customer service is usually based on powerful language models that have been trained on a large scale and have the ability to understand and generate natural language. They can understand the user's questions, intentions and context, and generate corresponding answers or solutions.

[0048] Figure 2 FIG. 1 is a flow chart showing a method for extracting a cross-page table in a target document according to an exemplary embodiment. Figure 2 As shown, the following steps may be included.

[0049] In step S201, a plurality of pages in a target document are converted into a plurality of images arranged in a target order.

[0050] In the embodiment of the present specification, the target document may be a document based on an extensible markup language, such as a .docx document based on XML.

[0051] Multiple pages may refer to at least two pages, so that there may be a cross-page table. That is to say, this application is aimed at extracting a cross-page table in a .docx document including multiple pages.

[0052] The target order may refer to the order in which the multiple pages are arranged in the target document, for example, the order in which the page numbers of each page in the .docx document are arranged.

[0053] In a possible implementation, multiple pages in the target document may be converted into corresponding multiple images, and the multiple images may correspond to the multiple pages one by one. In order to make the order of the multiple images consistent with the order of the corresponding multiple pages, the page arrangement order in the target document may be marked for each image, for example, the page number of the corresponding page may be marked as the order of the corresponding image, so that multiple images arranged in the target order may be obtained.

[0054] In step S203, the tables in the multiple images are identified for their proximity based on the optical character recognition technology to obtain a target adjacent table.

[0055] In the embodiments of this specification, the target adjacent table here may refer to a table that is adjacent across pages, which can be regarded as a cross-page table. The target adjacent table may include a first table in a first picture and a second table in a second picture, the first picture and the second picture are adjacent in the target sequence arrangement, the first table is at the bottom of the first picture, the second table is at the top of the second picture, and no other page elements except table elements are included between the first table and the second table.

[0056] It should be noted that the number of target adjacent tables can be one or more. In the case of multiple target adjacent tables, for any target adjacent table, the target merged table corresponding to each target adjacent table can be obtained based on the same extraction method, thereby obtaining multiple target merged tables.

[0057] In practical applications, the tables in multiple images can be identified for their proximity based on optical character recognition (OCR) technology to obtain target adjacent tables. For example, tables in multiple images can be identified based on OCR technology to select adjacent tables across pages as target adjacent tables.

[0058] In a possible implementation, the step of performing adjacency recognition on tables in multiple images based on optical character recognition technology to obtain a target adjacent table may include:

[0059] Based on the optical character recognition technology, multiple target images containing tables are obtained from multiple images, that is, the target images are images including tables from multiple images.

[0060] Adjacent image pairs that are adjacent in the target sequence are screened out from multiple target images, and the adjacent image pairs may include a first image and a second image; in the target sequence, the first image may be before the second image. The first image here may be before the second image only for the convenience of introducing the subsequent processing flow, and is not limited to the present application, that is, in the case of swapping the image names, the subsequent processing flow can still be adapted. It can be understood that the first image here is before the second image, which is a description based on the target order being an arrangement order based on the order of the contents of multiple pages. For example, multiple pages are arranged from first to last according to the content of the document, and the corresponding page numbers are arranged in order from 1 to P, where P is an integer greater than 1. Based on this, the first image is before the second image, for example, the first image may correspond to page number 3, and the second image may correspond to page number 4.

[0061] Obtain the first position of the first table in the first picture, the second position of the second table in the second picture, and the page elements between the first table and the second table in the adjacent picture pair. The first position and the second position may be represented by coordinates, or may be represented by quantized positions in the picture, for example, the quantized positions may include but are not limited to the top, middle, and bottom of the picture. In the coordinate representation, the coordinate information of the table uses the coordinate system in the corresponding page, and the origin of the coordinate system of each page may be the same at the same position in each page to ensure the consistency of the coordinate representation.

[0062] If the page elements do not include other page elements except the table elements, and the first position indicates that the first table is at the bottom of the first image and the second position indicates that the second table is at the top of the second image, the above-mentioned target adjacent table consisting of the first table and the second table is obtained.

[0063] Optionally, if the page elements include other page elements besides the table elements, or the first position indicates that the first table is not at the bottom of the first image, or the second position indicates that the second table is not at the top of the second image, it can be determined that the first table and the second table do not belong to adjacent tables and are not used as target adjacent tables. Based on this, if there are multiple adjacent image pairs, for each adjacent image pair, the above processing method can be used to determine whether it belongs to an adjacent table. If it does, it can be used as a target adjacent table; if it does not, it can be filtered out or discarded, so that one or more target adjacent tables can be obtained.

[0064] In step S205, table attributes of the first table and the second table in the target adjacent page of the target document are identified based on the extensible markup language parsing technology to obtain first table attribute information corresponding to the first table and second table attribute information corresponding to the second table.

[0065] In the embodiment of the present specification, the target adjacent page may be the first page corresponding to the first image and the second page corresponding to the second image. Optionally, the target adjacent page may be obtained in the above step S203, and when the target adjacent table is screened out, the first page corresponding to the first table and the second page corresponding to the second table in the target adjacent table may be used as the target adjacent page.

[0066] In a possible implementation, the table attributes of the first table and the second table in the target adjacent page of the target document can be identified based on the parsing of the extensible markup language XML technology. For example, at least one of the row attributes, column attributes, border attributes, etc. of the table can be identified to obtain the first table attribute information corresponding to the first table and the second table attribute information corresponding to the second table. Among them, the row attributes may include but are not limited to the number of rows, etc.; the column attributes may include but are not limited to the number of columns, column width, etc.; the border attributes may include but are not limited to the border style, etc., and the border style can be used to indicate whether there is a border, which is not limited in this application.

[0067] In one example, the first table attribute information may include the first number of columns and the first column width corresponding to each column. Based on this, the above-mentioned table attribute recognition of the first table and the second table in the target page pair of the target document based on the parsing extensible markup language technology to obtain the first table attribute information corresponding to the first table and the second table attribute information corresponding to the second table may include: according to the direction of the rows in the first table (such as the horizontal direction), sequentially traversing each column in the first table, based on the parsing extensible markup language technology, performing column attribute recognition on the first table to obtain the first number of columns and the first column width; and according to the direction of the rows in the second table, sequentially traversing each column in the second table, based on the parsing extensible markup language technology, performing column attribute recognition on the second table to obtain the second number of columns and the second column width.

[0068] In a possible implementation, when traversing each column in the first table in sequence, the column traversal can be performed based on the row, so that the number of columns corresponding to each row can be obtained, and further, the highest column number of the column numbers corresponding to each row can be used as the first column number of the first table. The second column number can also be obtained based on the same method, which will not be repeated here.

[0069] In another possible implementation, the above-mentioned traversing each column in the first table in sequence according to the direction of the rows in the first table, identifying the column attributes of the first table based on the parsing extensible markup language technology, and obtaining the first column number may include: traversing each column in the first table in sequence according to the direction of the rows in the first table, if there are merged cells in the traversed target column, increasing the number of cells merged by the merged cells based on the current counted column number; if there are no merged cells in the traversed target column, increasing the current counted column number by 1; until the last column is traversed to obtain the first column number. Here, based on a certain row, each column in a certain row in the first table can be traversed in sequence. When the target column is traversed, it can be identified whether the target column has merged cells compared with other rows, that is, whether it spans multiple cells. If so, the number of cells merged by the merged cells can be increased based on the current counted column number; if there are no merged cells in the traversed target column, the current counted column number can be increased by 1; until the last column is traversed to obtain the first column number. Exemplarily, at the beginning of the traversal, the current number of statistical columns may be 0, that is, 0 is used as the initial number of statistical columns.

[0070] In another example, the first table attribute information may also include the bottom border attribute of the last row in the first table; the second table attribute information may also include the top border attribute of the first row in the second table. Based on this, the above-mentioned table attribute identification of the first table and the second table in the target page pair of the target document based on the parsing extensible markup language technology to obtain the first table attribute information corresponding to the first table and the second table attribute information corresponding to the second table may also include: performing border attribute analysis on the bottom border of the last row in the first table based on the parsing extensible markup language XML technology to obtain the bottom border attribute; and performing border attribute analysis on the top border of the first row in the second table based on the parsing extensible markup language technology to obtain the top border attribute. Among them, border attribute analysis may refer to border style analysis. Exemplarily, the border style can be used to characterize whether there is a border. The bottom border attribute can be used to characterize whether there is a border at the bottom, and the top border attribute can be used to characterize whether there is a border at the top.

[0071] In step S207, the first table and the second table are merged according to the first table attribute information and the second table attribute information to obtain a target merged table corresponding to the target adjacent table.

[0072] In the embodiment of this specification, the above-mentioned target adjacent table based on OCR recognition can be regarded as a cross-page table, and then the first table and the second table are merged according to the first table attribute information and the second table attribute information to obtain a target merged table corresponding to the target adjacent table. For example, each row of the second table is merged under each column of the first table to obtain the target merged table.

[0073] In an optional implementation, whether the target adjacent table is a cross-page table can be further judged to further improve the extraction accuracy of the cross-page table, so that the above-mentioned target adjacent table based on OCR recognition can be regarded as a possible cross-page table. Based on this, it can be further determined whether the target adjacent table is a cross-page table based on the first table attribute information and the second table attribute information. If so, it can be determined as a cross-page table, so that the first table and the second table can be merged to obtain the target merged table corresponding to the target adjacent table; if not, it can be determined as a non-cross-page table, and the first table and the second table are not merged, indicating that the first table and the second table are just two adjacent tables in adjacent pages.

[0074] In a possible implementation, the first table attribute information may include the first number of columns and the first column width corresponding to each column; the second table attribute information may include the second number of columns and the second column width corresponding to each column. Based on this, step S207 may include: when the first number of columns is the same as the second number of columns, and the first column width is the same as the corresponding second column width, determining that the target adjacent table is a cross-page table, merging the first table and the second table, and obtaining a target merged table corresponding to the target adjacent table. The positional relationship of tables in multiple pages is identified by OCR, and table attributes are obtained by XML analysis. These two methods are combined to achieve step-by-step judgment from positional relationship to fine-grained table attributes, avoid unnecessary table attribute recognition processing, and save processing resources.

[0075] In an optional implementation, the first table attribute information may also include the bottom border attribute of the last row in the first table; the second table attribute information may also include the top border attribute of the first row in the second table. Based on this, the above-mentioned merging of the first table and the second table to obtain the target merged table corresponding to the target adjacent table may include: merging the first table and the second table according to the bottom border attribute and the top border attribute to obtain the target merged table corresponding to the target adjacent table. That is, it is possible to determine whether the last row and the first row are the same row according to the bottom border attribute and the top border attribute, so as to determine whether to merge the last row and the first row, thereby realizing different table merging operations. Among them, the last row may refer to the row farthest from the table header, or may refer to the row closest to the bottom of the page; the first row may refer to the row closest to the top of the page.

[0076] In an example, merging the first table and the second table according to the bottom border attribute and the top border attribute to obtain a target merged table corresponding to the target adjacent table may include:

[0077] Use the header of the first table as the header of the merged table;

[0078] When the bottom border attribute indicates that the bottom border of the last row is empty, and the top border attribute indicates that the top border of the first row is empty, merge cells of the last row and the first row to obtain a merged row;

[0079] Furthermore, the rows in the first table except the last row and the header row corresponding to the header, the merged rows, and the rows in the second table except the first row may be merged in sequence under the header to obtain a target merged table.

[0080] By using OCR technology to identify target adjacent tables in multiple pages of a target document, and extracting table attribute information from target adjacent pages of a target document based on parsing XML technology, the recognition accuracy of target adjacent tables can be improved based on the recognition accuracy of table positions by OCR, and the extraction accuracy of table attribute information can be improved. Moreover, the recognition and extraction of table attribute information will not be affected by the complexity of table layout, text overlap, image quality, etc., so that the extraction of table attribute information can be effectively applied to complex table scenarios, such as cross-page table scenarios. By limiting the target adjacent table to include a first table in a first image and a second table in a second image, the first image and the second image are adjacent in the target sequence arrangement, the first table is at the bottom of the first image, the second table is at the top of the second image, and no other page elements except table elements are included between the first table and the second table, here, the scenario in which the first table and the second table are cross-page tables is represented, and according to more accurate first table attribute information and second table attribute information, a target merged table corresponding to the target adjacent table is obtained by merging, so that the extraction accuracy and efficiency of the cross-page table can be improved, and the extraction complexity of the cross-page table can be effectively reduced.

[0081] In addition, first, the target adjacent table is obtained by performing table adjacency recognition based on OCR, and then the table attributes of the table in the target adjacent page corresponding to the target adjacent table are recognized based on the XML parsing technology, so that the XML parsing technology can only target the target adjacent page, avoiding XML parsing of non-cross-page table pages, and further improving the extraction efficiency of cross-page tables.

[0082] Reference Figure 3In an application example, in the docx document parsing process, OCR parsing and engineering parsing (parsing XML files) each have their own advantages. By parsing XML files, you can accurately obtain information such as rows, columns, cell sizes, cell merges and splits of the table, but usually does not contain specific location coordinates. The OCR method can identify the text in the image as editable text, and extract the location information of the table from the scanned document or image, but it is difficult to accurately describe the attribute characteristics of the table. Based on these analyses, the embodiment of this specification chooses to handle the extraction of cross-page tables by combining the two. For example, multiple pages in the target document can be converted into multiple pictures arranged in a target order. Then, the location information of adjacent tables (the first table and the second table) and the page elements between adjacent tables can be obtained through OCR. Therefore, it is possible to determine whether the first table and the second table are target adjacent tables, that is, to determine whether there are other page elements between the adjacent tables, and whether the ordinate of the last row of the previous table is lower than the ordinate of the first row of the next table (whether the page elements include other page elements except the table elements, and whether the first table in the first position is at the bottom of the first picture and the second position represents whether the second table is at the top of the second picture). If not, it is determined that it does not belong to a cross-page table and the table merging process is not performed. If so, the table attributes of the docx document can be extracted by calling Unioffice's XML parsing technology. Assuming that the previous adjacent table is table a (i.e., the first table) and the next one is table b (i.e., the second table), the table attributes obtained based on the XML parsing technology can be: the number of columns M, the first column width, and the bottom border attributes of the last row in table a of table a; the number of columns N, the second column width, and the top border attributes of the first row in table b of table b.

[0083] Furthermore, considering the scenario where there are merged cells in the table, the number of cell columns here needs to take merged cells into account. In the XML file, the "span" attribute can be used to indicate the number of cells that a cell spans in the row or column direction. The "span" attribute of the cell can be used to specify the span of the cell. The number of table columns can be calculated as follows:

[0084] Traverse the cells in the first row of the table,

[0085] If the cell property has no span, the number of columns + 1.

[0086] If the cell has a span, the number of columns + span.

[0087] Next, determine the relationship between M and N. If the number of columns M!=N, it means that table a and table b are not cross-page tables. Otherwise, you can continue to determine the column width.

[0088] Xml language usage <gridcol>Elements are used to define the width of table columns. By parsing the XML file and extracting <gridcol>The width attribute of the element is used to obtain the width of each column. Traverse each column of the table. If the corresponding column widths are inconsistent, it means that table a and table b are not cross-page tables, otherwise they are considered to be cross-page tables.

[0089] In addition, the border properties of table a and table b can be read separately. <border>Elements to describe borders can be found <border-bottom>and <border-top>element, and extract the corresponding attribute values ​​(such as border style (whether the border is empty), etc.). Based on this, it can be determined whether the bottom border attribute represents the bottom border of the last row (the bottom border of the cell in the last row) is empty, and whether the top border attribute represents the top border of the first row is empty. If either is not true, the tables can be merged, that is, there are no rows that span pages in the cross-page table. The header of table a can be directly used as the merged header, and then the rows other than the header row where the header of table a is located and the rows of table b are merged under the header to obtain the target merged table of the cross-page table.

[0090] If both are yes, that is, the bottom borders of the cells in the last row of table a are all empty, and the top borders of the first row of table b are all empty, then it is considered that the cells in the last row of table a and the cells in the first row of table b belong to the same cell, that is, there are rows that span pages in the cross-page table. At this time, you can choose the cell merging method, that is, you can first merge the cell contents of the corresponding columns of the last row of table a and the first row of table b to obtain a merged row; then merge the rows in the first table except the last row and the header row corresponding to the header, the merged rows, and the rows in the second table except the first row in turn under the header row to obtain the target merged table.

[0091] For example, refer to Figures 4 to 6 , Figure 4 For a cross-page table, Figure 5 Based on OCR recognition of cross-page tables, two tables are obtained, which is different from Figure 4 The table across pages is inconsistent, and Figure 5 Figure b in the figure cannot be understood because it has no header. Figure 4 In the question and answer of the table across pages, you cannot answer correctly Figure 5 The problem corresponding to Figure b in .

[0092] The target merged table obtained by using the cross-page table extraction method of the embodiment of this specification is as follows Figure 6 As shown, it is Figure 4 The cross-page table is consistent, and the content of each cell in the target merged table can be understood and answered correctly in the question and answer. Figure 7 As shown in the Q&A interface of the big model customer service, you can ask "What is the data description in 1-2xxxxx?", and the intelligent question-answering robot can reply "C22222", which is the same as Figure 4 The content of the table across two pages is consistent.

[0093] The cross-page table extraction method using the embodiment of this specification still has a high degree of recognition in complex table scenarios. XML files are usually generated by raw data rather than converted by optical character recognition. This means that the data in the XML file is more accurate and will not be affected by OCR recognition errors. By directly parsing the XML file, more accurate and reliable table data can be obtained. In addition, by parsing the XML file to obtain table attributes, there is no need to rely on OCR recognition, and thus there is no need to rely on the quality and diversity of the training data of the OCR algorithm, reducing the algorithm difficulty and maintenance cost of OCR recognition. It can also improve the accuracy of knowledge questions and answers for docx documents by large model customer service.

[0094] Figure 8 The present invention is a block diagram of a device for extracting a cross-page table in a target document according to an exemplary embodiment; the target document is a document based on the Extensible Markup Language. Figure 8 , the device may include:

[0095] The image conversion module 801 is used to convert the multiple pages in the target document into multiple images arranged in a target order; the target order refers to the page arrangement order of the multiple pages in the target document;

[0096] The adjacent table recognition module 803 is used to perform adjacency recognition on the tables in the multiple images based on the optical character recognition technology to obtain target adjacent tables; the target adjacent tables include a first table in the first image and a second table in the second image, the first image and the second image are adjacent in the target sequence arrangement, the first table is at the bottom of the first image, the second table is at the top of the second image, and no other page elements except table elements are included between the first table and the second table;

[0097] The table attribute recognition module 805 is used to perform table attribute recognition on the first table and the second table in the target adjacent page of the target document based on the extensible markup language parsing technology to obtain first table attribute information corresponding to the first table and second table attribute information corresponding to the second table; the target adjacent page is the first page corresponding to the first picture and the second page corresponding to the second picture;

[0098] The target merged table acquisition module 807 is used to merge the first table and the second table according to the first table attribute information and the second table attribute information to obtain a target merged table corresponding to the target adjacent table.

[0099] By using OCR technology to identify target adjacent tables in multiple pages of a target document, and extracting table attribute information from target adjacent pages of a target document based on parsing XML technology, the recognition accuracy of target adjacent tables can be improved based on the recognition accuracy of table positions by OCR, and the extraction accuracy of table attribute information can be improved. Moreover, the recognition and extraction of table attribute information will not be affected by the complexity of table layout, text overlap, image quality, etc., so that the extraction of table attribute information can be effectively applied to complex table scenarios, such as cross-page table scenarios. By limiting the target adjacent table to include a first table in a first image and a second table in a second image, the first image and the second image are adjacent in the target sequence arrangement, the first table is at the bottom of the first image, the second table is at the top of the second image, and no other page elements except table elements are included between the first table and the second table, here, the scenario in which the first table and the second table are cross-page tables is represented, and according to more accurate first table attribute information and second table attribute information, a target merged table corresponding to the target adjacent table is obtained by merging, so that the extraction accuracy and efficiency of the cross-page table can be improved, and the extraction complexity of the cross-page table can be effectively reduced.

[0100] In addition, first, the target adjacent table is obtained by performing table adjacency recognition based on OCR, and then the table attributes of the table in the target adjacent page corresponding to the target adjacent table are recognized based on the XML parsing technology, so that the XML parsing technology can only target the target adjacent page, avoiding XML parsing of non-cross-page table pages, and further improving the extraction efficiency of cross-page tables.

[0101] In an optional implementation, the adjacent table identification module 803 may include:

[0102] A target image acquisition unit, configured to acquire a plurality of target images containing tables from the plurality of images based on the optical character recognition technology;

[0103] an adjacent picture pair screening unit, configured to screen out adjacent picture pairs that are adjacent in the target sequence arrangement from the plurality of target pictures, the adjacent picture pairs comprising the first picture and the second picture; in the target sequence arrangement, the first picture is before the second picture;

[0104] a table position and page element acquisition unit, configured to acquire a first position of a first table in the first picture, a second position of a second table in the second picture, and page elements between the first table and the second table in the adjacent picture pair;

[0105] An adjacent table identification unit is used to obtain the target adjacent table consisting of the first table and the second table if the page elements do not include other page elements except the table elements, and the first position represents that the first table is at the bottom of the first picture and the second position represents that the second table is at the top of the second picture.

[0106] In an optional implementation, the first table attribute information includes a first number of columns and a first column width corresponding to each column; the target merged table acquisition module 807 may include:

[0107] A target merged table acquisition unit is used to determine that the target adjacent table is a cross-page table when the first number of columns is the same as the second number of columns and the first column width is sequentially the same as the corresponding second column width, merge the first table and the second table, and obtain a target merged table corresponding to the target adjacent table.

[0108] In an optional implementation, the table attribute identification module 805 may include:

[0109] A table attribute identification unit is used to sequentially traverse each column in the first table according to the direction of the rows in the first table, identify the column attributes of the first table based on the parsing extensible markup language technology, and obtain the first number of columns and the first column width; and sequentially traverse each column in the second table according to the direction of the rows in the second table, identify the column attributes of the second table based on the parsing extensible markup language technology, and obtain the second number of columns and the second column width.

[0110] In an optional implementation, the table attribute identification unit is also used to traverse each column in the first table in sequence in the direction of the rows in the first table. If there are merged cells in the traversed target column, the number of cells merged by the merged cells is increased based on the current counted column number; if there are no merged cells in the traversed target column, the number of cells merged by the merged cells is increased by 1 based on the current counted column number; until the last column is traversed to obtain the first column number.

[0111] In an optional implementation, the first table attribute information also includes the bottom border attributes of the last row in the first table; the second table attribute information also includes the top border attributes of the first row in the second table; the target merged table acquisition unit is further used to merge the first table and the second table according to the bottom border attributes and the top border attributes to obtain a target merged table corresponding to the target adjacent table.

[0112] In an optional implementation manner, the merge table acquisition unit may include:

[0113] A header determination subunit, configured to use the header of the first table as the header of the merged table;

[0114] A row merging subunit, used for merging cells of the last row and the first row to obtain a merged row when the bottom border attribute indicates that the bottom border of the last row is empty and the top border attribute indicates that the top border of the first row is empty;

[0115] The merged table acquisition subunit is used to merge the rows in the first table except the last row and the header row corresponding to the header, the merged row, and the rows in the second table except the first row in sequence under the header row to obtain the target merged table.

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

[0117] Fig. 9 is a block diagram of an electronic device for extracting a cross-page table in a target document according to an exemplary embodiment. The electronic device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig. 9 As shown. The electronic device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for extracting a cross-page table in a target document is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0118] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0119] Fig.10 The block diagram of an electronic device for extracting a cross-page table in a target document is shown based on an exemplary embodiment. The electronic device may be a server, and its internal structure diagram may be as shown in FIG. Fig.10 As shown. The electronic device includes a processor, a memory and a network interface connected via a system bus. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for extracting a cross-page table in a target document is implemented.

[0120] Those skilled in the art will understand that Fig.10 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0121] In an exemplary embodiment, an electronic device is also provided, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement a method for extracting a cross-page table in a target document as in an embodiment of the present application.

[0122] In an exemplary embodiment, a computer-readable storage medium is also provided, and when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method for extracting a cross-page table in a target document in an embodiment of the present application. The computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.

[0123] In an exemplary embodiment, a computer program product containing instructions is also provided. When the computer program product is run on a computer, the computer executes the method for extracting a cross-page table in a target document in an embodiment of the present application.

[0124] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0125] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0126] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims. < / border> < / gridcol> < / gridcol>

Claims

1. A method for extracting a cross-page table in a target document, characterized in that: The target document is a document based on extensible markup language; the method comprises: Converting multiple pages in the target document into multiple images arranged in a target order; the target order refers to the order in which the multiple pages are arranged in the target document; Based on the optical character recognition technology, the tables in the multiple images are identified for adjacency to obtain target adjacent tables; the target adjacent tables include a first table in a first image and a second table in a second image, the first image and the second image are adjacent in the target sequence arrangement, the first table is at the bottom of the first image, the second table is at the top of the second image, and no other page elements except table elements are included between the first table and the second table; Based on the extensible markup language parsing technology, table attributes of the first table and the second table in the target adjacent page of the target document are identified to obtain first table attribute information corresponding to the first table and second table attribute information corresponding to the second table; the target adjacent page is a first page corresponding to the first picture and a second page corresponding to the second picture; The first table and the second table are merged according to the first table attribute information and the second table attribute information to obtain a target merged table corresponding to the target adjacent table.

2. The method according to claim 1, characterized in that The method of performing adjacency recognition on the tables in the plurality of images based on the optical character recognition technology to obtain a target adjacent table includes: Acquire multiple target images containing tables from the multiple images based on the optical character recognition technology; Filtering out, from the plurality of target pictures, a pair of adjacent pictures that are adjacent in the target sequence arrangement, the pair of adjacent pictures comprising the first picture and the second picture; in the target sequence arrangement, the first picture is before the second picture; Acquire a first position of a first table in the first picture, a second position of a second table in the second picture, and a page element between the first table and the second table in the adjacent picture pair; If the page elements do not include other page elements except table elements, and the first position represents that the first table is at the bottom of the first picture and the second position represents that the second table is at the top of the second picture, the target adjacent table consisting of the first table and the second table is obtained.

3. The method according to claim 1, characterized in that The first table attribute information includes a first number of columns and a first column width corresponding to each column; the second table attribute information includes a second number of columns and a second column width corresponding to each column; and merging the first table and the second table according to the first table attribute information and the second table attribute information to obtain a target merged table corresponding to the target adjacent table includes: When the first number of columns is the same as the second number of columns, and the first column width is sequentially the same as the corresponding second column width, the target adjacent table is determined to be a cross-page table, and the first table and the second table are merged to obtain a target merged table corresponding to the target adjacent table.

4. The method according to claim 3, characterized in that The step of performing table attribute recognition on the first table and the second table in the target page pair of the target document based on parsing the extensible markup language technology to obtain first table attribute information corresponding to the first table and second table attribute information corresponding to the second table includes: Traversing each column in the first table in sequence according to the direction of the rows in the first table, identifying column attributes of the first table based on the parsing extensible markup language technology, and obtaining the first number of columns and the first column width; Each column in the second table is traversed in sequence according to the direction of the rows in the second table, and column attributes of the second table are identified based on the parsing extensible markup language technology to obtain the second number of columns and the second column width.

5. The method according to claim 4, characterized in that The step of traversing each column in the first table in sequence according to the direction of the rows in the first table, and identifying column attributes of the first table based on the parsing extensible markup language technology to obtain the first number of columns includes: According to the direction of the rows in the first table, each column in the first table is traversed sequentially. If there are merged cells in the traversed target column, the number of cells merged by the merged cells is increased based on the current number of counted columns; if there are no merged cells in the traversed target column, the number of cells merged by the merged cells is increased by 1 based on the current number of counted columns; until the last column is traversed, the first number of columns is obtained.

6. The method according to claim 3, characterized in that The first table attribute information further includes a bottom border attribute of the last row in the first table; the second table attribute information further includes a top border attribute of the first row in the second table; and the merging of the first table and the second table to obtain a target merged table corresponding to the target adjacent table includes: The first table and the second table are merged according to the bottom border attribute and the top border attribute to obtain a target merged table corresponding to the target adjacent table.

7. The method according to claim 6, characterized in that The step of merging the first table and the second table according to the bottom border attribute and the top border attribute to obtain a target merged table corresponding to the target adjacent table includes: Using the header of the first table as the header of the merged table; When the bottom border attribute indicates that the bottom border of the last row is empty, and the top border attribute indicates that the top border of the first row is empty, merging cells of the last row and the first row to obtain a merged row; The rows in the first table except the last row and the header row corresponding to the header, the merged row, and the rows in the second table except the first row are merged in sequence below the header row to obtain the target merged table.

8. A device for extracting a cross-page table in a target document, characterized in that: The target document is a document based on extensible markup language; the device comprises: An image conversion module is used to convert multiple pages in the target document into multiple images arranged in a target order; the target order refers to the page arrangement order of the multiple pages in the target document; an adjacent table recognition module, configured to perform adjacency recognition on tables in the plurality of images based on an optical character recognition technology to obtain a target adjacent table; the target adjacent table comprises a first table in a first image and a second table in a second image, the first image and the second image are adjacent in the target sequence arrangement, the first table is at the bottom of the first image, the second table is at the top of the second image, and no other page elements except table elements are included between the first table and the second table; a table attribute recognition module, configured to perform table attribute recognition on the first table and the second table in a target adjacent page of the target document based on parsing extensible markup language technology, and obtain first table attribute information corresponding to the first table and second table attribute information corresponding to the second table; the target adjacent page is a first page corresponding to the first picture and a second page corresponding to the second picture; The target merged table acquisition module is used to merge the first table and the second table according to the first table attribute information and the second table attribute information to obtain a target merged table corresponding to the target adjacent table.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method for extracting a cross-page table in a target document as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method for extracting a cross-page table in a target document as described in any one of claims 1 to 7.

11. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, enable the computer to execute the method for extracting a cross-page table in a target document as claimed in any one of claims 1 to 7.

Citation Information

Cited By

  • File cross-page table restoration method and device

    CN122176735A

  • Method and device for extracting table in image, computer readable medium and electronic equipment

    CN122313502A