Method, device and equipment for retrieving table in file, medium and product

By extracting complete and incomplete tables from the file, merging cross-page tables when necessary, and performing semantic retrieval based on subject words and search keywords, the problem of accuracy and comprehensiveness in table retrieval in the file is solved and improved. to ensure the accuracy and reliability of search results.

CN118550880APending Publication Date: 2024-08-27PICC INFORMATION TECH CO LTD

Patent Information

Application Number
CN202410800006.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

The existing technology has problems of poor accuracy and comprehensiveness in table retrieval in documents. In particular, due to the limited recognition effect of tables with incomplete frames, the extracted tables are incomplete and affect the accuracy of the retrieval results.

Method used

By receiving the table retrieval request in the target file, the text position information is obtained to extract the complete and incomplete tables, and merged when there are cross-page situations. The subject words of each table are determined for semantic retrieval, combining the subject words and Search keywords for table search.

Benefits of technology

It ensures the comprehensiveness and completeness of the table, improves the accuracy and reliability of the search results, avoids erroneous extraction caused by splitting the same table, and enhances the accuracy of table retrieval in the file.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550880A
    Figure CN118550880A
Patent Text Reader

Abstract

The invention provides a method, device and equipment for retrieving a table in a file, a medium and a product, and relates to the field of artificial intelligence. The method comprises the following steps: receiving a retrieval request of a table in a target file; obtaining multiple pieces of text position information in the target file according to the retrieval request and extracting a first type table, wherein the first type table is a table with complete frame lines; extracting a second type table according to the text position information, wherein the second type table is a table with incomplete frame lines; if at least one of the first type of table and the second type of table has a cross-page condition, merging the tables having the cross-page condition to obtain a merged table; determining a subject term corresponding to each table, wherein each table comprises a combined table, a first type table and a second type table, wherein the first type table and the second type table are not combined; and retrieving each table according to the subject term and the retrieval keyword to obtain a target table. According to the method, the table retrieval method is enriched, and the accuracy and comprehensiveness of table retrieval in the file are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence, and in particular to a method, device, equipment, medium and product for table retrieval in a document. Background Art

[0002] The table has a simple structure and clear separation and summary. It is suitable for displaying large amounts of information content and key data. It is a simple, effective and intuitive form of data presentation. Users can quickly obtain the required information by browsing the table. Therefore, if you want to obtain the required information from a large number of files, retrieving the table is a very quick way.

[0003] Currently, most methods of retrieving tables are to first extract the table from the file, then calculate the repetition rate between the search keyword and the row and column names of the extracted table, and output the table corresponding to the row and column names with the highest repetition rate of the search keyword as the result.

[0004] However, the row and column names of the table in the file may be the same or similar. The accuracy of the retrieved table is low by simply comparing the repetition rate of the search keywords and the row and column names. In addition, the recognition effect of the table with incomplete borders in the prior art is limited, and the extracted table is not all the tables in the file, resulting in the final result being incomplete, which indirectly reduces the accuracy of the search results. Summary of the invention

[0005] The present application provides a method, apparatus, device, medium and product for table retrieval in a document, so as to solve the technical problem of poor accuracy and comprehensiveness of table retrieval in a document.

[0006] In a first aspect, the present application provides a method for table retrieval in a document, the method comprising:

[0007] receiving a search request for a table in a target file, the search request including the target file and a search keyword;

[0008] Acquire multiple text position information in the target file according to the search request and extract a first type of table, where the first type of table is a table with complete frame lines;

[0009] Extracting a second type of table according to the text position information, where the second type of table is a table with incomplete frame lines;

[0010] If at least one of the first type table and the second type table spans across pages, merging the table spanning across pages to obtain a merged table;

[0011] Determine a subject word corresponding to each table, wherein each table includes a merged table and an unmerged first-type table and a second-type table;

[0012] The tables are searched according to the subject words and the search keywords to obtain a target table.

[0013] In a possible design, the obtaining of multiple text position information in the target file includes:

[0014] Obtaining text content in the target file;

[0015] Generate multiple text boxes according to the text content of each line, and determine the coordinates of four vertices of the multiple text boxes;

[0016] The four vertex coordinates of each of the text boxes are determined as corresponding text position information.

[0017] In a possible design, obtaining the text content in the target file includes:

[0018] Extracting character features of each page in the target file;

[0019] Matching the character features with a preset character template to identify the character;

[0020] The characters are converted into corresponding text contents to obtain the text contents in the target file.

[0021] In a possible design, extracting the first type of table includes:

[0022] Determine the position and length of the table border in the target file;

[0023] Determine the cell position information in the table according to the position and length of the table frame line;

[0024] Determine the text content corresponding to each cell according to the text position information and the cell position information;

[0025] The corresponding text contents in the cells are filled into the corresponding cells to extract the first type table.

[0026] In a possible design, extracting the second type of table according to the text position information includes:

[0027] Determining the number of spaces in a line of text content, the line of text content not including text content included in the first type of table, the line of text content being located in the target file;

[0028] Calculate the mean of the horizontal coordinates of the texts between the spaces;

[0029] Determining text content corresponding to the second type table according to the number of spaces and the mean;

[0030] The corresponding text content is filled into a corresponding table according to the text position information to extract a second type table.

[0031] In a possible design, determining the text content corresponding to the second type table according to the number of spaces and the mean value includes:

[0032] If there are two or more lines of text content that meet the preset conditions, the text content that meets the preset conditions will be determined as the text content corresponding to the second type of table, and the preset conditions are: the lines of text content all contain two or more spaces, and the average values ​​of the horizontal coordinates of the text between the spaces are equal.

[0033] In a possible design, identifying that at least one of the first type of table and the second type of table has a cross-page situation includes:

[0034] For each page in the target file, perform the following operations in sequence:

[0035] Determine whether the table included in the current page is at the beginning of the current page; the table included in the current page is a first type table or a second type table;

[0036] If so, determine whether the table contained on the previous page is the end of the previous page;

[0037] If yes, determining whether the frames of the table included in the current page and the table included in the previous page are the same;

[0038] If so, it is determined that the table on the current page spans across pages.

[0039] In a possible design, determining whether the table included in the current page is at the beginning of the current page includes:

[0040] Determine whether the first line of text content in the table contained in the current page is the same as the first line of text content in the current page;

[0041] If they are different, determining whether the first line of text content in the table contained in the current page is the same as the second line of text content in the current page;

[0042] If they are the same, it is determined that the table contained in the current page is at the beginning of the current page.

[0043] In a possible design, before determining the subject words corresponding to each table, the method further includes:

