A method and system for generating a header

By building a knowledge graph of headers and defining headers' entities and their relationships and attributes, the fixity and complexity of traditional report headers is solved, and dynamic generation and flexible management of report headers are realized to meet the needs of complex data display.

CN119203959BActive Publication Date: 2025-03-28CHINESE ACAD OF SURVEYING & MAPPING
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411731808.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-28
Estimated Expiration
2044-11-29

AI Technical Summary

Technical Problem

Traditional report headers are difficult to adjust flexibly due to fixed formats and contents, especially when displaying complex data or multi-dimensional information.

Method used

By defining the relationships and entity attributes between header entities and entities, a header knowledge graph is built, and the flexibility and multi-level characteristics of the knowledge graph are used to achieve dynamic generation and management of headers.

Benefits of technology

It realizes flexible generation and management of report headers, can adapt to the display needs of complex data and multi-dimensional information, and improves the dynamics and configurability of table headers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119203959B_ABST
    Figure CN119203959B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of data processing technology, and in particular to a method and system for generating a header. The present invention successfully constructs a header knowledge graph by defining header entities, the relationship between header entities, and the attributes of header entities, and uses the constructed header knowledge graph to calculate the total number of rows and columns of the header, generate a header array, traverse each header entity in the header entity knowledge graph, calculate the starting cell row number and column number of the content coverage area of ​​each header entity, generate the content, position and attribute of the header entity in the form of a key-value pair in JSON format, store them in the corresponding position of the header array, traverse the non-empty elements in the header array storing the content and attribute information of the header entity, and generate a header based on the content, position and attributes of the header entity. The present invention utilizes the flexibility, multi-level and extensible characteristics of the knowledge graph, and the efficient information integration, association and retrieval capabilities to realize the dynamic generation and flexible management of report headers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a method and system for generating a header. Background Art

[0002] The report header plays a vital role in the data report. It is not only a component of the report, but also the cornerstone of data display and analysis. The report header provides the reader with the framework and background of the report, provides a clear definition and explanation for the data in the table, clarifies the organization and classification of the data information in the table, is a navigation tool for the data in the table, and provides a structured display framework for the data. Through the header, readers can understand the report and the meaning of the numbers in the report. In view of the role and important position of the header in the report, the report header also has a certain degree of complexity. A complex header may contain multiple levels, each level represents a different data classification or dimension. In addition to a simple hierarchical structure, the header may also contain cross-dimensions. In some cases, some items in the header may be nested or grouped. In addition, in some advanced reports, the header also needs to have strong flexibility. The header may be dynamic or configurable, which means that users can add, delete or rearrange the items in the header according to their needs. Traditional report headers often use fixed formats and content templates, which leads to limitations in displaying complex data or multi-dimensional information. Once the header is set, it is often difficult to adjust flexibly. Summary of the invention

[0003] In view of the above-mentioned deficiencies in the prior art, the present invention proposes a method and system for generating headers, which utilize the flexibility, multi-level and scalable characteristics of knowledge graphs, and efficient information integration, association and retrieval capabilities to realize the dynamic generation and management of report headers.

[0004] In order to solve the above problems, the present invention adopts the following technical solutions:

[0005] In one aspect, the present invention provides a method for generating a header, comprising:

[0006] Define the header entity, with each independently displayed content in the header as the header entity.

[0007] Define the relationship between header entities, and use the adjacency relationship type between the header areas where the header entities are located as the relationship between the header entities.

[0008] The properties of the header entity are defined, and the properties of the header entity include the entity type, shape, grid spacing, border, and merging method.

[0009] Constructing a header knowledge graph based on the header entities, the relationships between the header entities, and the attributes of the header entities;

[0010] Using the constructed header knowledge graph, calculate the total number of rows and columns in the header and generate a header array.

[0011] Traverse each header entity in the header entity knowledge graph, calculate the starting cell row number and column number of each header entity content coverage area, generate the content, position and attributes of the header entity in JSON format in the form of key-value pairs, and store them in the corresponding position of the header array.

[0012] Traverse the non-empty elements in the header array that store the content and attribute information of the header entity, and generate the header based on the content, position and attributes of the header entity.

[0013] As an implementable embodiment, the relationship between the header entities includes a right adjacency relationship, a bottom adjacency relationship, and a bottom-right adjacency relationship.

[0014] As an implementable embodiment, the types of entities include a start entity, an intermediate entity, and a last entity;

[0015] The shape of the entity is the shape of the area where the header entity content is located, including a rectangular entity domain and a gun-shaped entity domain. The rectangular entity domain includes a single-row and single-column rectangular entity domain, a single-row and multiple-column rectangular entity domain, a multiple-row and single-column rectangular entity domain, and a multiple-row and multiple-column rectangular entity domain. The gun-shaped entity domain includes a longitudinal support area gun-shaped entity domain and a transverse tube area gun-shaped entity domain. The longitudinal support area gun-shaped entity domain includes a multiple-row and single-column longitudinal support area gun-shaped entity domain and a multiple-row and multiple-column longitudinal support area gun-shaped entity domain. The transverse tube area gun-shaped entity domain includes a single-row and single-column transverse tube area gun-shaped entity domain and a single-row and multiple-column transverse tube area gun-shaped entity domain.

