Method and device for extracting information from family tree registration form, and electronic device
By preprocessing and parsing the family tree registration form to generate structural analysis results and attribute coordinates, automatic identification and extraction of character information in the family tree registration form is realized, solving the problem of low efficiency in the existing technology and improving the accuracy of information extraction. degree and efficiency.
Patent Information
- Application Number
- CN202110888402.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-03
- Publication Date
- 2024-09-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the existing technology, the information extraction efficiency of the genealogy registration form is low because different table structures cannot be automatically recognized, resulting in the need for manual verification and entry, which wastes manpower and time.
By preprocessing and parsing the family tree registration form template, the first dictionary and the second dictionary are generated, the table structure and attribute name cell coordinates are saved, and then character information is extracted to achieve automated parsing and information extraction.
It improves the accuracy and efficiency of information extraction, saves manpower and time costs, and solves the problem of low efficiency in manual registration.
Smart Images

Figure CN113743072B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a method for extracting information from a family tree registration form, a device thereof, and an electronic device. Background Art
[0002] A family tree is a specialized document that presents family relationship information in a tabular format. Family tree registration forms can have a variety of table structures. Existing technologies lack information extraction techniques specifically designed for these types of tables. Existing techniques often rely on manual verification of the information in the registration form before manually entering it into the system. Therefore, relying on manual processing of family tree tables is not only time-consuming and labor-intensive, but also inefficient.
[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0004] An embodiment of the present invention provides a method and device for extracting information from a family tree registration form, as well as an electronic device, to at least solve the technical problem in the related art that manual registration cannot automatically perform structural recognition and extract character information from family tree registration forms with different table structures, resulting in low information extraction efficiency.
[0005] According to one aspect of an embodiment of the present invention, a method for extracting information from a family tree registration form is provided, comprising: preprocessing a family tree registration form template to obtain a processed family tree registration form template; parsing the tables in the processed family tree registration form template to obtain a first dictionary and a second dictionary, wherein the first dictionary stores the structural parsing results of each table, and the second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values; based on the first dictionary and the second dictionary, extracting information from all entered family tree registration forms to obtain a third dictionary, wherein the third dictionary stores the person information in each cell of each family tree registration form.
[0006] Optionally, the step of pre-processing the family tree registration form template to obtain the processed family tree registration form template includes: marking the attribute value cells in different tables in the family tree registration form template, wherein if there are identical tables in the family tree registration form, repeated marking is not required; if the correspondence between the attribute name cell and the attribute value cell in the same table in the family tree registration form template is repeated, only one of the attribute value cells is marked, and the other repeated attribute value cells are not marked.
[0007] Optionally, the steps of parsing the table in the processed family tree registration form template to obtain a first dictionary and a second dictionary include: analyzing the number of table blocks and the number of table columns in the initial row of the table in the family tree registration form template, and saving the analysis results in a first preset list; parsing the table structure in each table block, and saving the analysis results in a second preset list, wherein the number of cell rows or table rows is saved in the second preset list; saving the second preset list corresponding to all tables in the family tree registration form template in the first dictionary, wherein the key of the first dictionary is the serial number of each table in the family tree registration form template, and the value is the second preset list; determining the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the first preset list and the second preset list, and saving the attribute name cell coordinates and the attribute value cell coordinates in the second dictionary.
[0008] Optionally, the step of parsing the table structure in each table block and saving the parsing results to a second preset list includes: selecting any table block from the table blocks, and using the first row of cell content in the selected table block as the benchmark comparison content, wherein the selected table block does not include the initial row; traversing all rows of the selected table block, and if cell content identical to the benchmark comparison content appears, recording the number of cell rows in the traversed rows and saving it to the second preset list; if cell content identical to the benchmark comparison content does not appear, saving the number of traversed rows in the selected table block to the second preset list.
[0009] Optionally, the step of determining the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the first preset list and the second preset list includes: traversing the cells of each table in the family tree registration form template based on the first preset list and the second preset list; extracting the coordinate values of each cell to obtain the row coordinates and column coordinates of each cell; reading the content of the cell based on the row coordinates and column coordinates, judging whether the cell is an attribute name cell, and saving the judgment result to a fourth dictionary; determining the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the fourth dictionary.
[0010] Optionally, based on the first dictionary and the second dictionary, the information of all the entered family tree registration tables is extracted to obtain the step of a third dictionary, including: converting the first dictionary and the second dictionary into a first file and a second file; reading the first file and the second file to generate a fifth dictionary and a third preset list, wherein the elements in the third preset list are the values in the first dictionary; traversing each table in the entered family tree registration table to obtain the number of table blocks and the number of table columns of each table, and saving them to the first preset list; parsing the table structure of the table based on the third preset list, and saving the parsed table structure to the fourth preset list; extracting the information in the family tree registration table based on the first preset list and the fourth preset list, and saving it to the third dictionary.
[0011] Optionally, based on the first preset list and the fourth preset list, the step of extracting information from the family tree registration table and saving it to the third dictionary includes: based on the first preset list, filtering out non-repeated first-type table blocks in the table in the family tree registration table, wherein the first-type table blocks are used to indicate blocks corresponding to multiple table columns; based on the fourth preset list, for each of the non-repeated table blocks, filtering out non-repeated second-type table blocks, wherein the second-type table blocks are used to indicate blocks corresponding to multiple table rows; traversing the non-repeated second-type table blocks to obtain the cell contents in the non-repeated second-type table blocks, and saving them to the third dictionary.
[0012] According to another aspect of an embodiment of the present invention, a device for extracting information from a family tree registration form is also provided, including: a processing unit for preprocessing a family tree registration form template to obtain a processed family tree registration form template; a parsing unit for parsing the table in the processed family tree registration form template to obtain a first dictionary and a second dictionary, wherein the first dictionary stores the structural parsing results of each table, and the second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values; an extraction unit for extracting information of all entered family tree registration forms based on the first dictionary and the second dictionary to obtain a third dictionary, wherein the third dictionary stores the person information in each cell of each family tree registration form.
[0013] Optionally, the processing unit includes: a first marking module, used to mark the attribute value cells in different tables in the family tree registration form template, wherein, if there are identical tables in the family tree registration form, repeated marking is not required; a second marking module, used to mark only one attribute value cell if the correspondence between the attribute name cell and the attribute value cell in the same table in the family tree registration form template is repeated, and the other repeated attribute value cells are not marked.
[0014] Optionally, the parsing unit includes: a first analysis module, used to analyze the number of table blocks and the number of table columns in the initial row of the table in the family tree registration form template, and save the analysis results to a first preset list; a first parsing module, used to parse the table structure in each table block, and save the parsing results to a second preset list, wherein the number of cell rows or table rows is saved in the second preset list; a first saving module, used to save the second preset list corresponding to all tables in the family tree registration form template in a first dictionary, wherein the key of the first dictionary is the serial number of each table in the family tree registration form template, and the value is the second preset list; a first determination module, used to determine the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the first preset list and the second preset list, and save the attribute name cell coordinates and the attribute value cell coordinates to a second dictionary.
[0015] Optionally, the first parsing module includes: a first selection submodule, used to select any table block in the table block, and use the first row of cell content in the selected table block as the benchmark comparison content, wherein the selected table block does not include the initial row; a first traversal submodule, used to traverse all rows of the selected table block, and if cell content identical to the benchmark comparison content appears, record the number of cell rows of the traversed row and save it to the second preset list; a first saving submodule, used to save the number of traversed rows in the selected table block to the second preset list if cell content identical to the benchmark comparison content does not appear.
[0016] Optionally, the first determination module includes: a second traversal submodule, used to traverse the cells of each table in the family tree registration form template based on the first preset list and the second preset list; a first extraction submodule, used to extract the coordinate values of each cell to obtain the row coordinates and column coordinates of each cell; a first reading submodule, used to read the content of the cell based on the row coordinates and column coordinates, determine whether the cell is an attribute name cell, and save the judgment result to a fourth dictionary; the first determination submodule, used to determine the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the fourth dictionary.
[0017] Optionally, the extraction unit includes: a first conversion module, used to convert the first dictionary and the second dictionary into a first file and a second file; a first generation module, used to read the first file and the second file, and generate a fifth dictionary and a third preset list, wherein the elements in the third preset list are the values in the first dictionary; a first traversal module, used to traverse each table in the entered family tree registration table, obtain the number of table blocks and the number of table columns of each table, and save them to the first preset list; a second parsing module, used to parse the table structure of the table based on the third preset list, and save the parsed table structure to the fourth preset list; a first extraction module, used to extract the information in the family tree registration table based on the first preset list and the fourth preset list, and save it to the third dictionary.
[0018] Optionally, the first extraction module includes: a first screening submodule, used to screen out non-repeated first-type table blocks in the table in the genealogy registration form based on the first preset list, wherein the first-type table blocks are used to indicate blocks corresponding to multiple table columns; a second screening submodule, used to screen out non-repeated second-type table blocks for each non-repeated table block based on the fourth preset list, wherein the second-type table blocks are used to indicate blocks corresponding to multiple table rows; a third traversal submodule, used to traverse the non-repeated second-type table blocks, obtain the cell content in the non-repeated second-type table blocks, and save them in a third dictionary.
[0019] According to another aspect of an embodiment of the present invention, an electronic device is also provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned methods for extracting information from a family tree registration form by executing the executable instructions.
[0020] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is also provided, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned methods for extracting information from the family tree registration form.
[0021] In this application, a family tree registration form template is preprocessed to obtain a processed family tree registration form template. The tables in the processed family tree registration form template are then parsed to obtain a first dictionary and a second dictionary. The first dictionary stores the structural parsing results for each table, and the second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values. Based on the first and second dictionaries, information from all entered family tree registration forms is extracted to obtain a third dictionary. The third dictionary stores the person information in each cell of each family tree registration form. In this embodiment, a method for automatically extracting information from family tree registration forms with different table structures is employed. By automatically parsing the table structure using a computer, the table structure is quickly identified and the person information therein is extracted. This method not only saves manpower and time costs but also improves the accuracy and efficiency of information extraction. This solves the technical problem in the related art of manual registration, which cannot automatically identify the structure and extract person information from family tree registration forms with different table structures, resulting in low information extraction efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0023] Figure 1 is a flow chart of an optional method for extracting information from a family tree registration form according to an embodiment of the present invention;
[0024] Figure 2 2 is a schematic diagram of an information extraction device for a family tree registration table according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described 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 making creative efforts should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] To facilitate those skilled in the art to understand the present invention, some of the terms or nouns involved in the embodiments of the present invention are explained below:
[0028] Genealogy registration form template: refers to a genealogy registration form in which the attribute name in the registration form is not empty and the attribute value is empty.
[0029] Genealogy registration form: refers to a genealogy registration form that has been filled in with information, the attribute name is not empty, and the attribute values are not all empty.
[0030] The family tree registration forms involved in the following embodiments of the present invention can have the same structure or multiple different structures. The information entered in the family tree registration forms can include not only information about people within the same family, but also information about people within a group or organization, such as schools, hospitals, or companies. In this embodiment of the present invention, a method for automatically extracting information from family tree registration forms with multiple structures is proposed. The proposed table structure parsing method and information extraction method can automatically identify the family tree registration form structure and extract the personal information therein. Finally, the information can be directly and conveniently entered into the system, saving manpower and time costs while also achieving a very high accuracy of the extracted information.
[0031] According to an embodiment of the present invention, an embodiment of a method for extracting information from a family tree registration form is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0032] Example 1
[0033] Figure 1 FIG. 1 is a flow chart of an optional method for extracting information from a family tree registration table according to an embodiment of the present invention. Figure 1 As shown, the method includes the following steps:
[0034] Step S102: pre-process the family tree registration form template to obtain a processed family tree registration form template.
[0035] Step S104, parse the table in the processed family tree registration form template to obtain a first dictionary and a second dictionary, wherein the first dictionary stores the structural analysis results of each table, and the second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values.
[0036] Step S106 , extracting information of all entered family tree registration forms based on the first dictionary and the second dictionary to obtain a third dictionary, wherein the third dictionary stores the character information in each cell of each family tree registration form.
[0037] Through the above steps, the family tree registration form template can be preprocessed to obtain a processed family tree registration form template. The tables in the processed family tree registration form template are then parsed to obtain a first dictionary and a second dictionary. The first dictionary stores the structural parsing results of each table. The second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values. Based on the first and second dictionaries, information from all entered family tree registration forms is extracted to obtain a third dictionary. The third dictionary stores the person information in each cell of each family tree registration form. In this embodiment, a method for automatically extracting information from family tree registration forms with different table structures is adopted. By automatically parsing the table structure through a computer, the structure of the family tree registration form is quickly identified and the person information therein is extracted. This method not only saves manpower and time costs, but also improves the accuracy and efficiency of information extraction. This solves the technical problem in the related art that manual registration cannot automatically perform structural recognition and extract person information from family tree registration forms with different table structures, resulting in low information extraction efficiency.
[0038] The embodiment of the present invention is described in detail below in conjunction with the above steps.
[0039] Step S102: pre-process the family tree registration form template to obtain a processed family tree registration form template.
[0040] In an embodiment of the present invention, the family tree registration form template can be processed first to filter out the same table or the corresponding attribute name and attribute value cells that appear in a repeated pattern in the same table, so as to avoid multiple processing of these repeated structures and reduce efficiency.
[0041] Optionally, the step of pre-processing the family tree registration form template to obtain the processed family tree registration form template includes: marking the attribute value cells in different tables in the family tree registration form template, wherein, if there are identical tables in the family tree registration form, repeated marking is not required; if the correspondence between the attribute name cell and the attribute value cell in the same table in the family tree registration form template is repeated, only one attribute value cell is marked, and the other repeated attribute value cells are not marked.
[0042] In an embodiment of the present invention, as shown in Table 1, the attribute value cells in different tables in the family tree registration form template can be marked with different labels (such as numbers, letters, etc., this embodiment uses numbers as labels for schematic illustration). If the same table appears in the same family tree registration form, there is no need to repeat the labeling.
[0043] Table 1
[0044]
[0045]
[0046] As shown in Table 2, if the corresponding attribute name cells and attribute value cells appear repeatedly in the same table of the genealogy registration form, they only need to be marked once, and the remaining duplicates do not need to be marked.
[0047] Table 2
[0048]
[0049] Step S104, parse the table in the processed family tree registration form template to obtain a first dictionary and a second dictionary, wherein the first dictionary stores the structural analysis results of each table, and the second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values.
[0050] In this embodiment of the present invention, the first dictionary (which can be recorded as the dictionary allSameText) is used to store the parsed results of each table, where the dictionary key is the sequence number of each table (for example, the tables in the family tree registration form template can be numbered starting from 0, so the sequence number of the first table is 0, and so on, which will not be repeated here), and the value is the parsed result of the corresponding table (which can be recorded as the list SameText). The second dictionary (which can be recorded as the dictionary propertyDict) uses the corresponding attribute name cell coordinates and attribute value cell coordinates as keys and values, respectively.
[0051] Optionally, the steps of parsing the table in the processed family tree registration form template to obtain a first dictionary and a second dictionary include: analyzing the number of table blocks and the number of table columns in the initial row of the table in the family tree registration form template, and saving the analysis results in a first preset list; parsing the table structure in each table block, and saving the analysis results in a second preset list, wherein the number of cell rows or the number of table rows is saved in the second preset list; saving the second preset list corresponding to all tables in the family tree registration form template in the first dictionary, wherein the key of the first dictionary is the serial number of each table in the family tree registration form template, and the value is the second preset list; determining the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the first preset list and the second preset list, and saving the attribute name cell coordinates and attribute value cell coordinates in the second dictionary.
[0052] In an embodiment of the present invention, for each table in the family tree registration form template, it is possible to analyze and determine how many table blocks are divided in the initial row of each table (each row in the table can be numbered, for example, starting with 0, then the initial row is numbered 0), and save the analysis and determination results in a first preset list (which can be recorded as list kuai_num). The specific method is as follows: traverse all cells in the initial row, and use the cell content of the initial row and initial column in the table as the benchmark comparison content; if the cell content of a column in the initial row is the same as the benchmark comparison content, then add the column number to the list kuai_num, and finally add the column number of the table to the list kuai_num; thereafter, the table structure in each table block can be parsed, and the parsing results can be saved in a second preset list (which can be recorded as list SameText), and then based on list kuai_num and list SameText, the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template can be obtained.
[0053] Optionally, the step of parsing the table structure in each table block and saving the parsing results to a second preset list includes: selecting any table block in the table block, and using the cell content of the first row in the selected table block as the benchmark comparison content, wherein the selected table block does not include the initial row; traversing all rows of the selected table block, and if cell content identical to the benchmark comparison content appears, recording the number of cell rows in the traversed row and saving it to the second preset list; if cell content identical to the benchmark comparison content does not appear, saving the number of traversed rows in the selected table block to the second preset list.
[0054] In an embodiment of the present invention, the table structure in each table block is parsed to determine whether the table structure in each table block is repeated. The specific method is as follows: arbitrarily select a table block (which can be recorded as A), and use the cell content of the first row in table block A as the benchmark comparison content (because the structure of the initial row is not included when analyzing the table structure, the initial row is not included in table block A, that is, the analysis starts from the first row, and the first row is numbered 1); traverse the number of rows of table block A, and if cell content that is exactly the same as the benchmark comparison content appears during the traversal process, the row number of the cell is recorded and saved in the list SameText (that is, the second preset list) until the traversal ends; if the table structure is not repeated (that is, there is only one element in the list SameText), then add an element to the list SameText, which is the number of rows of the table.
[0055] Optionally, the step of determining the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the first preset list and the second preset list includes: traversing the cells of each table in the family tree registration form template based on the first preset list and the second preset list; extracting the coordinate value of each cell to obtain the row coordinates and column coordinates of each cell; reading the content of the cell based on the row coordinates and column coordinates, judging whether the cell is an attribute name cell, and saving the judgment result to a fourth dictionary; determining the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the fourth dictionary.
[0056] In an embodiment of the present invention, a cell may have multiple rows and columns. When traversing each cell, the span occupied by the cell (i.e., the number of rows and columns) may be determined. If the cell contents are the same, they are considered to be the same cell and the same cells are skipped. The specific method is as follows:
[0057] Perform a double loop traversal on the table. The range of the outer loop row number r is from 1 to SameText[1]-SameText[0]+1 (the element subscripts in the list are marked starting with 0, SameText[1] represents the second element in the list SameText, and SameText[0] represents the first element in the list SameText), and the range of the inner loop column number c is from kuai_num[j] to kuai_num[j+1] (indicating that the range of the inner loop is from one element value of the list kuai_num to its next element value, that is, the number of times the inner loop is performed is the number of columns in each table block), where j ranges from 0 to len(kuai_num)-1, and len(kuai_num) represents the length of the list kuai_num, that is, how many elements it has, so as to obtain the row coordinates and column coordinates of different cells.
[0058] After that, the values of the row coordinates and column coordinates can be converted into one value (for example, the row coordinate multiplied by 100 plus the column coordinate) and saved in the list flag. Then, based on the list flag, it is determined which of all cells are attribute names and attribute values, as well as the corresponding relationship between attribute names and attribute values. The specific steps are as follows:
[0059] Traverse the list flag, get the row and column coordinates of each element flag[i] (indicates the i-th element of the list flag), and then get the cell content based on the row and column coordinates. If the cell content is a number, is_property[flag[i]]=0 (indicates whether the element flag[i], i.e., the corresponding cell, is an attribute name. If it is an attribute name, it is recorded as 1, otherwise it is recorded as 0 to indicate an attribute value. For example, is_property[a]=0 indicates that a is an attribute value). Otherwise, is_property[flag[i]]=1, thereby obtaining the dictionary is_property (i.e., the fourth dictionary).
[0060] Set the dictionary check to determine whether the elements in the list flag have been used (if check[flag[i]]=0, it means flag[i] has not been used). The dictionary check is initialized to 0.
[0061] Traverse the dictionary is_property, if is_property[flag[i]]=1, take out the row coordinate row and column coordinate col of flag[i] and pos=(row+1)*100+col (indicates the element value of the next row of cells in the list flag corresponding to the cell represented by the current element flag[i] in the table), if is_property[flag[i+1]]=0, Property_belong[flag[i]]=flag[i+1] (indicates the value of the element flag[i] and the element flag[i+1] in the table). The represented cell is the corresponding attribute name and attribute value, that is, the attribute value of the attribute name flag[i] is flag[i+1]), and set check[flag[i]]=1, check[flag[i+1]]=1 (indicating that the element flag[i] and the element flag[i+1] have been used); if is_property[pos]=0, then Property_belong[flag[i]]=pos (indicating that the attribute value of the attribute name flag[i] is pos), and set check[flag[i]]=1, check[pos]=1;
[0062] Finally, the corresponding attribute name and attribute value coordinates are saved in the dictionary propertyDict.
[0063] Step S106 , extracting information of all entered family tree registration forms based on the first dictionary and the second dictionary to obtain a third dictionary, wherein the third dictionary stores the character information in each cell of each family tree registration form.
[0064] In an embodiment of the present invention, based on the obtained dictionary allSameText (i.e., the first dictionary) and the dictionary propertyDict (i.e., the second dictionary), a third dictionary (which can be recorded as dictionary resultdict) can be obtained to save the character information in each cell of each family tree registration table.
[0065] Optionally, based on the first dictionary and the second dictionary, the information of all entered genealogy registration forms is extracted to obtain the step of a third dictionary, including: converting the first dictionary and the second dictionary into a first file and a second file; reading the first file and the second file to generate a fifth dictionary and a third preset list, wherein the elements in the third preset list are the values in the first dictionary; traversing each table in the entered genealogy registration form to obtain the number of table blocks and the number of table columns of each table, and saving them to the first preset list; parsing the table structure of the table based on the third preset list, and saving the parsed table structure to the fourth preset list; extracting the information in the genealogy registration form based on the first preset list and the fourth preset list, and saving it to the third dictionary.
[0066] In an embodiment of the present invention, the obtained dictionary allSameText (i.e., the first dictionary) and the dictionary propertyDict (i.e., the second dictionary) can be converted into sameText_pos.json (i.e., the first file) and property_pos.json (i.e., the second file) and saved locally to facilitate the subsequent extraction of genealogy registration form information.
[0067] Then, the first file and the second file are read to generate the dictionary property_dict (i.e., the fifth dictionary, which stores the same content as the second dictionary) and the list sameText1 (i.e., the third preset list, whose elements are the values in the dictionary allSameText).
[0068] Then traverse each table in the family tree registration form, and save the number of list blocks of each table in the list kuai_num (i.e., the first preset list). Denote L = len(sameText1) (representing the length of the list sameText1, that is, the number of different tables in this family tree registration form). When the loop index i < L - 1 (i represents the table number), it means the table has not appeared repeatedly. At this time, denote sameText2[i] = sameText1[i] (indicating that the i-th element of the list sameText2 is the i-th element [i] in the list sameText1); if i >= L - 1, it means the table has appeared repeatedly. At this time, denote sameText2[i] = sameText1[i % L] (indicating that when looping to the repeated table, the i-th element of the list sameText2 at this time is the i-th element modulo L in the list sameText1, that is, indicating that the structure of the current table is the same as that of its repeated table). Obtain the table structures of all tables and save them in the list sameText2 (i.e., the fourth preset list).
[0069] Optionally, the step of extracting information from the family tree registration form based on the first preset list and the fourth preset list and saving it in the third dictionary includes: based on the first preset list, screening out the non-repeated first type of table blocks in the tables of the family tree registration form, where the first type of table block is used to indicate the block corresponding to multiple table columns; based on the fourth preset list, for each non-repeated table block, screening out the non-repeated second type of table blocks, where the second type of table block is used to indicate the block corresponding to multiple table rows; traversing the non-repeated second type of table blocks to obtain the cell contents in the non-repeated second type of table blocks and saving them in the third dictionary.
[0070] In the embodiment of the present invention, it is necessary to judge the table structure of the family tree registration form according to the lengths of the obtained list kuai_num and list sameText2 to extract the information therein.
[0071] First, it can be judged whether the table has repeated table blocks (i.e., the first type of table blocks) according to the length of the list kuai_num, and then it can be judged whether each table block in the table has repeated row table blocks (i.e., the second type of table blocks) according to the length of the list sameText2. The specific method is as follows:
[0072] If len(kuai_num) = 2, it means the table has no repeated table blocks, which is divided into the following two cases:
[0073] In the first case, if len(sameText) = 2, it means that there are no duplicate row table blocks inside the table at this time, and there is only one table block. At this time, only need to traverse the dictionary property_dict to get the row and column coordinates of each cell, then take out the content of the cell, and save it in the dictionary resultdict (the third dictionary).
[0074] In the second case, if len(sameText) > 2, it means that there are duplicate row table blocks inside the table, and there is only one table block. At this time, first obtain the attribute coordinates pos = propertydict[i] of each row table block inside the table according to the loop index i (this index i represents the serial number of each row table block), then record d = sameText2[1] - sameText2[0] (representing the number of rows of each row table block), rows is the total number of rows of the table, and then set the index sindex = 0 (representing the row number serial number of each row of the table). When sindex < rows - 1, take out the cell content of each row table block inside the table, then sindex += d (representing skipping the duplicate row table block and continuing to take out the cell content of the next row table block), and save the result in the dictionary resultdict.
[0075] If len(kuai_num) > 2, it means that there are duplicate table blocks in the table. Record addtimes = len(sameText2), which represents how many duplicate row table blocks each table block in the table is divided into. First, obtain the internal attribute coordinate dictionary pos = property_dict[kuai_num[j]] of the current table block from the table block serial number kuai_num[j], and then the cell content in the first row table block of each table block can be obtained from pos. Similarly, for the cell coordinates of other duplicate row table blocks in each table block, they can be obtained by adding d to the row coordinate of the cell in the same position in the first row table block, and the column coordinate remains unchanged. Then traverse the cells in each non-duplicate row table block. After the traversal of this table block is completed, select the next table block for the same traversal, and finally save the result in the dictionary resultdict.
[0076] The information extraction method for different structures in different genealogy registration forms proposed in the embodiments of the present invention solves the problems of structure recognition and character information extraction of various genealogy registration forms. At the same time, for genealogy companies that need to process genealogy information, the method for automatically parsing genealogy registration forms proposed in the embodiments of the present invention greatly saves development costs, manpower, and time, and improves work efficiency.
[0077] The following illustrates the present invention through another optional embodiment.
[0078] Example 2
[0079] The information extraction device for a family tree registration form provided in this embodiment includes multiple implementation units, each of which corresponds to each implementation step in the above-mentioned embodiment 1.
[0080] Figure 2 FIG. 1 is a schematic diagram of an information extraction device for a family tree registration table according to an embodiment of the present invention. Figure 2 As shown, the information extraction device may include: a processing unit 20, a parsing unit 22, and an extraction unit 24, wherein:
[0081] The processing unit 20 is used to pre-process the family tree registration form template to obtain a processed family tree registration form template;
[0082] The parsing unit 22 is used to parse the tables in the processed family tree registration form template to obtain a first dictionary and a second dictionary, wherein the first dictionary stores the structural parsing results of each table, and the second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values;
[0083] The extraction unit 24 is used to extract information of all entered family tree registration tables based on the first dictionary and the second dictionary to obtain a third dictionary, wherein the third dictionary stores the character information in each cell of each family tree registration table.
[0084] The above-mentioned information extraction device can pre-process the family tree registration form template via processing unit 20 to obtain a processed family tree registration form template. The parsing unit 22 then parses the tables in the processed family tree registration form template to obtain a first dictionary and a second dictionary. The first dictionary stores the structural parsing results of each table. The second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values. The extraction unit 24 then extracts information from all entered family tree registration forms based on the first and second dictionaries to obtain a third dictionary. The third dictionary stores the person information in each cell of each family tree registration form. In this embodiment, a method for automatically extracting information from family tree registration forms with different table structures is employed. By automatically parsing the table structure using a computer, the table structure is quickly identified and the person information therein is extracted. This method not only saves manpower and time costs but also improves the accuracy and efficiency of information extraction. This solves the technical problem in the related art of manual registration, which cannot automatically identify the structure and extract person information from family tree registration forms with different table structures, resulting in low information extraction efficiency.
[0085] Optionally, the processing unit includes: a first marking module, used to mark the attribute value cells in different tables in the family tree registration form template, wherein, if there are identical tables in the family tree registration form, repeated marking is not required; a second marking module, used to mark only one attribute value cell if the correspondence between the attribute name cell and the attribute value cell in the same table in the family tree registration form template is repeated, and the other repeated attribute value cells are not marked.
[0086] Optionally, the parsing unit includes: a first analysis module, used to analyze the number of table blocks and the number of table columns in the initial row of the table in the genealogy registration form template, and save the analysis results to a first preset list; a first parsing module, used to parse the table structure in each table block, and save the parsing results to a second preset list, wherein the number of cell rows or table rows is saved in the second preset list; a first saving module, used to save the second preset list corresponding to all tables in the genealogy registration form template in a first dictionary, wherein the key of the first dictionary is the serial number of each table in the genealogy registration form template, and the value is the second preset list; a first determination module, used to determine the attribute name cell coordinates and attribute value cell coordinates of each table in the genealogy registration form template based on the first preset list and the second preset list, and save the attribute name cell coordinates and attribute value cell coordinates to the second dictionary.
[0087] Optionally, the first parsing module includes: a first selection sub-module, used to select any table block in the table block, and use the first row of cell content in the selected table block as the benchmark comparison content, wherein the selected table block does not include the initial row; a first traversal sub-module, used to traverse all rows of the selected table block, and if cell content identical to the benchmark comparison content appears, record the number of cell rows of the traversed row and save it to a second preset list; a first saving sub-module, used to save the number of traversed rows in the selected table block to the second preset list if cell content identical to the benchmark comparison content does not appear.
[0088] Optionally, the first determination module includes: a second traversal sub-module, used to traverse the cells of each table in the family tree registration form template based on the first preset list and the second preset list; a first extraction sub-module, used to extract the coordinate value of each cell to obtain the row coordinates and column coordinates of each cell; a first reading sub-module, used to read the content of the cell based on the row coordinates and column coordinates, determine whether the cell is an attribute name cell, and save the judgment result to a fourth dictionary; the first determination sub-module, used to determine the attribute name cell coordinates and attribute value cell coordinates of each table in the family tree registration form template based on the fourth dictionary.
[0089] Optionally, the extraction unit includes: a first conversion module, used to convert the first dictionary and the second dictionary into a first file and a second file; a first generation module, used to read the first file and the second file, and generate a fifth dictionary and a third preset list, wherein the elements in the third preset list are the values in the first dictionary; a first traversal module, used to traverse each table in the entered genealogy registration table, obtain the number of table blocks and the number of table columns of each table, and save them to the first preset list; a second parsing module, used to parse the table structure of the table based on the third preset list, and save the parsed table structure to the fourth preset list; a first extraction module, used to extract information from the genealogy registration table based on the first preset list and the fourth preset list, and save it to the third dictionary.
[0090] Optionally, the first extraction module includes: a first screening submodule, used to screen out non-repeated first-type table blocks in the table in the genealogy registration form based on a first preset list, wherein the first-type table blocks are used to indicate blocks corresponding to multiple table columns; a second screening submodule, used to screen out non-repeated second-type table blocks for each non-repeated table block based on a fourth preset list, wherein the second-type table blocks are used to indicate blocks corresponding to multiple table rows; a third traversal submodule, used to traverse the non-repeated second-type table blocks, obtain the cell contents in the non-repeated second-type table blocks, and save them in a third dictionary.
[0091] The above-mentioned information extraction device may also include a processor and a memory. The above-mentioned processing unit 20, parsing unit 22, extraction unit 24, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0092] The processor includes a core, which retrieves the corresponding program unit from the memory. One or more cores can be set, and the information of all the family tree registration forms that have been entered can be extracted by adjusting the core parameters.
[0093] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0094] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: pre-processing the family tree registration form template to obtain a processed family tree registration form template, then parsing the table in the processed family tree registration form template to obtain a first dictionary and a second dictionary, and then extracting information of all entered family tree registration forms based on the first dictionary and the second dictionary to obtain a third dictionary, wherein the third dictionary stores the character information in each cell of each family tree registration form.
[0095] According to another aspect of an embodiment of the present invention, an electronic device is also provided, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any of the above-mentioned information extraction methods for the family tree registration form by executing the executable instructions.
[0096] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is also provided, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute any of the above-mentioned methods for extracting information from a family tree registration form.
[0097] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0098] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0099] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0100] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0101] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0102] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.
[0103] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A method for extracting information from a family tree registration form, characterized in that: include: Preprocessing the family tree registration form template to obtain a processed family tree registration form template; Parsing the table in the processed family tree registration form template to obtain a first dictionary and a second dictionary, wherein the first dictionary stores the structural parsing results of each table, and the second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values; The step of parsing the table in the processed family tree registration form template to obtain the first dictionary and the second dictionary includes: analyzing the number of table blocks and the number of table columns in the initial row of the table in the family tree registration form template, and saving the analysis result in a first preset list; parsing the table structure in each table block, and saving the analysis result in a second preset list, wherein the number of cell rows or the number of table rows is saved in the second preset list; saving the second preset list corresponding to all tables in the family tree registration form template in the first dictionary, wherein the key of the first dictionary is the serial number of each table in the family tree registration form template, and the value is the second preset list; determining the attribute name cell coordinates and the attribute value cell coordinates of each table in the family tree registration form template based on the first preset list and the second preset list, and saving the attribute name cell coordinates and the attribute value cell coordinates in the second dictionary; Based on the first dictionary and the second dictionary, extract the information of all the entered family tree registration forms to obtain a third dictionary, wherein the third dictionary stores the character information in each cell of each family tree registration form; The step of extracting information of all entered family tree registration tables based on the first dictionary and the second dictionary to obtain a third dictionary includes: converting the first dictionary and the second dictionary into a first file and a second file; reading the first file and the second file to generate a fifth dictionary and a third preset list, wherein the elements in the third preset list are the values in the first dictionary; traversing each table in the entered family tree registration table to obtain the number of table blocks and the number of table columns of each table, and saving them to the first preset list; parsing the table structure of the table based on the third preset list, and saving the parsed table structure to the fourth preset list; extracting information from the family tree registration table based on the first preset list and the fourth preset list, and saving them to the third dictionary.
2. The information extraction method according to claim 1, characterized in that: The step of preprocessing the family tree registration form template to obtain the processed family tree registration form template includes: Marking the attribute value cells in different tables in the family tree registration form template, wherein if there are identical tables in the family tree registration form, repeated marking is not required; If the corresponding relationship between the attribute name cell and the attribute value cell in the same table in the family tree registration form template is repeated, only one attribute value cell is marked, and the other repeated attribute value cells are not marked.
3. The information extraction method according to claim 1, characterized in that: The step of parsing the table structure in each table block and saving the parsing result into a second preset list includes: Select any table block in the table blocks, and use the first row of cell contents in the selected table block as the reference comparison content, wherein the selected table block does not include the initial row; Traversing all rows of the selected table block, if there is a cell content that is the same as the reference comparison content, recording the cell row number of the traversed row and saving it to the second preset list; If there is no cell content that is the same as the reference comparison content, the number of traversed rows in the selected table block is saved in the second preset list.
4. The information extraction method according to claim 1, characterized in that: The step of determining the attribute name cell coordinates and the attribute value cell coordinates of each table in the family tree registration form template based on the first preset list and the second preset list includes: Based on the first preset list and the second preset list, traverse the cells of each table in the family tree registration form template; Extracting the coordinate value of each cell to obtain the row coordinate and column coordinate of each cell; Based on the row coordinates and the column coordinates, read the content of the cell, determine whether the cell is an attribute name cell, and save the determination result in a fourth dictionary; Based on the fourth dictionary, the attribute name cell coordinates and the attribute value cell coordinates of each table in the family tree registration form template are determined.
5. The information extraction method according to claim 1, characterized in that: The step of extracting information from the family tree registration table based on the first preset list and the fourth preset list and saving the information to the third dictionary comprises: Based on the first preset list, filter out non-repeated first-type table blocks in the table in the family tree registration table, wherein the first-type table blocks are used to indicate blocks corresponding to multiple table columns; Based on the fourth preset list, for each of the non-repeated table blocks, filter out non-repeated second-type table blocks, wherein the second-type table blocks are used to indicate blocks corresponding to multiple table rows; The non-repeated second-type table blocks are traversed to obtain cell contents in the non-repeated second-type table blocks, and are saved in a third dictionary.
6. A device for extracting information from a family tree registration form, characterized in that: include: A processing unit, used for pre-processing the family tree registration form template to obtain a processed family tree registration form template; A parsing unit, used to parse the table in the processed family tree registration form template to obtain a first dictionary and a second dictionary, wherein the first dictionary stores the structural parsing results of each table, and the second dictionary uses the attribute name cell coordinates as keys and the attribute value cell coordinates corresponding to the attribute name cell as values; The parsing unit includes: a first analysis module, used to analyze the number of table blocks and the number of table columns of the initial row of the table in the family tree registration form template, and save the analysis result in a first preset list; a first parsing module, used to parse the table structure in each table block, and save the parsing result in a second preset list, wherein the number of cell rows or the number of table rows is saved in the second preset list; a first saving module, used to save the second preset list corresponding to all tables in the family tree registration form template in a first dictionary, wherein the key of the first dictionary is the serial number of each table in the family tree registration form template, and the value is the second preset list; a first determination module, used to determine the attribute name cell coordinates and the attribute value cell coordinates of each table in the family tree registration form template based on the first preset list and the second preset list, and save the attribute name cell coordinates and the attribute value cell coordinates in the second dictionary; An extraction unit, configured to extract information of all entered family tree registration tables based on the first dictionary and the second dictionary to obtain a third dictionary, wherein the third dictionary stores character information in each cell of each family tree registration table; The extraction unit includes: a first conversion module, used to convert the first dictionary and the second dictionary into a first file and a second file; a first generation module, used to read the first file and the second file, and generate a fifth dictionary and a third preset list, wherein the elements in the third preset list are the values in the first dictionary; a first traversal module, used to traverse each table in the entered family tree registration table, obtain the number of table blocks and the number of table columns of each table, and save them to the first preset list; a second parsing module, used to parse the table structure of the table based on the third preset list, and save the parsed table structure to the fourth preset list; a first extraction module, used to extract the information in the family tree registration table based on the first preset list and the fourth preset list, and save it to the third dictionary.
7. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the information extraction method of the family tree registration table as described in any one of claims 1 to 5 by executing the executable instructions.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the information extraction method for the family tree registration form described in any one of claims 1 to 5.