[0044] The target text content corresponding to each table is extracted, wherein the target text content includes the three lines of text content before each table and the row and column names of each table.

[0045] In a possible design, determining the subject words corresponding to each table includes:

[0046] The topic extraction model is used to extract topic words from the target text content corresponding to each table.

[0047] In a possible design, searching the tables according to the subject words and the search keywords to obtain the target table includes:

[0048] Creating a subject word list corresponding to each table, wherein the subject word list corresponding to each table is used to store the subject words and search keywords corresponding to each table;

[0049] Calculating the Normalized Pointwise Mutual Information (NPMI) values ​​of the subject words corresponding to each table and the search keywords in the subject word list corresponding to each table to obtain multiple NPMI values;

[0050] The multiple NPMI values ​​are sorted from large to small and the table corresponding to the NPMI value ranked first is output to obtain a target table.

[0051] In a second aspect, the present application provides a device for searching a table in a document, the device comprising:

[0052] An acquisition module, used for acquiring multiple text position information in the target file according to the search request;

[0053] An extraction module, used for extracting a first type of table, where the first type of table is a table with complete frame lines;

[0054] The extraction module is further used to extract a second type of table according to the text position information, where the second type of table is a table with incomplete frame lines;

[0055] a merging module, configured to merge the tables that cross pages if at least one of the first type table and the second type table crosses pages, so as to obtain a merged table;

[0056] A determination module, used to determine the subject words corresponding to each table, wherein each table includes a first type table and a second type table after merging and an unmerged first type table;

[0057] The search module is used to search the tables according to the subject words and the search keywords to obtain a target table.

[0058] In a third aspect, the present application provides a device for searching a table in a document, comprising: a processor, and a memory and an input device in communication with the processor;

[0059] The memory stores computer-executable instructions;

[0060] The input device is used to receive a search request for a table in a target file, wherein the search request includes the target file and a search keyword;

[0061] The processor executes the computer-executable instructions stored in the memory to implement the method according to the first aspect.

[0062] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect.

[0063] In a fifth aspect, the present application provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.

[0064] The present application provides a method, apparatus, device, medium and product for table retrieval in a file, which receives a retrieval request for a table in a target file, wherein the retrieval request includes a target file and a retrieval keyword; obtains multiple text position information in the target file according to the retrieval request and extracts a first type of table, wherein the first type of table is a table with complete borders; extracts a second type of table according to the text position information, wherein the second type of table is a table with incomplete borders; if at least one of the first type of table and the second type of table crosses pages, merges the tables with cross-pages to obtain a merged table; determines the subject words corresponding to each table, wherein each table includes a merged table and unmerged first type of table and second type of table; and retrieves each table according to the subject words and the retrieval keyword to obtain a target table. After receiving the search request, the table with complete borders is extracted from the target file according to the search request, and multiple text position information is obtained. Then, it is possible to determine which texts are in the table based on the text position information, thereby extracting the table with incomplete borders. In this way, all tables in the file are extracted, ensuring the comprehensiveness of the table and making the search results more reliable. If there are cross-page situations in the extracted tables, the tables with cross-page situations are merged to ensure the integrity of the tables and avoid the same table being split into two, which affects the final search results. Finally, the subject words of each table are determined, and the table is searched based on the subject words and search keywords. The subject words are determined in combination with the semantic context and are used to reflect the words expressed in each table. Then, when searching the table, the target table can be obtained in combination with the semantic context, rather than just comparing the repetition rate of the search keywords and the table row and column names. This not only enriches the table search method, but also improves the accuracy of the table search in the file. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0066] Figure 1 An application scenario diagram of the table retrieval method in the document provided in this application;

[0067] Figure 2 A flowchart of a method for table retrieval in a file provided in an embodiment of the present application;

[0068] Figure 3 A flowchart of a method for table retrieval in a file provided in another embodiment of the present application;

[0069] Figure 4 A schematic diagram of the structure of a table search device in a document provided in an embodiment of the present application;

[0070] Figure 5 A schematic diagram of the structure of a device for searching a table in a document provided in an embodiment of the present application.

[0071] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0072] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0073] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.

[0074] At present, the technologies used to retrieve tables from files include computer vision technology, deep neural network positioning technology, etc. For example, computer recognition technology is used to convert the text in the file into editable text, identify the table structure in the file, and integrate the table content to obtain a complete table. The repetition rate is calculated based on the search keywords and the row and column names of each table, and the table corresponding to the row and column name with the highest repetition rate of the search keyword is output as the result. However, the row and column names of the table in the file may be the same or similar. The accuracy of the retrieved table is low by simply comparing the repetition rate of the search keywords and the row and column names. In addition, the recognition effect of the table with incomplete frame lines in the prior art is limited, and the extracted table is not all the tables in the file, resulting in the final result not being comprehensive, which indirectly reduces the accuracy of the search results.

[0075] Therefore, when facing the technical problems in the prior art, in order to extract all the tables in the file, in addition to extracting the tables with complete borders, it is also necessary to extract the tables with incomplete borders. Since the table structure cannot be identified due to incomplete borders, the text position information can be used to determine which texts belong to the text in the table, thereby extracting the tables with incomplete borders to ensure the comprehensiveness of the extracted tables; in order to make each extracted table complete, it is necessary to determine whether the table crosses pages, and merge the tables that cross pages to avoid the same table being split into two, affecting the final search results; since the row and column names of the tables in the file may be the same or similar, the accuracy of the target table obtained by comparing the repetition of the search keywords and the row and column names is low. In order to improve the accuracy of the search results, the table can be subjected to subject word extraction. The subject words are determined in combination with the semantic context, so the target table can be retrieved by taking into account the semantics of the subject words and the search keywords, which not only enriches the table search method, but also improves the accuracy of the table search results.

[0076] Figure 1 This is an application scenario diagram that can implement the method for table retrieval in the document provided by this application, such as Figure 1 As shown, the scenario diagram corresponding to the method for table retrieval in a file provided by the present application includes: a terminal device 101 and a server 102. The table retrieval device in a file can be integrated in the server 102, wherein the server is a form of the table retrieval device in a file, and the table retrieval device in a file can also be in other forms, which is not limited in this embodiment.

[0077] Specifically, the user may initiate a table search request in the target file through the terminal device 101, and the server 102 obtains multiple text position information in the target file according to the search request and extracts the first type of table, and then extracts the second type of table according to the text position information; after extracting the first type of table and the second type of table, the server 102 determines whether there is a table cross-page situation in the extracted table, and if so, merges the tables with cross-page situation to obtain a merged table; after obtaining all the final tables, the server 102 determines the subject words corresponding to each table, and searches each table according to the subject words and search keywords, and sends a table search response in the file to the terminal device 101. The table search response in the file includes the target table, so that the user can view the content included in the target table.