[0016] The entity grid spacing is the number of cells covered by the header entity content coverage area, including the right grid spacing, bottom grid spacing, lower right grid spacing and lower right grid spacing.

[0017] The border of the entity is the border of the cell in the area covered by the header entity content, including the top border, bottom border, left border and right border. The border value is 0 or 1, 0 means no border line, and 1 means there is a border line.

[0018] The entity merging method is the merging method of the cells in the area covered by the header entity content, including merging, merging to the right and merging to the bottom; the rectangular entity domain merging method is merging, that is, the cells covered by the header entity content are directly merged into one cell, and the gun-shaped entity domain merging method is merging to the right or merging to the bottom. When the display position of the header entity content is the gun-shaped entity domain in the horizontal tube area, the merging method is merging to the right, that is, first merging the first row of cells in the vertical support area of ​​the entity domain and the cells in the horizontal tube area, and then merging the remaining cells in the vertical support area; when the display position of the header entity content is the gun-shaped entity domain in the vertical support area, the merging method is merging to the bottom, that is, first merging the cells in the vertical support area of ​​the entity domain, and then merging the cells in the horizontal tube area of ​​the entity domain.

[0019] As an implementable method, the method of using the constructed header knowledge graph to calculate the total number of rows and columns of the header and generate a two-dimensional array of the header includes:

[0020] S510: Query the header entity whose entity type is the starting entity from the header knowledge graph , and extract the right grid distance of the starting entity , and initialize , let the starting entity be the current entity; where R is the total number of rows in the header, the starting row number is 1, C is the total number of columns in the header, the starting column number in the header is 1, there are i entities in the first row of the header, and j entities in the first column.

[0021] S520, query the right adjacent entity of the current entity from the header knowledge graph. If it does not exist, terminate the query. If it does exist, set i=i+1 and query the right adjacent entity from the header knowledge graph to obtain the right adjacent entity that does not exist and has a downward adjacent relationship. And set it as the current entity, extract the right grid distance of the current entity ,set up .

[0022] S530, repeat S520 until the last right adjacent entity.

[0023] S540, set the starting entity as the current entity, and extract the grid distance below the starting entity ,initialization .

[0024] S550. Obtain the next adjacent entity of the current entity from the header knowledge graph query. If it does not exist, terminate the query. If it does exist, set j=j+1 and obtain the next adjacent entity whose pointing relationship is the right adjacent relationship from the header knowledge graph query. And set it as the current entity, extract the grid distance under the current entity ,set up .

[0025] S560, repeat S550 until the last lower adjacent entity.

[0026] S570: Generate a header array based on the calculated total number of rows R and total number of columns C of the header .

[0027] As an implementation method, the method traverses each header entity in the header entity knowledge graph, calculates the starting cell row number and column number of the content coverage area of ​​each header entity, generates JSON format in the form of key-value pairs for the content, position and attributes of the header entity, and stores them in the corresponding position of the header array, including:

[0028] S610, calculate the row number and column number of the entity's starting cell by backtracking the relationship of the header knowledge graph. If the entity type of the header entity is the starting entity, the entity's coordinates are [1,1]. The row number of other header entities is the sum of the bottom grid distance or the bottom right grid distance of the entity and the entity on the backtracking relationship chain plus one, and the column number is the sum of the right grid distance or the bottom right grid distance of the entity and the entity on the backtracking relationship chain plus one. Traverse the header entities , set the starting line number The initial value is 1, the starting column number The initial value is 1, set the current header entity For the current entity .

[0029] S620, obtain the current entity from the header knowledge graph The content, location and attributes of the current entity The position and header array The rules corresponding to the subscripts fill the header array with the JSON data of the content, location, and attributes of the header entity.

[0030] As an implementable method, the S610 includes:

[0031] S611, find the current entity Entities on the upward traceability chain:

[0032] 1) Query the current entity from the header knowledge graph Entity , traverse , find the Get the entity with the lower-right adjacency, if any. The lower right grid ,make , stop traversal , set the current for , repeat 1), if it does not exist, go to 2).

[0033] 2) Continue to search for Entities with lower adjacency, if any, get the lower grid distance of the entity with the largest lower grid distance ,make , stop traversal , set the current for , repeat 1), if it does not exist, terminate Calculation, let the current for .

[0034] S612, find the current entity Entities on the left-backward relationship chain:

[0035] 1) Query the current entity from the header knowledge graph Entity , traverse , find the Get the entity with the lower-right adjacency, if any. The bottom right spacing ,make , stop traversal , let the current for , repeat 1), if it does not exist, go to 2).

[0036] 2) Find and Entities with right adjacency, if any, get the right spacing of the entity with the largest right spacing ,make , stop traversal , set the current for , repeat 1), if it does not exist, terminate Calculation, let the current for .

[0037] As an implementable method, traversing non-empty elements in a header array storing content and attribute information of a header entity and generating a header based on the content, position and attributes of the header entity includes:

[0038] Read the non-empty elements in the header array, read their position information, locate the cell to be filled with entity content, read its content, and fill the located cell with the content of the header entity.

[0039] Read the shape, grid spacing, merging mode attributes and position information of the current non-empty element, calculate the starting row number, ending row number, starting column number and ending column number of the cells covered by the entity domain, and merge the cells;

