A table processing method and system
By using header detection and classification models to process tables, the problem of low efficiency in locating and extracting information from multiple tables is solved, enabling fast and accurate acquisition of table information.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2026-03-31
AI Technical Summary
In multiple or numerous tables, it is difficult for users to quickly and accurately locate and efficiently extract the information they need.
By acquiring the table to be processed, the table header detection model is used to determine the row headers and column headers, and the table is classified based on the table header classification model. Then, the table is extracted to determine the classification result and the extraction result.
It enables precise positioning and efficient information extraction from tables, thus improving the efficiency of table processing.
Smart Images

Figure CN114328536B_ABST
Abstract
Description
Technical Field
[0001] This manual relates to the field of data processing, and in particular to a table processing method and system. Background Technology
[0002] Tables can store various types of information (such as a company's financial data) in a structured manner. Users can extract the information they need from the table using certain constraints or natural language query conditions. However, when there are multiple or a large number of tables, users cannot accurately locate the required table in a short time using the above method, and the efficiency of extracting the required information from the table is also low.
[0003] Therefore, it is desirable to provide a table processing method and system that can accurately locate the required table and improve the efficiency of table extraction. Summary of the Invention
[0004] One embodiment of this specification provides a table processing method, the table processing method comprising: acquiring a table to be processed; processing the table to be processed based on a table header detection model to determine the row headers and / or column headers of the table to be processed; processing the row headers based on a table header classification model to determine the classification results of the columns in the table to be processed, and / or processing the column headers based on a table header classification model to determine the classification results of the rows in the table to be processed; and extracting from the table to be processed based on the classification results of the columns and / or rows in the table to be processed to determine a first extraction result.
[0005] One embodiment of this specification provides a table processing system, the table processing system comprising: an acquisition module for acquiring a table to be processed; a first determination module for processing at least one row and / or at least one column in the table to be processed based on a header detection model to determine row headers and / or column headers in the table to be processed; a second determination module for processing the row headers based on a header classification model to determine the classification results of the columns in the table to be processed, and / or processing the column headers based on a header classification model to determine the classification results of the rows in the table to be processed; and an extraction module for extracting from the table to be processed based on the classification results of each column and / or each row in the table to be processed to determine a first extraction result.
[0006] One embodiment of this specification provides a table processing apparatus, the apparatus including at least one processor and at least one memory; the at least one memory is used to store computer instructions; the at least one processor is used to execute at least a portion of the computer instructions to implement the table processing method as described in any of the above embodiments.
[0007] One embodiment of this specification provides a computer-readable storage medium that stores computer instructions that, when executed by a processor, implement the table processing method as described in any of the above embodiments. Attached Figure Description
[0008] This specification will be further described by way of exemplary embodiments, which will be described in detail with reference to the accompanying drawings. These embodiments are not limiting; in these embodiments, the same reference numerals denote the same structures, wherein:
[0009] Figure 1 These are exemplary block diagrams of a table processing system according to some embodiments of this specification;
[0010] Figure 2 This is an exemplary flowchart of a table processing method according to some embodiments of this specification;
[0011] Figure 3A This is a schematic diagram of a table to be processed according to some embodiments of this specification;
[0012] Figure 3B This is yet another schematic diagram of the table to be processed according to some embodiments of this specification;
[0013] Figure 4 This is yet another exemplary flowchart of a table processing method according to some embodiments of this specification;
[0014] Figure 5 This is an exemplary flowchart illustrating the determination of a table to be processed according to some embodiments of this specification;
[0015] Figure 6 This is a schematic diagram of the detection row header according to some embodiments of this specification;
[0016] Figure 7 This is a schematic diagram of the detection list header according to some embodiments of this specification;
[0017] Figure 8 This is a schematic diagram illustrating the classification results of the determined columns according to some embodiments of this specification;
[0018] Figure 9 This is a schematic diagram illustrating the classification results of the determined rows according to some embodiments of this specification;
[0019] Figure 10A This is a schematic diagram of a mask matrix according to some embodiments of this specification;
[0020] Figure 10B This is yet another schematic diagram of a mask matrix shown according to some embodiments of this specification. Detailed Implementation
[0021] To more clearly illustrate the technical solutions of the embodiments in this specification, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are merely some examples or embodiments of this specification. For those skilled in the art, these drawings can be applied to other similar scenarios without creative effort. Unless obvious from the context or otherwise specified, the same reference numerals in the drawings represent the same structures or operations.
[0022] It should be understood that the terms “system,” “device,” “unit,” and / or “module” used herein are one way to distinguish different components, elements, parts, sections, or assemblies at different levels. However, if other terms can achieve the same purpose, they may be replaced by other expressions.
[0023] As indicated in this specification and claims, unless the context clearly indicates otherwise, the words "a," "an," "an," and / or "the" do not specifically refer to the singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of expressly identified steps and elements, which do not constitute an exclusive list, and the method or apparatus may also include other steps or elements.
[0024] Flowcharts are used in this specification to illustrate the operations performed by the system according to embodiments of this specification. It should be understood that the preceding or following operations are not necessarily performed in exact order. Instead, the steps can be processed in reverse order or simultaneously. Furthermore, other operations can be added to these processes, or one or more steps can be removed from them.
[0025] Figure 1 This is an exemplary block diagram of a table processing system 100 according to some embodiments of this specification.
[0026] In some embodiments, the table processing system 100 may include an acquisition module 110, a first determination module 120, a second determination module 130, and an extraction module 140.
[0027] The acquisition module can be used to acquire tables to be processed. For more information about tables to be processed, see [link to relevant documentation]. Figure 2 The details and related explanations will not be elaborated here.
[0028] The first determination module 120 can be used to process at least one row and / or at least one column in the table to be processed based on the header detection model, and determine the row headers and / or list headers in the table to be processed. For more information on header detection models, row headers, and list headers, please refer to [link to documentation / documentation]. Figure 2The details and related descriptions will not be repeated here.
[0029] The second determining module 130 can be used to process row headers and / or column headers based on the header classification model to determine the classification result for each column and / or each row in the table to be processed. For more information on header classification models and classification results, please refer to [link to relevant documentation]. Figure 2 The details and related descriptions will not be repeated here.
[0030] The extraction module 140 can be used to extract data from the table to be processed based on the classification results of each column and / or each row, determining a first extraction result. For more information on the first extraction result, see [link to relevant documentation]. Figure 2 The details and related descriptions will not be repeated here.
[0031] In some embodiments, the table processing system 100 may further include a third determining module 150 and a cell extraction module 160.
[0032] The third determining module 150 can process the words in the cells of the table to be processed based on a text classification model to determine the type of the words in the cells. For more information on text classification models, cell words, and word types, please refer to [link to relevant documentation]. Figure 4 The details and related descriptions will not be repeated here.
[0033] The cell extraction module 160 can extract data from the table to be processed based on the type of words in the cells, and determine a second extraction result. For more information on the second extraction result, please refer to [link to relevant documentation]. Figure 4 The details and related descriptions will not be repeated here.
[0034] It should be understood that Figure 1 The system and its modules shown can be implemented in various ways.
[0035] It should be noted that the above descriptions of each module are for convenience only and should not limit this specification to the scope of the illustrated embodiments. It is understood that those skilled in the art, after understanding the principles of the system, may arbitrarily combine the modules or construct subsystems connected to other modules without departing from these principles. In some embodiments, Figure 1 The modules disclosed herein can be different modules within a system, or a single module can implement the functions of two or more of the aforementioned modules. For example, modules can share a single storage module, or each module can have its own separate storage module. Such variations are all within the scope of protection of this specification.
[0036] Figure 2This is an exemplary flowchart illustrating a table processing method according to some embodiments of this specification. Figure 2 As shown, process 200 includes the following steps.
[0037] Step 210: Obtain the table to be processed. In some embodiments, step 210 may be performed by the acquisition module 110.
[0038] The table to be processed refers to the table from which extraction needs to be performed. This table may contain information of interest to the user. In some embodiments, the table to be processed can be obtained in various ways. For example, it can be a user-generated table stored on the processor, and can be obtained directly from the processor. Another example is that it can be obtained from the network.
[0039] In some embodiments, the table to be processed can also be obtained based on the initial table and its header. For more information on obtaining the table to be processed based on the initial table and its header, see [link to relevant documentation]. Figure 5 The details and related descriptions will not be repeated here.
[0040] In some embodiments, an initial table can be obtained, and then the initial table can be cleaned by deleting redundant rows and / or columns to determine the table to be processed. Redundant rows and / or columns can refer to blank rows and / or columns. For example, the column numbers corresponding to all non-empty cells can be obtained and deduplicated to obtain a minimum subset of the column numbers corresponding to all non-empty cells. Based on this minimum subset, the column numbers corresponding to blank cells in the table can be determined, the columns corresponding to blank cells can be removed, the rearranged index can be obtained, and the columns after removing blank cells can be rearranged to obtain a cleaned table. This cleaned table is then used as the table to be processed. For more information on the initial table, see [link to relevant documentation]. Figure 5 For more information on column numbering, please refer to the related descriptions. Figure 8 The details and related descriptions will not be repeated here.
[0041] like Figure 3B As shown, the table can be cleaned by deleting the contents of the second row and the second column, resulting in the following: Figure 3A The cleaned table shown can be used as the table to be processed.
[0042] Step 220: Process the table to be processed based on the header detection model to determine the row headers and / or list headers of the table to be processed. In some embodiments, step 220 may be performed by the first determining module 120.
[0043] Table headers refer to the beginning of a table and are used to categorize the content within the table. Tables consist of rows and columns; correspondingly, table headers can be divided into row headers and list headers. Row headers are located on rows within the table, and each cell in a row header categorizes the column it corresponds to. List headers are located on columns within the table, and each cell in a list header categorizes the row it corresponds to.
[0044] It should be understood that a table includes row headers and / or list headers. Row headers can be one or more rows in the table, and list headers can be one or more columns. As shown in Figure 3, this table contains two row headers and two list headers. The row headers contain "Category," "Subject," "2030," "2031," "First Half," and "Second Half," while the list headers contain "Income," "Expenses," "Sales Revenue," "Other Income," "Taxes," and "Salaries."
[0045] In some embodiments, the table to be processed can be input into the header detection model, and the output can be the row headers and / or list headers of the table to be processed.
[0046] In some embodiments, the header detection model may include a row header detection model and a list header detection model.
[0047] In some embodiments, rows in the table to be processed can be processed based on a row header detection model to determine the row headers of the table to be processed. In some embodiments, cells in rows of the table to be processed are concatenated based on row concatenation rules to obtain a first concatenation result; the first concatenation result is then processed based on the row header detection model to determine the row headers of the table to be processed. For more details on the above embodiments, please refer to... Figure 6 The relevant descriptions are omitted here. In some embodiments, the row headers of the table to be processed can also be determined based on the row header detection model in other ways. For example, the table to be processed can be directly input into the row header detection model, and the output can be the row headers of the table to be processed.
[0048] In some embodiments, columns in the table to be processed can be processed based on a list header detection model to determine the list header of the table to be processed. In some embodiments, based on column concatenation rules, cells in the columns of the table to be processed are concatenated to obtain a second concatenation result; the second concatenation result is then processed based on the list header detection model to determine the list header of the table to be processed. For more details on the above embodiments, please refer to [link to relevant documentation]. Figure 7 The details and related descriptions will not be repeated here. In some embodiments, the list header of the table to be processed can also be determined based on the list header detection model in other ways. For example, the table to be processed can be directly input into the list header detection model, and the output can be the list header of the table to be processed.
[0049] In some embodiments, the row headers and / or column headers can also be determined in other ways. For example, the first row of the table to be processed can be used as the row header and the first column as the column header, according to preset rules.
[0050] Step 230 involves processing the row headers based on the header classification model to determine the classification results of the columns in the table to be processed, and / or processing the list headers based on the header classification model to determine the classification results of the rows in the table to be processed. In some embodiments, step 230 may be performed by the second determining module 130.
[0051] The row classification result refers to the result of classifying the content represented by each row in the table to be processed. Correspondingly, the column classification result refers to the result of classifying the content represented by each column in the table to be processed. In some embodiments, the row and / or column classification results may include only the categories required by the user, as well as others. For example... Figure 3A As shown, the first and second rows are designated as the table headers. Since the user only needs the category "time", the first and second columns of the table can be designated as "other", and the third to fifth columns can be designated as "time".
[0052] In some embodiments, the second determining module can input the row headers of the table to be processed into the header classification model and output the column classification results. In some embodiments, the second determining module 130 can also input the column headers of the table to be processed into the header classification model and output the row classification results.
[0053] In some embodiments, the second determining module may further determine whether the character length of the row header and / or list header is greater than a preset threshold before inputting them into the header classification model; if the character length of the row header and / or list header is greater than the preset threshold, the row header and / or list header is segmented into multiple groups of sub-row headers and / or sub-list headers; each group of sub-row headers and / or sub-list headers is used as input to the header classification model. In other words, classification is performed based on the header classification model, with each input of a group of sub-row headers and / or sub-list headers, and all row headers and list headers are processed through multiple executions.
[0054] In some embodiments, the header classification model may include a row header classification model and a list header classification model.
[0055] In some embodiments, the second determining module can process the row header based on the row header classification model to determine the classification result of the columns in the table to be processed. In some embodiments, the cells in the row header can be concatenated based on column concatenation rules to obtain a third concatenation result; the third concatenation result, the cell numbers and column numbers in the row header are processed based on the row header classification model to determine the classification result of the columns in the table to be processed. For more details on the above embodiments, please refer to [link to relevant documentation]. Figure 8 The relevant descriptions are not elaborated here. In some embodiments, the classification results of the columns in the table to be processed can also be determined based on the row header classification model in other ways. For example, the row headers of the table to be processed can be directly input into the row header classification model, and the output can be the classification results of the columns in the table to be processed.
[0056] In some embodiments, the list header can be processed based on a list header classification model to determine the classification result of the rows in the table to be processed. In some embodiments, the cells in the list header can be concatenated based on row concatenation rules to obtain a fourth concatenation result; the fourth concatenation result, the cell numbers and column numbers of the cells in the list header are processed based on the list header classification model to determine the classification result of the rows in the table to be processed. For more details on the above embodiments, please refer to [link to relevant documentation]. Figure 8 The relevant descriptions are not elaborated here. In some embodiments, the classification results of rows in the table to be processed can also be determined based on the list header classification model in other ways. For example, the list header of the table to be processed can be directly input into the list header classification model, and the output can be the classification results of the rows in the table to be processed.
[0057] Step 240: Based on the classification results of columns and / or rows in the table to be processed, extract data from the table to be processed to determine a first extraction result. In some embodiments, step 240 may be performed by the extraction module 140.
[0058] The first extraction result may refer to the information of cells in the table to be processed extracted based on the classification results of columns and / or rows in the table to be processed. In some embodiments, the extraction module 140 may extract information from the table to be processed according to user requirements based on the classification results of columns and / or rows in the table to be processed, and determine the first extraction result. For example, when the user requirement is time-related table data, the extraction may be based on the classification results of columns and / or rows, such as... Figure 3A When extracting data from the table shown, extract the data from columns three through five of the table.
[0059] In some embodiments, the table to be processed can also be extracted in other ways. For example, the table can be extracted based on the type of words in the text of the cells. For more details on extracting the table based on word type, please refer to Figure 3 and its related description, which will not be repeated here.
[0060] Some embodiments of this specification can determine the row headers or list headers in the table to be processed through a header detection model, and then further classify the row headers or list headers through a header classification model, thereby extracting information from the table to be processed and determining the extraction results. This can accurately locate the information needed by the user in the table to be processed and improve the efficiency of table extraction.
[0061] Figure 4 This is yet another exemplary flowchart of a table processing method according to some embodiments of this specification. In some embodiments, process 400 may be executed by a third determining module 150 and a cell extraction module 160. Figure 4 As shown, process 400 may include the following steps:
[0062] Step 410: Process the text of the cells in the table to be processed based on the text classification model to determine the type of words in the text of the cells in the table to be processed. In some embodiments, step 410 may be performed by a third determining module 150.
[0063] The word type can be preset according to requirements. For example... Figure 3A As shown, the type of "Category" in the first row and first column is "Class," the type of "Subject" in the first row and second column is also "Class," and the type of "2030" in the first row and third column is "Time." In some embodiments, types that the user does not need can be set to other types. For example, when the user needs the "Class" type, the type can be set to "Other." Figure 3A In the table shown, the cell in the first row and third column for "2030" has its type set to "Other". In some embodiments, the word type can be set according to actual needs.
[0064] In some embodiments, word types can be categorized into multiple levels. For example, primary category, secondary category, and others. The secondary category can be a subcategory of the primary category, and "other" can be a collective term for information that the user does not need.
[0065] In some embodiments, the words in the cells of the table to be processed may be purely numerical (e.g., ...). Figure 3A As shown, the text in a cell can be "8000". When the text in a cell exists alone as a numerical value, it has no meaning on its own. Therefore, when determining the type of words in the text of a cell, the purely numerical part of the cell can be omitted.
[0066] In some embodiments, the input to the text classification model can be the text of a cell, and the output can be the type of each word in that cell. For example, if the text content of a cell in the table to be processed is "The number of supermarkets has been counted, which is 5", then the type of the word "supermarket" is "name", the type of "of" is "other", the type of "already" is "other", the type of "counted" is "other", the type of "number" is "attribute", and the type of "5" is "number".
[0067] In some embodiments, the text classification model may include an encoding layer and a third classification layer. The encoding layer encodes characters in the text of cells within a table to determine character encoding vectors. The input to the encoding layer can be the text of the cell, and the output may include the encoding vectors of the characters in the text. The third classification layer analyzes the character encoding vectors to determine the type of words in the text of the cell. The input to the third classification layer can be the encoding vectors of the characters in the text, and the output may be the type of words in the text. In some embodiments, the encoding layer in the text classification model and the encoding layer in the header classification model may be the same (i.e., shared) or different.
[0068] In some embodiments, the text classification model can use the BIO (Begin Inside Outside) annotation pattern to label the type of each character in the word in the input cell. Here, B represents the beginning character of the word; I represents the middle character of the word; and O represents other characters in the word.
[0069] In some embodiments, the text classification model can be a bidirectional encoder representation from transformers-named entity recognition (BERT-NER) model.
[0070] In some embodiments, a text classification model can be trained based on historical table data. When the text classification model is a BERT-NER model, the encoding layer in this model can be pre-trained and obtained in various ways (e.g., via a network). Therefore, during training, only the third classification layer of the text classification model can be trained based on multiple training samples. After training the third classification layer, a trained text classification model is obtained. The text of cells in the historical table data can be input into the encoding layer of the initial text classification model to obtain the encoding vectors corresponding to the characters in the text of the cells in the historical table data. The encoding vectors of the characters in the text are used as training samples. The labels of the training samples can be the type of words in the text of the cells in the historical table data. The training samples can also be other corpora other than those from the table. The labeled training samples are input into the third classification layer of the initial text classification model. The parameters of the third classification layer of the initial text classification model are updated through training. When the trained third classification layer of the text classification model meets the preset conditions, the training ends, and a trained text classification model is obtained.
[0071] Step 420: Extract words from the table to be processed based on the type of words in the text of the cells in the table to be processed, and determine the second extraction result.
[0072] The second extraction result can refer to the table content after extracting the words from the cells of the table to be processed based on word types. In some embodiments, the second extraction result can be determined based on the word types in the cells of the table to be processed and the user's requirements. For example, if the content of a cell in the table is "The number of supermarkets has been counted, which is 5", and the user's required word type is location, then the word in the cell can be extracted, and the content of the extracted cell will be "supermarket".
[0073] In some embodiments, the table to be processed can be extracted based on the word types in the text of cells and the classification results of columns and / or rows, resulting in a third extraction result. This third extraction result can be the table content obtained after extracting the table content based on the word types in the text of cells and the classification results of columns and / or rows. For example, cells in the table obtained from the first extraction result can be processed to determine the word types in the text of those cells; then, the content of those cells can be extracted based on the word types in the text of those cells to determine the third extraction result.
[0074] In some embodiments, the extraction method can be selected based on needs or table type. For example, if all cells in the table except the header are numerical, extraction can be based solely on... Figure 2The corresponding extraction method. If, excluding the header, other cells in the table contain both numerical values and text or letters, then extraction can be based on... Figure 2 Extraction is done in the manner of 3.
[0075] For more information on extracting data from a table based on the type of words in the text of a cell, please refer to steps 410-420 and their related descriptions. For more information on extracting data from the table to be processed based on the classification results of columns and / or rows, please refer to steps 210-240 and their related descriptions. These details will not be repeated here.
[0076] In some embodiments of this specification, the text classification model can be used to determine the word type of a cell, and then a second extraction result can be determined based on the word type. This setup allows for the extraction of content from cells in a table to be processed, determining the extraction result, and obtaining the content needed by the user. In some embodiments of this specification, the table to be processed can be extracted based on the word type of the cells and the classification results of the columns and / or rows, resulting in a third extraction result. This allows for two extractions of the table, making the resulting table content more concise and easier for users to view. Furthermore, in some embodiments of this specification, the text classification model is set to the BERT-NER model. Since the word encoding layer of the BERT-NER model can be pre-processed and obtained through various methods, only the word classification layer of the BERT-NER model needs to be trained, reducing the number of training samples and lowering the training difficulty.
[0077] Figure 5 This is an exemplary flowchart illustrating the determination of a table to be processed according to some embodiments of this specification. In some embodiments, process 500 may be executed by the acquisition module 110. Figure 5 As shown, process 500 may include the following steps:
[0078] Step 510: Obtain the initial table and its title.
[0079] An initial form refers to a form that initially needs to be determined to contain information of interest to the user. The initial form can contain various types of information, which may be of interest to the user or not. For example, an initial form may include financial statements, personnel reports, annual reports, etc. Financial statements may include balance sheets, income statements, cash flow statements, statements of changes in equity, notes to the financial statements, etc. In some embodiments, the initial form can be obtained in multiple ways. For example, the initial form can be a user-generated form stored on the processor and can be obtained directly from the processor. Another example is that the initial form can be obtained from the network.
[0080] The title can be the filename when the initial table is stored. For example, if the filename of an initial table is "2031 Business Status Statistics", then "2031 Business Status Statistics" is the title of that initial table. In some embodiments, when the initial table is obtained, its title can also be obtained.
[0081] Step 520: Process the text in the initial table and its title based on the table classification model to determine the classification result of the initial table.
[0082] The classification result of the initial table can refer to the classification result of the initial table. The categories of the initial table can be determined according to user needs. For example, the initial table can be classified into finance, human resources, etc., based on the fields involved in the initial table. Or, the initial table can be classified into 2030 table, 2031 table, 2032 table, etc., based on the time period involved in the initial table.
[0083] In some embodiments, the initial table classification results may include positive sample tables and negative sample tables, where positive sample tables may refer to tables that meet user needs, and negative sample tables may refer to tables that do not meet user needs. For example, in a certain business scenario, the tables required by users are the three major financial statements, so the positive sample tables in the initial table may be the balance sheet, income statement, and cash flow statement, and the negative sample tables may be other statements.
[0084] In some embodiments, the title and text of the initial table can be preprocessed to obtain preprocessed text. For example, the title and text of the initial table can be concatenated to obtain a concatenated result, which can then be used as the preprocessed text. A special identifier "[SEP]" can be added to the title and text of the initial table during concatenation to distinguish the content of each part in the concatenated result. Figure 3A As shown, the table is named "2031 Business Status Statistics". By combining the title and the table, the result is "2031 Business Status Statistics [SEP] Category; First Half of the Year; Second Half of the Year; Item; Revenue; Sales Revenue; Other Revenue; Expenses; Taxes; Wages".
[0085] It should be understood that the specific meaning of a value cannot be represented solely by the values in each cell of the initial table. Therefore, when preprocessing the text in the initial table, the numerical content of each cell can be omitted.
[0086] In some embodiments, preprocessed text can be input into a table classification model, and the output of the table classification model can include the classification result of the initial table. For example, a table may be classified as a positive sample table or a negative sample table.
[0087] In some embodiments, the number of characters in the text input to the table classification model should be less than a first threshold. The first threshold may refer to the number of characters in the input text allowed by the table classification model. For example, the first threshold may be 100, which means that the number of characters in the concatenated text input to the table classification model needs to be less than 100.
[0088] In some embodiments, the number of words taken from the title in the text input to the table classification model should be less than a second threshold. The second threshold may refer to the number of words in the title that the table classification model allows in the input text. For example, the second threshold may be 20, which means that the number of words taken from the title in the concatenated result input to the table classification model needs to be less than 20.
[0089] In some embodiments, the table classification model can be a Bidirectional Encoder Representations from Transformers (BERT) model. Correspondingly, when the table classification model is a BERT model, the first threshold can be the maximum number of characters allowed as input by the BERT model. For example, when the table classification model is a BERT model, the maximum number of characters allowed as input by the BERT model is 512, and correspondingly, the first threshold is also 512.
[0090] In some embodiments, when the table classification model is a BERT model, it can be trained based on historical table data. The BERT model may include a vectorization part and a task processing part, where the vectorization part can be obtained through pre-training. Therefore, during training, only the task processing part of the table classification model can be trained based on multiple training samples. After training the task processing part, a trained table classification model is obtained. Historical table data can be preprocessed to obtain preprocessed text, which is then input into the vectorization part of the initial table classification model to obtain vectorized historical table data. This vectorized historical table data is used as training samples. The labels of the training samples can be the classification results corresponding to the historical table data, which can be obtained based on manual annotation. Labeled training samples are input into the task processing part of the initial table classification model. The parameters of the task processing part of the initial table classification model are updated through training. When the trained task processing part of the table classification model meets preset conditions, training ends, and a trained table classification model is obtained.
[0091] In some embodiments, the table classification model can also be other types of models, such as, but not limited to, support vector machine models, logistic regression models, naive Bayes classification models, Gaussian distribution Bayes classification models, decision tree models, random forest models, KNN classification models, and neural network models.
[0092] Step 530: When the classification result of the initial table meets the first preset condition, the initial table is determined as the table to be processed.
[0093] The first preset condition can represent the condition in the initial table that meets the user's requirements. In some embodiments, the first preset condition can refer to the classification result of the initial table being a positive sample table. For example, if the user needs the three major financial statements, when the initial table contains the contents of the balance sheet, income statement, and cash flow statement, it can be determined that the classification result of the initial table is a positive sample table, thereby confirming that the classification result of the initial table meets the first preset condition. The acquisition module 110 can determine the initial table that meets the first preset condition as the table to be processed.
[0094] In some embodiments, after the classification results of the initial table meet the first preset condition, the initial table can be further cleaned by deleting redundant rows and / or columns, and the cleaned initial table can be identified as the table to be processed. For more information on cleaning the initial table, see [link to relevant documentation]. Figure 2 The details and related descriptions will not be repeated here.
[0095] In some embodiments, when the classification result of the initial table does not meet the first preset condition, the initial table is filtered out and no further processing is performed. For example, the user needs the three major financial statements, while initial table A is an annual report and initial table B is a statement of changes in equity. Their content is unrelated to the three major financial statements, so the classification results of initial tables A and B are negative sample tables, which do not meet the first preset condition. The acquisition module 110 can filter out initial tables A and B that do not meet the first preset condition and not perform further processing on them.
[0096] Some embodiments in this specification use a table classification model to determine the classification result of the initial table, thereby identifying positive sample tables as the tables to be processed. This allows for precise location of the tables to be processed and filtering out redundant negative sample tables that are irrelevant to the user. Furthermore, some embodiments in this specification use the BERT model for table classification. Since the vectorization part of the BERT model is pre-processed and can be obtained through various methods, only the task processing part of the BERT model needs to be trained, reducing the number of training samples and lowering the training difficulty. Simultaneously, processing the initial table based on the BERT model allows for a more accurate learning of the meaning of the input text, thus accurately classifying the initial table and determining the tables to be processed.
[0097] Figure 6 This is a schematic diagram of the detection row header according to some embodiments of this specification. In some embodiments, process 600 may be executed by the first determining module 120. Figure 6 As shown, process 600 includes the following steps:
[0098] Step 610: Based on the row concatenation rules, concatenate the cells of the rows in the table to be processed to obtain the first concatenation result.
[0099] In some embodiments, the first determining module 120 may concatenate the cells of the rows in the table to be processed based on row concatenation rules to obtain a first concatenation result.
[0100] Row concatenation rules refer to rules for concatenating cells based on row order. In some embodiments, row concatenation rules may include concatenating cells from different rows based on row order, and concatenating cells within a row based on their order within that row. For example, a row concatenation rule might concatenate cells from left to right within each row, and then concatenate the results from different rows from top to bottom. In some embodiments, row concatenation rules may also include the number of times merged cells are concatenated. For example, merged cells might be concatenated only once.
[0101] For example, such as Figure 3A As shown, the first three rows of the table are concatenated based on the row concatenation rules, and the concatenation result is "Category; Subject; 2030; 2031; First Half; Second Half; Revenue; Sales Revenue; 15000; 8000; 9000".
[0102] The first concatenation result can refer to the result of concatenating cells in the rows of the table to be processed based on row concatenation rules.
[0103] In some embodiments, the first determining module 120 may concatenate the first m rows of a table to be processed based on row concatenation rules, wherein the table to be processed contains n rows, and m is less than or equal to n. In some embodiments, m may be preset (e.g., m is 2, etc.). For example, Figure 3A As shown, the first three rows are concatenated. The first concatenation result can be "Category; Subject; 2030; 2031; First Half; Second Half; Revenue; Sales Revenue; 15000; 8000; 9000".
[0104] Step 620: Process the first splicing result based on the row header detection model to determine the row header of the table to be processed.
[0105] In some embodiments, the first concatenation result corresponding to the table to be processed can be input into the row header detection model, and the output of the row header detection model can be the probability that each row in the input rows belongs to the row header. Further, the first determining module 120 can determine the row header based on the output of the row header detection model. For example, rows with a probability greater than a probability threshold can be used as row headers. Another example is determining the starting row of the row header based on rows with a probability greater than the probability threshold, thus further determining the row header. It is understood that the output of the row header detection model can also be in other forms, such as directly outputting the row number of the row header.
[0106] like Figure 3A As shown, when the first concatenation result of the first three rows of the table, based on the row concatenation rules, is "Category; Subject; 2030; 2031; First Half; Second Half; Revenue; Sales Revenue; 15000; 8000; 9000", this first concatenation result is input into the row header detection model. The output of the row header detection model can be [0,1], which means that the first and second rows of the table are the row headers of the table. It should be understood that when the processor processes the table, the row index starts from 0, so [0,1] represents the first and second rows of the table.
[0107] In some embodiments, the row header detection model may include a feature embedding layer, a first sequence layer, a first fusion layer, a second sequence layer, and a first classification layer connected in sequence. Correspondingly, step 620 may include the following steps:
[0108] Step 621: Based on the first splicing result, determine the first feature vector of the cell in the row of the table to be processed.
[0109] In some embodiments, the feature embedding layer can be used to determine a first feature vector of a cell in a table to be processed, based on the concatenation result of the cells in the table to be processed. For example, the input of the feature embedding layer is the first concatenation result, and the output is the first feature vector of the cell in the row of the table to be processed.
[0110] The first feature can include the cell's positional feature and textual feature. Correspondingly, the first feature vector can be vector information representing the cell's positional and textual features. The cell's positional feature represents the cell's location within the table to be processed. In some embodiments, the cell's positional feature can be [a, b, c, d], where a represents the cell's row number, b represents its column number, c represents whether the cell spans multiple rows, and d represents whether the cell spans multiple columns. For example, a cell's positional feature vector being [0,0,1,1] indicates that the cell is in the 1st row and 1st column of the table to be processed, spanning one row and one column. The textual feature represents the text content within the cells of the table to be processed.
[0111] In some embodiments, the feature embedding layer may include an embedding layer, a linear transformation layer, etc. The first determining module 120 can determine the first feature vector of a cell in the table to be processed based on the embedding layer and the linear transformation layer, using the cell's positional features and text features. For example, in the embedding layer, the four positional information elements of the cell's positional features are each represented by an embedding vector; the four embedding vectors corresponding to the four positional information elements yield a feature vector representing the cell's positional information. As another example, the text in the cell can be represented as a vector in the embedding layer to obtain a feature vector representing the text information. The linear transformation layer performs a linear transformation on the feature vectors representing the cell's positional information and the feature vectors representing the text information, making their vector dimensions the same. The feature vectors representing the cell's positional information and the feature vectors representing the text information, both with the same dimension, are added together using vector matrix addition to obtain the first feature vector of the cell.
[0112] Step 622: Determine the second feature vector of the cell in the row of the table to be processed based on the first feature vector of the cell in the row of the table to be processed.
[0113] In some embodiments, the first sequence layer can be used to determine a second feature vector of a cell in a table to be processed based on a first feature vector of the cell in the table to be processed. For example, the input of the first sequence layer is the first feature vector of the cell in a row of the table to be processed, and the output is the second feature vector of the cell in the row of the table to be processed.
[0114] The second feature vector refers to a feature vector that can represent the relationship information between cells input before and after; it is a feature vector that integrates the relationship information between cells. For example, it represents the semantic information between cells.
[0115] In some embodiments, the first sequence layer may be implemented based on a Long Short-Term Memory (LSTM) network. The first sequence layer may also be other sequence models, such as RNNs.
[0116] Step 623: Determine the third feature vector of the row in the table to be processed based on the second feature vector of the cell in the row.
[0117] In some embodiments, the first fusion layer can be used to determine a third feature vector of a row or column in the table to be processed based on a second feature vector of a cell in the table to be processed. For example, the input of the first fusion layer is the second feature vector of a cell in a row of the table to be processed, and the output is the third feature vector of the row.
[0118] The third feature vector refers to a feature vector that can represent a specific row or column in a table to be processed. In other words, the third feature vector is a vector generated by integrating the feature information of all cells in a row or column. For example, when the first row of a table to be processed contains the second feature vectors of 4 cells, the corresponding third feature vector of the first row can represent the feature vector of the information of those 4 cells. As another example, if the first column of a table to be processed contains the second feature vectors of 3 cells, the third feature vector of the first column can represent the feature vector of the information of the second feature vectors of those 3 cells.
[0119] In some embodiments, the first fusion layer can be a pooling layer. The pooling layer can perform pooling on the cells in each row or column, obtaining a third feature vector for each row or column through max pooling or average pooling, etc. For example, the pooling layer can merge the second feature vectors of multiple cells in a row into a third feature vector for that row.
[0120] Step 624: Determine the fourth feature vector of the row in the table to be processed based on the third feature vector of the row in the table to be processed.
[0121] In some embodiments, the second sequence layer can be used to determine a fourth feature vector of a row in the table to be processed based on a third feature vector of the row in the table to be processed. The second sequence layer can also be used to determine a fourth feature vector of a column in the table to be processed based on a third feature vector of the column in the table to be processed. For example, the input to the second sequence layer can be the third feature vector of the row, and the output can be the fourth feature vector of the row.
[0122] The fourth feature vector refers to a feature vector that can characterize the relationship information between rows or columns. In other words, the fourth feature vector integrates the information of the correlation between rows or columns. For example, the relationship information can include semantic information.
[0123] In some embodiments, the second sequence layer can be implemented based on LSTM. The second sequence layer can also be other sequence models, such as RNNs.
[0124] Step 625: Determine the row header of the table to be processed based on the fourth feature vector of the rows in the table to be processed.
[0125] In some embodiments, the first classification layer can be used to determine the row headers of the table to be processed based on the fourth feature vectors of the rows in the table. For example, the input of the first classification layer is the fourth feature vector of the row, and the output is the row header. Further details regarding the output format can be found in the description of step 620.
[0126] In some embodiments, the first classification layer may include, but is not limited to, support vector machine models, logistic regression models, naive Bayes classification models, Gaussian distribution Bayes classification models, etc.
[0127] In some embodiments, the parameters of the feature embedding layer, first sequence layer, first fusion layer, second sequence layer, and first classification layer in the row header detection model can be obtained through joint training. Historical table data can be processed based on row concatenation rules to obtain the first concatenation results of multiple samples corresponding to the historical table data, and these first concatenation results are used as training samples. The labels of the training samples are the row headers of the historical table data. In some embodiments, the training samples can be input into the feature embedding layer of the initial row header detection model to obtain the output of the feature embedding layer. The output of the feature embedding layer is then input into the first sequence layer to obtain the output of the first sequence layer. The output of the first sequence layer is then input into the first fusion layer to obtain the output of the first fusion layer. The output of the first fusion layer is then input into the first classification layer to obtain the output of the first classification layer. A loss function is constructed based on the output of the first classification layer and the labels, and the parameters of each layer in the initial row header detection model are iteratively updated simultaneously based on the loss function until preset conditions are met and training is complete, resulting in a trained row header detection model.
[0128] The parameters of each layer in the row header detection model obtained by the above training method can help solve the problem of difficulty in obtaining labels when training each layer in the row header detection model alone in some cases.
[0129] Figure 7 This is a schematic diagram of the detection list header according to some embodiments of this specification. In some embodiments, process 700 may be executed by the first determining module 120. Figure 7 As shown, process 700 may include the following steps:
[0130] Step 710: Based on the column concatenation rules, concatenate the cells of the columns in the table to be processed to obtain the second concatenation result.
[0131] Column concatenation rules refer to rules for concatenating cells based on column order. In some embodiments, column concatenation rules may include concatenating cells from different columns based on column order, and concatenating cells within each column based on their order within that column. For example, a column concatenation rule might concatenate cells from top to bottom within each column, and then concatenate the results from different columns from left to right. In some embodiments, column concatenation rules may also include the number of times merged cells are concatenated. For example, merged cells might be concatenated only once. For instance, as shown... Figure 3A As shown, the first two columns of the table are concatenated based on the column concatenation rules, and the concatenated result is "Category; Income; Expenses; Items; Sales Revenue; Other Income; Taxes; Salaries".
[0132] The second concatenation result can refer to the result of concatenating cells in the columns of the table to be processed based on column concatenation rules.
[0133] The content of step 710 is similar to that of step 610, the only difference being that step 710 processes the cells in a column, while step 610 processes the cells in a row. Therefore, for more details about step 710, please refer to step 610, which will not be repeated here.
[0134] Step 720: Process the second splicing result based on the list header detection model to determine the list header of the table to be processed.
[0135] In some embodiments, the second concatenation result corresponding to the table to be processed can be input into the list header detection model, and the output of the list header detection model can be the list header of the table to be processed. In some embodiments, the list header detection model may also include a feature embedding layer, a first sequence layer, a first fusion layer, a second sequence layer, and a first classification layer connected in sequence. Correspondingly, step 720 may also include the following steps:
[0136] Step 721: Based on the second concatenation result, determine the first feature vector of the cell in the column of the table to be processed. In some embodiments, the input to the feature embedding layer is the second concatenation result, and the output is the first feature vector of the cell in the column of the table to be processed.
[0137] Step 722: Determine the second feature vector of the cells in the column of the table to be processed based on the first feature vector of the cells in the column of the table to be processed. In some embodiments, the input of the first sequence layer is the first feature vector of the cells in the column of the table to be processed, and the output is the second feature vector of the cells in the column of the table to be processed.
[0138] Step 723: Determine the third feature vector of the column in the table to be processed based on the second feature vector of the cell in the column. In some embodiments, the input to the first fusion layer can be the second feature vector of the cell in the column of the table to be processed, and the output can be the third feature vector of the column.
[0139] Step 724: Determine the fourth feature vector of the column in the table to be processed based on the third feature vector of the column. In some embodiments, the input to the second sequence layer can be the third feature vector of the column, and the output can be the fourth feature vector of the column.
[0140] Step 725: Determine the list header of the table to be processed based on the fourth feature vector of the columns in the table to be processed. In some embodiments, the first classification layer can be used to determine the list header of the table to be processed based on the fourth feature vector of the columns in the table to be processed. For example, the input of the first classification layer can be the fourth feature vector of the column, and the output is the list header.
[0141] The content of step 720 is similar to that of step 620 (model content, execution method, training process). The only difference is that step 720 processes the columns in the table to be processed and determines the column headers, while step 620 processes the rows in the table to be processed and determines the row headers. Therefore, for more information about step 720, please refer to step 620, which will not be repeated here.
[0142] In some embodiments of this specification, the row headers of the table to be processed can be determined using a row header detection model, and the list headers can be determined using a list header detection model. Both the row header and list header detection models include a feature embedding layer, a first sequence layer, a first fusion layer, a second sequence layer, and a first classification layer connected in sequence. These models can obtain information about different cells in the table to be processed and the relationships between cells. They can also obtain the relationships between different rows or columns and the rows or columns before and after them, thereby determining the row headers and list headers. This allows for precise location of the row headers and list headers of the table to be processed, ensuring the accuracy of the extraction results.
[0143] Figure 8 This is a schematic diagram illustrating the classification results of determined columns according to some embodiments of this specification. In some embodiments, process 800 may be executed by a second determining module 130. Figure 8 As shown, process 800 may include the following steps:
[0144] Step 810: Based on the column concatenation rules, concatenate the cells in the row header to obtain the third concatenation result.
[0145] The third concatenation result can refer to the result of concatenating cells in the row header based on column concatenation rules. For example... Figure 3A As shown, the table headers are rows one and two. Based on column concatenation rules, the cells in rows one and two are concatenated to obtain the third concatenated result: "Category; Subject; 2030; 2031; First Half; Second Half". For more information on column concatenation rules, please see [link to relevant documentation]. Figure 7 The details and related descriptions will not be repeated here.
[0146] Step 820: Based on the row header classification model, process the third concatenation result, the cell number and column number of the cells in the row header, and determine the classification result of the columns in the table to be processed.
[0147] Cell numbers represent the location information of each cell in the table to be processed. Column numbers represent the location information of each column in the table to be processed. Correspondingly, row numbers represent the location information of each row in the table to be processed.
[0148] In some embodiments, the rows and columns in the table to be processed can be numbered according to preset rules. For example, the rows in the table to be processed can be numbered A, B, C, ... from top to bottom, and the columns can be numbered 0, 1, 2, ... from left to right.
[0149] In some embodiments, the cell number can be determined based on the row and column of the cell. For example, if the rows in the table to be processed are numbered A, B, C, ... from top to bottom, and the columns are numbered 0, 1, 2, ... from left to right, the table to be processed is... Figure 3A In the table shown, the numbers corresponding to "Category" are A to B0, "Subject" is A to B1, "Expenditure" is E to F0, "First Half of the Year" is B3, and "Salary" is F1. In some embodiments, when a cell is a merged cell, the row number corresponding to that cell can also be the number of the first row in the merged row, or the column number corresponding to that cell can also be the number of the first column in the merged column. For example, the table to be processed is... Figure 3A In the table shown, the number corresponding to "2031" can be A3, and the number corresponding to "Income" can be C0. In some embodiments, cells can also be numbered in other ways. For example, starting directly from the cell table corresponding to the first row and first column, the cell corresponding to the first row and first column can be numbered as 1, and so on from left to right. The cell corresponding to the first row and second column can be numbered as 2, the cell corresponding to the first row and third column as 3, and so on. After the cells in the first row are numbered, the cells corresponding to the second row and first column can be numbered, until all cells in the table to be processed are numbered.
[0150] In some embodiments, the third concatenation result, the cell number and column number of the cell in the row header can be input into the row header classification model, and the output of the row header classification model can be the classification result of the column in the table to be processed.
[0151] In some embodiments, the row header classification model may include a coding layer, a second fusion layer, an attention layer, a third fusion layer, and a second classification layer connected in sequence. Correspondingly, step 820 may include the following steps:
[0152] Step 821: Based on the third concatenation result, encode the characters in the cells of the row header to obtain the character encoding vector.
[0153] The characters can be any text in the cell, such as words, numbers, etc.
[0154] In some embodiments, the encoding layer can be used to encode characters in cells of the row header or list header based on the concatenation result of the header cells, to obtain the encoding vector of the characters in the row header or list header. For example, the input to the encoding layer can be a third concatenation result, and the output can be the encoding vector of the characters in the row header.
[0155] In some embodiments, the encoding layer can be a BERT model. In some embodiments, the encoding layer can be pre-trained.
[0156] Step 822: Determine the cell's encoding vector based on the cell number in the row header and the encoding vector of each character in that cell.
[0157] In some embodiments, the second fusion layer can be used to determine the encoding vector of a cell in the row header based on the cell number of the cell in the row header and the encoding vector of each character in that cell. For example, the input of the second fusion layer is the cell number of the cell in the row header and the encoding vector of each character in that cell, and the output is the encoding vector of the cell in the row header.
[0158] A cell's encoding vector is an encoding vector that can represent the text information in a cell.
[0159] The second fusion layer can fuse the encoding vectors of characters in the same cell based on the cell number to obtain the cell's encoding vector. In some embodiments, the second fusion layer can be a pooling layer, and the fusion process is a pooling process, such as max pooling or average pooling.
[0160] Step 823: Determine the cell fusion feature vector of the cell in the row header based on the encoding vector of the cell and the column number of the cell.
[0161] In some embodiments, the attention layer can be used to determine the cell fusion feature vector of a cell in the row header based on the encoding vector of that cell and the column number of that cell. For example, the input to the attention layer is the encoding vector of the cell in the row header and the column number of that cell, and the output is the cell fusion feature vector of that cell.
[0162] The cell fusion feature vector of a cell in the row header can refer to a feature vector that contains the relationship between the cell and other cells in the same column of the row header. For example, the relationship can be correlation or attention information.
[0163] In some embodiments, when processing the row header, the attention layer can obtain a cell fusion feature vector for each cell based on the attention magnitude between cells in the same column of the row header. The cell fusion feature vector contains the relationship between the cell and other cells in the same column. That is, the cell fusion feature vector can fuse information from other cells in the same column.
[0164] like Figure 10A As shown, Figure 10A This is the header row of a table. The header row contains 4 cells: cell number 1 for "2030", cell number 2 for "2031", cell number 3 for "first half of the year", and cell number 4 for "second half of the year". Figure 10B This is a mask array corresponding to the row header, where "1", "2", "3", and "4" represent different cell numbers. In the mask matrix, black circles represent cells that are visible relative to the given cell, and white circles represent cells that are not visible relative to the given cell. When classifying the row headers, cells in the same column are visible. For example... Figure 10B As shown, Figure 10A In the row header shown, cell number 1 is visible only to itself (i.e., cell number 1). Cell number 2 is visible to cells numbered 2, 3, and 4. Cell number 3 is visible to cells numbered 2 and 3, and cell number 4 is visible to cells numbered 2 and 4. The attention layer, during the classification of the row header, can determine the attention level between cells in the same column using the aforementioned mask array method. This allows for the fusion of information from visible cells, calculation of the attention level between cells, and ultimately, determination of the cell fusion feature vector in the row header.
[0165] Step 824: Based on the cell fusion feature vector of the cell in the row header, determine the column fusion feature vector of the column corresponding to the row header.
[0166] In some embodiments, the third fusion layer can be used to determine the column fusion feature vector of the column corresponding to the row header based on the cell fusion feature vector of the cell in the row header. For example, the input of the third fusion layer is the cell fusion feature vector of the cell in the row header, and the output is the column fusion feature vector of the column corresponding to the row header.
[0167] It should be understood that the cells in the row headers of the table to be processed are used to classify the columns in the table, while the cells in the list headers of the table to be processed are used to classify the rows in the table. Therefore, when classifying the row headers, the column fusion feature vector of the corresponding column is determined, while when classifying the list headers, the row fusion feature vector of the corresponding row is determined.
[0168] Column fusion feature vectors refer to feature vectors that can represent cells in the same column of a table header.
[0169] When classifying the row headers, the third fusion layer can fuse the feature vectors of cells in the same column of the row headers to obtain the column fusion feature vector of the column corresponding to the row header. In some embodiments, the third fusion layer can be a pooling layer. Accordingly, the fusion process can be a pooling process, such as max pooling or average pooling.
[0170] Step 825: Determine the classification result of the column based on the column fusion feature vector corresponding to the column header.
[0171] In some embodiments, the second classification layer can be used to determine the classification result of a column based on the column fusion feature vector of the column corresponding to the row header. For example, the input of the second classification layer can be the column fusion feature vector of the column corresponding to the row header, and the output can be the classification result of the column.
[0172] In some embodiments, the second classification layer may include, but is not limited to, support vector machine models, logistic regression models, naive Bayes classification models, Gaussian distribution Bayes classification models, etc.
[0173] In some embodiments, the parameters of the encoding layer, second fusion layer, attention layer, third fusion layer, and second classification layer in the row header classification model can be obtained through joint training. The row headers in historical table data can be processed based on column concatenation rules to obtain the third concatenation results of multiple samples corresponding to the historical table data. These third concatenation results are used as training samples. The labels of the training samples are the classification results of each column in the historical table data. In some embodiments, the training samples can be input into the encoding layer of the initial row header classification model to obtain the output of the encoding layer. The output of the encoding layer is then input into the second fusion layer to obtain the output of the second fusion layer. The output of the second fusion layer is then input into the attention layer to obtain the output of the attention layer. The output of the attention layer is then input into the second classification layer to obtain the output of the second classification layer. A loss function is constructed based on the output of the second classification layer and the labels. The parameters of each layer in the initial row header classification model are iteratively updated based on the loss function until preset conditions are met and training is complete, resulting in a trained row header classification model.
[0174] The parameters of each layer in the row header classification model obtained by the above training method can help solve the problem of difficulty in obtaining labels when training each layer in the row header classification model alone in some cases.
[0175] Figure 9 This is a schematic diagram illustrating the determination of the classification results of rows in a table to be processed according to some embodiments of this specification. In some embodiments, process 900 may be executed by a second determining module 130. Figure 9 As shown, process 900 may include the following steps:
[0176] Step 910: Based on the row concatenation rules, concatenate the cells in the list header to obtain the fourth concatenation result.
[0177] The fourth concatenation result can refer to the result of concatenating the cells in the list header based on row concatenation rules. For more information on row concatenation rules, see [link to relevant documentation]. Figure 6 The details and related descriptions will not be repeated here.
[0178] Step 920: Based on the list header classification model, process the fourth concatenation result, the cell number and row number of the cells in the list header, and determine the classification result of the rows in the table to be processed.
[0179] In some embodiments, the fourth concatenation result, the cell number and row number of the cells in the list header can be input into the list header classification model, and the output can be the classification result of the rows in the table to be processed. In some embodiments, the list header classification model also includes an encoding layer, a second fusion layer, an attention layer, a third fusion layer and a second classification layer connected in sequence. Correspondingly, step 920 may also include the following steps:
[0180] Step 921: Based on the fourth concatenation result, encode the characters in the cells of the list header to obtain the character encoding vector. In some embodiments, the input to the encoding layer can be the fourth concatenation result, and the output can be the encoding vector of the characters in the list header.
[0181] Step 922: Determine the encoding vector of the cell based on the cell number of the cell in the list header and the encoding vector of each character in that cell. In some embodiments, the second fusion layer can be used to determine the encoding vector of the cell in the list header based on the cell number of the cell in the list header and the encoding vector of each character in that cell. For example, the input to the second fusion layer can be the cell number of the cell in the list header and the encoding vector of each character in that cell, and the output can be the encoding vector of the cell in the list header.
[0182] Step 923: Determine the cell fusion feature vector of the cell in the list header based on the encoding vector of the cell and the row number of the cell. In some embodiments, the attention layer can be used to determine the cell fusion feature vector of the cell in the list header based on the encoding vector of the cell and the row number of the cell. For example, the input of the attention layer is the encoding vector of the cell in the list header and the column number of the cell, and the output is the cell fusion feature vector of the cell. Here, the cell fusion feature vector of the cell in the list header can refer to a feature vector that contains the relationship between the cell and other cells in the same row of the list header.
[0183] Step 924: Based on the cell fusion feature vectors of the cells in the list header, determine the row fusion feature vector of the row corresponding to the list header. In some embodiments, the third fusion layer can be used to determine the row fusion feature vector of the row corresponding to the list header based on the cell fusion feature vectors of the cells in the list header. For example, the input to the third fusion layer can be the cell fusion feature vectors of the cells in the list header, and the output can be the row fusion feature vector of the row corresponding to the list header. Here, the row fusion feature vector refers to the feature vector that can represent the cells in the same row of the list header.
[0184] Step 925: Determine the classification result of the row based on the row fusion feature vector of the row corresponding to the list header. In some embodiments, the second classification layer can be used to determine the classification result of the row based on the row fusion feature vector of the row corresponding to the list header. For example, the input of the second classification layer can be the row fusion feature vector of the row corresponding to the list header, and the output is the classification result of the row.
[0185] The content of step 920 is similar to that of step 820 (model content, execution method, training process). The only difference is that step 920 determines the classification results of the rows in the table to be processed, while step 820 determines the classification results of the columns in the table to be processed. Therefore, for more information about step 920, please refer to step 820, which will not be repeated here.
[0186] In some embodiments of this specification, the classification results of columns in the table to be processed can be determined by a row header classification model, and the classification results of rows in the table to be processed can be determined by a list header classification model. Both the row header and list header classification models include a coding layer, a second fusion layer, a self-attention layer, a third fusion layer, and a second classification layer connected in sequence. The multi-layered structure of the row header classification model can be used to obtain the fusion features of cells in the same column of the row header in the table to be processed, and the same row of cells in the same list header in the table to be processed can also be obtained through the row header classification model, thereby determining the classification results of columns and rows. This allows for accurate classification of columns or rows in the table to be processed, improving the accuracy of extraction from the table and determining the accuracy of the extraction results.
[0187] Some embodiments of this specification also disclose a table processing apparatus, the apparatus including at least one processor and at least one memory; the at least one memory is used to store computer instructions; the at least one processor is used to execute at least a portion of the computer instructions to implement the table processing method as described in any of the foregoing embodiments.
[0188] Some embodiments of this specification also disclose a computer-readable storage medium that can store computer instructions that, when executed by a processor, implement the table processing method as described in any of the foregoing embodiments.
[0189] The basic concepts have been described above. Obviously, for those skilled in the art, the detailed disclosure above is merely illustrative and does not constitute a limitation of this specification. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and corrections to this specification. Such modifications, improvements, and corrections are suggested in this specification and therefore remain within the spirit and scope of the exemplary embodiments described herein.
[0190] Furthermore, this specification uses specific terms to describe embodiments thereof. For example, "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Moreover, certain features, structures, or characteristics in one or more embodiments of this specification can be appropriately combined.
[0191] Furthermore, unless expressly stated in the claims, the order of processing elements and sequences, the use of numbers and letters, or other names described in this specification are not intended to limit the order of the processes and methods described herein. Although various examples have been discussed in the foregoing disclosure of some embodiments of the invention that are currently considered useful, it should be understood that such details are for illustrative purposes only, and the appended claims are not limited to the disclosed embodiments; rather, the claims are intended to cover all modifications and equivalent combinations that conform to the spirit and scope of the embodiments described herein. For example, while the system components described above can be implemented using hardware devices, they can also be implemented solely using software solutions, such as installing the described system on existing servers or mobile devices.
[0192] Similarly, it should be noted that, in order to simplify the description disclosed herein and thus aid in the understanding of one or more embodiments of the invention, the foregoing description of embodiments in this specification may sometimes combine multiple features into a single embodiment, drawing, or description thereof. However, this method of disclosure does not imply that the subject matter of this specification requires more features than those mentioned in the claims. In fact, the embodiments contain fewer features than all the features of a single embodiment disclosed above.
[0193] In some embodiments, numbers describing the quantity of components and attributes are used. It should be understood that such numbers used in the description of embodiments are modified in some examples with the terms "approximately," "approximately," or "generally." Unless otherwise stated, "approximately," "approximately," or "generally" indicates that the numbers are allowed to vary by ±20%. Accordingly, in some embodiments, the numerical parameters used in the specification and claims are approximate values, which may be changed depending on the characteristics required by individual embodiments. In some embodiments, numerical parameters should take into account specified significant digits and employ a general method of digit reservation. Although the numerical ranges and parameters used to confirm their breadth of range in some embodiments of this specification are approximate values, in specific embodiments, such values are set as precisely as feasible.
[0194] For each patent, patent application, patent application publication, and other material, such as articles, books, specifications, publications, and documents, referenced in this specification, the entire contents of which are incorporated herein by reference. This excludes historical application documents that are inconsistent with or conflict with the content of this specification, as well as documents that limit the broadest scope of the claims in this specification (currently or subsequently appended to this specification). It should be noted that in the event of any inconsistency or conflict between the descriptions, definitions, and / or terminology used in the supplementary materials to this specification and the content of this specification, the descriptions, definitions, and / or terminology used in this specification shall prevail.
[0195] Finally, it should be understood that the embodiments described in this specification are merely illustrative of the principles of the embodiments described herein. Other variations may also fall within the scope of this specification. Therefore, alternative configurations of the embodiments described herein are intended to be illustrative rather than limiting, and should be considered consistent with the teachings of this specification. Accordingly, the embodiments described herein are not limited to those explicitly introduced and described herein.
Claims
1. A form processing method characterized by, The method comprises: obtaining a to-be-processed table; processing the to-be-processed table based on a table header detection model to determine row headers and / or column headers of the to-be-processed table; processing the row headers based on a table header classification model to determine classification results of columns in the to-be-processed table, and / or processing the column headers based on the table header classification model to determine classification results of rows in the to-be-processed table; extracting the to-be-processed table based on the classification results of the columns and / or rows in the to-be-processed table to determine a first extraction result; The table header detection model comprises a feature embedding layer, a first sequence layer, a first fusion layer, a second sequence layer and a first classification layer connected in sequence: The feature embedding layer is configured to determine a first feature vector of a cell in the to-be-processed table based on a splicing result of the cell in the to-be-processed table; The first sequence layer is configured to determine a second feature vector of the cell in the to-be-processed table based on the first feature vector of the cell in the to-be-processed table; The first fusion layer is configured to determine a third feature vector of a row or a column in the to-be-processed table based on the second feature vector of the cell in the to-be-processed table; The second sequence layer is configured to determine a fourth feature vector of the row in the to-be-processed table based on the third feature vector of the row in the to-be-processed table, or to determine a fourth feature vector of the column in the to-be-processed table based on the third feature vector of the column in the to-be-processed table; The first classification layer is configured to determine the row headers of the to-be-processed table based on the fourth feature vector of the row in the to-be-processed table, or to determine the column headers of the to-be-processed table based on the fourth feature vector of the column in the to-be-processed table; The table header classification model comprises a row header classification model and a column header classification model, and the table header classification model comprises an encoding layer, a second fusion layer, an attention layer, a third fusion layer and a second classification layer connected in sequence, wherein The encoding layer is configured to encode characters of a cell in the row headers or the column headers to obtain an encoding vector of the characters; The second fusion layer is configured to determine an encoding vector of the cell based on the encoding vector of the characters and a cell number of the cell in the column headers or the row headers; The attention layer is configured to determine a cell fusion feature vector of a cell in the column headers based on the encoding vector of the cell in the column headers and a row number of the cell, or to determine a cell fusion feature vector of a cell in the row headers based on the encoding vector of the cell in the row headers and a column number of the cell; The third fusion layer is configured to determine a row fusion feature vector of a row corresponding to the column headers based on the cell fusion feature vector of the cell in the column headers, or to determine a column fusion feature vector of a column corresponding to the row headers based on the cell fusion feature vector of the cell in the row headers; The second classification layer is configured to determine a classification result of the row based on the row fusion feature vector of the row corresponding to the column headers, or to determine a classification result of the column based on the column fusion feature vector of the column corresponding to the row headers.
2. The method of claim 1, wherein, The method further comprises: The text classification model is used to process the text in the cells in the to-be-processed table, to determine the type of the words in the text in the cells. The to-be-processed table is extracted based on the type of the words in the text in the cells, to determine a second extraction result.
3. The method of claim 1, wherein, The to-be-processed table is obtained by: obtaining an initial table and a title thereof; processing the text in the initial table and the title thereof based on a table classification model, to determine a classification result of the initial table; when the classification result of the initial table meets a first preset condition, determining the initial table as the to-be-processed table.
4. The method of claim 1, wherein, The table header detection model includes a row table header detection model and a list table header detection model, and the processing of the to-be-processed table based on the table header detection model to determine the row table header and / or the list table header of the to-be-processed table includes: processing the rows in the to-be-processed table based on the row table header detection model, to determine the row table header of the to-be-processed table; and / or processing the columns in the to-be-processed table based on the list table header detection model, to determine the list table header of the to-be-processed table.
5. The method of claim 4, wherein the processing of the rows in the to-be-processed table based on the row table header detection model to determine the row table header of the to-be-processed table includes: splicing the cells in the rows in the to-be-processed table based on a row splicing rule, to obtain a first splicing result; processing the first splicing result based on the row table header detection model, to determine the row table header of the to-be-processed table. The processing of the to-be-processed table based on the list table header detection model to determine the list table header of the to-be-processed table includes: splicing the cells in the columns in the to-be-processed table based on a column splicing rule, to obtain a second splicing result; processing the second splicing result based on the list table header detection model, to determine the list table header of the to-be-processed table.
6. The method of claim 1, wherein, The splicing result of the cells in the to-be-processed table includes a third splicing result or a fourth splicing result, wherein the third splicing result is obtained based on the following steps: splicing the cells in the row table header based on a column splicing rule, to obtain the third splicing result; The fourth splicing result is obtained based on the following steps: splicing the cells in the list table header based on a row splicing rule, to obtain the fourth splicing result.
7. The method of claim 1, wherein, The cell fusion feature vector of a cell in the list table header contains attention information of other cells in the same row as the cell, and the cell fusion feature vector of a cell in the row table header contains attention information of other cells in the same column as the cell.
8. A form processing system characterized by comprising: The system includes: an acquisition module configured to acquire a to-be-processed table; a first determination module configured to process at least one row and / or at least one column in the to-be-processed table based on a table header detection model, to determine a row table header and / or a list table header in the to-be-processed table; a second determination module configured to process the row table header based on a table header classification model, to determine a classification result of the columns in the to-be-processed table, and / or to process the list table header based on a table header classification model, to determine a classification result of the rows in the to-be-processed table; The extraction module is configured to extract the to-be-processed table based on the classification result of each column and / or each row in the to-be-processed table, and determine a first extraction result. The table header detection model comprises, in sequence, a feature embedding layer, a first sequence layer, a first fusion layer, a second sequence layer, and a first classification layer. The feature embedding layer is configured to determine a first feature vector of a cell in the to-be-processed table based on a splicing result of the cell. The first sequence layer is configured to determine a second feature vector of the cell in the to-be-processed table based on the first feature vector of the cell. The first fusion layer is configured to determine a third feature vector of a row or a column in the to-be-processed table based on the second feature vector of the cell in the to-be-processed table. The second sequence layer is configured to determine a fourth feature vector of the row in the to-be-processed table based on the third feature vector of the row, or determine a fourth feature vector of the column in the to-be-processed table based on the third feature vector of the column. The first classification layer is configured to determine the row header of the to-be-processed table based on the fourth feature vector of the row, or determine the column header of the to-be-processed table based on the fourth feature vector of the column. The table header classification model comprises a row header classification model and a column header classification model, and the table header classification model comprises, in sequence, an encoding layer, a second fusion layer, an attention layer, a third fusion layer, and a second classification layer. The encoding layer is configured to encode characters of a cell in the row header or the column header to obtain an encoding vector of the characters. The second fusion layer is configured to determine an encoding vector of the cell based on the encoding vector of the characters and a cell number of the cell in the row header or the column header. The attention layer is configured to determine a cell fusion feature vector of the cell in the column header based on the encoding vector of the cell in the column header and a row number of the cell, or determine a cell fusion feature vector of the cell in the row header based on the encoding vector of the cell in the row header and a column number of the cell. The third fusion layer is configured to determine a row fusion feature vector of a row corresponding to the column header based on the cell fusion feature vector of the cell in the column header, or determine a column fusion feature vector of a column corresponding to the row header based on the cell fusion feature vector of the cell in the row header. The second classification layer is configured to determine a classification result of the row based on the row fusion feature vector of the row corresponding to the column header, or determine a classification result of the column based on the column fusion feature vector of the column corresponding to the row header.
9. A table processing apparatus characterized by comprising: The apparatus comprises at least one processor and at least one memory. The at least one memory is configured to store computer instructions. The at least one processor is configured to execute at least part of the computer instructions to implement the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores computer instructions which, when executed by a processor, implement the method of any one of claims 1-7.
Citation Information
Patent Citations
Processing method for mass semi-structured data
CN109522452A
Table classification method and device, equipment, and storage medium
CN112989050A
Data table processing method and device, electronic equipment and storage medium
CN113204555A