[0078] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0079] It should be noted that the method for table retrieval in a file provided in the present application is mainly aimed at extracting tables from image files of various formats, for example, files in Portable Document Format (PDF).

[0080] Figure 2 A flowchart of a method for table retrieval in a file provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the execution subject of this embodiment is a table retrieval device in a file, which can be implemented by a computer program, or by a medium storing relevant computer programs, such as a USB flash drive and / or an optical disk, or by a physical device integrated or installed with relevant computer programs, such as a chip or a table retrieval device in a file. The table retrieval device in a file can be a server, a server cluster, etc. The method for table retrieval in a file provided in this embodiment includes the following steps:

[0081] Step 201: receiving a search request for a table in a target file, wherein the search request includes the target file and search keywords.

[0082] The target file refers to the file from which the table needs to be retrieved, and the target file may be in PDF format, jpg format, or png format, which is not limited in this embodiment. One or more target files may be input at a time, which is not limited in this embodiment.

[0083] Among them, the search keyword is a word used to retrieve a table from a file, and is a word with semantics close to the required table content. The search keyword can be one or more, and the user can decide according to the actual situation. This embodiment does not limit this.

[0084] Specifically, the user can input the target file and search keywords through the terminal device to initiate a search request, so that the table search device in the file receives the search request for the table in the target file and starts subsequent work.

[0085] Step 202: acquiring multiple text position information in the target file according to the search request and extracting a first type of table, where the first type of table is a table with complete borders.

[0086] Among them, a table with complete border lines refers to a table whose border lines are continuous and closed, without any breaks or missing parts.

[0087] The text position information may include the position index of each line of text, the position coordinates of the target sentence text, and the page number of the target sentence text; it is understandable that each line of text may contain the position coordinates of multiple target sentence texts.

[0088] The position index may be a numerical value numbered sequentially from 0, such as 0, 1, and 2.

[0089] Among them, the target sentence text is a sentence obtained after dividing the target file according to a preset division rule; the preset division rule can be starting with the first character and ending with a semicolon, a period, a space, etc., and dividing the target file in sequence to obtain multiple target sentence texts; the position coordinates of the target sentence text can be the position coordinates of the character at the beginning of the sentence and the position coordinates of the character at the end of the sentence.

[0090] Specifically, after receiving the search request, optical character recognition (OCR) technology is used to identify the text in the target file, and the text is converted into editable text, a position index for each line of text is generated, and then the text in the target file is divided according to a preset division rule, and the position coordinates of the target sentence text and the page number of the target sentence text are output to obtain multiple text position information in the target file; OCR technology can also detect the frame structure of the table, and fill the text into the corresponding table according to the obtained text position information to extract the first type of table.

[0091] Step 203: extracting a second type of table according to the text position information, where the second type of table is a table with incomplete frame lines.

[0092] Among them, a table with incomplete borders refers to a table with missing borders or no borders.

[0093] Specifically, since some table frames are incomplete and the table cannot be extracted by detecting the table frame structure, a preset rule for extracting the second type of table according to the text position information is configured to extract the second type of table. Among them, the preset rule can be to compare the text position information of each line of text. If the difference values ​​of the horizontal coordinates of multiple text positions in the same line are equal, and two or more consecutive lines of text contain the above situation, and the mean values ​​of the horizontal coordinates of the text positions of each line are also equal, then the text that meets the above conditions is determined as the text corresponding to the second type of table, and it is filled into the corresponding position of the table according to the text position information and output, so as to extract the second type of table.

[0094] It is understandable that the preset rule may also be other rules, which is not limited in this embodiment.

[0095] Step 204: If at least one of the first type table and the second type table spans across pages, the table spanning across pages is merged to obtain a merged table.

[0096] The cross-page situation refers to the same table being split and placed on two consecutive pages.

[0097] Specifically, after extracting the first type of table and the second type of table, all the tables in the target file are extracted. At this time, the extracted tables may have cross-page situations. It is necessary to determine whether there is a cross-page situation in the extracted tables. If so, the tables with cross-page situations are merged to obtain a merged table.

[0098] Among them, judging whether there is a page span in the extracted table can be based on the text position coordinates of the starting row and the ending row of each table to determine whether it is the beginning or the end of the current page. If the tables in two consecutive pages are the end and the beginning of the page respectively, then compare whether the frame line structures of the two tables are the same. If they are the same, it is determined that the table spans pages.

[0099] It is understandable that other methods may be used to determine whether there is a cross-page situation in the extracted table, and this embodiment does not limit this.

[0100] Step 205 , determining the subject words corresponding to each table, wherein each table includes the merged table and the unmerged first type table and second type table.

[0101] Among them, the subject words corresponding to each table refer to the words used to generally describe the core content of the table, and each table has corresponding subject words; the number of subject words can be one or more, which can be determined according to actual conditions, and this embodiment does not limit this.

[0102] It is understandable that before determining the subject words corresponding to each table, it is necessary to determine the subject word extraction text corresponding to each table. To ensure that the subject words can accurately summarize the content contained in each table, the text used to describe the content of each table can be determined as the text for subject word extraction for each table.

[0103] Specifically, the trained topic extraction model is used to extract topic words from the topic word extraction text corresponding to each table. For example, the Latent Dirichlet Allocation (LDA) model will generate a word distribution for each topic, that is, the words that are most likely to appear under each topic. The words with the highest repetition rate in the topic word extraction text corresponding to each table and the word distribution are determined as the topic words corresponding to each table.

[0104] It is understandable that other methods may be used to determine the subject words corresponding to each table, and this embodiment does not limit this.

[0105] Step 206, searching each table according to the subject word and the search keyword to obtain the target table.

[0106] Specifically, the similarity between the subject words corresponding to each table and the search keyword is calculated, such as calculating the Euclidean distance, and the table corresponding to the subject word with the highest similarity to the search keyword is determined as the target table.

[0107] It is understandable that other calculation methods may also be used to search based on subject words and search keywords to obtain the target table, and this embodiment does not limit this.