[0040] Read the type, shape, spacing, border attributes, and position information of the current non-empty element, and set the border line of the entity domain covering the cell.

[0041] As an implementable method, the reading of the shape, grid spacing, merging mode attributes and position information of the current non-empty element, calculating the starting row number, ending row number, starting column number and ending column number of the cells covered by the entity domain, and merging the cells includes:

[0042] If the current element shape is a rectangular entity domain, the starting row number is , starting with column number , the ending line number is , the ending column number is .

[0043] If the shape attribute of the current element is a gun-shaped entity domain, and the merge mode attribute is right merge, for the entity domain horizontal pipe area, the starting row number is , the ending line number is , starting with column number , the ending column number is , for the entity domain vertical support area, the starting line number is , the ending line number is , starting with column number , the ending column number is .

[0044] If the shape attribute of the current element is gun-shaped, The attribute is merged downwards. For the entity domain vertical support area, the starting line number is , the ending line number is , starting with column number , the ending column number is , for the physical domain transverse pipe area, the starting line number is , the ending line number is , starting with column number , the ending column number is .

[0045] Calculate the starting row number, ending row number, starting column number, and ending column number of the cells covered by the entity domain, and merge the cells.

[0046] As an implementable method, the reading of the type, shape, grid spacing, border attributes and position information of the current non-empty element and setting the border line of the entity domain covering the cell includes:

[0047] Read the type, shape, spacing, border attributes, and position information of the current non-empty element.

[0048] If the shape attribute of the current element is a rectangle, set the border line according to the values ​​of the top border, bottom border, left border, and right border in the border attribute.

[0049] If the shape attribute of the current element is gun-shaped, divide the entity domain into three parts and set the border lines respectively. The starting line number of the first part is , the ending line number is , starting with column number , the ending column number is ,according to The value of sets the border lines of the top and left borders, and leaves the border lines of the right and bottom borders empty; the starting line number of the second part is , the ending line number is , starting with column number , the ending column number is , according to the values ​​of the upper border, lower border and right border, set the border lines of the upper border, lower border and right border, and the border line of the left border is empty; the starting line number of the third part is , the ending line number is , starting with column number , the ending column number is , according to the values ​​of the left border, bottom border and right border, set the border lines of the left border, bottom border and right border, and leave the border line of the top border empty.

[0050] If the current element type is the last row entity, read the column width attribute of the current element and set the cell width to the value of the column width attribute.

[0051] On the other hand, the present invention provides a header generation system, including an entity definition module, a relationship definition module, an attribute definition module, a header knowledge graph construction module, a header array generation module, an information storage module and a header generation module.

[0052] The entity definition module is used to define a table header entity, with each independently displayed content in the table header as the table header entity.

[0053] The relationship definition module is used to define the relationship between the header entities, and the adjacency relationship type between the header areas where the header entities are located is used as the relationship between the header entities.

[0054] The attribute definition module is used to define the attributes of the header entity, and the attributes of the header entity include the type, shape, grid spacing, border and merging method of the entity.

[0055] The header knowledge graph construction module is used to construct a header knowledge graph based on the header entities, the relationships between header entities, and the attributes of header entities.

[0056] The header array generation module is used to use the constructed header knowledge graph to calculate the total number of rows and columns of the header and generate a header array.

[0057] The information storage module is used to traverse each header entity in the header entity knowledge graph, calculate the starting cell row number and column number of the content coverage area of ​​each header entity, generate the content, position and attributes of the header entity in JSON format in the form of key-value pairs, and store them in the corresponding position of the header array.

[0058] The header generation module is used to traverse the non-empty elements in the header array storing the content and attribute information of the header entity, and generate the header based on the content, position and attributes of the header entity.

[0059] The beneficial effects of the present invention are as follows: the present invention successfully constructs a header knowledge graph by defining header entities, the relationships between header entities, and the attributes of header entities. Using the constructed header knowledge graph, the header can be generated flexibly and accurately, and the flexibility, multi-level and scalable characteristics of the knowledge graph, as well as the efficient information integration, association and retrieval capabilities, can be used to achieve dynamic generation and flexible management of report headers. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 This is a flow chart of the method for generating a header in Example 1 of the present invention.

[0061] Figure 2 Schematic diagram of the adjacency relationship of the header entity in Example 1 of the present invention.

[0062] Figure 3 This is a schematic diagram of the shape of the header entity field in Example 1 of the present invention.

[0063] Figure 4 Schematic diagram of the grid spacing of the header entity in Example 1 of the present invention.

[0064] Figure 5 It is a schematic diagram of the gun-shaped header entity content display method and the header entity domain merging method in Example 1 of the present invention.

[0065] Figure 6 This is a schematic diagram of the JSON structure stored in the header entity in Example 1 of the present invention.

[0066] Figure 7 Schematic diagram of a system for generating a header in Example 1 of the present invention.

[0067] Figure 8 This is a diagram showing an example of a table header in Example 2 of the present invention. DETAILED DESCRIPTION

[0068] The present invention is further described in detail below in conjunction with specific embodiments.

[0069] It should be noted that these embodiments are only used to illustrate the present invention rather than to limit the present invention. Simple improvements to the method based on the concept of the present invention all fall within the scope of protection claimed by the present invention.

[0070] Example 1

[0071] How to generate the header

