Methods, devices and computer equipment for extracting information from tables
Patent Information
- Application Number
- CN202310311810.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2043-03-28
AI Technical Summary
表格中的信息通常较为重要,但表格形式多种多样,如果想完整保留表格信息,则抽取每个表格信息都需要开发人员进行定制化开发,极为耗时,严重影响了信息处理效率
[0032] In the technical solution provided by this disclosure, by obtaining the text information of cells in a table, it is possible to determine whether a cell is a key-type cell or a value-type cell based on the text information. Then, by determining whether there are value-type cells in the first row of the table, the table type can be obtained. Table information is then extracted and output based on the table type. In this way, obtaining cell text information and confirming cell and table types can be completed automatically through scripts or models. Furthermore, the table types are either record-type tables or key-value pair tables. Extracting table information using these two methods can be applied to tables of all structures, eliminating the need for manual table analysis. This results in high efficiency in table information extraction and a wide range of applications.
Smart Images

Figure CN116343245B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing, and in particular to a method, apparatus, computer equipment, computer-readable storage medium, and computer program product for extracting information from tables. Background Technology
[0002] With the explosive growth of information on the internet, the efficiency of information processing has become increasingly important. In the information processing process, quickly acquiring effective information is a crucial prerequisite for improving efficiency. Among related technologies, various web crawling tools can be used to quickly extract large amounts of text information from the internet for analysis by big data models.
[0003] Existing information retrieval methods are highly efficient at processing plain text, but their effectiveness diminishes significantly when tables are included. Tables not only save text length but also provide a more intuitive representation of information, making them widely applicable. The information within tables is typically quite important, but table formats vary greatly. To fully preserve table information, developers must perform customized development for each table entry, which is extremely time-consuming and severely impacts information processing efficiency. Summary of the Invention
[0004] Based on this, and to address the aforementioned technical problems, a method, apparatus, computer device, computer-readable storage medium, and computer program product for extracting table information are provided. The technical solution of this disclosure is as follows:
[0005] According to one aspect of the present disclosure, a method for extracting table information is provided, comprising:
[0006] Get the text information of cells in a table;
[0007] Based on the text information, the cell is confirmed to be either a key-type cell or a value-type cell.
[0008] Based on whether there are value cells in the first row of the table, the type of the table is determined to be either a record table or a key-value pair table.
[0009] Extract and output the information of the table according to the extraction method of record-type table or key-value pair table.
[0010] In one embodiment, confirming that the cell is a key-type cell or a value-type cell based on the text information includes:
[0011] Check whether the text information meets any of the criteria for value-type text. If it does, confirm that the cell containing the text information is a value-type cell.
[0012] The value-based text standard includes: the text contains floating-point numbers; the text contains preset fields; and the text length is within a preset range.
[0013] In one embodiment, determining whether the table type is a record table or a key-value pair table based on whether there are value cells in the first row of the table includes:
[0014] If the first row of the table does not contain value cells, then the table type is confirmed to be a record table.
[0015] Check all rows except the first row. If the proportion of value cells in other rows is lower than a preset first threshold, change the table type from a record table to a key-value pair table.
[0016] In one embodiment, determining whether the table type is a record table or a key-value pair table based on whether there are value cells in the first row of the table includes:
[0017] If the first row of the table contains value cells, then the table type is confirmed to be a key-value pair table;
[0018] Check all rows except the first row. If the proportion of value cells in other rows is higher than a preset second threshold, change the table type from a key-value pair table to a record table.
[0019] In one embodiment, before obtaining the text information of the cells in the table, the method further includes:
[0020] Find nested tables within a table;
[0021] Replace the nested table with a preset placeholder.
[0022] In one embodiment, after confirming that the cell is either a key cell or a value cell based on the text information, the method further includes:
[0023] The table is split until the first column of each split table contains no duplicate key cells.
[0024] According to another aspect of the embodiments of this disclosure, a table information extraction apparatus is provided, comprising:
[0025] The information acquisition module is used to acquire text information from cells in a table;
[0026] The cell confirmation module is used to confirm, based on the text information, whether the cell is a key-type cell or a value-type cell.
[0027] The table type confirmation module is used to confirm whether the table type is a record table or a key-value pair table based on whether there are value cells in the first row of the table.
[0028] The information extraction module is used to extract and output the information of the table according to the extraction method of record-type table or key-value pair table.
[0029] According to another aspect of the present disclosure, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0030] According to another aspect of the present disclosure, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the above-described method.
[0031] According to another aspect of the present disclosure, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of the above-described method.
[0032] In the technical solution provided by this disclosure, by obtaining the text information of cells in a table, it is possible to determine whether a cell is a key-type cell or a value-type cell based on the text information. Then, by determining whether there are value-type cells in the first row of the table, the table type can be obtained. Table information is then extracted and output based on the table type. In this way, obtaining cell text information and confirming cell and table types can be completed automatically through scripts or models. Furthermore, the table types are either record-type tables or key-value pair tables. Extracting table information using these two methods can be applied to tables of all structures, eliminating the need for manual table analysis. This results in high efficiency in table information extraction and a wide range of applications.
[0033] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0035] Figure 1 This is a flowchart illustrating a method for extracting table information in one embodiment;
[0036] Figure 2This is a flowchart illustrating the process of determining the table type based on the first row cell of a table in one embodiment.
[0037] Figure 3 This is a flowchart illustrating the process of determining the table type based on the first row cell of the table in another embodiment;
[0038] Figure 4 This is a schematic diagram of a table to be extracted in one embodiment;
[0039] Figure 5 This is a flowchart illustrating a method for extracting table information in another embodiment;
[0040] Figure 6 This is a flowchart illustrating a method for extracting table information in another embodiment;
[0041] Figure 7 This is a schematic diagram illustrating the result of splitting a table to be extracted in one embodiment;
[0042] Figure 8 This is a schematic diagram of the structure of an object model conversion device of an Internet of Things platform in one embodiment;
[0043] Figure 9 This is a schematic diagram of the internal structure of a computer device in one embodiment. Detailed Implementation
[0044] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0045] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims. The terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitation, the presence of other identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any specific order.
[0046] The terms “vertical,” “horizontal,” “left,” “right,” “up,” “down,” “front,” “back,” “circumferential,” “direction of travel,” and similar expressions used herein are based on the orientation or positional relationship shown in the accompanying drawings and are used only for the convenience of describing the invention and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention.
[0047] Unless otherwise defined, the technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the specification of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The terms “and / or,” “and / or,” and “at least one of” as used herein include any and all combinations of one or more of the associated listed items. It should be noted that the connections, links, etc., described in this disclosure can be direct connections via interfaces or pins between devices, connections via leads, or wireless connections (communication connections).
[0048] Compared to pure text information, tables offer a simpler and more intuitive presentation. Tables are ubiquitous on various web pages, but existing methods for extracting information from them merely stack the text within each cell, failing to preserve the table's complete information. To retain table information, developers often need to define the header tags for each table based on specific business requirements, resulting in highly inefficient and unreliable extraction methods for different tables.
[0049] The applicant's research revealed that information in tables generally includes the data itself and field names representing data types. In two-dimensional data storage and representation structures such as databases, the data itself can be called VALUE, and the field representing the data type can be called KEY. Besides representing the data type, the KEY can also serve as an index to locate the data within the table or database. Based on the table structure, the applicant categorizes tables into record-type tables and key-value pair tables. A record-type table, as shown in Table 1, uses "Name," "Gender," and "Age" as KEYs to represent the corresponding VALUEs. Data such as "A," "Female," and "20" are VALUEs. Each KEY in Table 1 appears only once, and each KEY corresponds to at least two VALUEs. The VALUEs in each row can be combined to form a record corresponding to a KEY. This type of table can be considered a record-type table. For record-type tables, a unified information extraction method can be adopted.
[0050] A female 20 B male 22
[0051] Table 1
[0052] gender male nationality Chinese
[0053] Table 2
[0054] A key-value pair table can be represented as shown in Table 2. In Table 2, "Name," "Gender," "Age," and "Ethnicity" are keys, and "C," "Male," "23," and "Han" are values. The number of keys and values in Table 2 is equal, with one key corresponding to one value. This type of table can be classified as a key-value pair table. For record-type tables, a unified information extraction method can also be adopted.
[0055] Based on this, according to one aspect of the embodiments of this disclosure, such as Figure 1 As shown, a method for extracting information from a table is provided, including:
[0056] Step S210: Obtain the text information of the cells in the table.
[0057] Specifically, you can extract the text from cells in a table using scripts or spreadsheet tools in languages like Python. Some implementations allow you to extract the text from all cells, or select specific cells and extract the text from those selected cells.
[0058] Step S220: Based on the text information, confirm that the cell is either a key cell or a value cell.
[0059] Among them, key cells can be cells with text information KEY, and value cells can be cells with text information VALUE.
[0060] Specifically, identification criteria for key-type cells and value-type cells can be pre-set, and the cell type can be determined as either a key-type cell or a value-type cell based on these criteria. For example, the approximate range of information contained in the table can be obtained, and certain special fields can be set as detection criteria for VALUE data based on this range. If the text of a cell contains the aforementioned special fields, the text information in that cell can be considered VALUE, and the cell is a value-type cell; if the text of a cell does not contain the pre-set special fields, the text information in that cell can be considered KEY, and the cell is a key-type cell. In some other implementations, a classification model for identifying cell types can be pre-trained. The text of a cell is input into the classification model, and after the model identifies the cell, it outputs whether the cell type is a key-type cell or a value-type cell.
[0061] It should be noted that in this embodiment, identifying cell type can mean identifying the type of all cells in the table or identifying the type of some cells in the table.
[0062] Step S230: Based on whether there are value-type cells in the first row of the table, confirm that the table type is either a record table or a key-value pair table.
[0063] Specifically, after confirming the cell type, the first row of cells in the table can be examined. The presence of value cells in the first row determines the table type. If no value cells are present in the first row, the table is considered a record table; if value cells are present, it is considered a key-value pair table. For example, in Table 1, none of the three cells in the first row contain VALUE, indicating no value cells exist in the first row, so Table 1 is considered a record table. In Table 2, both "C" and "23" in the first row are VALUE, indicating two value cells exist in the first row, so Table 2 is considered a key-value pair table.
[0064] Step S240: Extract and output the information of the table according to the extraction method of record-type table or key-value pair table.
[0065] The extraction methods for record-type tables or key-value pair tables can be pre-configured scripts or trained models.
[0066] Specifically, after confirming the table type, the corresponding extraction method can be adopted according to the table type to extract and output the table information. For example, if the table is a record-type table as shown in Table 1, the text of the first row cell can be matched one by one with the text of the other rows cell, and then output. The result of extracting and outputting Table 1 is {['Name': A, 'Gender': Female, 'Age': 10], ['Name': B, 'Gender': Male, 'Age': 12]}. If the table is a key-value pair table as shown in Table 2, since the KEY and VALUE of this type of table correspond one-to-one, two cells can be extracted sequentially from each row as a group for output. The result of extracting and outputting Table 2 is {'Name': C, 'Age': 23, 'Gender': Male, 'Ethnicity': Han}. In some specific implementations, the extraction and output of table information can be completed by a preset extraction script or extraction model.
[0067] In the technical solution provided by this disclosure, by obtaining the text information of cells in a table, it is possible to determine whether a cell is a key-type cell or a value-type cell based on the text information. Then, by determining whether there are value-type cells in the first row of the table, the table type can be obtained. Table information is then extracted and output based on the table type. In this way, obtaining cell text information and confirming cell and table types can be completed automatically through scripts or models. Furthermore, the table types are either record-type tables or key-value pair tables. Extracting table information using these two methods can be applied to tables of all structures, eliminating the need for manual table analysis. This results in high efficiency in table information extraction and a wide range of applications.
[0068] It should be noted that the cell mentioned in this disclosure refers to the smallest unit that makes up a table, which is the intersection of rows and columns in the table, and is not a specific term used in individual software.
[0069] In one embodiment, confirming that the cell is a key-type cell or a value-type cell based on the text information includes:
[0070] Check whether the text information meets any of the criteria for value-type text. If it does, confirm that the cell containing the text information is a value-type cell.
[0071] The value-based text standard includes: the text contains floating-point numbers; the text contains preset fields; and the text length is within a preset range.
[0072] Specifically, the cell type can be determined by examining the text information of the cell. If the text information contains floating-point numbers or preset fields, or if the text length is within a preset range, the data in the cell can be considered VALUE, and the cell is a value-type cell; otherwise, the cell is considered a key-type cell. In some other implementations, preset fields can be set according to the table's theme. For example, if the table theme may be related to equipment leasing, keywords such as "company," "yuan," and "term" can be set as preset fields. Cells containing any of these keywords are considered VALUE, and the corresponding cells are value-type cells. In some other implementations, since the KEY representing the data type and the VALUE representing the actual data value differ in text length, a range of 2 to 20 characters can be set. Text within this range is considered a KEY, and text outside this range is considered a VALUE.
[0073] In the above embodiments, text information can be identified and the cell type confirmed based on conditions such as whether it contains floating-point numbers, preset fields, or text length. Since floating-point numbers are often used to represent actual data values, combining factors such as preset fields and text length can more accurately confirm the meaning of the data in the cell, thereby determining whether the cell type is a key-type cell or a value-type cell, reducing the probability of misjudgment, and ensuring the reliability of the table information extraction results.
[0074] In one embodiment, such as Figure 2 As shown, the step of determining whether the table type is a record table or a key-value pair table based on whether there are value cells in the first row of the table includes:
[0075] Step S2302: If there are no value cells in the first row of the table, confirm that the table type is a record table.
[0076] Specifically, it can check whether there are value cells in the first row of the table. If not, the table type can be confirmed as a record table.
[0077] Step S2304: Check all rows except the first row. If the proportion of value cells in other rows is lower than a preset first threshold, change the table type from a record table to a key-value pair table.
[0078] The first threshold can be determined based on the number of cells in the table.
[0079] Specifically, after confirming the table type, the rows other than the first row can be checked, and the ratio of the median cells in the other rows to all cells in the other rows can be calculated. If the ratio is lower than a first threshold, the table type is changed to a key-value pair table. In some other implementations, the first threshold can be set to 70%.
[0080] It is worth noting that misjudgments may occur when confirming cell types based on text information. Even with pre-set recognition criteria or pre-trained models, the accuracy of the confirmation cannot be guaranteed. For example, if there is a cell containing VALUE in the first row, but that VALUE data is mistakenly identified as KEY, this will cause a key-value pair table to be incorrectly identified as a record table, resulting in an incorrect information extraction method and affecting the extraction and output results.
[0081] In the above embodiments, after confirming the table type based on the first row cell, the table type can be verified based on the proportion of value-type cells in other rows, and the table type can be corrected if the proportion is abnormal. In this way, the table type can be confirmed a second time by the proportion of value-type cells in other rows, avoiding the misidentification of the entire table type due to errors in the first row cell type, further improving the reliability of the extraction and output results, and eliminating the need for manual verification, thus improving the efficiency of table information extraction.
[0082] In one embodiment, such as Figure 3 As shown, the step of determining whether the table type is a record table or a key-value pair table based on whether there are value cells in the first row of the table includes:
[0083] Step S2306: If the first row of the table contains value cells, confirm that the table type is a key-value pair table.
[0084] Specifically, it can detect whether there are value cells in the first row of the table. If so, the table type can be confirmed as a key-value pair table.
[0085] Step S2308: Check all rows except the first row. If the proportion of value cells in other rows is higher than the preset second threshold, change the table type from a key-value pair table to a record table.
[0086] The second threshold can be determined based on the number of cells in the table.
[0087] Specifically, after confirming the table type, the rows other than the first row can be checked, and the ratio of the median cells in the other rows to all cells in the other rows can be calculated. If this ratio is higher than a second threshold, the table type is changed to a record table. In some other implementations, the second threshold can be set to 70%.
[0088] It's worth noting that misjudgments can occur when identifying cell types based on text information. Even with pre-set recognition criteria or pre-trained models, the accuracy of the identification cannot be guaranteed. If the number of cells in the first row is too small, the probability of misjudgment will also increase. Since the key appears only once in a record-type table, the number of value-type cells containing VALUE is often much higher than the number of key-type cells containing KEY. Setting a second threshold can prevent record-type tables from being mistakenly identified as key-value pair tables.
[0089] In the above embodiments, after confirming the table type based on the first row cell, the table type can be verified based on the proportion of value-type cells in other rows, and the table type can be corrected if the proportion is abnormal. In this way, the table type can be confirmed a second time by the proportion of value-type cells in other rows, avoiding the misidentification of the entire table type due to errors in the first row cell type, further improving the reliability of the extraction and output results, and eliminating the need for manual verification, thus improving the efficiency of table information extraction.
[0090] Figure 4 This is a schematic diagram of a table to be extracted in one embodiment. For example... Figure 4 As shown, the information in the table to be extracted, such as "Sewage Cleaning Equipment Rental Agreement", "Name", and "Rental Fee", belongs to KEY, while information such as "XX Equipment Manufacturing Company", "5", and "10,000 Yuan" belongs to VALUE. In addition, the table to be extracted also contains a table 0.
[0091] In one embodiment, such as Figure 5 As shown, before retrieving the text information from the cells in the table, the following steps are also included:
[0092] Step S202: Locate nested tables within the table.
[0093] Nested tables can be tables contained within cells of a table. For example, Figure 4 Table 0 within the dashed box is a nested table.
[0094] Specifically, before retrieving cell text information, you can first check if there are nested tables within the table.
[0095] Step S204: Replace the nested table with a preset placeholder.
[0096] Specifically, when nested tables exist within a table, the nested tables can be replaced with preset placeholders. These preset placeholders can be meaningless strings or pre-defined characters unrelated to the table content. In some other implementations, the placeholders can be set to TABLE_0, TABLE_1, etc., or they can be set to long, random characters.
[0097] In the above embodiments, before obtaining the cell text information, nested tables within the table can be identified and replaced with preset placeholders. This avoids interference from the large amount of information in the nested tables during the extraction process. Treating the nested tables as placeholders simplifies the extraction process and reduces workload. Furthermore, the nested tables can be processed as separate tables in the above steps to avoid missing information within them.
[0098] In one embodiment, such as Figure 6 As shown, after confirming that the cell is either a key-type cell or a value-type cell based on the text information, the method further includes:
[0099] Step S222: Split the table until the first column of each split table does not contain any duplicate key cells.
[0100] Specifically, after obtaining the cell types in the table, the table can be split into multiple sub-tables until the first column of each sub-table contains no duplicate key-type cells. This is especially relevant when some table structures are complex, such as in... Figure 4 In the table shown, the cell containing "Lessor" spans two rows. Extracting this data using a key-value pair table will result in an error. To handle this situation where a key spans two rows, the table can be split. Use the key as the dividing point to split the table along the vertical axis, and extract the cells on the other side of the key as sub-table A (e.g., ...). Figure 7 (As shown). Similarly, we can split it into sub-table B, and the remaining parts that do not have duplicate key cells in the first column will be sub-table C. The split diagram is shown below. Figure 7 As shown.
[0101] In the above embodiments, by splitting the table, a complex table structure can be decomposed into a simpler table structure, ultimately making the split table conform to the standards of a record-type table or a key-value pair table. In this way, any table can be viewed as a combination of multiple record-type or key-value pair tables, and extraction can be performed according to table type after splitting, effectively solving the problem of low extraction efficiency for complex tables.
[0102] In one embodiment, after confirming that the cell is either a key cell or a value cell based on the text information, the method further includes:
[0103] Check if there is a cell in the table that occupies a row. If so, split the table along the horizontal axis using that row as the dividing point.
[0104] Specifically, such as Figure 7The table shown has only one cell in the first row. The text of this cell is usually KEY and there is no corresponding VALUE. It exists only as a title and can be separated out.
[0105] In the above embodiments, by splitting the cells that occupy a row, useless keys such as titles in the table can be effectively removed, while retaining valid information, thus improving the efficiency of table information extraction.
[0106] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0107] According to another aspect of the embodiments of this disclosure, such as Figure 8 As shown, a table information extraction device is also provided, comprising:
[0108] The information acquisition module 310 is used to acquire text information from cells in a table;
[0109] The cell confirmation module 320 is used to confirm, based on the text information, whether the cell is a key-type cell or a value-type cell;
[0110] The table type confirmation module 330 is used to confirm the type of the table as either a record table or a key-value pair table based on whether there are value cells in the first row of the table.
[0111] The information extraction module 340 is used to extract and output the information of the table according to the extraction method of record-type table or key-value pair table.
[0112] For specific limitations regarding the extraction device, please refer to the limitations of the extraction method described above, which will not be repeated here. According to the extraction method, the extraction device can be supplemented with a first module, a second module, etc., to implement the steps in the corresponding method embodiments. Each module in the extraction device can be implemented entirely or partially through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0113] According to another aspect of the embodiments of this disclosure, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 9 As shown. The computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements the aforementioned extraction method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0114] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0115] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0116] According to another aspect of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0117] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one relational database and non-relational database. Non-relational databases can include blockchain-based distributed databases, etc., and are not limited thereto. The processors involved in the various embodiments provided in this application may be general-purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited thereto.
[0118] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0119] The embodiments described above are merely illustrative of several implementations of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art, upon considering the specification and practicing the invention disclosed herein, will readily conceive of other embodiments of this disclosure. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0120] It should be understood that this disclosure is not limited to the precise structures already described and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
Claims
1. A method for extracting information from a table, characterized in that, include: Get the text information of cells in a table; Based on the text information, the cell is confirmed to be either a key-type cell or a value-type cell. Detect whether there is a cell occupying a row in the table. If so, use that row as the dividing point to split the table along the horizontal axis to obtain the split table. Based on whether there are value cells in the first row of the split table, the type of the split table is confirmed to be either a record table or a key-value pair table. If the first row of the split table does not contain a value cell, the type of the split table is confirmed to be a record table. Check all rows except the first row. If the proportion of value cells in other rows is lower than a preset first threshold, change the type of the split table from a record table to a key-value pair table. If the first row of the split table contains value cells, then the type of the split table is confirmed to be a key-value pair table; Check all rows except the first row. If the proportion of value cells in other rows is higher than a preset second threshold, change the type of the split table from a key-value pair table to a record table. Extract and output the information of the split table according to the extraction method of record-type table or key-value pair table.
2. The method according to claim 1, characterized in that, The step of confirming that the cell is a key cell or a value cell based on the text information includes: Check whether the text information meets any of the criteria for value-type text. If it does, confirm that the cell containing the text information is a value-type cell. The value-based text standard includes: the text contains floating-point numbers; the text contains preset fields; and the text length is within a preset range.
3. The method according to claim 1, characterized in that, Before retrieving the text information from the cells in the table, the following steps are also included: Find nested tables within a table; Replace the nested table with a preset placeholder.
4. The method according to claim 1, characterized in that, After confirming that the cell is either a key cell or a value cell based on the text information, the process further includes: The table is split until the first column of each split table contains no duplicate key cells.
5. A device for extracting table information, characterized in that, include: The information acquisition module is used to acquire text information from cells in a table; The cell confirmation module is used to confirm whether the cell is a key cell or a value cell based on the text information; to detect whether there is a cell occupying a row in the table; if so, to split the table along the horizontal axis using that row as the dividing point to obtain the split table. The table type confirmation module is used to confirm whether the type of the split table is a record table or a key-value pair table based on whether there are value cells in the first row of the split table. If the first row of the split table does not contain a value cell, the type of the split table is confirmed to be a record table. Check all rows except the first row. If the proportion of value cells in other rows is lower than a preset first threshold, change the type of the split table from a record table to a key-value pair table. If the first row of the split table contains value cells, then the type of the split table is confirmed to be a key-value pair table; Check all rows except the first row. If the proportion of value cells in other rows is higher than a preset second threshold, change the type of the split table from a key-value pair table to a record table. The information extraction module is used to extract and output the information of the split table according to the extraction method of record-type table or key-value pair table.
6. The apparatus according to claim 5, characterized in that, Before retrieving the text information from the cells in the table, the following steps are also included: Find nested tables within a table; Replace the nested table with a preset placeholder.
7. The apparatus according to claim 5, characterized in that, After confirming that the cell is either a key cell or a value cell based on the text information, the process further includes: The table is split until the first column of each split table contains no duplicate key cells.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Picture table content extraction method based on computer vision and natural language processing
CN113989822A