[0108] The method for table retrieval in a file provided in the present embodiment receives a retrieval request for a table in a target file, the retrieval request includes the target file and a retrieval keyword; obtains multiple text position information in the target file according to the retrieval request and extracts a first type of table, the first type of table is a table with complete borders; extracts a second type of table according to the text position information, the second type of table is a table with incomplete borders; if at least one of the first type of table and the second type of table crosses pages, merges the tables with cross pages to obtain a merged table; determines the subject words corresponding to each table, each table includes the merged table and the unmerged first type of table and the second type of table; and retrieves each table according to the subject words and the retrieval keyword to obtain a target table. After receiving the search request, the table with complete borders is extracted from the target file according to the search request, and multiple text position information is obtained. Then, it is possible to determine which texts are in the table based on the text position information, thereby extracting the table with incomplete borders. In this way, all tables in the file are extracted, ensuring the comprehensiveness of the table and making the search results more reliable. If there are cross-page situations in the extracted tables, the tables with cross-page situations are merged to ensure the integrity of the tables and avoid the same table being split into two, which affects the final search results. Finally, the subject words of each table are determined, and the table is searched based on the subject words and search keywords. The subject words are determined in combination with the semantic context and are used to reflect the words expressed in each table. Then, when searching the table, the target table can be obtained in combination with the semantic context, rather than just comparing the repetition rate of the search keywords and the table row and column names. This not only enriches the table search method, but also improves the accuracy of the table search in the file.

[0109] As an optional implementation, based on the above embodiment, multiple text position information in the target file is obtained, including:

[0110] Get the text content in the target file;

[0111] Generate multiple text boxes according to each line of text content, and determine the coordinates of four vertices of the multiple text boxes;

[0112] The coordinates of the four vertices of each text box are determined as the corresponding text position information.

[0113] Specifically, the text content in the target file is identified using OCR technology, and the identified text content is converted into editable text content and output to obtain the text content in the target file. Then, multiple text boxes are generated for each line of text content, and the end points of the generated text boxes are semicolons, periods, and spaces. The upper left corner of the current page is used as the origin to generate the coordinate values ​​of the four vertices of each text box, and the coordinates of the four vertices of the text box are output as the corresponding text position information.

[0114] Generating multiple text boxes for each line of text content may include: using a preset text processing tool to generate a text box for each line of text content, or using a string processing function of a programming language to generate text content containing a text box mark based on each line of text content.

[0115] The method for table retrieval in a file provided in this embodiment obtains multiple text position information in a target file, including: obtaining the text content in the target file; generating multiple text boxes according to each line of text content, and determining the four vertex coordinates of the multiple text boxes; determining the four vertex coordinates of each text box as the corresponding text position information. A text box is generated for each line of text content to ensure that the generated text box is not disordered and contains multiple lines of text content, which is convenient for the subsequent use of text box information; the four vertex coordinates of the text box are determined as the corresponding text position information, even for files with complex layouts, the text position information can be clearly and accurately expressed through the vertex coordinates of the text box, laying a solid position information foundation for subsequent table retrieval.

[0116] As an optional implementation manner, based on the above embodiment, obtaining the text content in the target file includes:

[0117] Extract character features of each page in the target file;

[0118] Matching character features with preset character templates to recognize characters;

[0119] Convert characters to corresponding text contents to obtain the text contents in the target file.

[0120] Among them, character features include the shape, size, color, and edge information of the characters.

[0121] The preset character template is a character template pre-configured in the OCR system, which contains characters corresponding to various character features and is used to recognize the text content in the target file.

[0122] Specifically, pixel analysis is performed on each page in the target file to extract information such as the color and brightness of each pixel. Based on the pixel information, features such as the shape, outline, and color of the character can be extracted. The extracted character features are searched in a preset character template, and the corresponding characters are determined based on the corresponding relationship in the template to identify the characters. Finally, the characters are converted into editable text content to obtain the text content in the target file.

[0123] The method for table retrieval in a file provided in this embodiment obtains the text content in the target file, including: extracting character features of each page in the target file; matching the character features with a preset character template to identify the characters; converting the characters into corresponding text content to obtain the text content in the target file. Extracting character features provides sufficient information for subsequent character recognition, thereby improving the accuracy of character recognition; matching with a preset character template saves processing time, and the character template can also be adjusted as needed to adapt to different files; converting characters into corresponding text content makes the text content easy to edit and retrieve.

[0124] As an optional implementation, based on the above embodiment, extracting the first type of table includes:

[0125] Determine the position and length of the table border in the target file;

[0126] Determine the cell position information in the table according to the position and length of the table border;

[0127] Determine the corresponding text content in each cell according to the text position information and the cell position information;

[0128] The corresponding text content in each cell is filled into the corresponding cell to extract the first type table.

[0129] The cell location information may be the boundary coordinates of the cell.

[0130] Specifically, OCR technology is used to detect table frame lines in the target file, and the position coordinates and length values ​​of each frame line are output. The table frame lines are integrated according to the position and length, and the line segment intersection method is used to calculate the intersection points. The number of intersection points at different vertical positions is determined as the number of rows, and the number of intersection points at different horizontal positions is determined as the number of columns. Cells are identified based on the row and column positions, and the boundary coordinates of the cells are output as the cell position information. According to the acquired text position information and the boundary coordinates of the cells, the corresponding text content in each cell is determined, and the text content is filled into the corresponding cell and output to extract the first type of table.

[0131] It is understandable that the corresponding table information will also be output, including the number of rows, columns, cell merge information, and row and column names.

[0132] The method for table retrieval in a file provided in this embodiment extracts a first type of table, including: determining the position and length of the table frame line in the target file; determining the cell position information in the table according to the position and length of the table frame line; determining the corresponding text content in each cell according to the text position information and the cell position information; and filling the corresponding text content in each cell into the corresponding cell to extract the first type of table. According to the position and length of the table frame line, the structure and cell position information of the table can be accurately determined, and the text content corresponding to the table can be determined by the text position information and the cell position information, so as to ensure the consistency with the table content in the original file.

[0133] As an optional implementation manner, based on the above embodiment, extracting the second type of table according to the text position information includes:

[0134] determining the number of spaces in a row of text content, the row of text content excluding text content contained in a first type of table, the row of text content being located in a target file;

[0135] Calculate the mean of the horizontal coordinates of the text between spaces;

[0136] Determine the text content corresponding to the second type of table according to the number of spaces and the mean value;

[0137] The corresponding text content is filled into the corresponding table according to the text position information to extract the second type table.

[0138] It is understandable that, since the first type of table has been extracted, it is not necessary to process the text content contained in the first type of table when determining the number of spaces, thus saving retrieval time.

[0139] Specifically, OCR technology can directly identify the position of spaces, determine the number of spaces in each line of text content in units of lines, calculate the mean of the horizontal coordinates of the text position corresponding to the text content between two spaces in each line of text, and after obtaining the number of spaces and the mean, determine whether the number of spaces in each line of text content is greater than a preset value and whether the means are equal. If the above two conditions are met at the same time, the corresponding text content can be determined as the text content in the second type of table, and the corresponding text content can be filled into the corresponding table according to the text position information to extract it into the second type of table.