[0072] The header in the present invention includes a row header or a column header in a report. The method for constructing a header knowledge graph and the method for generating a header are applicable to reports with only row headers, only column headers, and both row headers and column headers. The header knowledge graph includes three parts: header entities, relationships between header entities, and header entity attributes.

[0073] S100. Define a header entity, with each independently displayed content in the header as the header entity.

[0074] The content displayed in the header is the header entity, and each independently displayed content in the header is a header entity.

[0075] S200: define the relationship between header entities, and use the adjacency relationship type between the header areas where the header entities are located as the relationship between the header entities. The relationship between the header entities includes right adjacency relationship, bottom adjacency relationship and bottom-right adjacency relationship.

[0076] The relationship between table header entities is a unidirectional relationship. The adjacency relationship between table headers starts from the first entity in the table header. The first entity does not have a pointed adjacency relationship, and the last entity does not have an execution adjacency relationship. For example, Figure 2 As shown, the entity The first entity in the table header. With entity , , For the next adjacency relationship, and is the lower right adjacency relationship, and is the lower right adjacency relationship, and is the right adjacency relationship, and It is a right adjacency relationship.

[0077] S300, defining the attributes of the header entity, the attributes of the header entity including the entity type, shape, grid spacing, border and merging method.

[0078] On this basis, the properties of the header entity can be expanded, such as font, alignment, column width, row height, etc.

[0079] The types of entities include start entity, middle entity and end row entity.

[0080] The starting entity refers to the entity starting from the first row and the first column; the last row entity is the row after the last row of the table header, that is, the first row of the table body, which exists together with the column width attribute to identify the width of each column; the others are intermediate entities.

[0081] The shape of the entity is the shape of the area where the header entity content is located, that is, the shape of the area covered by the entity content. Figure 3 The shape of the entity includes a rectangular entity domain and a gun-shaped entity domain, and the rectangular entity domain includes a single-row and single-column rectangular entity domain. , Single row and multiple column rectangular entity domain , Multiple row and single column rectangular entity domain and a rectangular entity domain with multiple rows and columns The gun-shaped entity domain includes the gun-shaped entity domain of the longitudinal support area and the gun-shaped entity domain of the transverse tube area. The gun-shaped entity domain of the longitudinal support area includes the gun-shaped entity domain of the longitudinal support area with a double row and single column type. And the gun-shaped entity domain of the double-row and double-column type longitudinal support area , the gun-shaped entity domain of the transverse tube area includes the single-row single-column type gun-shaped entity domain of the transverse tube area and single row multiple row transverse tube area gun type entity domain .

[0082] The adjacency relationships between the rectangular entity and other entities include right adjacency relationship and bottom adjacency relationship, and the adjacency relationships between the gun-shaped entity and other entities include right adjacency relationship, bottom adjacency relationship and bottom-right adjacency relationship.

[0083] The entity grid spacing refers to the number of cells covered by the header entity content coverage area, including the right grid spacing, bottom grid spacing, lower right grid spacing, and lower right grid spacing.

[0084] like Figure 4 As shown, the entity grid spacing of the header includes the right grid spacing (rd), lower grid spacing (dd), lower right grid spacing (rdd) and lower right grid spacing (drd). The right grid spacing is the number of cells covered by the entity coverage area from the upper left cell to the right, the lower grid spacing is the number of cells covered by the entity coverage area from the upper left cell to the bottom, the lower right grid spacing is the number of cells covered by the gun-type entity horizontal tube area downwards, and the lower right grid spacing is the number of cells covered by the gun-type entity vertical support area to the right.

[0085] The border of the entity is the border of the cell in the area covered by the header entity content, including the top border, bottom border, left border and right border. The border value is 0 or 1, 0 means no border line, and 1 means there is a border line.

[0086] The border properties can also be further expanded according to actual needs, such as border style, color, etc.

[0087] The entity merging method is the merging method of the cells in the area covered by the header entity content, including merging, merging to the right, and merging to the bottom. Figure 5As shown, according to the shape of the header entity, the merging mode of the rectangular entity domain is merging, that is, the cells covered by the header entity content are directly merged into one cell; the merging mode of the gun-shaped entity domain is merging to the right or merging to the bottom. When the display position of the header entity content is the gun-shaped entity domain in the horizontal tube area, the merging mode is merging to the right, that is, first merging the first row of cells in the vertical support area of ​​the entity domain and the cells in the horizontal tube area, and then merging the remaining cells in the vertical support area. When the display position of the header entity content is the gun-shaped entity domain in the vertical support area, the merging mode is merging to the bottom, that is, first merging the cells in the vertical support area of ​​the entity domain, and then merging the cells in the horizontal tube area of ​​the entity domain.

[0088] S400. Construct a header knowledge graph based on the above-mentioned header entities, the relationships between header entities, and the attributes of header entities. The process of constructing the knowledge graph can adopt the general knowledge graph construction method, which will not be elaborated here.

[0089] S500. Using the constructed header knowledge graph, calculate the total number of rows and columns of the header, and generate a header array.

[0090] S510: Query the header entity whose entity type is the starting entity from the header knowledge graph , and extract the right grid distance of the starting entity , and initialize , let the starting entity be the current entity; where R is the total number of rows in the header, the starting row number is 1, C is the total number of columns in the header, the starting column number in the header is 1, there are i entities in the first row of the header, and j entities in the first column.

