Table information extraction method and system based on position information and layout matching
Through a method based on position information and layout matching, integrating semantic features and position features, training a cell classification model, and combining with layout analysis, the problem of high complexity of table information extraction in the existing technology is solved, and efficient and accurate table information is achieved. Extraction.
Patent Information
- Application Number
- CN202411139671.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-08-20
AI Technical Summary
The existing technology is limited by keywords, path rules and table styles in table information extraction, resulting in high extraction complexity and difficulty in adapting to different table styles and structures, resulting in low accuracy and low efficiency of information extraction.
Using a method based on position information and layout matching, by constructing a table text data set and a two-dimensional position information data set, semantic features and position features are extracted, and then used to train the cell classification model after fusion, determine the category of the cell, and combine it with the layout Analyze and extract table information.
It achieves high-precision and robust table information extraction, simplifies the determination of cell attributes, is suitable for various structured tables, improves the efficiency and accuracy of information extraction, and is suitable for other fields not limited to bidding and bidding.
Smart Images

Figure CN118657139B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of table processing, and in particular to a table information extraction method and system based on position information and format matching. Background Art
[0002] Websites of all walks of life publish a large number of bidding announcements such as tenders and winning bids every day. These announcements are mostly presented in the form of text plus tables. However, the disclosure of tables is more intuitive and comprehensive, and is mostly presented in unstructured and semi-structured forms. It is highly integrated and rich in information, but the style is complex and difficult to extract. For tenderers, automatic information extraction from tables can quickly process a large number of bidding documents, reduce the burden of manual review, and improve the efficiency of the entire bidding process; at the same time, accurate and complete data support enables tenderers to make more reasonable decisions based on sufficient information. For bidders, automatic information extraction from tables can help them obtain new bidding announcements in a timely manner, so as not to miss any potential business opportunities; at the same time, through in-depth analysis of bidding conditions, bidders can better evaluate the risks and benefits of the project, make decisions on whether to participate in the bidding, and improve their competitiveness.
[0003] In summary, it is crucial to use advanced technology to achieve high-precision and high-robustness table information extraction. Automated table extraction greatly reduces the burden of manual review and information capture, and speeds up information processing. To address this problem, existing methods can generally be divided into the following two types: (1) Extraction based on statistical knowledge, for example, based on keyword tag items and learning web page samples, the path rules (such as DOM tree) of the web page tags where the keywords are located are summarized, and then combined with specific filtering rules or manual marking to extract table information. However, this method is only suitable for extracting tables with relatively regular styles or simple structures. In addition, since specifying path rules based on keywords has limitations, and different table styles may have different path rules, it greatly reduces practicality. (2) Combined with deep learning models to achieve information extraction, for example, the semantic features of each row of the table are used as the input of the model to convert table extraction into a search-based text question-answering method. However, this method is limited to specific table styles, and because the line-by-line input cannot process the upper and lower line information, it leads to certain semantic loss, and it is too dependent on the question paradigm. Summary of the invention
[0004] In order to solve the technical problem in the prior art that table information extraction is relatively complicated due to limitations of factors such as keywords, path rules, table styles, etc., the present invention provides a table information extraction method and system based on position information and layout matching.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] In a first aspect, the present invention discloses a method for extracting table information based on position information and layout matching, comprising the following steps, namely S1 to S5.
[0007] S1. Construct a table text dataset in the document to be parsed and a corresponding two-dimensional position information dataset.
[0008] S2. Extract the semantic features of the table text dataset and the position features of the two-dimensional position information dataset, and fuse the two features to obtain the fused features.
[0009] S3. Construct a cell classification model based on cell position information, and input the fusion features into the trained cell classification model to obtain the label of each cell of each table text in the document to be parsed.
[0010] S4. Perform layout analysis on the table in combination with the label of each cell, so as to obtain the table layout of each table.
[0011] S5. Extract information from tables of different table formats according to preset logical extraction rules.
[0012] In a second aspect, the present invention further discloses a table information extraction system based on position information and layout matching, which applies the table information extraction method based on position information and layout matching. The table information extraction system includes: a data construction module, a feature extraction module, a cell classification module, a layout analysis module and an extraction module.
[0013] The data construction module is used to construct a table text dataset and a corresponding two-dimensional position information dataset in the document to be parsed;
[0014] The feature extraction module is used to extract the semantic features of the table text data set and the position features of the two-dimensional position information data set, and fuse the two features to obtain the fused features.
[0015] The cell classification module is used to construct a cell classification model based on cell position information, and input the fusion features into the trained cell classification model to obtain the label of each cell of each table text in the document to be parsed.
[0016] The layout analysis module is used to perform layout analysis on the table in combination with the label of each cell, so as to obtain the table layout of each table.
[0017] The extraction module is used to extract information from tables of different table formats according to preset logical extraction rules.
[0018] Compared with the prior art, the present invention has the following beneficial effects:
[0019] 1. The table information extraction method based on position information and layout matching disclosed in the present invention is an end-to-end table information extraction method, which refers to the process of accurately obtaining the category to which the cell belongs by integrating the position information of each cell of the table into the semantic information of the cell, obtaining the layout to which the table belongs based on the category to which the cell belongs, and finally realizing the table information extraction according to the corresponding layout. The determination of cell attributes is converted into a cell classification problem, which reduces the complexity of determining the cell category based on the keyword of the statistical rule and simplifies the difficulty of the table information extraction task.
[0020] 2. The present invention classifies the cell types into the following categories by analyzing to help determine the style of the table, such as clear types of key (can have multiple categories), generic of unknown type key , attribute value value , Header title In addition, through key By carrying out labeling in different fields, this technology can also be extended and applied to other fields not limited to bidding.
[0021] 3. Based on the cross-row and cross-column information of cells, the present invention fills the table with original values and empty values, and obtains the cell location information by comparing the text differences of cells at the same position. A cell classification model is constructed by integrating the cell location information with the semantic information of the cell. The model effectively utilizes the semantic information of the cell above and below, across rows and columns, and is of certain importance in assisting in determining the cell category.
[0022] 4. The present invention statistically analyzes the style of the table, divides simple tables and complex tables into four categories, and with the help of the prediction results of the cell classification model, any table can be matched to the four preset table formats. For different table formats, according to the corresponding logical extraction rules, accurate table extraction can be achieved. For various structured results, multiple data can be directly obtained by splitting the list after the colon and directly stored, which simplifies the difficulty of table information extraction.
[0023] 5. The table information extraction system based on position information and layout matching disclosed in the present invention can produce the same beneficial effects as the above method by applying the above method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 This is a flow chart of a table information extraction method based on position information and layout matching in Example 1 of the present invention.
[0025] Figure 2 Schematic diagram of a cell classification model based on cell location information in Example 1 of the present invention.
[0026] Figure 3 This is an architecture diagram of a table information extraction system based on location information and layout matching in Example 2 of the present invention. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] Example 1
[0029] See also Figure 1 , this embodiment provides a table information extraction method based on position information and layout matching, which is performed in the following steps, namely S1~S5.
[0030] S1. Constructing a table text dataset and a corresponding two-dimensional position information dataset in the document to be parsed. Step S1 may include the following specific steps, namely S11 to S15.
[0031] The document to be parsed can be obtained through a web crawler. In some embodiments, the document to be parsed can also be obtained from a pre-built database without web crawling. In this embodiment, the document to be parsed is a bidding document stored in Html form.
[0032] S11. Get the table data set in the document to be parsed T , ;in, T Any table in It consists of the text data of all cells in the table. , K The total number of tables in the document to be parsed.
[0033] In this embodiment, a regular matching string can be used to obtain a table from the Html document to be parsed. After that, the table can be pre-processed, including steps such as removing interfering tags and converting full-width to half-width.
[0034] S12. Based on the rowspan information and / or colspan information of the table, Fill the cells with original values and empty values respectively. Based on the two filling methods, two types of table texts can be obtained: the table text after filling with original values and the table text after null filling , and each table has the characteristic that each row has the same number of columns, and each column has the same number of rows.
[0035] Among them, colspan represents the cross-column information of the cell, and rowspan represents the cross-row information of the cell. If the cell element td (tabledatacell, data cell in the table) or th (tableheadercell, header cell) has colspan=X or rowspan=X, and X is a natural number not less than 1, it means that the cell actually merges X cells horizontally or vertically. In this embodiment, with the help of some table configurators, by configuring the vertical and horizontal padding to the original value padding, a table filled with the original value can be obtained; at the same time, by configuring the vertical and horizontal padding to the empty value padding, a table filled with the empty value can be obtained.
[0036] S13. According to the set maximum number of cell rows maxRow and the maximum number of columns maxCol , for two table texts and Do row and column truncation and / or row and column padding to keep the table a uniform size.
[0037] The row and column truncation can be understood as the number of rows or columns exceeding the set maximum number of rows or columns, and the table is truncated. maxRow The row or table is out of range maxCol The row and column filling means that the number of rows or columns is less than the maximum number of rows or columns set, then the last row or column of the original table is filled with some content as "[ PAD ]" so that the final table size is maxRow OK, maxCol List.
[0038] In this embodiment, after statistical analysis of the bidding tables, the proportion of tables with ≤20 rows and ≤10 columns is about 98%, so maxRow =20, maxCol =10. Assume that the maximum number of rows of the two table texts obtained in step S12 is RowNum , the maximum number of columns is ColNum ,like RowNum ≤20, then transform the matrix row by row = Fill to the last row; if RowNum >20, then the first 20 rows of the table are captured. ColNum ≤10, transform the matrix column by column = After filling to the last column; if ColNum >10, then the first 10 columns of the table text will be captured.
[0039] S14. By comparing the table text and Each cell in the same position Get the text difference in each cell The absolute position , thereby obtaining the table text A two-dimensional location information set , From table text The absolute positions of all cells in ; where 0≤ i < maxRow , 0≤ j < maxCol ; 0≤ i’ ≤ i ; 0≤ j’ ≤ j ; i , j ∈ N , N is a set of natural numbers.
[0040] It should be noted that the absolute position information described here refers to the actual position of the cell, and the relative position information refers to the row and column offset relative to the first row and first column. Specifically, if the cell does not involve row and column merging (i.e. cowspan=0 and colspan=0 mentioned above), the absolute position of the cell is , which is equal to the relative position; if it involves row and column merging, it is necessary to determine which cell the cell actually comes from To determine whether the current cell involves row and column filling, you can use the table text filled with the original value. and the table text filled with null values When the text in cells at the same position is the same, the cell is a cell that is not obtained across rows and columns. If the text is different, the cell is a cell obtained based on the cross-row and cross-column information.
[0041] To find cells The real location The process is described in detail as follows:
[0042] (1) If the current cell text is No. i OK j -1 column cell text is the same, compare the current cell text with No. i Row, No. j -2, j -3,…, j -f Difference in cell text for the column, where 1≤ f ≤ j , if exists j - f If the cell text of the column is different from the current cell text, then , otherwise there is .
[0043] (2) If the current cell text is No. i OK j -1 The cell text of the column is different, and the current cell text is compared with No. i -1, i -2,…, i - g OK, j Difference in cell text for the column, where 1≤ g ≤ i , if exists i - g If the cell text of the row is different from the current cell text, then Otherwise there is .
[0044] S15. Referring to steps S11 to S14, construct a table text dataset of the document to be parsed And the corresponding two-dimensional location information dataset ;in, ;
[0045] Table text ; Representation table No. i Line j The cell text of the column; .
[0046] S2. Extracting semantic features of the table text dataset and position features of the two-dimensional position information dataset, and fusing the two features to obtain fused features. Step S2 may include the following specific steps, namely, S21 to S24.
[0047] S21. Tokenizer based on pre-trained model to convert tabular text dataset Table text in Converted into text digital vectors, that is, three tokens that the pre-trained model can understand, respectively , , ; At the same time, determine whether the text value in the cell is a fill value, and use this to construct a mask feature vector .
[0048] Will , , As the input of the pre-trained model, refer to Perform semantic feature extraction to obtain semantic feature vector .
[0049] It should be noted that, because of step S13, the table may be filled with rows / columns, and the filling content is [pad]. For cells with non-[pad] content, it can be marked with 1; for cells with [pad] content, it can be marked with 0. Based on this, the mask feature vector of the table can be obtained. The mask feature vector is used to mark the actual valid cells of the table, which is equivalent to adding an attention weight to each cell. The model does not need to pay too much attention to the filled cells when extracting semantic features.
[0050] In this embodiment, the Roberta-Small pre-training model, which is lighter and has a faster inference speed than the BERT pre-training model, is used to extract the semantic features of the cell. The semantic feature vector extracted by the pre-training model The dimension is (200,512).
[0051] S22. According to the two-dimensional position information set Calculated table text One-dimensional location information set , From table text The absolute positions of all cells in the 1D information are linearly transformed. For example, for the absolute position , and the result after linear change is , of course, other linear transformations are also possible; and based on a randomly initialized embedding layer, the one-dimensional position information Perform feature extraction to obtain the position feature vector .
[0052] In this embodiment, a randomly initialized embedding layer (embedding layer) with a size of 200×384 is preset to extract features of position information, and the parameters of the embedding layer will be iteratively updated during the training process.
[0053] S23. Semantic feature vectors according to feature dimensions and position feature vector Splice and rearrange the spliced features according to the table size to obtain the table text The corresponding fusion feature vector .
[0054] In this embodiment, by vertically splicing the semantic feature vector and the position feature vector according to the last feature dimension and rearranging the table according to the table size (20 rows and 10 columns), the feature dimension of the final feature vector can be (20×10×896).
[0055] S24. Obtain a table text data set by referring to steps S21 to S24. The fused feature vector corresponding to each table text in .
[0056] S3. Construct a cell classification model based on cell position information, and input the fusion features into the trained cell classification model to obtain the label of each cell of each table text in the document to be parsed.
[0057] In step S3, the training method of the cell classification model includes the following steps, namely S31~S33.
[0058] S31. Obtain sample documents and construct a table text dataset of sample documents in accordance with steps S1 to S2 , get The fused feature vector corresponding to each table text in .
[0059] It should be noted that the sample document and the document to be parsed have the same attributes as format, type and field, and the sample document is used for model training. In this embodiment, the sample document is also a bidding document in Html format.
[0060] S32.Yes Each cell of each table text in is labeled with a corresponding one-dimensional label according to the extracted indicator type, thereby obtaining a label set for each table text, and the label sets of all table texts constitute the label set of the sample document; wherein the indicator type includes: C A clear type of key Attributes , Generic of unknown type key Attributes key unknown , attribute value value Attributes, and headers title property.
[0061] Taking the actual application object of table information extraction, that is, the document to be parsed, as an example, Each cell of is labeled with a corresponding one-dimensional label according to the extracted bidding indicator type. , p ≤ maxCol × maxRow . Thus, the table text can be obtained Label set ;
[0062] It should be noted that key Attributes can be understood as attribute words / keywords in natural language processing; value It can be understood as an attribute value; title Attributes can be understood as the header inside the table. As shown in Table 1a, in the text of each cell in Table 1a, for example, "0,1" represents the coordinate information of the cell, and [·] represents the label of the indicator type.
[0063] Table 1a: Example of cell labels for some table text
[0064] ;
[0065] S33. Construct a cell classification model, wherein the cell classification model uses a convolutional neural network (CNN) to The fused feature vector corresponding to each table text is used for feature extraction, and the fully connected layer is used for model prediction, that is, the probability value of each indicator type to which each cell belongs is predicted; through several rounds of iterative training, the training of the model is terminated when the output of the cell classification model greatly fits the true label.
[0066] Since each cell may have multiple labels, in order to avoid the problem of imbalanced categories, a loss function suitable for multi-label classification is selected, and the back propagation algorithm and gradient descent algorithm are used to train the cell classification model to minimize the loss function; among them, the loss function Loss The expression is:
[0067] ;
[0068] In the formula, C+3 is the total amount of indicator type; and Respectively k The true label vector of the samples and the output vector of the fully connected layer; exp (·) is an exponential function with the real number e as its base.
[0069] In this embodiment, in order to more fully integrate the position information, two structures of convolutional neural network + fully connected layer are selected as further feature extractors. The convolutional neural network structures used are respectively: the convolution kernel size is 5 and the padding is 2, and the convolution kernel size is 3 and the padding is 1. The features extracted by the convolutional neural network of the two structures are spliced according to the feature dimension and used as the input of the fully connected layer to obtain the final prediction result. Figure 2 It is a schematic diagram of the model structure of the present invention.
[0070] S4. Analyze the table layout in combination with the label of each cell, so as to obtain the table layout of each table. Step S4 may include the following specific steps, namely S41-S42.
[0071] S41. According to the label of each cell of the table text, obtain a label table whose cell content is the cell classification result; wherein the table text The corresponding marking table is ,
[0072] ;in, For the i Line j The cell classification results of the column, and .
[0073] S42. According to the preset layout definition rules, each table text in the document to be parsed is analyzed to obtain the corresponding table layout; the four types of table layouts are horizontal table, vertical table, row table and complex nested table, and the setting methods of each are as follows:
[0074] The layout definition rules for horizontal tables are as follows: Judge line by line, if the starting line appears All cells in key Attributes, then traverse in sequence The following lines, until a line containing key The cell or all cells of the attribute are title When the attribute is set, the previous row of the row is set as the cutoff row ; If until the last row of the table Before the end, all cells in the row are value Attribute, then there is ; At this point, the starting line To the end line The table consisting of all rows is defined as a horizontal table; start and end Represents the starting and ending row numbers respectively.
[0075] The layout definition rules for vertical tables are as follows: Judge line by line, if the starting line appears Also included key Attributes and value Attributes of two types of cells, and value The cell for the property is always located in key After the cell with the attribute, it will traverse in sequence The following rows continue until a row meets the cutoff condition, that is, all cells in the row are title Attributes or both key When the attribute is set, the row is set as the cutoff row ; If until the last row of the table If the cut-off condition is not met, then there is ; So far, the starting line To the end line The table consisting of all rows is defined as a vertical table;
[0076] The layout definition rules for the row table are: Judge row by row and column by column. If a column =[ ] and all previous columns ( ) describe multiple details of the same subject, and the columns following this column ( ) describes multiple details of another entity, the beginning is listed as Until the end of All columns of , and the starting column is Until the end of A table with all columns is defined as a row table; n is the offset and satisfies .
[0077] Complex nested tables, whose layout definition rules are: several horizontal and vertical tables are stacked up and down, or several horizontal tables are connected by a row. title Attribute cells are spliced, or several vertical tables are connected by a row of title If cells with the same attributes are connected, the combination of the tables is defined as a complex nested table.
[0078] S5. Extract information from tables of different table formats according to preset logical extraction rules.
[0079] In step S5, the process of extracting information from the horizontal table is as follows, namely S511 to S512.
[0080] S511. Define horizontal table based on layout analysis Existence start Line j The cell classification results of the column are , there is also m 1st row j The cell classification results of the column are ;in, start +1≤ m 1≤ end < maxRow。
[0081] Get the start +1 line of text information , get the first start The cell classification result of the row , get the first structured result , .
[0082] In the formula, the symbol: in the structured result formula is a colon, which means key colon value. For example, the tenderer key: the party name, this is a structured result display.
[0083] S512. Construct a set of all first structured results in a horizontal table in the manner of step S511.
[0084] In step S5, the process of extracting information from the vertical table is as follows, namely S521 to S526.
[0085] S521. Define vertical tables based on layout analysis Existence m 2nd row j The cell classification results of the column are ;in, start ≤ m 2≤ end < maxRow ;
[0086] S522. When the extraction object is start When a row is created, the first category of the row is set to any key Attributes Cell text As the starting point, the column where the starting point is located is regarded as j Column; then for the row The cells after that are traversed.
[0087] S523. If The cell class after that is value Attribute, then the second structured result is obtained ,
[0088] ;like The cell category after this is the current category or another key Attributes , then use this cell as the new starting point and traverse it in sequence until you reach a cell with the category value The current cell text of the property , thus obtaining the second structured result , ;in, q The column offset of the current cell relative to the starting point.
[0089] S524. If the next offset of the current cell j + q +1< maxCol , and the cell text The category is value Attribute, then the third structured result is obtained ,
[0090] .
[0091] S525. If the next offset of the current cell j + q +1< maxCol , and the cell text The category is , then the cell text As a new starting point, the operation of step S523 is repeated.
[0092] S526. If j + q +1≥ maxCol , then the following line is start +1 row is taken as the extraction object, and the process returns to step S522 to extract information from all rows of the vertical table.
[0093] In step S5, the information extraction process of the joint table is as follows, namely S531-S532.
[0094] S531. Split the row table into several groups of independent tables by column, i.e. ( )、( ), etc., re-analyze the table layout of each group of independent tables, define each group of independent tables as horizontal tables or vertical tables, and convert them into horizontal or vertical table extraction problems.
[0095] S532. Extract information from each group of independent tables by referring to the information extraction process of the horizontal table and the vertical table.
[0096] In step S5, the information extraction process of the complex nested table is as follows, namely S541 to S543.
[0097] S541. The complex nested table is judged row by row. When a row that will change the horizontal and vertical types of the table appears, it is truncated according to this row, and all rows before this row are regarded as a group of independent tables.
[0098] S542. Re-analyze the table layout of each group of independent tables, define each group of independent tables as a horizontal table or a vertical table, and convert them into horizontal table or vertical table extraction problem.
[0099] S543. Extract information from each group of independent tables by referring to the information extraction process of the horizontal table and the vertical table.
[0100] The following is a detailed description of the technical solution implemented by the present invention in conjunction with Tables 1 to 4. It should be noted that the absolute position (real position) coordinates of the cell are attached at the end of each cell in the following table. If the coordinates are consistent with the coordinates of the previous cell or the cell in the previous row and column, it means that the cell and the previous cell or the cell in the previous row and column are derived from the same cell.
[0101] Table 1-1: Table 1 filled with original values and with coordinate information
[0102] ;
[0103] Table 1-2: Prediction results of cell classification model based on cell location information 1
[0104] ;
[0105] Table 2-1: Table 2 filled with original values and containing coordinate information
[0106] ;
[0107] Table 2-2: Prediction results of cell classification model based on cell location information 2
[0108] ;
[0109] Table 3-1: Table 3 filled with original values and with coordinate information
[0110] ;
[0111] Table 3-2: Prediction results of cell classification model based on cell location information 3
[0112] ;
[0113] Table 4-1: Table 4 filled with original values with coordinate information
[0114] ;
[0115] Table 4-2: Prediction results of cell classification model based on cell location information 4
[0116] ;
[0117] In this embodiment, Tables 1-1, 2-1, 3-1, and 4-1 are tables processed by step S1, that is, tables filled with original values with coordinate information. According to step S22, feature extraction is performed on Tables 1-1, 2-1, 3-1, and 4-1 respectively, and cell classification is performed using the cell classification model based on cell position information fusion constructed in step S3, so that Tables 1-2, 2-2, 3-2, and 4-2 can be obtained respectively. According to the model prediction results of Table 3-2, it can be seen that the necessity of using cell position information as auxiliary information when classifying cells is necessary. This is because the specific party referred to by the cell with the disclosure content of "address:" or "telephone:" in Table 3-1 cannot be determined based on the semantic information of the cell alone. However, through the fusion of location information, the generalization of the model makes it possible to distinguish the party to which the cell belongs and label it accordingly. According to step S4, combined with Tables 1-2, 2-2, 3-2, and 4-2, table information extraction is performed on Tables 1-1, 2-1, 3-1, and 4-1, as described below.
[0118] Regarding Tables 1-1 and 1-2.
[0119] (1) Layout analysis: Analyze Table 1-2 row by row. The first row meets the following conditions: key Attribute, all cells from the second row to the last row are value Attribute, so Table 1-1 is a horizontal table.
[0120] (2) Table information extraction: First, value Information is extracted from the first row of attributes according to the extraction path, which is (0,0)→(1,0), (0,1)→(1,1), (0,2)→(1,2), (0,3)→(1,3), (0,4)→(1,4), (0,5)→(1,5), (0,6)→(1,6); the same extraction is performed on the second row, and the extraction path is (0,0)→(2,0), (0,1)→(2,1), (0,2)→(2,2), (0,3)→(2,3), (0,4)→(2,4), (0,5)→(2,5), (0,6)→(2,6).
[0121] Regarding Tables 2-1 and 2-2.
[0122] (1) Layout analysis: Analyze Table 2-2 row by row. The cell attributes of the first two rows are title , from the third line to the last line, each line contains key The attribute cell also contains value Attribute cell, so the table starting from the third row in Table 2-1 is a vertical table.
[0123] (2) Extracting information from the table: First, extract information from the third row according to the extraction path (2,1)→(2,2) and (2,3)→(2,4). Perform the same extraction on the next row, using the extraction path (3,1)→(3,2) and (3,3)→(3,4).
[0124] Regarding Tables 3-1 and 3-2.
[0125] (1) Layout analysis: Analyzing Table 3-2 column by column, the first and second columns describe the information of the tenderer, and the third and fourth columns describe the information of the tendering agency. Therefore, Table 3-1 is a joint table.
[0126] (2) Extraction of table information: Split Table 3-2 into two independent tables according to the second column, re-analyze the layout of the two tables, and analyze them row by row. The two tables after splitting are vertical tables. According to the extraction method of vertical tables, the extraction paths are (1,0)→(1,1), (2,0)→(2,1), (3,0)→(3,1), (4,0)→(4,1) and (1,2)→(1,3), (2,2)→(2,3), (3,2)→(3,3), (4,2)→(4,3).
[0127] Regarding Tables 4-1 and 4-2.
[0128] (1) Layout analysis: Analyze Table 4-2 column by column. The middle of the table contains a title row that contains a whole row, so Table 4-1 is a complex nested table.
[0129] (2) Extraction of table information: Split Table 4-2 into two independent tables according to the fourth row of the title row, and re-analyze the layout of the two tables. Through line-by-line analysis, the two tables after splitting are horizontal tables. Extract according to the horizontal table extraction method, combined with the position information in Table 4-1, for example, the relative position coordinates of the second, third, and fourth cells in the first row are all (0,1), so they can be regarded as the starting point of the same path. Extracting the second row can obtain the path (0,0)→(1,0), (0,1)→(1,1); Based on this, the extraction paths of the remaining rows are summarized as (0,0)→(2,0), (0,1)→(2,1); (4,0)→(5,0), (4,2)→(5,2).
[0130] Example 2
[0131] This embodiment provides a table information extraction system 10 based on position information and layout matching, and can apply the table information extraction method in Embodiment 1. The table information extraction system 10 includes: a data construction module 101, a feature extraction module 102, a cell classification module 103, a layout analysis module 104 and an extraction module 105.
[0132] The data construction module 101 is used to construct a table text data set and a corresponding two-dimensional position information data set in the document to be parsed.
[0133] The feature extraction module 102 is used to extract the semantic features of the table text data set and the position features of the two-dimensional position information data set, and fuse the two features to obtain a fused feature.
[0134] The cell classification module 103 is used to construct a cell classification model based on cell position information, and input the fusion features into the trained cell classification model, so as to obtain the label of each cell of each table text in the document to be parsed.
[0135] The layout analysis module 104 is used to perform layout analysis on the table in combination with the label of each cell, so as to obtain the table layout of each table.
[0136] The extraction module 105 is used to extract information from tables of different table formats according to preset logical extraction rules.
[0137] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A table information extraction method based on position information and layout matching, characterized in that: The following steps are involved: S1. Construct a table text dataset in the document to be parsed and a corresponding two-dimensional position information dataset; S2. extracting semantic features of the table text dataset and position features of the two-dimensional position information dataset, and fusing the two features to obtain fused features; S3. Constructing a cell classification model based on cell position information, inputting the fusion feature into the trained cell classification model, thereby obtaining the label of each cell of each table text in the document to be parsed; in step S3, the training method of the cell classification model includes the following steps: S31. Obtain a sample document, and construct a table text dataset T″ of the sample document in accordance with steps S1 to S2, and obtain a fused feature vector corresponding to each table text in T″; S32. For each cell of each table text in T″, a corresponding one-dimensional label is added according to the extracted indicator type, thereby obtaining a label set of each table text, and the label sets of all table texts constitute the label set of the sample document; wherein, the indicator type includes: key attributes with C clear types, namely {key1, key2, ..., key c }、The generic key attribute of unknown type is key unknown , the value attribute of the attribute value, and the title attribute of the table header; S33. Construct a cell classification model, wherein the cell classification model uses a convolutional neural network to extract features from the fused feature vector corresponding to each table text in T″, and uses a fully connected layer to perform model prediction, that is, predict the probability value of each indicator type to which each cell belongs; through several rounds of iterative training, when the output of the cell classification model greatly fits the true label, the training of the model is terminated; S4. Analyze the layout of the table in combination with the label of each cell to obtain the table layout of each table; step S4 includes the following specific steps: S41. According to the label of each cell of the table text, obtain a label table whose cell content is the cell classification result; wherein the table text The corresponding marking table is Among them, L i,j is the classification result of the cell in row i and column j, and S42. According to the preset layout definition rules, each table text in the document to be parsed is analyzed to obtain the corresponding table layout; four types of table layouts and their setting methods are as follows: The layout definition rules for horizontal tables are as follows: Judge row by row, if the starting row Row appears start =[L start,0 , L start,1 , …, L start,maxCol ] all cells are key attributes, then traverse the Row start For the following rows, until a row contains a cell with the key attribute or all cells have the title attribute, the row before the row is set as the cutoff row. end ; If until the last row of the table Row maxRow Before the end, all cells in the row have the value attribute, then there is a Row end =Row maxRow-1 ; At this point, the starting row Row start To the end row end The table consisting of all rows is defined as a horizontal table; start and end indicate the starting and ending row numbers respectively; The layout definition rules for vertical tables are as follows: Judge row by row, if the starting row Row appears start =[L start,0 , L start,1 , …, L start,maxCoz ] contains both key attribute and value attribute cells, and the value attribute cell is always located after the key attribute cell, then traverse the Row in sequence start The following rows, until a row meets the cutoff condition, that is, all cells in the row have the title attribute or all have the key attribute, set the row as the cutoff row. end ; If until the last row of the table Row maxRow If the cutoff condition is not met, there is a Row end =Row maxRow-1 ; So far, the starting row Row start To the end row end The table consisting of all rows is defined as a vertical table; The layout definition rules for the row table are: Judge row by row and column by column. If a column Col j =[L 0,j , L 1,j , …, L maxRow,j ] and all previous columns (Col0, Col1, ..., Col j-1 ) describes multiple details of the same subject, and the columns following this column (Col j+1 , Col j+2 , …, Col j+n ) describes multiple details of another entity, the starting column is Col0 and the ending column is Col j All columns, starting with Col j+1 Until the end of the column is Col j+n A table with all columns is defined as a row table; n is the offset, and j+n<maxCol; The layout definition rule of complex nested tables is: when several horizontal and vertical tables are stacked up and down, or several horizontal tables are spliced through a row of cells with all title attributes, or several vertical tables are spliced through a row of cells with all title attributes, the combination of each table is defined as a complex nested table; S5. Extract information from tables of different table formats according to preset logical extraction rules; in step S5, the information extraction process of the horizontal table is as follows: S511. Define horizontal table t according to layout analysis k The classification result of the cell in the start row and column j is There is also a cell in row m1 and column j whose classification result is Among them, start+1≤m1≤end <maxRow; Get the text information of the start+1th line Get the cell classification result of the start row according to the column coordinates [L start,0 , …, L start,maxCol ], get the first structured result result1′, S512. Construct a set of all first structured results in a horizontal table in the manner of step S511; The information extraction process of the vertical table is as follows: S521. Define vertical table t according to layout analysis k The classification result of the cell in row m2 and column j is Among them, start≤m2≤end <maxRow; S522. When the extraction object is the start row, the first cell text of the row with any key attribute, namely keyc, is extracted. As the starting point, the column where the starting point is located is regarded as the jth column; then the row The cells that follow are traversed; S523. If If the cell type is value attribute, the second structured result result" is obtained. like The cell category after that is the current category key c Or another key attribute, key′ c , the cell is used as a new starting point and it is traversed in sequence until the current cell text with the value attribute is traversed Thus, the second structured result "result" is obtained. Among them, q is the column offset of the current cell relative to the starting point; S524. If the next offset of the current cell j+q+1<maxCol, and the cell text The category of is the value attribute, then the third structured result result″′ is obtained. S525. If the next offset of the current cell j+q+1>maxCol, and the cell text The category is key′ c , then the cell text As a new starting point, the operation of step S523 is repeated; S526. If +q+1≥maxCol, the next row, i.e., the start+1 row, is taken as the extraction object, and the process returns to step S522 to extract information from all rows of the vertical table.
2. The table information extraction method based on position information and layout matching according to claim 1 is characterized in that: Step S1 includes the following specific steps: S11. Obtain the table data set T in the document to be parsed, where T = {t1, t2, ..., t k ,…,t K }; any table t in T k It consists of the text data of all cells in the table, k∈[1,K], where K is the total number of tables in the document to be parsed; S12. Based on the cross-row information and / or cross-column information of the table, k Fill the cells with original values and empty values respectively to get the table text filled with original values and the table text after null filling S13. According to the set maximum number of rows and columns of cells, the two table text and Do row and column truncation and / or row and column padding to keep the table size uniform; S14. By comparing the table text and The text difference in each cell [i, j] at the same position, obtains the absolute position [i', j'] of each cell [i, j], and thus obtains the table text The two-dimensional location information set L k , L k From table text The absolute positions of all cells in the ; where 0≤i<maxRow, 0≤j<maxCol; 0≤i'≤i; 0≤j'≤j; i, j∈N, N is a natural number set; S15. Referring to steps S11 to S14, construct a table text dataset T′ and a corresponding two-dimensional position information dataset L of the document to be parsed; wherein, Table text Represents the table t k The cell text in row i and column j; L = {L1, L2, ..., L k , …, L K }.
3. The table information extraction method based on position information and layout matching according to claim 2 is characterized in that: Step S2 includes the following specific steps: S21. The table text in the table text dataset T′ Convert it into a text numeric vector; at the same time, determine whether the text value in the cell is a fill value, so as to construct a mask feature vector of the table text; Using the text digital vector as the input of the pre-trained model, and extracting semantic features with reference to the mask feature vector to obtain a semantic feature vector; S22. Based on the two-dimensional position information set L k Calculated table text One-dimensional location information set And based on a randomly initialized embedding layer, the one-dimensional position information Perform feature extraction to obtain a position feature vector; S23. splicing the semantic feature vector and the position feature vector according to the feature dimension, and rearranging the spliced features according to the table size, thereby obtaining a table text The corresponding fused feature vector; S24. Obtain the fused feature vector corresponding to each table text in the table text data set T′ by referring to steps S21 to S24.
4. The table information extraction method based on position information and layout matching according to claim 1, characterized in that: In step S33, a loss function suitable for multi-label classification is selected, and the back propagation algorithm and the gradient descent algorithm are used to train the cell classification model; wherein the expression of the loss function Loss is: In the formula, C+3 is the total amount of indicator type; y k and are the true label vector of the kth sample and the output vector of the fully connected layer, respectively; exp(·) is an exponential function with the real number e as the base.
5. The table information extraction method based on position information and layout matching according to claim 1, characterized in that: In step S5, the information extraction process of the joint table is as follows: S531. Divide the row table into several groups of independent tables by column, re-analyze the table format of each group of independent tables, and define each group of independent tables as a horizontal table or a vertical table; S532. Extract information from each group of independent tables by referring to the information extraction process of the horizontal table and the vertical table.
6. The table information extraction method based on position information and layout matching according to claim 1, characterized in that: In step S5, the information extraction process of the complex nested table is as follows: S541. The complex nested table is judged row by row. When a row that changes the horizontal and vertical types of the table appears, it is truncated according to this row, and all rows before this row are regarded as a group of independent tables; S542. Re-analyze the table format of each group of independent tables, and define each group of independent tables as a horizontal table or a vertical table; S543. Extract information from each group of independent tables by referring to the information extraction process of the horizontal table and the vertical table.
7. A table information extraction system based on position information and layout matching, characterized in that: The table information extraction method based on position information and layout matching as described in any one of claims 1 to 6 is applied; the table information extraction system comprises: A data construction module, which is used to construct a table text dataset and a corresponding two-dimensional position information dataset in the document to be parsed; A feature extraction module is used to extract semantic features of the table text data set and position features of the two-dimensional position information data set, and fuse the two features to obtain a fused feature; A cell classification module is used to construct a cell classification model based on cell position information, and input the fusion features into the trained cell classification model to obtain a label for each cell of each table text in the document to be parsed; A layout analysis module, which is used to analyze the layout of the table in combination with the label of each cell, so as to obtain the table layout of each table; and The extraction module is used to extract information from tables of different table formats according to preset logical extraction rules.
Citation Information
Patent Citations
Table structure identification method and device, storage medium and electronic equipment
CN113297975A
Method and system for automatically analyzing bidder information in bidding material
CN114782122A