[0140] Among them, the preset value can be pre-configured in the table retrieval device in the file, such as 2, 3, etc.

[0141] The method for table retrieval in a file provided in this embodiment extracts a second type of table according to text position information, including: determining the number of spaces in the text content of a row, the text content of the row does not include the text content contained in the first type of table, and the text content of the row is located in the target file; calculating the mean of the horizontal coordinates of the text between the spaces; determining the text content corresponding to the second type of table according to the number of spaces and the mean; filling the corresponding text content into the corresponding table according to the text position information to extract the second type of table. For a table with incomplete frame lines, the frame lines cannot be directly identified for extraction, and the number of spaces is determined to determine whether the text content has a spacing similar to the text content in the table; the text content between the upper and lower lines is determined by calculating the mean of the horizontal coordinates of the text to determine whether the text content between the upper and lower lines is aligned similar to the text content of the upper and lower lines in the table, thereby determining the text content corresponding to the second type of table to extract the second type of table, so that all types of tables can be extracted from the file, ensuring the accuracy and comprehensiveness of the tables extracted from the file, and indirectly improving the accuracy of the retrieved table.

[0142] As an optional implementation, based on the above embodiment, determining the text content corresponding to the second type of table according to the number and average of spaces includes:

[0143] If there are two or more lines of text content that meet the preset conditions, the text content that meets the preset conditions will be determined as the text content corresponding to the second type of table. The preset conditions are: the line text content contains two or more spaces, and the average values ​​of the horizontal coordinates of the text between the spaces are equal.

[0144] Specifically, after obtaining the number of spaces and the mean horizontal coordinate of the text, if there are two or more lines of text content that contain two or more spaces, it means that these text contents may be in cells such as the text contents in the table, so there are gaps between the text contents, and then compare whether the mean horizontal coordinates of the texts between the spaces are equal. If they are equal, it means that the text positions corresponding to these rows of text contents are aligned in the upper and lower lines. Then the text content that meets the above conditions can be determined as the text content corresponding to the second type of table.

[0145] The method for table retrieval in a file provided in this embodiment determines the text content corresponding to the second type of table according to the number and mean of spaces, including: if there are two or more lines of text content that meet the preset conditions, the text content that meets the preset conditions is determined as the text content corresponding to the second type of table, and the preset conditions are: the line text content contains two or more spaces, and the mean of the horizontal coordinates of the text between the spaces is equal. The text content of two or more lines that meet the preset conditions is determined as the text content corresponding to the second type of table to ensure the accuracy of the extraction results and avoid misidentifying a single line of text content as table text content; the preset conditions must simultaneously meet the number of spaces of two or more and the mean of the horizontal coordinates of the text between the spaces are equal, further improving the accuracy of table extraction; this method can adapt to tables of different sizes and layouts, and they can be identified as long as they meet the preset conditions. The preset conditions can also be flexibly adjusted according to actual needs to adapt to different application scenarios.

[0146] As an optional implementation, based on the above embodiment, identifying that at least one of the first type table and the second type table has a cross-page situation includes:

[0147] Perform the following operations for each page in the target file:

[0148] Determine whether the table included in the current page is the beginning of the current page; whether the table included in the current page is a first type table or a second type table;

[0149] If so, determine whether the table contained on the previous page is the end of the previous page;

[0150] If so, determine whether the frames of the table contained in the current page and the table contained in the previous page are the same;

[0151] If so, it is determined that the table on the current page spans across pages.

[0152] Specifically, after extracting the first type of table and the second type of table, it is necessary to identify whether there is a cross-page situation in the table, and identify each page in the target file in turn. First, determine whether the table contained in the current page is the beginning of the current page. If so, it means that the table may be the same table as a table in the previous page. Then find the previous page of the current page according to the row text index, and determine whether the table contained in the previous page is the end of the previous page. If so, it means that the two tables may be the same table. Finally, determine whether the frames of the above two tables are the same, that is, determine whether the number of columns and column names of the two tables are the same. If all the above conditions are met, it can be determined that the table on the current page crosses pages, and the two tables are merged.

[0153] It can be understood that if the result of any of the above judgment steps is no, it proves that there is no cross-page situation, and the current page table is saved.

[0154] Optionally, it is also possible to determine whether the first table on the current page is the beginning of the current page and whether the last table on the previous page is the end of the previous page, without determining all tables.

[0155] To determine whether the table is at the beginning of the current page, the coordinates of the top boundary line of the table can be compared with the boundary coordinates of the current page to determine whether it is the beginning of the current page, or other methods can be used to determine it, which is not limited in this embodiment.

[0156] Optionally, to determine whether the table is the end of the previous page, you can also use the method of comparing coordinates, or compare the last line of text content of the table with the last line of text content of the page to determine whether the contents are the same. If they are different, compare the last line of text content of the table with the second to last line of text content of the page. If they are the same, it can be determined that there is only page number content after the table, that is, the table is the end of the previous page; or use other methods to make a judgment, which is not limited to this embodiment.

[0157] It can be understood that after all tables are extracted, all extracted tables are checked, unnecessary line breaks and spaces are deleted, and the misidentified cells are integrated. If there is only one cell in a row containing text content, it is integrated to the end of the previous row, and blank rows and columns are deleted to obtain the final complete table.

[0158] The method for table retrieval in a file provided in this embodiment identifies that at least one of the first type table and the second type table has a cross-page situation, including: performing the following operations in sequence for each page in the target file: determining whether the table contained in the current page is the beginning of the current page; the table contained in the current page is the first type table or the second type table; if so, determining whether the table contained in the previous page is the end of the previous page; if so, determining whether the frames of the table contained in the current page and the table contained in the previous page are the same; if so, determining that the table on the current page has a cross-page situation. By determining whether the table is at the beginning of the current page, it is possible to accurately identify which tables may have a cross-page situation; then checking whether the table on the previous page is the end of the previous page, further improving the accuracy of cross-page table identification; finally checking whether the table frames are the same, it can be ensured that even on different pages, different parts of the same table can be correctly identified as belonging to the same table; correctly handling cross-page tables can ensure the integrity and accuracy of data, and avoid data loss or erroneous extraction caused by cross-page tables.

[0159] As an optional implementation, based on the above embodiment, determining whether the table included in the current page is the beginning of the current page includes:

[0160] Determine whether the first row of text in the table contained in the current page is the same as the first row of text in the current page;