[0091] S520, query the right adjacent entity of the current entity from the header knowledge graph. If it does not exist, terminate the query. If it does exist, set i=i+1 and query the right adjacent entity from the header knowledge graph to obtain the right adjacent entity that does not exist and has a downward adjacent relationship. And set it as the current entity, extract the right grid distance of the current entity ,set up .

[0092] S530, repeat S520 until the last right adjacent entity.

[0093] S540, set the starting entity as the current entity, and extract the grid distance below the starting entity ,initialization .

[0094] S550. Obtain the next adjacent entity of the current entity from the header knowledge graph query. If it does not exist, terminate the query. If it does exist, set j=j+1 and obtain the next adjacent entity whose pointing relationship is the right adjacent relationship from the header knowledge graph query. And set it as the current entity, extract the grid distance under the current entity ,set up .

[0095] S560, repeat S550 until the last lower adjacent entity.

[0096] S570: Generate a header array based on the calculated total number of rows R and total number of columns C of the header . Header array Used to store header entity information, initially empty.

[0097] S600, traverse each header entity in the header entity knowledge graph, calculate the starting cell row number and column number of the area covered by the content of each header entity, generate the content, position and attributes of the header entity in the form of key-value pairs in JSON format, and store them in the corresponding position of the header array.

[0098] S610, calculate the row number and column number of the entity's starting cell by backtracking the relationship of the header knowledge graph. If the entity type of the header entity is the starting entity, the entity's coordinates are [1,1]. The row number of other header entities is the sum of the bottom grid distance or the bottom right grid distance of the entity and the entity on the backtracking relationship chain plus one, and the column number is the sum of the right grid distance or the bottom right grid distance of the entity and the entity on the backtracking relationship chain plus one. Traverse the header entities , set the starting line number The initial value is 1, the starting column number The initial value is 1, set the current header entity For the current entity .

[0099] S610 includes:

[0100] S611, find the current entity Entities on the upward traceability chain:

[0101] 1) Query the current entity from the header knowledge graph Entity , traverse , find the Get the entity with the lower-right adjacency, if any. The lower right grid ,make , stop traversal , set the current for , repeat 1), if it does not exist, go to 2).

[0102] 2) Continue to search for Entities with lower adjacency, if any, get the lower grid distance of the entity with the largest lower grid distance ,make , stop traversal , set the current for , repeat 1), if it does not exist, terminate Calculation, let the current for .

[0103] S612, find the current entity Entities on the left-backward relationship chain:

[0104] 1) Query the current entity from the header knowledge graph Entity , traverse , find the Get the entity with the lower-right adjacency, if any. The bottom right spacing ,make , stop traversal , let the current for , repeat 1), if it does not exist, go to 2).

[0105] 2) Find and Entities with right adjacency, if any, get the right spacing of the entity with the largest right spacing ,make , stop traversal , set the current for , repeat 1), if it does not exist, terminate Calculation, let the current for .

[0106] S620, obtain the current entity from the header knowledge graph Contents ,Location and properties , you can press Figure 6 The JSON structure shown is organized to the current entity The position and header array The rules corresponding to the subscript fill the JSON data of the content, position and attributes of the header entity into the header array. The content is the string displayed in the entity coverage area, and the position is the calculated , , attributes include the type of the header entity ,shape , Merger method , Grid spacing and border If the entity has other attributes, you can Figure 6 Structural rules are added to JSON.

[0107] S700 , traverse the non-empty elements in the header array storing the content and attribute information of the header entity, and generate a header based on the content, position and attributes of the header entity.

[0108] According to the actual application scenario, use a third-party table operation tool or method library, such as NOPI, openpyxl, etc. for Excel operation, traverse the non-empty elements in array A, and use the generated header entity information to generate the header:

[0109] S710, read the non-empty elements in the header array, read their position information, locate the position of the cell to be filled with entity content, read its content, and fill the located cell with the content of the header entity.

[0110] S720, read the shape, grid spacing, merge mode attributes and position information of the current non-empty element, calculate the starting row number, ending row number, starting column number and ending column number of the cells covered by the entity domain, and merge the cells.

[0111] 1) If the current element shape If it is a rectangular entity domain, the starting row number is , starting with column number , the ending line number is , the ending column number is .

[0112] 2) If the shape attribute of the current element is a gun-shaped entity domain, and the merge mode attribute is right merge, for the entity domain horizontal pipe area, the starting row number is , the ending line number is , starting with column number , the ending column number is , for the entity domain vertical support area, the starting line number is , the ending line number is , starting with column number , the ending column number is .

[0113] 3) If the shape attribute of the current element is gun-shaped, The attribute is merged downwards. For the entity domain vertical support area, the starting line number is , the ending line number is , starting with column number , the ending column number is , for the physical domain transverse pipe area, the starting line number is , the ending line number is , starting with column number , the ending column number is .

[0114] 4) Calculate the starting row number, ending row number, starting column number, and ending column number of the cells covered by the entity domain, and merge the cells.

[0115] S730. Read the type, shape, grid spacing, border attributes and position information of the current non-empty element, and set the border line of the entity domain covering the cell.

[0116] 1) Read the type of the current non-empty element ,shape , Grid spacing and border Attributes and location information.

[0117] 2) If the shape attribute of the current element is a rectangle, according to the border attribute , , and The value of is the value of the top border, bottom border, left border and right border, which sets the border line.

[0118] 3) If the shape attribute of the current element is gun-shaped, divide the entity domain into three parts and set the border lines respectively. The starting line number of the first part is , the ending line number is , starting with column number , the ending column number is ,according to The value of sets the border lines of the top and left borders, and leaves the border lines of the right and bottom borders empty; the starting line number of the second part is , the ending line number is , starting with column number , the ending column number is , according to the values ​​of top, bottom and right, set the border lines of the top, bottom and right borders, and leave the border line of the left border empty; the starting line number of the third part is , the ending line number is , starting with column number , the ending column number is , according to the values ​​of left border left, bottom border bottom and right border right, set the border lines of the left border, bottom border and right border, and leave the border line of the top border empty.

[0119] 4) If the current element type is the last row entity, read the column width attribute of the current element and set the cell width to the value of the width attribute.

[0120] You can refer to the above method and set the header according to the characteristics of other attributes of the header entity.

[0121] See also Figure 7 According to the above-mentioned header generation method, a header generation system is designed, including an entity definition module 100, a relationship definition module 200, an attribute definition module 300, a header knowledge graph construction module 400, a header array generation module 500, an information storage module 600 and a header generation module 700.

[0122] The entity definition module 100 is used to define a header entity, with each independently displayed content in the header as the header entity.

[0123] The relationship definition module 200 is used to define the relationship between header entities, and the adjacency relationship type between the header areas where the header entities are located is used as the relationship between the header entities.

[0124] The attribute definition module 300 is used to define the attributes of the header entity. The attributes of the header entity include the entity type, shape, grid spacing, border and merging method.

[0125] The header knowledge graph construction module 400 is used to construct a header knowledge graph based on the header entities, the relationships between the header entities, and the attributes of the header entities.

[0126] The header array generation module 500 is used to calculate the total number of rows and columns of the header by using the constructed header knowledge graph to generate a header array.

[0127] The information storage module 600 is used to traverse each header entity in the header entity knowledge graph, calculate the starting cell row number and column number of each header entity content coverage area, generate the content, position and attributes of the header entity in the form of key-value pairs in JSON format, and store them in the corresponding position of the header array.

[0128] The header generation module 700 is used to traverse the non-empty elements in the header array storing the content and attribute information of the header entity, and generate the header based on the content, position and attributes of the header entity.

[0129] Example 2

[0130] The header generation method of the present invention has been applied in the header generation of radio and television and network audio-visual statistical reports. Taking the header generation of "Guangzong Appendix" as an example, the main process of using the header generation method of the present invention is explained.

[0131] 1. Establish the knowledge graph of the Guangzong Appendix

[0132] 29 entities and 52 relationships were created, and 10 categories and 19 attributes were defined, as shown in Table 1, Table 2, and Table 3.

[0133] According to actual application needs, the entity attributes are expanded and four types of attributes are added: line height, font, alignment and empty content. The reasons are as follows: (1) The title entity is different from other header entities in font and line height. The font is generally bold and the font size is larger to make the title more eye-catching; (2) The content of the header entity is more beautiful when it is centered vertically and horizontally; (3) Some positions in the header are empty, so the empty content attribute is added. By judging the value of this attribute, no content is written in the corresponding entity field when generating the header.

[0134] 2. Generate header

[0135] According to the established knowledge graph of the general comprehensive table, and in accordance with the table header generation method of the present invention, by calling the NPOI library, the table header of the general comprehensive table in EXCEL format is generated, such as Figure 8 shown.

[0136] Table 1 Entity table of the Guangzong Appendix

[0137]

[0138] Table 2 Entity relationship table of Guangzong appendix

[0139]

[0140] Table 3 Entity attribute table of Guangzong Appendix

[0141]

[0142] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described with reference to the preferred embodiments of the present invention, it should be understood by those skilled in the art that various changes may be made in form and details without departing from the spirit and scope of the present invention as defined in the appended claims.

Claims

1. A method for generating a header, characterized in that: include: Define the header entity, with each independently displayed content in the header as the header entity; Define the relationship between header entities, using the adjacency relationship type between the header areas where the header entities are located as the relationship between the header entities; Define the properties of the header entity, wherein the properties of the header entity include the entity type, shape, grid spacing, border, and merging method; Constructing a header knowledge graph based on the header entities, the relationships between the header entities, and the attributes of the header entities; Using the constructed header knowledge graph, calculate the total number of rows and columns in the header and generate a header array; Traverse each header entity in the header entity knowledge graph, calculate the starting cell row number and column number of each header entity content coverage area, generate the content, position and attributes of the header entity in the form of key-value pairs in JSON format, and store them in the corresponding position of the header array; Traverse the non-empty elements in the header array that store the content and attribute information of the header entity, and generate the header based on the content, position and attributes of the header entity; The method traverses each header entity in the header entity knowledge graph, calculates the starting cell row number and column number of the area covered by each header entity content, generates the content, position and attributes of the header entity in the form of key-value pairs in JSON format, and stores them in the corresponding position of the header array, including: S610, calculate the row number and column number of the entity's starting cell by backtracking the relationship of the header knowledge graph. If the entity type of the header entity is the starting entity, the entity's coordinates are [1,1]. The row number of other header entities is the sum of the bottom grid distance or the bottom right grid distance of the entity and the entity on the backtracking relationship chain plus one, and the column number is the sum of the right grid distance or the bottom right grid distance of the entity and the entity on the backtracking relationship chain plus one. Traverse the header entities , set the starting line number The initial value is 1, the starting column number The initial value is 1, set the current header entity For the current entity ; S620, get the current entity from the header knowledge graph The content, location and attributes of the current entity The position and header array The rules corresponding to the subscripts fill the header array with the JSON data of the content, location, and attributes of the header entity.