[0161] If they are different, determine whether the first line of text in the table contained in the current page is the same as the second line of text in the current page;

[0162] If they are the same, it is determined that the table contained in the current page is at the beginning of the current page.

[0163] Specifically, extract the first line of text content of the table contained in the current page, compare it with the first line of text content of the current page, and compare whether the text contained in the two lines of text content is the same; if different, it means that there is other text content before the table, then compare the first line of text content of the table contained in the current page with the second line of text content of the current page, and compare whether the text contained in the two lines of text content is the same. If they are the same, it means that there is only header content before the table, so it is determined that the table is the beginning of the current page.

[0164] It is understandable that if the first line of text content of the table included in the current page is the same as the first line of text content of the current page, it can be directly determined that the table is the beginning of the current page.

[0165] The method for table retrieval in a file provided in this embodiment determines whether the table included in the current page is the beginning of the current page, including: determining whether the first line of text content in the table included in the current page is the same as the first line of text content in the current page; if different, determining whether the first line of text content in the table included in the current page is the same as the second line of text content in the current page; if the same, determining that the table included in the current page is the beginning of the current page. By determining whether the first line of text content in the table included in the current page is the same as the second line of text content in the current page, it can be preliminarily determined whether there is other text content before the table, and then determining whether the first line of text content in the table included in the current page is the same as the second line of text content in the current page, it can be determined whether there is only one line of text content before the table, that is, only the header content. This method can ensure that different types of tables can be effectively processed and improve the accuracy of judging the cross-page situation of the table.

[0166] As an optional implementation manner, based on the above embodiment, before determining the subject words corresponding to each table, the method further includes:

[0167] The target text content corresponding to each table is extracted, and the target text content includes the three lines of text content before each table and the row and column names of each table.

[0168] The target text content is used to extract the text content of the keywords of each table, and corresponds to each table one by one.

[0169] Specifically, the three lines of text content before each table are extracted according to the row text index, and merged with the row and column names of each table. Then, each text content is preprocessed, including word segmentation, stop word removal, stem extraction, part-of-speech tagging, etc. The preprocessed text content is used as the target text content corresponding to each table.

[0170] The method for table retrieval in a file provided in this embodiment, before determining the subject words corresponding to each table, also includes: extracting the target text content corresponding to each table, the target text content includes the three lines of text content before each table and the row and column names of each table. The text content before the table often briefly introduces the content and information contained in the table, so three lines of text content are selected from it and put into the target text content, so the subject words extracted from the target text content can more accurately summarize the table content, so that the retrieved table has a higher matching degree with the search keyword.

[0171] As an optional implementation, based on the above embodiment, determining the subject words corresponding to each table includes:

[0172] The topic extraction model is used to extract keywords from the target text content corresponding to each table.

[0173] Among them, the topic extraction model is a model trained based on unsupervised learning methods. It judges the importance of words to the entire text content based on the frequency of occurrence and semantic context of words in the text content, thereby obtaining the topic sequence and its probability that are most similar to the semantics of the text content.

[0174] Specifically, the term frequency-inverse document frequency (TF-IDF) values ​​of all words in each target text content can be calculated, and the calculation results can be sorted. According to the TF-IDF value sorting results, the words with the top N TF-IDF values ​​can be selected as the subject words for each table.

[0175] The value of N can be determined according to specific requirements, such as 5 or 10.

[0176] It is understandable that there are many topic extraction models and methods. In addition to the above method, other topic extraction models and methods can also be used to extract keyword words, which is not limited in this embodiment.

[0177] The method for table retrieval in a document provided in this embodiment determines the subject words corresponding to each table, including: extracting subject words from the target text content corresponding to each table using a subject extraction model.

[0178] As an optional implementation, based on the above embodiment, each table is searched according to the subject words and search keywords to obtain the target table, including:

[0179] Create a subject word list corresponding to each table, and the subject word list corresponding to each table is used to store the subject words and search keywords corresponding to each table;

[0180] Calculate the normalized point mutual information NPMI value of the subject words and search keywords corresponding to each table in the subject word list corresponding to each table to obtain multiple NPMI values;

[0181] Sort multiple NPMI values ​​from large to small and output the table corresponding to the NPMI value ranked first to obtain the target table.

[0182] The NPMI value calculation formula is shown in formula (1):

[0183]

[0184] In formula (1), p(x) is the frequency of the subject words corresponding to each table appearing in the corresponding target text content; p(y) is the frequency of the search keywords appearing in the corresponding target text content; p(x,y) is the frequency of the subject words and search keywords corresponding to each table appearing simultaneously in the corresponding target text content.

[0185] Specifically, after extracting the subject words corresponding to each table, a subject word list is created for each table, the subject words and search keywords corresponding to each table are placed in the corresponding list, and then the NPMI values ​​of the subject words and search keywords in each list are calculated respectively, thereby obtaining multiple NPMI values, and all NPMI values ​​are sorted from large to small, and the table corresponding to the subject word with the first NPMI value is output to obtain the target table.

[0186] The method for table retrieval in a file provided in this embodiment searches each table according to subject words and search keywords to obtain a target table, including: creating a subject word list corresponding to each table, the subject word list corresponding to each table is used to store the subject words and search keywords corresponding to each table; calculating the standardized point mutual information NPMI value of the subject words and search keywords corresponding to each table in the subject word list corresponding to each table to obtain multiple NPMI values; sorting the multiple NPMI values ​​from large to small and outputting the table corresponding to the NPMI value ranked first to obtain the target table. Standardized point mutual information is a standardized form of point mutual information. The value of point-by-point mutual information is normalized between -1 and 1, which can well judge the consistency between words according to the degree of closeness. By calculating the NPMI value between words to retrieve the table, not only the table retrieval method is enriched, but also the accuracy of table retrieval is improved.

[0187] Figure 3 A flowchart of a method for table retrieval in a file provided in another embodiment of the present application is shown in FIG. Figure 3As shown, the method for table retrieval in a document provided in this embodiment includes a specific implementation scheme of extracting various types of tables, determining the subject words of each table, and searching each table according to the subject words and search keywords. The method for table retrieval in a document provided in this embodiment includes the following steps:

[0188] Step 301: receiving a search request for a table in a target file, wherein the search request includes the target file and search keywords.

[0189] Step 302, obtaining text content in the target file and generating multiple text boxes according to the text content.

[0190] Step 303: determine the coordinates of the four vertices of each text box as the corresponding text position information.

[0191] Step 304, determining the structure of the table in the target file, where the table structure includes the position and length of the table border and the cell position information.