2. The method for generating a header according to claim 1, characterized in that: The relationships between the header entities include a right adjacency relationship, a bottom adjacency relationship, and a bottom-right adjacency relationship.

3. The method for generating a header according to claim 2, characterized in that: The types of entities include starting entities, middle entities and end-line entities; The shape of the entity is the shape of the area where the header entity content is located, including a rectangular entity domain and a gun-shaped entity domain. The rectangular entity domain includes a single-row and single-column rectangular entity domain, a single-row and multiple-column rectangular entity domain, a multiple-row and single-column rectangular entity domain, and a multiple-row and multiple-column rectangular entity domain. The gun-shaped entity domain includes a longitudinal support area gun-shaped entity domain and a transverse tube area gun-shaped entity domain. The longitudinal support area gun-shaped entity domain includes a multiple-row and single-column longitudinal support area gun-shaped entity domain and a multiple-row and multiple-column longitudinal support area gun-shaped entity domain. The transverse tube area gun-shaped entity domain includes a single-row and single-column transverse tube area gun-shaped entity domain and a single-row and multiple-column transverse tube area gun-shaped entity domain. The entity grid spacing is the number of cells covered by the header entity content coverage area, including right grid spacing, bottom grid spacing, lower right grid spacing and lower right grid spacing; The border of the entity is the border of the cell in the area covered by the header entity content, including the top border, bottom border, left border and right border. The border value is 0 or 1, 0 means no border line, and 1 means there is a border line; The entity merging method is the merging method of the cells in the area covered by the header entity content, including merging, merging to the right and merging to the bottom; the rectangular entity domain merging method is merging, that is, the cells covered by the header entity content are directly merged into one cell, and the gun-shaped entity domain merging method is merging to the right or merging to the bottom. When the display position of the header entity content is the gun-shaped entity domain in the horizontal tube area, the merging method is merging to the right, that is, first merging the first row of cells in the vertical support area of ​​the entity domain and the cells in the horizontal tube area, and then merging the remaining cells in the vertical support area; when the display position of the header entity content is the gun-shaped entity domain in the vertical support area, the merging method is merging to the bottom, that is, first merging the cells in the vertical support area of ​​the entity domain, and then merging the cells in the horizontal tube area of ​​the entity domain.

4. The method for generating a header according to claim 3, characterized in that: The method of using the constructed header knowledge graph to calculate the total number of rows and columns of the header and generate a two-dimensional array of the header includes: S510: Query the header entity whose entity type is the starting entity from the header knowledge graph , and extract the right grid distance of the starting entity , and initialize , let the starting entity be the current entity; where R is the total number of rows in the header, the starting row number is 1, C is the total number of columns in the header, the starting column number in the header is 1, there are i entities in the first row of the header, and j entities in the first column; S520, query the right adjacent entity of the current entity from the header knowledge graph. If it does not exist, terminate the query. If it does exist, set i=i+1 and query the right adjacent entity with a non-existent pointing relationship as the lower adjacent relationship from the header knowledge graph. And set it as the current entity, extract the right grid distance of the current entity ,set up ; S530, repeat S520 until the last right adjacent entity; S540, set the starting entity as the current entity, and extract the grid distance below the starting entity ,initialization ; S550. Obtain the next adjacent entity of the current entity from the header knowledge graph query. If it does not exist, terminate the query. If it does exist, set j=j+1 and obtain the next adjacent entity whose pointing relationship is the right adjacent relationship from the header knowledge graph query. And set it as the current entity, extract the grid distance under the current entity ,set up ; S560, repeat S550 until the last lower adjacent entity; S570: Generate a header array based on the calculated total number of rows R and total number of columns C of the header .

5. The method for generating a header according to claim 1, characterized in that: The S610 includes: S611, find the current entity Entities on the upward traceability chain: 1) Query the current entity from the header knowledge graph Entity , traverse , find the Get the entity with the lower-right adjacency, if any. The lower right grid ,make , stop traversal , set the current for , repeat 1), if it does not exist, execute 2); 2) Continue to search for Entities with lower adjacency, if any, get the lower grid distance of the entity with the largest lower grid distance ,make , stop traversal , set the current for , repeat 1), if it does not exist, terminate Calculation, let the current for ; S612, find the current entity Entities on the left-backward relationship chain: 1) Query the current entity from the header knowledge graph Entity , traverse , find the Get the entity with the lower-right adjacency, if any. The bottom right spacing ,make , stop traversal , let the current for , repeat 1), if it does not exist, execute 2); 2) Find and Entities with right adjacency, if any, get the right spacing of the entity with the largest right spacing ,make , stop traversal , set the current for , repeat 1), if it does not exist, terminate Calculation, let the current for .

6. The method for generating a header according to claim 5, characterized in that: The traversing of non-empty elements in the header array storing the content and attribute information of the header entity and generating the header based on the content, position and attributes of the header entity comprises: Read the non-empty elements in the header array, read their position information, locate the cell to be filled with entity content, read its content, and fill the located cell with the content of the header entity; Read the shape, grid spacing, merging mode attributes and position information of the current non-empty element, calculate the starting row number, ending row number, starting column number and ending column number of the cells covered by the entity domain, and merge the cells; Read the type, shape, spacing, border attributes, and position information of the current non-empty element, and set the border line of the entity domain covering the cell.

7. The method for generating a header according to claim 6, characterized in that: The step of reading the shape, grid spacing, merging mode attributes and position information of the current non-empty element, calculating the starting row number, ending row number, starting column number and ending column number of the cells covered by the entity domain, and merging the cells comprises: If the current element shape is a rectangular entity domain, the starting row number is , starting with column number , the ending line number is , the ending column number is ; If the shape attribute of the current element is a gun-shaped entity domain, and the merge mode attribute is right merge, for the entity domain horizontal pipe area, the starting row number is , the ending line number is , starting with column number , the ending column number is , for the entity domain vertical support area, the starting line number is , the ending line number is , starting with column number , the ending column number is ; If the shape attribute of the current element is gun-shaped, The attribute is merged downwards. For the entity domain vertical support area, the starting line number is , the ending line number is , starting with column number , the ending column number is , for the entity domain horizontal pipe area, the starting line number is , the ending line number is , starting with column number , the ending column number is ; Calculate the starting row number, ending row number, starting column number, and ending column number of the cells covered by the entity domain, and merge the cells.

8. The method for generating a header according to claim 7, characterized in that: The reading of the type, shape, grid spacing, border attributes and position information of the current non-empty element and setting the border line of the entity domain covering the cell includes: Read the type, shape, spacing, border attributes and position information of the current non-empty element; If the shape attribute of the current element is a rectangle, set the border line according to the values ​​of the top border, bottom border, left border, and right border in the border attribute; If the shape attribute of the current element is gun-shaped, divide the entity domain into three parts and set the border lines respectively. The starting line number of the first part is , the ending line number is , starting with column number , the ending column number is ,according to The value of sets the border lines of the top and left borders, and leaves the border lines of the right and bottom borders empty; the starting line number of the second part is , the ending line number is , starting with column number , the ending column number is , according to the values ​​of the upper border, lower border and right border, set the border lines of the upper border, lower border and right border, and the border line of the left border is empty; the starting line number of the third part is , the ending line number is , starting with column number , the ending column number is , according to the values ​​of left border, bottom border and right border, set the border lines of left border, bottom border and right border, and leave the border line of top border empty; If the current element type is the last row entity, read the column width attribute of the current element and set the cell width to the value of the column width attribute.

9. A system for generating a header, characterized in that: It includes entity definition module, relationship definition module, attribute definition module, header knowledge graph construction module, header array generation module, information storage module and header generation module; The entity definition module is used to define a table header entity, with each independently displayed content in the table header as the table header entity; The relationship definition module is used to define the relationship between the header entities, taking the adjacency relationship type between the header areas where the header entities are located as the relationship between the header entities; The attribute definition module is used to define the attributes of the header entity, and the attributes of the header entity include the type, shape, grid spacing, border and merging mode of the entity; The header knowledge graph construction module is used to construct a header knowledge graph based on the header entities, the relationships between the header entities, and the attributes of the header entities; The table header array generation module is used to calculate the total number of rows and columns of the table header by using the constructed table header knowledge graph to generate a table header array; The information storage module is used to traverse each header entity in the header entity knowledge graph, calculate the starting cell row number and column number of each header entity content coverage area, generate the content, position and attributes of the header entity in the form of key-value pairs in JSON format, and store them in the corresponding position of the header array; The header generation module is used to traverse the non-empty elements in the header array storing the content and attribute information of the header entity, and generate the header based on the content, position and attributes of the header entity; The method traverses each header entity in the header entity knowledge graph, calculates the starting cell row number and column number of the area covered by each header entity content, generates the content, position and attributes of the header entity in the form of key-value pairs in JSON format, and stores them in the corresponding position of the header array, including: S610, calculate the row number and column number of the entity's starting cell by backtracking the relationship of the header knowledge graph. If the entity type of the header entity is the starting entity, the entity's coordinates are [1,1]. The row number of other header entities is the sum of the bottom grid distance or the bottom right grid distance of the entity and the entity on the backtracking relationship chain plus one, and the column number is the sum of the right grid distance or the bottom right grid distance of the entity and the entity on the backtracking relationship chain plus one. Traverse the header entities , set the starting line number The initial value is 1, the starting column number The initial value is 1, set the current header entity For the current entity ; S620, get the current entity from the header knowledge graph The content, location and attributes of the current entity The position and header array The rules corresponding to the subscripts fill the header array with the JSON data of the content, location, and attributes of the header entity.

Citation Information

Patent Citations

  • Knowledge graph construction method and device, electronic equipment and storage medium

    CN111813963A

  • Double-header table generation method, device and system

    CN118468836A