[0192] Step 305: extract the first type of table according to the table structure and text position information.

[0193] Step 306, determining the number of spaces in the line text content and the average value of the horizontal coordinates of the text between the spaces.

[0194] Step 307: determine the text content that meets the preset conditions as the text content corresponding to the second type table.

[0195] Step 308: Fill the corresponding text content into the corresponding table according to the text position information to extract the second type table.

[0196] Step 309, for each page in the target file, the following operations are performed in sequence: determine whether the table included in the current page is the beginning of the current page. If so, determine whether the table included in the previous page is the end of the previous page. If so, determine whether the frames of the table included in the current page and the table included in the previous page are the same. If so, determine whether the table on the current page spans across pages and merge the tables.

[0197] Step 310 , extracting the three lines of text content before each table and the row and column names of each table as target text content.

[0198] Step 311, using the topic extraction model to extract keywords from the target text content corresponding to each table.

[0199] Step 312: Create a keyword list corresponding to each table.

[0200] Step 313, calculating the NPMI values ​​of the subject words and search keywords corresponding to each table in the subject word list corresponding to each table to obtain a plurality of NPMI values.

[0201] Step 314 , sorting the multiple NPMI values ​​and outputting the table corresponding to the first-ranked NPMI value to obtain a target table.

[0202] In this embodiment, the implementation method and technical effects of steps 301 to 314 are similar to the implementation method of the corresponding solutions in the above embodiments, and will not be repeated here.

[0203] Figure 4 A schematic diagram of the structure of a table search device in a document provided by an embodiment of the present application is as follows: Figure 4 As shown, the file table search device provided in this embodiment is located in the file table search device. Then the file table search device 40 provided in this embodiment includes: a receiving module 41, an acquisition module 42, an extraction module 43, a merging module 44, a determination module 45 and a search module 46.

[0204] Among them, the receiving module 41 is used to receive a retrieval request for a table in a target file, and the retrieval request includes the target file and the retrieval keyword; the obtaining module 42 is used to obtain multiple text position information in the target file according to the retrieval request; the extracting module 43 is used to extract a first type of table according to the retrieval request, and the first type of table is a table with complete border lines; the extracting module 43 is also used to extract a second type of table according to the text position information, and the second type of table is a table with incomplete border lines; the merging module 44 is used to merge the tables with cross-page situations if at least one of the first type of table and the second type of table has cross-page situations to obtain a merged table; the determining module 45 is used to determine the subject words corresponding to each table, and each table includes the merged and unmerged first type of table and second type of table; the retrieval module 46 is used to search each table according to the subject words and the retrieval keywords to obtain the target table.

[0205] Optionally, when acquiring multiple text position information in a target file, the acquisition module 42 is specifically used to: acquire the text content in the target file; generate multiple text boxes according to each line of text content, and determine the four vertex coordinates of the multiple text boxes; and determine the four vertex coordinates of each text box as the corresponding text position information.

[0206] Optionally, when acquiring the text content in the target file, the acquisition module 42 is specifically used to: extract character features of each page in the target file; match the character features with preset character templates to identify characters; and convert the characters into corresponding text content to obtain the text content in the target file.

[0207] Optionally, when extracting the first type of table, the extraction module 43 is specifically used to: determine the position and length of the table border line in the target file; determine the cell position information in the table based on the position and length of the table border line; determine the corresponding text content in each cell based on the text position information and the cell position information; fill the corresponding text content in each cell into the corresponding cell to extract the first type of table.

[0208] Optionally, the extraction module 43, when extracting the second type of table according to the text position information, is specifically used to: determine the number of spaces in the line text content, the line text content does not include the text content contained in the first type of table, and the line text content is located in the target file; calculate the mean of the horizontal coordinates of the text between the spaces; determine the text content corresponding to the second type of table based on the number of spaces and the mean; fill the corresponding text content into the corresponding table according to the text position information to extract the second type of table.

[0209] Optionally, when the extraction module 43 determines the text content corresponding to the second type of table based on the number of spaces and the mean, it is specifically used to: if there are two or more lines of text content that meet the preset conditions, then the text content that meets the preset conditions will be determined as the text content corresponding to the second type of table, and the preset conditions are: the line text content contains two or more spaces, and the mean of the horizontal coordinates of the text between the spaces is equal.

[0210] Optionally, the document table retrieval device provided in the present application further includes: an identification module.

[0211] The identification module is used to identify whether at least one of the first type of table and the second type of table spans across pages. Specifically, the identification module is used to perform the following operations in sequence for each page in the target file: determine whether the table included in the current page is the beginning of the current page; whether the table included in the current page is the first type of table or the second type of table; if so, determine whether the table included in the previous page is the end of the previous page; if so, determine whether the frames of the table included in the current page and the table included in the previous page are the same; if so, determine whether the table on the current page spans across pages.

[0212] Optionally, the determination module 45, when determining whether the table contained in the current page is the beginning of the current page, is specifically used to: determine whether the first line of text content in the table contained in the current page is the same as the first line of text content in the current page; if different, determine whether the first line of text content in the table contained in the current page is the same as the second line of text content in the current page; if the same, determine that the table contained in the current page is the beginning of the current page.

[0213] Optionally, before determining the subject words corresponding to each table, the extraction module 43 is specifically used to: extract the target text content corresponding to each table, the target text content including the three lines of text content before each table and the row and column names of each table.

[0214] Optionally, when determining the keywords corresponding to each table, the determination module 45 is specifically used to: extract keywords from the target text content corresponding to each table using a topic extraction model.

[0215] Optionally, when searching each table according to subject words and search keywords to obtain a target table, the retrieval module 46 is specifically used to: create a subject word list corresponding to each table, the subject word list corresponding to each table is used to store the subject words and search keywords corresponding to each table; calculate the standardized point mutual information NPMI value of the subject words and search keywords corresponding to each table in the subject word list corresponding to each table to obtain multiple NPMI values; sort the multiple NPMI values ​​and output the table corresponding to the NPMI value ranked first to obtain the target table.

[0216] Figure 5 A schematic diagram of a structure of a table retrieval device in a document provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the document table retrieval device 50 provided in this embodiment includes: a processor 51, a memory 52 and an input device 53.

[0217] The memory 52 is used to store computer-executable instructions; the processor 51 is used to execute the computer-executable instructions stored in the memory 52 to implement the method for searching a table in a file provided by any of the above embodiments. The input device 53 is used to receive a search request for a table in a target file, the search request including the target file and search keywords. For details, please refer to the relevant description in the above method embodiment, and no further details will be given here.

[0218] The program may include program codes, and the program codes include computer-executable instructions. The memory 52 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.

[0219] In this embodiment, the memory 52 is connected to the processor 51 via a bus. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0220] The present application also provides a computer-readable storage medium, in which a computer-executable instruction is stored, and when the computer-executable instruction is executed by a processor, it is used to implement the method for table retrieval in a file provided in any of the above embodiments. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.

[0221] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the method for table retrieval in a file provided by any one of the above embodiments.

[0222] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0223] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0224] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0225] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0226] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. If not specifically stated, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. If not specifically stated, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.

[0227] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0228] In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For the part that is not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above-mentioned embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered as the scope recorded in this specification. Those skilled in the art will easily think of other implementation schemes of the present application after considering the specification and practicing the invention disclosed here. This 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 technical means in the technical field that are not disclosed in this application. The description and embodiments are only regarded as exemplary, and the true scope and spirit of the present application are indicated by the following claims.

[0229] 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.

Claims

1. A method for table retrieval in a file, characterized in that: The method comprises: receiving a search request for a table in a target file, the search request including the target file and a search keyword; Acquire multiple text position information in the target file according to the search request and extract a first type of table, where the first type of table is a table with complete frame lines; Extracting a second type of table according to the text position information, where the second type of table is a table with incomplete frame lines; If at least one of the first type table and the second type table spans across pages, merging the table spanning across pages to obtain a merged table; Determine the subject words corresponding to each table, wherein each table includes the merged table and the unmerged first type table and second type table; The tables are searched according to the subject words and the search keywords to obtain a target table.

2. The method according to claim 1, characterized in that: The obtaining of multiple text position information in the target file includes: Obtaining text content in the target file; Generate multiple text boxes according to the text content of each line, and determine the coordinates of four vertices of the multiple text boxes; The four vertex coordinates of each of the text boxes are determined as corresponding text position information.

3. The method according to claim 2, characterized in that The obtaining of the text content in the target file includes: Extracting character features of each page in the target file; Matching the character features with a preset character template to identify the character; The characters are converted into corresponding text contents to obtain the text contents in the target file.

4. The method according to claim 1, characterized in that: The extracting the first type of table includes: Determine the position and length of the table border in the target file; Determine the cell position information in the table according to the position and length of the table border; Determine the text content corresponding to each cell according to the text position information and the cell position information; The corresponding text contents in the cells are filled into the corresponding cells to extract the first type table.

5. The method according to claim 1, characterized in that The extracting the second type table according to the text position information comprises: Determining the number of spaces in a line of text content, the line of text content not including text content included in the first type of table, the line of text content being located in the target file; Calculate the mean of the horizontal coordinates of the texts between the spaces; Determining text content corresponding to the second type table according to the number of spaces and the mean; The corresponding text content is filled into a corresponding table according to the text position information to extract a second type table.

6. The method according to claim 5, characterized in that The determining, according to the number of spaces and the mean, text content corresponding to the second type table includes: If there are two or more lines of text content that meet the preset conditions, the text content that meets the preset conditions will be determined as the text content corresponding to the second type of table, and the preset conditions are: the lines of text content all contain two or more spaces, and the average values ​​of the horizontal coordinates of the text between the spaces are equal.

7. The method according to claim 1, characterized in that Identifying that at least one of the first type table and the second type table has a cross-page situation, including: For each page in the target file, perform the following operations in sequence: Determine whether the table included in the current page is at the beginning of the current page; the table included in the current page is a first type table or a second type table; If so, determine whether the table contained on the previous page is the end of the previous page; If yes, determining whether the frames of the table included in the current page and the table included in the previous page are the same; If so, it is determined that the table on the current page spans across pages.

8. The method according to claim 7, characterized in that The step of determining whether the table included in the current page is at the beginning of the current page includes: Determine whether the first line of text content in the table contained in the current page is the same as the first line of text content in the current page; If they are different, determining whether the first line of text content in the table contained in the current page is the same as the second line of text content in the current page; If they are the same, it is determined that the table contained in the current page is at the beginning of the current page.

9. The method according to claim 1, characterized in that: Before determining the subject words corresponding to each table, the method further includes: The target text content corresponding to each table is extracted, wherein the target text content includes the three lines of text content before each table and the row and column names of each table.

10. The method according to claim 1, characterized in that Determining the subject words corresponding to each table includes: The topic extraction model is used to extract topic words from the target text content corresponding to each table.

11. The method according to claim 1, characterized in that: The searching of the tables according to the subject words and the search keywords to obtain the target table includes: Creating a subject word list corresponding to each table, wherein the subject word list corresponding to each table is used to store the subject words and search keywords corresponding to each table; Calculate the normalized point mutual information NPMI value of the subject words and search keywords corresponding to each table in the subject word list corresponding to each table to obtain multiple NPMI values; The multiple NPMI values ​​are sorted from large to small and the table corresponding to the NPMI value ranked first is output to obtain a target table.

12. A device for searching a table in a document, characterized in that: The device comprises: A receiving module, used to receive a search request for a table in a target file, wherein the search request includes the target file and a search keyword; An acquisition module, used for acquiring multiple text position information in the target file according to the search request; An extraction module, used for extracting a first type of table, where the first type of table is a table with complete frame lines; The extraction module is further used to extract a second type of table according to the text position information, where the second type of table is a table with incomplete frame lines; a merging module, configured to merge the tables that cross pages if at least one of the first type table and the second type table crosses pages, so as to obtain a merged table; A determination module, used to determine the subject words corresponding to each table, wherein each table includes a first type table and a second type table after merging and an unmerged first type table; The search module is used to search the tables according to the subject words and the search keywords to obtain a target table.

13. A device for searching a table in a document, characterized in that: include: A processor, and a memory and an input device communicatively connected to the processor; The memory stores computer-executable instructions; The input device is used to receive a search request for a table in a target file, wherein the search request includes the target file and a search keyword; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 11 when executed by a processor.

15. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 11 when being executed by a processor.

Citation Information

Patent Citations

  • Quick retrieval method for documents in knowledge base, application server and computer readable storage medium

    CN108038096A

  • A method for extracting table information in a PDF file

    CN109635268A

  • Table extraction method and device, terminal and computer readable storage medium

    CN110659346A

  • Information extraction method and device

    CN113961685A

  • Method, device and system for extracting irregular table of PDF (Portable Document Format) document and medium

    CN117475461A

Cited By

  • Cross-page table intelligent processing and retrieval enhancement system and method

    CN122262247A

  • Intelligent processing and retrieval enhancement system and method for cross-page tables

    CN122262247B