Table column width adjustment method and device, equipment and storage medium
Patent Information
- Application Number
- CN202611304859.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-26
- Publication Date
- 2026-10-30
AI Technical Summary
[0004]基于此,本公开提供一种表格列宽调整方法、装置、设备及存储介质,以解决如何提高文档自动生成过程中表格列宽调整的适应性和排版稳定性的问题
[0010]在本公开上述实施例的表格列宽调整方法中,通过根据目标文档的文档场景标识和版式参数确定表格可用宽度及列宽边界,使列宽分配与目标文档的实际版面条件相适应;通过根据表头数据确定列语义类别,并利用源表格的业务主题对语义基础宽度参数进行修正,使各列形成与其业务含义及当前业务主题相匹配的宽度偏好;通过根据相应文档场景下的历史用户列宽调整记录更新统计特征权重,并利用目标统计特征权重对各列的多个内容统计特征进行加权,使内容修正参数能够反映当前内容分布,并随相应文档场景下的历史调整结果持续更新。
Smart Images

Figure CN123013884A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of office automation and document processing technology, specifically to a method, apparatus, device, and storage medium for adjusting table column width. Background Technology
[0002] In the automatic generation of reports, manuals, and other documents, it is often necessary to write structured data from spreadsheets or business systems into the target document and display it in tabular form. Because the source application and the target document have different layout settings, and the target document is also limited by factors such as page size, margins, and content display area, the column widths set on the source end are often difficult to directly apply to the target document. When the source table is imported into the target document, issues may arise such as some columns occupying excessive horizontal space, some columns frequently wrapping, tables exceeding the page limits, or uneven use of page space. Especially when the table content, number of columns, or the target document layout changes, the pre-set fixed column widths are prone to failure.
[0003] Solutions typically address these issues by preserving the original table format, setting uniform column widths, or automatically adjusting based on cell content. However, in different table types and batch document generation scenarios, the adjustments may still require repeated manual corrections, resulting in room for improvement in the adaptability of column width adjustments and layout stability. Summary of the Invention
[0004] Based on this, this disclosure provides a method, apparatus, device, and storage medium for adjusting table column widths to solve the problem of how to improve the adaptability and layout stability of table column width adjustment during automatic document generation.
[0005] Firstly, this disclosure provides a method for adjusting the column width of a table, the method comprising: Obtain the header data and content data of each column of the source table, as well as the document scene identifier and layout parameters of the target document. Determine the available width of the table based on the layout parameters, and determine the column width boundaries based on the document scene identifier and the layout parameters. The semantic category of each column is determined based on the header data. The business theme of the source table is determined based on the header data and the content data of each column. The semantic base width parameter corresponding to the semantic category of each column is corrected based on the business theme to obtain the theme correction width parameter of each column. And multiple content statistical features are determined based on the content data of each column. Obtain the target statistical feature weights corresponding to the document scene identifier from the parameter library, wherein each set of statistical feature weights in the parameter library is updated according to the historical user column width adjustment records under the corresponding document scene; weight multiple content statistical features of each column according to the target statistical feature weights to obtain the content correction parameters of each column, and use the content correction parameters of each column to correct the corresponding topic correction width parameters to obtain the width requirement weight of each column. Based on the proportion of each column's width requirement weight in the total width requirement weight of all columns, the initial column width of each column is allocated within the available width of the table; columns whose initial column width exceeds the corresponding column width boundary are fixed to the column width boundary and removed from the set of columns to be allocated; the remaining available width is re-allocated proportionally according to the width requirement weight of the remaining columns until the column width of each column meets the corresponding column width boundary; and a table is generated in the target document according to the column width of each column.
[0006] Secondly, this disclosure also provides a table column width adjustment device, the device comprising: The data acquisition module is used to acquire the header data and content data of each column of the source table, as well as the document scene identifier and layout parameters of the target document, determine the available width of the table based on the layout parameters, and determine the column width boundaries based on the document scene identifier and the layout parameters. The feature analysis module is used to determine the semantic category of each column based on the header data, determine the business theme of the source table based on the header data and the content data of each column, correct the semantic base width parameter corresponding to the semantic category of each column based on the business theme to obtain the theme correction width parameter of each column, and determine the corresponding multiple content statistical features based on the content data of each column. The weight determination module is used to obtain the target statistical feature weights corresponding to the document scene identifier from the parameter library. The statistical feature weights in the parameter library are updated according to the historical user column width adjustment records under the corresponding document scene. The module weights multiple content statistical features of each column are weighted according to the target statistical feature weights to obtain the content correction parameters of each column. The content correction parameters of each column are then used to correct the corresponding topic correction width parameters to obtain the width requirement weight of each column. The column width allocation module is used to allocate the initial column width of each column within the available width of the table according to the proportion of the width requirement weight of each column in the total width requirement weight of all columns; fix the columns whose initial column width exceeds the corresponding column width boundary to the column width boundary and remove them from the set of columns to be allocated; reallocate the remaining available width proportionally according to the width requirement weight of the remaining columns until the column width of each column meets the corresponding column width boundary; and generate a table in the target document according to the column width of each column.
[0007] Thirdly, this disclosure also provides an electronic device, including: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of any of the above-described table column width adjustment methods.
[0008] Fourthly, this disclosure also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of any of the above-described table column width adjustment methods.
[0009] Fifthly, this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described table column width adjustment methods.
[0010] In the table column width adjustment method of the above embodiments of this disclosure, the available width of the table and column width boundaries are determined according to the document scene identifier and layout parameters of the target document, so that the column width allocation is adapted to the actual layout conditions of the target document; the semantic category of the column is determined according to the header data, and the semantic basic width parameters are modified using the business theme of the source table, so that each column forms a width preference that matches its business meaning and the current business theme; the statistical feature weights are updated according to the historical user column width adjustment records in the corresponding document scene, and the multiple content statistical features of each column are weighted using the target statistical feature weights, so that the content correction parameters can reflect the current content distribution and are continuously updated with the historical adjustment results in the corresponding document scene.
[0011] Furthermore, by combining the theme width correction parameter and the content correction parameter to form the width requirement weight, and performing proportional allocation and iterative redistribution under column width boundary constraints within the available width of the table, the width of each column is coordinated and matched with the available layout of the target document while meeting the corresponding column width boundaries.
[0012] This allows table column width decisions to take into account document context, business theme, current content distribution, and historical adjustment preferences, improving the adaptability and layout stability of table column width adjustments during automatic document generation. Attached Figure Description
[0013] To more clearly illustrate the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 A flowchart illustrating a table column width adjustment method provided in this embodiment of the disclosure; Figure 2A flowchart illustrating another table column width adjustment method provided in this embodiment of the disclosure; Figure 3 A schematic diagram of a table column width adjustment device provided in an embodiment of this disclosure; Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0015] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this disclosure.
[0016] It should be noted that, in the description of this disclosure, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this disclosure are used to distinguish similar objects and are not used to describe a particular order or sequence.
[0017] To enable those skilled in the art to better understand the present disclosure, the present disclosure will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0018] In one embodiment, please refer to Figure 1 , Figure 1 This is a flowchart illustrating a method for adjusting column width in a table, as provided in an embodiment of the present disclosure. The method may include the following steps: Step S101: Obtain the header data and content data of each column of the source table, as well as the document scene identifier and layout parameters of the target document. Determine the available width of the table based on the layout parameters, and determine the column width boundaries based on the document scene identifier and layout parameters.
[0019] Specifically, the source table is a structured table that needs to be part of the target document; the header data in the source table is used to characterize the meaning of the fields in each column, and the content data of each column in the source table includes the cell content in the corresponding column.
[0020] The target document is the document to be generated and used to carry the content of the source table. The document context identifier of the target document is used to characterize the document context of the target document, which includes at least one of the following: the overall type of the target document, its purpose, and its target audience. The layout parameters of the target document are used to characterize the layout conditions for arranging tables in the target document and serve as the basis for determining the available width of the table and the column width boundaries.
[0021] Determine the available table width in the target document for setting tables based on the target document's layout parameters.
[0022] Based on the document scenario identifier of the target document, the column width constraints under the corresponding document scenario are determined. Combined with the layout parameters of the target document, the column width boundaries that each column needs to meet in the current target document are determined. Among them, the column width boundaries of each column include the minimum column width and the maximum column width.
[0023] After determining the column width boundaries of each column, a feasibility check is performed on the column width boundaries of each column based on the available width of the table.
[0024] Specifically, when the sum of the minimum column widths of all columns is not greater than the available width of the table, and the sum of the maximum column widths of all columns is not less than the available width of the table, the column width boundaries of each column are determined to meet the feasibility conditions.
[0025] When the column width boundaries of each column do not meet the feasibility conditions, adjust the minimum or maximum column width of at least one column according to the document scene identifier and layout parameters of the current target document until the adjusted column width range can cover the available width of the table, and use the adjusted column width boundaries for subsequent column width allocation.
[0026] Therefore, before performing the reallocation under the column width boundary constraints, the allocable width range of each column is matched with the available width of the table to avoid the remaining available width being unable to be allocated because the sum of the minimum column widths of each column exceeds the available width of the table, or the sum of the maximum column widths of each column is less than the available width of the table.
[0027] Furthermore, the document scene identifier and layout parameters together constitute the document context conditions for this column width decision.
[0028] The document scene identifier is used to select column width constraints and parameter configurations that are appropriate for the current document scene, and the layout parameters are used to determine the available width of the table and convert the corresponding column width constraints into column width boundaries in the current layout.
[0029] Document context conditions are used to limit the global applicability of this column width decision, and are not directly used as the weight of the width requirement for each column.
[0030] Step S102: Determine the column semantic category of each column based on the header data, determine the business theme of the source table based on the header data and the content data of each column, correct the semantic base width parameter corresponding to the semantic category of each column based on the business theme to obtain the theme correction width parameter of each column, and determine the corresponding multiple content statistical features based on the content data of each column.
[0031] Specifically, the column semantic category is used to characterize the business meaning of the corresponding column in the source table. Different column semantic categories correspond to corresponding semantic base width parameters, thereby forming an initial width preference based on the business meaning of each column.
[0032] The business subject of the source table is used to characterize the business matters that are jointly involved in the header data and content data of the source table.
[0033] The semantic base width parameter of the corresponding column is modified according to the business theme of the current source table, so that the semantic category of the same column can form the corresponding theme-modified width parameter according to the current business theme.
[0034] Multiple content statistical features for each column are used to characterize the display requirements of the current content in the corresponding column within the target layout environment. These features are determined based on the content data of each column, enabling subsequent column width decisions to adjust width preferences based on column semantic categories and business themes using the statistical results of the current content.
[0035] Step S103: Obtain the target statistical feature weights corresponding to the document scene identifier from the parameter library. The statistical feature weights of each group in the parameter library are updated according to the historical user column width adjustment records under the corresponding document scene. The multiple content statistical features of each column are weighted according to the target statistical feature weights to obtain the content correction parameters of each column. The content correction parameters of each column are used to correct the corresponding topic correction width parameters to obtain the width requirement weight of each column.
[0036] Specifically, the parameter library stores the statistical feature weights corresponding to different document scenarios according to the document scenario identifier.
[0037] A set of statistical feature weights corresponding to the document scene identifier of the current target document is determined as the target statistical feature weights, so that the degree of influence of different content statistical features in the current document scene can be represented by the corresponding target statistical feature weights.
[0038] The weights of each group of statistical features in the parameter library are updated according to the historical user column width adjustment records in the corresponding document scenarios.
[0039] In this embodiment, the historical user column width adjustment records are used to update the statistical feature weights for subsequent scenarios of the same document, and are not directly used as the current column width requirement weights.
[0040] The content statistical features of the corresponding column are weighted according to the target statistical feature weights to obtain the content correction parameters of the column; the content correction parameters of each column are used to correct the corresponding theme correction width parameters to obtain the width requirement weight of each column, so as to characterize the width requirement intensity of each column relative to other columns in the same source table.
[0041] Step S104: Based on the proportion of the width requirement weight of each column in the total width requirement weight of all columns, allocate the initial column width of each column within the available width of the table; fix the columns whose initial column width exceeds the corresponding column width boundary to the column width boundary and remove them from the set of columns to be allocated; reallocate the remaining available width proportionally according to the width requirement weight of the remaining columns until the column width of each column meets the corresponding column width boundary; and generate a table in the target document according to the column width of each column.
[0042] Specifically, based on the proportional relationship between the width requirement weight of each column and the width requirement weight of all columns, the available width of the table is allocated to the corresponding columns to obtain the initial column width of each column.
[0043] The initial column width of each column is determined by boundary judgment, and columns whose initial column width exceeds the corresponding column width boundary are fixed to the corresponding column width boundary; columns with fixed column widths are removed from the set of columns to be allocated, and the remaining available width is determined based on the available width of the table and the fixed column widths.
[0044] The remaining available width is re-allocated proportionally based on the width requirement weight of each remaining column in the set of columns to be allocated.
[0045] Furthermore, after the reallocation, the column widths of each column in the set of columns to be allocated are further checked for boundaries. Columns that have newly reached the corresponding column width boundary are fixed to that boundary and removed from the set of columns to be allocated. Then, the next round of proportional allocation is performed based on the updated remaining available width and the width requirement weights of the remaining columns.
[0046] When there are no columns in the set of columns to be allocated whose widths exceed the corresponding column width boundaries, or when the set of columns to be allocated is empty, the reallocation is terminated, and the final column widths of each column are obtained. Since the column width boundaries of each column have passed the feasibility check, the final determined column widths can satisfy the corresponding column width boundaries respectively, and the sum of the column widths matches the available width of the table.
[0047] Generate a table in the target document according to the final determined column widths, so that the header data and content data of each column in the source table are set in the target document according to the corresponding column widths.
[0048] In the table column width adjustment method of the above embodiments of this disclosure, the available width of the table and column width boundaries are determined according to the document scene identifier and layout parameters of the target document, so that the column width allocation is adapted to the actual layout conditions of the target document; the semantic category of the column is determined according to the header data, and the semantic basic width parameters are modified using the business theme of the source table, so that each column forms a width preference that matches its business meaning and the current business theme; the statistical feature weights are updated according to the historical user column width adjustment records in the corresponding document scene, and the multiple content statistical features of each column are weighted using the target statistical feature weights, so that the content correction parameters can reflect the current content distribution and are continuously updated with the historical adjustment results in the corresponding document scene.
[0049] Furthermore, by combining the theme-based width adjustment parameter and the content-based width adjustment parameter to form a width requirement weight, and then proportionally allocating and iteratively redistributing the width within the available table width under column width boundary constraints, the width of each column is coordinated and matched with the available layout of the target document while meeting the corresponding column width boundaries. This allows table column width decisions to take into account document context, business theme, current content distribution, and historical adjustment preferences, improving the adaptability and layout stability of table column width adjustments during automatic document generation.
[0050] In one possible implementation of step S102 above, determining the column semantic category of each column based on the header data includes the following steps: Step S1021: Match the header data of each column with the semantic rule base to obtain the rule classification results and rule classification confidence of each column.
[0051] Specifically, the semantic rule base records the header matching rules corresponding to the semantic categories of different columns. The header data of each column in the source table is matched with the corresponding header matching rules. The rule classification result of each column is determined based on the matching results, and the rule classification confidence is determined based on the confidence information corresponding to the matching rules.
[0052] Step S1022: When the rule classification confidence is not lower than the confidence threshold, the rule classification result is determined as the column semantic category of the corresponding column, and the rule classification confidence is determined as the semantic classification confidence of the corresponding column.
[0053] Specifically, when the rule classification confidence of a column is not lower than the confidence threshold, it indicates that the corresponding rule classification result meets the confidence condition for directly determining the semantic category of the column. Therefore, the rule classification result and the rule classification confidence are respectively determined as the column semantic category and semantic classification confidence of the corresponding column.
[0054] Step S1023: When the rule classification confidence is lower than the confidence threshold, semantic classification input data is generated based on the header data and content data of the corresponding column. The semantic classification input data is processed by the semantic recognition model to obtain the model classification result and the model classification confidence. The header data and content data of the corresponding column are vector-encoded to obtain the target semantic vector. The target semantic vector is matched with the typical header vector in the semantic vector index library to obtain the vector classification result and the vector classification confidence. Based on the rule classification result, the model classification result, the vector classification result, and the corresponding classification confidence, the column semantic category and semantic classification confidence of the column are determined.
[0055] Specifically, when the confidence level of a rule classification in a column is lower than the confidence threshold, the header data and content data of that column are used to supplement the semantic information that the header matching results cannot fully represent.
[0056] The corresponding classification results and classification confidence scores are obtained by semantic recognition model and semantic vector matching, respectively. The column semantic category and semantic classification confidence score are determined by combining the rule classification results.
[0057] The semantic base width parameter can be determined based on the preset neutral width parameter, the category base width parameter corresponding to the semantic category of the corresponding column, and the semantic classification confidence.
[0058] Specifically, the confidence correction amount is determined based on the difference between the category base width parameter and the preset neutral width parameter and the semantic classification confidence. Then, the semantic base width parameter is determined based on the preset neutral width parameter and the confidence correction amount, so that the semantic base width parameter approaches the preset neutral width parameter when the semantic classification confidence decreases.
[0059] In one specific implementation of the semantic category determination process described above, each rule in the semantic rule base may include exact matching keywords, regular expression matching patterns, semantic categories, basic width parameters, exclusion matching patterns, fallback categories, and rule confidence.
[0060] Perform exact keyword matching on the header text of each column; if no exact match is obtained, then perform regular expression matching.
[0061] For table headers whose meaning may change with the column content, a sample of the content of the corresponding column can be selected to verify the initial rule classification results.
[0062] When the confidence level of a rule classification is lower than the confidence threshold, the header text of the column to be classified and the contents of the first five non-empty cells of that column can be concatenated into structured input data.
[0063] For example, structured input data may include candidate semantic categories, header text, and content samples.
[0064] The semantic recognition model can be a lightweight large language model or a text classification model trained using header classification samples; the structured input data is input into the semantic recognition model to obtain the model classification results and the corresponding model classification confidence.
[0065] The following formula can be used to fuse rule-based classification confidence with large language model classification confidence:
[0066] in, For the first Column rule classification confidence, For the first The classification confidence of the large language model in the column. The weights are configurable. In one implementation, The default value is 0.6.
[0067] The semantic vector index pre-stores typical header vectors for each semantic category in the semantic rule base. The header and content data of the column to be classified are vector-encoded, and similar typical headers are retrieved from the semantic vector index. Based on similarity scores, a weighted vote is performed on each candidate semantic category to obtain the vector classification result and vector classification confidence.
[0068] When rule classification, model classification, and vector classification all fail to produce a classification result that meets the requirements, the corresponding column can be assigned to the fallback category recorded in the semantic rule base.
[0069] In one column semantic category configuration, column semantic categories include identifiers, short text, numeric or monetary values, long text, and dates.
[0070] Specifically, the basic width parameter for the identifier class is 0.7, the basic width parameter for the short text class is 1.0, the basic width parameter for the numerical or monetary class is 1.0 or 1.1, the basic width parameter for the long text class is 1.8, and the basic width parameter for the date class is 1.0.
[0071] In one implementation, the confidence threshold is 0.6.
[0072] When the rule classification result meets the confidence condition, the subsequent semantic recognition model and semantic vector matching process will no longer be called, thereby reducing the amount of subsequent processing when the semantic category of the column can be determined by rule classification.
[0073] In the table column width adjustment method of the above embodiments of this disclosure, based on determining the semantic category of the column according to the header data and forming the semantic base width parameter, the rule classification confidence is used to distinguish between columns whose semantic category can be directly determined by the semantic rule base and columns that need further identification. For columns whose rule classification confidence is not lower than the confidence threshold, the rule classification result is directly adopted to reduce unnecessary model recognition and semantic vector matching processing; for columns with low rule classification confidence, the semantic category of the column is determined by combining the header data and content data of the corresponding column, using the semantic recognition model and semantic vector matching, and the semantic base width parameter is adjusted between the category base width parameter and the preset neutral width parameter according to the semantic classification confidence.
[0074] In summary, even when the meaning of the table header is ambiguous, the header is not included in the semantic rule base, or the header text is the same but the column content is different, a semantic base width parameter that matches the actual business meaning of the corresponding column can still be formed. Furthermore, when the semantic classification result is uncertain, the impact of that classification result on the weight of subsequent width requirements can be reduced, avoiding unreasonable enlargement or compression of corresponding columns due to misjudgment of the header semantics. Performing subsequent content correction and page width allocation based on this semantic base width parameter can further improve the adaptability and layout stability of width adjustments under complex header conditions.
[0075] In another possible implementation of step S102 above, the semantic base width parameter corresponding to the semantic category of each column is modified according to the business topic to obtain the topic-modified width parameter of each column, including: Step S1024: Obtain the topic offset parameter corresponding to the business topic and the column semantic category of each column.
[0076] Specifically, the business theme of the source table is determined based on all the header data in the source table and the content samples selected from the content data of each column. Then, based on the business theme and the column semantic category of each column, the corresponding theme offset parameters are obtained from the theme parameter library.
[0077] The topic parameter library stores topic offset parameters according to the correspondence between business topics and column semantic categories, so that the same column semantic category can correspond to the corresponding width preference under different business topics.
[0078] Step S1025: Adjust the corresponding semantic base width parameters according to the topic offset parameters to obtain the topic correction width parameters for each column.
[0079] Specifically, the topic offset parameter is applied to the semantic base width parameter of the corresponding column, so that the semantic base width parameter is adjusted accordingly based on the current business topic.
[0080] The topic offset parameter is used to correct the width preference formed by the semantic category of the current column, and does not assume the function of page constraints or user feedback updates.
[0081] In one scenario of processing amount columns, the amount column under the finance theme needs to reserve the appropriate width for decimal alignment or amount format, while the amount column under the project management theme is used to display budget figures. The two business themes correspond to the corresponding theme offset parameters.
[0082] In a date column processing scenario, the date column under the progress management topic includes start and end dates, while the date column under the log topic includes date stamps. The two business topics correspond to the respective topic offset parameters.
[0083] In the table column width adjustment method of the above embodiments of this disclosure, firstly, based on the semantic basic width parameter formed according to the column semantic category, the business theme is further determined according to the header data and content data of the source table, and the theme offset parameter is obtained according to the correspondence between the business theme and the column semantic category, so as to correct the semantic basic width parameter of the corresponding column.
[0084] Secondly, the same header or column semantic category can form different theme-corrected width parameters under different business themes. This allows the width preference adopted for subsequent content correction and page width allocation to reflect both the business meaning of the column itself and the business theme of the current table. This avoids adopting a fixed width preference based solely on the semantics of the header while ignoring the differences in display requirements under different business themes. This further improves the accuracy of column width adaptation for the same type of columns in different business reports and the coordination between the table layout and the current business content.
[0085] In another possible implementation of step S102 above, several content statistical features are determined based on the content data of each column, including: Step S1026: Based on the character length of the content data in each column, determine the average content length and target quantile length of each column, and normalize the average content length of each column relative to the maximum value among the average content lengths of all columns to obtain the normalized average length of each column.
[0086] Specifically, statistics Calculate the character length of the content in each non-empty cell of the column, and determine the average content length of the column based on the length of each character. and 90th percentile length .
[0087] The 90th percentile length is used to reflect the character length of most of the longer content in the column, in order to reduce the impact of a single longest content on the content statistics.
[0088] Let the maximum value among the average lengths of all columns be... Then the first The normalized average length of a column is determined according to the following formula:
[0089] Before participating in the above statistics, if there are more than If the abnormally long value is ten times larger, then the abnormally long value will be truncated to [the specified value]. The length of the content is increased by ten times before being included in the calculation to reduce the impact of abnormally long content on the content statistics results.
[0090] Step S1027: Determine the absolute length statistical characteristics of each column based on the ratio between the target quantile length and the average content length of each column, as well as the normalized average length.
[0091] Specifically, no. Column content length statistics parameters Determine according to the following formula:
[0092] in, For the first The 90th percentile of the column content length, For the first Average length of column content For the first The normalized average length of the column. When When it is 0, Set to 1.0.
[0093] and The ratio between them is used to reflect the degree of deviation of longer content from the average content; Used to reflect the overall absolute length level of the corresponding column relative to other columns in the same source table.
[0094] Therefore, it is possible to distinguish between columns whose content consists of shorter strings and columns whose content consists of longer strings.
[0095] In one implementation method for determining row height requirements based on existing line breaks in cells, the row height characteristic is obtained by adding 1 to the average number of line breaks in each cell of the corresponding column. The content length coefficient is determined according to the following formula:
[0096] in, and Weights are assigned to the statistical features of the corresponding content. In one implementation, It is 0.7. It is 0.3.
[0097] Step S1028: Determine the number of content rendering rows and the natural boundary line break ratio for each column under the candidate column width, and determine the row height complexity statistical characteristics of each column based on the number of content rendering rows and the natural boundary line break ratio.
[0098] Specifically, the number of content rendering rows is used to characterize the actual number of rows formed by the content sample of the corresponding column after simulated typesetting under the candidate column width.
[0099] The natural boundary line break ratio is used to represent the proportion of line breaks located at Chinese punctuation marks, English spaces, or other natural text boundaries out of the total number of line breaks.
[0100] The more rows of content rendered, the larger the vertical occupancy of the corresponding column within the current candidate column width; the lower the proportion of natural boundary line breaks, the higher the degree of non-natural boundary line breaks in the content of the corresponding column.
[0101] In the table column width adjustment method of the above embodiments of this disclosure, based on determining the content statistical characteristics according to the content data of each column, the ratio between the target quantile length and the average content length is used to characterize the distribution of longer content relative to the average content, the normalized average length is used to characterize the overall absolute length of the corresponding column relative to other columns in the same source table, and the number of content rendering rows and the natural boundary line wrapping ratio are used to characterize the actual line wrapping requirements of the corresponding column under the candidate column width.
[0102] Therefore, the content correction parameter can simultaneously distinguish between columns with generally short and long content, as well as columns with evenly distributed content and columns containing a small number of long pieces of content. This avoids the inability to reflect the absolute length of content by relying solely on the ratio between the target quantile length and the average length, and also reduces the degree to which a single abnormally long piece of content directly determines the column width. Using this content correction parameter to adjust the theme width parameter ensures that subsequent proportional allocation simultaneously reflects the absolute length of the content, its length distribution, and actual line breaks, further reducing width distribution imbalances caused by short content columns occupying too much page width or long content columns generating excessive line breaks.
[0103] In one possible implementation of step S1028 above, determining the number of content rendering rows and the natural margin wrapping ratio for each column under the candidate column width includes: Step A1: Determine the candidate column width for each column based on the semantic base width parameter corresponding to the column semantic category of each column.
[0104] Specifically, before the initial virtual rendering, an initial empirical width is assigned to the corresponding column based on its semantic category, and this initial empirical width is used as a candidate column width. The candidate column width is used for the initial simulated layout of the content sample of the corresponding column, and is not the final column width determined based on the virtual rendering results.
[0105] Step A2: Select content samples from the content data of each column, and simulate the layout of the content samples according to the candidate column widths of the corresponding columns.
[0106] Specifically, based on the candidate column widths and the font and font size of the target document, the content samples selected from the content data of each column are simulated for typesetting to obtain the typesetting results of each content sample under the corresponding candidate column widths.
[0107] Step A3: Calculate the number of lines rendered in the simulated layout of the content sample, and the percentage of line breaks at natural text boundaries in the total number of line breaks, to obtain the natural boundary line break ratio.
[0108] Specifically, the number of lines to be rendered is determined based on the number of lines formed after the content sample is simulated and the natural boundary line break ratio is determined based on the line break positions formed by the simulated layout.
[0109] The row height complexity statistics of the corresponding column are determined based on the number of lines rendered and the proportion of natural boundary line breaks.
[0110] In one virtual rendering implementation, the initial empirical width of short text is 50 pixels, and the initial empirical width of long text is 200 pixels. The first N rows of content from each column can be selected as content samples, with N defaulting to 20.
[0111] A headless browser can be launched in memory, or the object model of a word processing software can be invoked to simulate the layout of content samples according to the candidate column widths and the font and font size of the target document.
[0112] Let the first The number of rows rendered for the column content is The natural line break ratio is The penalty factor is The row complexity parameter obtained based on virtual rendering is determined according to the following formula:
[0113] In one implementation, The default value is 0.2. The lower the natural line break ratio, the better. The larger the value, the larger the corresponding row complexity parameter, thus increasing the width requirement of that column in subsequent width decisions.
[0114] When using virtual rendering, one can utilize Replacement based on the number of existing newline characters The content length coefficient is determined according to the following formula:
[0115] Based on the initial virtual rendering and Sure Then, update the content correction parameters and width requirement weight of the corresponding column, and then determine the column width of the corresponding column based on the updated width requirement weight.
[0116] In normal layout mode, the virtual rendering process ends after the column widths of the corresponding columns are determined. In extreme layout mode, a second round of fine-tuning rendering can be performed according to the already determined column widths, ensuring that the number of virtual rendering iterations does not exceed two.
[0117] In the table column width adjustment method of the above embodiments of this disclosure, based on the statistical characteristics of row height complexity to correct the column width requirement, candidate column widths are further determined according to the semantic basic width parameters corresponding to the column semantic category, and the content samples selected from the corresponding columns are simulated and typed according to the candidate column widths to obtain the number of content rendering rows and the natural boundary line wrapping ratio.
[0118] Therefore, before the final column width is determined, the actual number of line breaks and line break positions of the column content in the target typesetting environment can be evaluated according to the corresponding candidate column widths. This ensures that the row height complexity statistical characteristics are no longer determined solely by the number of characters or the original line breaks. Simultaneously, by selecting content samples to control the amount of data processed in the simulated typesetting, the virtual rendering results can participate in subsequent column width decisions while keeping the processing volume under control. Using these row height complexity statistical characteristics to form content correction parameters allows column width allocation to better match the actual display requirements of the target typesetting engine, further reducing unnatural line breaks and unreasonable increases in table row height, and improving the processing efficiency, typesetting adaptability, and stability of column width adjustments during automatic document generation.
[0119] In one possible implementation of the above embodiments, such as Figure 2 As shown, before obtaining the target statistical feature weights corresponding to the document scene identifier from the parameter library in step S103 above, the method further includes: Step S201: Obtain the column width before adjustment, column width after adjustment, and document scenario identifier corresponding to the user column width adjustment operation performed on the historically generated table.
[0120] Specifically, the user column width adjustment operation is the operation performed by the user on the corresponding column width after reviewing or viewing historically generated tables.
[0121] Get the column width before and after the user's column width adjustment operation, and get the document scene identifier of the target document to which the corresponding historically generated table belongs.
[0122] Step S202: Construct preference training samples based on the direction and amount of change of the adjusted column width relative to the original column width, and associate the preference training samples with the corresponding document scenario identifier to obtain historical user column width adjustment records.
[0123] Specifically, the direction of column width change is determined based on the size relationship between the adjusted column width and the original column width, and the amount of column width change is determined based on the difference between the adjusted column width and the original column width.
[0124] Preference training samples are constructed based on the direction and amount of change, and the document scene to which the preference training samples belong is marked using document scene identifiers.
[0125] Step S203: Group the preference training samples according to the document scene identifier, and update the statistical feature weights associated with the corresponding document scene identifier in the parameter library according to each group of preference training samples.
[0126] Specifically, preference training samples with the same document scenario identifier are grouped into the same group, and the statistical feature weights of the corresponding document scenarios are updated using the preference training samples of each group, so that the statistical feature weights corresponding to different document scenarios can be updated according to the historical user column width adjustment results of the corresponding scenarios.
[0127] In one implementation of user action logging, robotic process automation programs or document editing plugins can record column width adjustment operations performed by users after reviewing or viewing historically generated tables. These user column width adjustment operations include manually dragging column boundaries or confirming the retention of the current column width.
[0128] Record the column width before adjustment for each operation. And adjusted column width The adjustment range is determined according to the following formula:
[0129] When the adjusted column width is greater than the original column width, the adjustment direction is set to widen; when the adjusted column width is less than the original column width, the adjustment direction is set to narrow; when the user confirms to retain the current column width, the current column width is recorded as the retention preference.
[0130] Preference training samples may include document scene identifiers, content statistics of corresponding columns, column width before adjustment, column width after adjustment, adjustment direction, and adjustment range.
[0131] Using "retain current width" and "adjust to new width" as binary preference signals, we can also distinguish between widening and narrowing preferences for the corresponding columns based on the direction of adjustment.
[0132] In one statistical feature weight update method, preference training samples with the same document scene identifier are grouped into the same group; the Bradley-Terry preference model is used, with the user's choice to keep the current width or adjust to the new width as the preference signal, and a lightweight regression model is trained.
[0133] Update the corresponding statistical feature weights based on historical adjustment results within the same document context. Statistical feature weights may include the weights corresponding to content length statistical features. And the weights corresponding to the high-complexity statistical features of rows. or .
[0134] Parameter updates can be performed after receiving user feedback, or after accumulating a preset number of valid feedback responses within the same document context.
[0135] In one implementation, incremental training is triggered every 50 accumulated adjustments.
[0136] Furthermore, parameter groups can be maintained separately for weekly reports, financial statements, or other document types, so that the statistical feature weights under different document scenarios can be updated separately.
[0137] User feedback affects the update process of statistical feature weights in the corresponding document scenario, but is not used as the current column width weight item alongside the business theme.
[0138] By grouping the preference training samples according to the document scenario identifier and updating the statistical feature weights separately, the content statistical feature weights under different document scenarios can be updated independently based on the historical column width adjustment results in the corresponding scenario, reducing the mutual interference of parameters between different document scenarios.
[0139] In one implementation of parameter evaluation, the table layout quality evaluation function Q can be used to evaluate candidate parameters or updated parameters.
[0140] The evaluation function can be represented by the following formula:
[0141] in, Readability scores can be determined based on the column width variation coefficient; The compactness score can be determined by the ratio of the total number of characters to the total area of the table; The number of times the content is truncated or produces unnatural line breaks; The aspect ratio of each column should be within a comfortable range; , , and The weights are the corresponding values for each evaluation indicator.
[0142] The evaluation function Q is used to select or verify the statistical feature weights in the corresponding document scenario, without changing the aforementioned table column width decision process.
[0143] In the table column width adjustment method of the above embodiments of this disclosure, based on updating the statistical feature weights according to the historical user column width adjustment records under the corresponding document scenario, the column width before adjustment, the column width after adjustment, and the document scenario identifier corresponding to the user column width adjustment operation are further obtained. Preference training samples are constructed according to the direction and amount of column width change, and the preference training samples are grouped according to the document scenario identifier to update the statistical feature weights corresponding to the corresponding document scenario respectively.
[0144] Therefore, user actions to widen or narrow historically generated tables can be used to update the impact of various content statistical features on the corresponding document scenario. This allows subsequent content correction parameters in the same document scenario to gradually reflect the column width adjustment preferences already established for that scenario. Simultaneously, by updating the statistical feature weights separately according to document scenario, interference between target documents of different types or purposes can be avoided. Consequently, this reduces the likelihood of repeatedly adjusting the same column width after generating similar target documents, further improving the adaptability of column width decisions to actual user results and the consistency of layout results for similar documents.
[0145] In one possible implementation of step S1025 above, the corresponding semantic base width parameter is adjusted according to the topic offset parameter to obtain the topic correction width parameter for each column, including: Step B1: Determine the target historical case from the historical column-wide case library based on the document scenario identifier, business theme, and column semantic category of each column.
[0146] Specifically, the historical column width case library is used to store the column width configuration of historical tables, as well as the document scenario identifier, business theme, and column semantic category associated with the corresponding historical tables.
[0147] Based on the document scenario identifier of the current target document, the business theme of the current source table, and the column semantic category of each column, determine the target historical cases that match the current column width decision from the historical column width case library.
[0148] Step B2: Based on the historical column width configuration corresponding to the column semantic category in the target historical case, the corresponding semantic base width parameters are modified to obtain the empirical initial width parameters for each column.
[0149] Specifically, based on the historical column width configuration corresponding to the semantic category of the target historical case, the semantic base width parameters of each current column are modified so that the historical column width configuration provides an empirical starting point for the column width decision of the corresponding column in the current source table.
[0150] Step B3: Adjust the corresponding empirical initial width parameters according to the topic offset parameters of each column to obtain the topic correction width parameters of each column.
[0151] Specifically, after obtaining the empirical initial width parameters of each column based on the target historical cases, the corresponding topic offset parameters are obtained based on the business theme of the current source table and the column semantic category of each column, and the empirical initial width parameters are adjusted using the topic offset parameters.
[0152] In one implementation of a historical column width case library, the library stores table column width configurations that have been rated by users as aesthetically pleasing, acceptable, or already published. Each historical column width case is associated with a corresponding document scenario identifier, business theme, column semantic category, and historical column width configuration.
[0153] The historical column width configuration in the target historical case reflects the column width relationships that have been accepted by users under similar document scenarios and business themes.
[0154] The empirical initial width parameter is used to provide a starting point for the current column width decision, and does not directly replace the statistical analysis of the content of the current source table.
[0155] The historical column width case library and the aforementioned parameter library serve different functions. The historical column width case library stores complete column width configurations that have been confirmed or published, providing an empirical starting point for current column width decisions; the parameter library stores statistical feature weights maintained according to document scenario identifiers, used to determine the degree of influence of each content statistical feature on content correction parameters.
[0156] In the table column width adjustment method of the above embodiments of this disclosure, based on the correction of the semantic basic width parameter using the business theme, the target historical case is further determined from the historical column width case library according to the document scenario identifier, business theme and column semantic category, and the historical column width configuration in the target historical case is used to form the empirical initial width parameter of each column; then, the empirical initial width parameter is corrected using the theme offset parameter corresponding to the current business theme.
[0157] In summary, by using existing column width configurations within similar document scenarios and business themes as a starting point for current column width decisions, we can reduce initial deviations caused by re-allocating from preset category base width parameters every time similar tables are generated. Simultaneously, by continuously refining the initial empirical width parameters based on the current business theme and current content statistics, we can avoid directly copying historical column width configurations that are unsuitable for the current table. Therefore, we can balance the reuse of historical experience with the dynamic changes in current table content, further improving the consistency of table layout and the adaptability of column widths to current content when continuously generating similar target documents.
[0158] In an implementation that does not pre-adjust the base width parameter based on semantic classification confidence, the width requirement weights for each column can be determined using the following formula:
[0159] in, The base width parameter has not yet been adjusted based on semantic classification confidence. For the first Semantic classification confidence of the column For the first Statistical characteristics of the absolute length of a column This is a statistical feature of row complexity obtained based on virtual rendering. and The statistical feature weights corresponding to the statistical features of the content.
[0160] When the semantic classification confidence is 1, the correction result corresponding to the semantic classification confidence in the formula remains the base width parameter; when the semantic classification confidence is 0, the correction result converges to the neutral benchmark of 1.0. Therefore, in this implementation, the semantic classification confidence directly plays a role once in the process of determining the width requirement weight.
[0161] In another implementation, following steps S1021 to S1023, the semantic base width parameter is pre-determined based on the preset neutral width parameter, the category base width parameter, and the semantic classification confidence score. Since the semantic classification confidence score has already been used to determine the semantic base width parameter, after forming the topic-corrected width parameter based on the semantic base width parameter, the semantic classification confidence score is not applied again. Instead, the topic-corrected width parameter is corrected using the content correction parameter to obtain the width requirement weight of the corresponding column.
[0162] The two confidence correction methods described above are different implementation methods. In the process of determining the column width requirement weight, one of these methods is used to correct the confidence level of the semantic classification result, thereby avoiding the semantic classification confidence from being repeatedly applied and causing excessive adjustment of the basic width preference.
[0163] In one possible implementation of step S104 above, generating a table in the target document according to the column widths of each column includes: Step S1041: When it is determined that the source table spans multiple pages based on the effective content area of the target document's page and the expected row height of each row in the source table, determine the pagination position of the source table.
[0164] Specifically, based on the effective content area of each page of the target document and the expected row height of each row under the corresponding column width, the number of table rows that each page can accommodate is determined along the row order of the source table, and the row boundaries between adjacent pages are determined as the pagination positions.
[0165] The pagination position is located between adjacent data rows to maintain the integrity of the content of a single row.
[0166] Step S1042: Divide the source table into multiple sub-tables according to the pagination position, and add the table header data to the corresponding sub-table data of the next page.
[0167] Specifically, the source table remains a logical table in terms of data logic.
[0168] Here, the logical table is divided into multiple sub-tables corresponding to different pages according to the pagination position, and the header data of the source table is added to the continuation page sub-table data, so that each physical sub-table can independently represent the business meaning of its columns.
[0169] Step S1043: Determine the available width of each sub-table according to the layout parameters of the page corresponding to each sub-table data, and allocate the sub-table column width within the available width of the corresponding sub-table according to the width requirement weight of each column.
[0170] Specifically, the layout parameters of the corresponding page are read for each sub-table data, and the available width of the corresponding sub-table is determined accordingly.
[0171] Based on the width requirement weight of each column, the width of each physical sub-table is proportionally allocated within the available width of the corresponding sub-table and redistributed under boundary constraints to obtain the sub-table column width corresponding to each physical sub-table.
[0172] Step S1044: For the sub-table data of the corresponding continuation page, reduce the column width of the sub-table belonging to the long text category according to the continuation page width correction parameter, and proportionally allocate the width released by reducing the column width of the long text category sub-table according to the width requirement weight of the column belonging to the numeric or identifier category. Among them, the difference in column width between adjacent sub-tables of the same column is not greater than the width change threshold.
[0173] Specifically, the column width of the sub-table belonging to the long text category in the continuation page physical sub-table is reduced according to the continuation page width correction parameter, and the difference in width before and after the correction is determined as the release width.
[0174] Based on the width requirement weight of columns belonging to the numeric or identifier categories in the physical sub-table of the continuation page, the released width is proportionally allocated.
[0175] A width change threshold is applied to the difference in column width between adjacent physical sub-tables for the same column. When the difference in column width exceeds the width change threshold, the corresponding column is fixed to the boundary corresponding to the width change threshold, and the unallocated width is redistributed according to the width requirement weight of other columns that have not reached the width change threshold.
[0176] Step S1045: Based on the data of each sub-table and its corresponding column width, generate independent physical sub-tables in the target document.
[0177] Specifically, based on the data of each sub-table and the corresponding column width of the sub-table, physical sub-tables are generated in the corresponding pages of the target document, so that each physical sub-table can adopt a column width configuration that is compatible with the layout parameters of the page it is on.
[0178] In one method of adjusting the column width of a continuation page, the adjustment parameter is 0.85. The column width of the sub-table belonging to the long text category in the physical sub-table of the continuation page is multiplied by 0.85 to obtain the corresponding adjusted column width, and the released width is allocated to the columns belonging to the numeric or identifier categories.
[0179] In one implementation, the width variation threshold is 15% of the width of the same column in adjacent physical sub-tables.
[0180] When the difference between the adjusted column width of a sub-table and the same column width in the previous physical sub-table exceeds the width change threshold, the column is fixed at the boundary corresponding to the width change threshold, and the unallocated width is reallocated.
[0181] In the Word object model, each physical sub-table corresponds to an independent Table object.
[0182] Based on the column width of each physical sub-table, set the PreferredWidth property of the corresponding Table object to make the physical sub-tables on different pages adopt the corresponding column width configuration.
[0183] In the table column width adjustment method of the above embodiments of this disclosure, based on generating a table in the target document according to the column width of each column, the pagination position is further determined according to the effective content area of the page and the expected row height. The logical table spanning multiple pages is divided into multiple physical sub-tables, and the available width and column width of the sub-table are determined according to the layout parameters of the page where each physical sub-table is located. For the physical sub-table of the continuation page, the width of long text columns is corrected, and the released width is redistributed according to the width requirement weight of numerical or identifier columns. At the same time, the column width change of the same column in adjacent physical sub-tables is restricted.
[0184] Therefore, in layout environments where it's difficult to set column widths for different pages after a continuous table spans multiple pages, independent physical sub-tables can be used to match the column widths of each page to the effective content area of the corresponding page. This allows page space in subsequent pages to be reused according to the display requirements of the corresponding columns. Simultaneously, by repeatedly adding header data, the data structure correspondence between the physical sub-tables is maintained, and width variation thresholds limit the width difference of the same column between adjacent pages. Thus, while improving the page space utilization of cross-page tables, it reduces reading jumps caused by excessive column width changes between adjacent pages, further improving the layout coordination and display stability of cross-page tables.
[0185] In another possible implementation of step S104 above, when the target typesetting engine does not support splitting a logical table into multiple physical sub-tables, the column width of the entire table is uniformly determined according to the layout parameters of the target document, and the differential width allocation between the physical sub-tables of the continuation page is not performed.
[0186] In one data import scenario, the source table is a structured table read from an Excel spreadsheet file, and the target document is the final generated Word report, with the source table serving as a component of the target Word report.
[0187] Since Excel spreadsheets and Word documents use different typesetting engines, after reading the header data and column content data from the source spreadsheet, the column widths in the source spreadsheet are not directly used. Instead, the column widths in the target Word report are redefined according to the aforementioned implementation method.
[0188] In a multi-column table processing scenario where the source table has more than 10 columns, the header and content data of all columns in the source table are used as the column width decision objects, and the column width boundaries that meet the aforementioned feasibility conditions are determined based on the available table width in the target Word report. Subsequently, the column width of each column is determined according to steps S101 to S104, and a native table object is generated in the target Word report based on the determined column width, and the content data of each column is written into the corresponding table cells.
[0189] Therefore, even with a large number of columns, it is still possible to coordinate and allocate each column within the layout of the target Word report, and store the actual content and column width configuration of the multi-column cells directly in the target Word report, without relying on the external access path formed by hyperlinking the source Excel file.
[0190] The above-mentioned multi-column table processing method is used to solve the problem of embedded display when the source table has a large number of columns. The aforementioned cross-page physical sub-table processing method is used to solve the problem of column width adaptation when the table spans multiple pages along the data row direction. The two methods can be implemented separately or in combination, depending on the number of columns and rows of the source table.
[0191] In one column width allocation example, the table has an available width of 300 pixels, and the source table includes four columns: "Serial Number", "Name", "Amount" and "Remarks".
[0192] Among them, the "Serial Number" column belongs to the identifier category, the "Name" column belongs to the short text category, the "Amount" column belongs to the numerical or monetary category, and the "Remarks" column belongs to the long text category.
[0193] When allocating based solely on the semantic base width parameter, the width requirement weights for the four columns are 0.7, 1.0, 1.1, and 1.8, respectively, for a total weight of 4.6. After allocating according to the proportion of each column's width requirement weight in the total weight, the column widths for the four columns are approximately 46 pixels, 65 pixels, 72 pixels, and 117 pixels, respectively.
[0194] When allocating based solely on content parameters, the width requirement weights for the four columns are 1.0, 1.0, 1.0, and 2.5, respectively, for a total weight of 5.5. After allocating according to the proportion of each column's width requirement weight in the total weight, the column widths are approximately 55 pixels, 55 pixels, 55 pixels, and 135 pixels, respectively.
[0195] After combining the semantic width preference and content statistics results according to this scheme, the width requirement weights for the four columns are 0.7, 1.0, 1.1, and 4.2, respectively, with a total weight of 7.0. Based on the proportion of each column's width requirement weight in the total weight, the column widths are 30 pixels, approximately 43 pixels, approximately 47 pixels, and 180 pixels, respectively.
[0196] As can be seen from the above column width allocation results, when the allocation is based solely on the semantic base width parameter, the column width obtained by the remarks column still mainly depends on its semantic category; when the allocation is based solely on the content parameter, the serial number column, name column, and amount column receive the same width requirement weight, which cannot reflect the width preference corresponding to different column semantic categories.
[0197] This solution uses content statistics to adjust the semantic width preference of each column, allowing the notes column to have a relatively large width based on its long text semantics and the current content distribution, while keeping the serial number column relatively small based on its identifier semantics. This allows page space freed up by short content columns to be allocated to long text columns, reducing the tendency for long text columns to wrap unnecessarily and preventing short content columns from occupying excessive page space.
[0198] In one embodiment, a table column width adjustment device is provided, which corresponds one-to-one with the table column width adjustment methods in the above embodiments. For example... Figure 3 As shown, the table column width adjustment device includes: The data acquisition module 31 is used to acquire the header data and content data of each column of the source table, as well as the document scene identifier and layout parameters of the target document, determine the available width of the table based on the layout parameters, and determine the column width boundaries based on the document scene identifier and layout parameters. The feature analysis module 32 is used to determine the semantic category of each column based on the header data, determine the business theme of the source table based on the header data and the content data of each column, correct the semantic base width parameter corresponding to the semantic category of each column based on the business theme, obtain the theme correction width parameter of each column, and determine the corresponding multiple content statistical features based on the content data of each column. The weight determination module 33 is used to obtain the target statistical feature weights corresponding to the document scene identifier from the parameter library. The statistical feature weights of each group in the parameter library are updated according to the historical user column width adjustment records under the corresponding document scene. The multiple content statistical features of each column are weighted according to the target statistical feature weights to obtain the content correction parameters of each column. The content correction parameters of each column are used to correct the corresponding topic correction width parameters to obtain the width requirement weight of each column. The column width allocation module 34 is used to allocate the initial column width of each column within the available width of the table according to the proportion of the width requirement weight of each column in the total width requirement weight of all columns; fix the columns whose initial column width exceeds the corresponding column width boundary to the column width boundary and remove them from the set of columns to be allocated; reallocate the remaining available width proportionally according to the width requirement weight of the remaining columns until the column width of each column meets the corresponding column width boundary; and generate the table in the target document according to the column width of each column.
[0199] In one embodiment, the feature analysis module 32 is specifically used to: match the header data of each column with the semantic rule base to obtain the rule classification result and rule classification confidence of each column; When the confidence level of a rule classification is not lower than the confidence threshold, the rule classification result is determined as the semantic category of the corresponding column, and the rule classification confidence level is determined as the semantic classification confidence level of the corresponding column. When the rule classification confidence is lower than the confidence threshold, semantic classification input data is generated based on the header and content data of the corresponding column. The semantic classification input data is processed by a semantic recognition model to obtain the model classification result and model classification confidence. The header and content data of the corresponding column are vector-encoded to obtain the target semantic vector. The target semantic vector is matched with typical header vectors in the semantic vector index to obtain the vector classification result and vector classification confidence. Based on the rule classification result, model classification result, vector classification result, and corresponding classification confidence, the column semantic category and semantic classification confidence are determined. The semantic base width parameter is the sum of the preset neutral width parameter and the confidence correction amount. The confidence correction amount is the product of the difference between the category base width parameter and the preset neutral width parameter corresponding to the semantic category of the corresponding column and the semantic classification confidence.
[0200] In one embodiment, the feature analysis module 32 is specifically used to: obtain topic offset parameters corresponding to the business topic and the column semantic category of each column; The corresponding semantic base width parameter is adjusted based on the topic offset parameter to obtain the topic correction width parameter for each column.
[0201] In one embodiment, the feature analysis module 32 is specifically used to: determine the average content length and target quantile length of each column based on the character length of the content data of each column, and normalize the average content length of each column relative to the maximum value among the average content lengths of all columns to obtain the normalized average length of each column; The absolute length statistical characteristics of each column are determined based on the ratio between the target quantile length and the average content length of each column, as well as the normalized average length. Determine the number of content rendering rows and the natural boundary line break ratio for each column under the candidate column width, and determine the row height complexity statistics of each column based on the number of content rendering rows and the natural boundary line break ratio; Among them, several content statistical features include absolute length statistical features and line height complexity statistical features.
[0202] In one embodiment, the feature analysis module 32 is specifically used to: determine the candidate column width of each column based on the semantic base width parameter corresponding to the column semantic category of each column; Select content samples from the content data of each column, and simulate the layout of the content samples according to the candidate column widths of the corresponding columns; The natural boundary line break ratio is obtained by statistically analyzing the number of lines rendered in the simulated typesetting sample and the percentage of line breaks at natural text boundaries in the total number of line breaks.
[0203] In one embodiment, the weight determination module 33, before obtaining the target statistical feature weights corresponding to the document scene identifier from the parameter library, is further configured to: Get the column width before adjustment, column width after adjustment, and document scenario identifier for user column width adjustment operations performed on historically generated tables; Based on the direction and amount of change of the adjusted column width relative to the original column width, a preference training sample is constructed, and the preference training sample is associated with the corresponding document scenario identifier to obtain the historical user column width adjustment record; The preference training samples are grouped according to the document scene identifier, and the statistical feature weights associated with the corresponding document scene identifier in the parameter library are updated according to the preference training samples of each group.
[0204] In one embodiment, the feature analysis module 32 is specifically used for: Based on the document scenario identifier, business theme, and column semantic category, the target historical case is determined from the historical column width case library. The target historical case includes the historical column width configuration of each column in the historical table. Based on the historical column width configuration corresponding to the column semantic category in the target historical cases, the corresponding semantic base width parameters are modified to obtain the empirical initial width parameters for each column. The corresponding empirical initial width parameters are adjusted based on the topic offset parameters of each column to obtain the topic correction width parameters of each column.
[0205] In one embodiment, the column width allocation module 34 is specifically used for: When the source table spans multiple pages, determine the pagination position of the source table based on the effective content area of the target document's page and the expected row height of each row in the source table; The source table is divided into multiple sub-tables based on the pagination position, and the header data is added to the corresponding sub-table data on the next page. The available width of each sub-table is determined based on the layout parameters of the page corresponding to the data of each sub-table, and the column width of each sub-table is allocated within the available width of the corresponding sub-table according to the width requirement weight of each column. For the sub-table data of the corresponding continuation page, the column width of the sub-table belonging to the long text category is reduced according to the continuation page width correction parameter. The width released by reducing the column width of the long text category is proportionally allocated according to the width requirement weight of the column belonging to the numeric or identifier category. Among them, the difference in column width between adjacent sub-tables of the same column is not greater than the width change threshold. Based on the data in each sub-table and its corresponding column width, generate independent physical sub-tables in the target document.
[0206] It should be noted that the table column width adjustment device provided in the above embodiments is only illustrated by the division of the above functional modules when implementing the corresponding table column width adjustment method. In practical applications, the above processing can be assigned to different functional modules as needed to complete all or part of the processing described above. In addition, the above table column width adjustment device embodiments and table column width adjustment method embodiments belong to the same concept, and their specific implementation process can be found in the corresponding method embodiments, which will not be repeated here.
[0207] This disclosure also provides an electronic device for performing the table column width adjustment method described in the above embodiments.
[0208] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure.
[0209] The following is a detailed reference. Figure 4The diagram illustrates a structural schematic suitable for implementing an electronic device according to embodiments of the present disclosure. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 401, which can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) 402 or a program loaded from memory 408 into random access memory (RAM) 403. RAM 403 also stores various programs and data required for the operation of the electronic device. The processor 401, ROM 402, and RAM 403 are interconnected via bus 404. Input / output (I / O) interface 405 is also connected to bus 404.
[0210] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 408 including, for example, magnetic tapes, hard disks, etc.; and communication devices 409. Communication device 409 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 4 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0211] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 409, or installed from memory 408, or installed from ROM 402. When the computer program is executed by processor 401, it performs the functions defined in the table column width adjustment method of embodiments of this disclosure.
[0212] Figure 4 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0213] This disclosure also provides a computer-readable storage medium in which the methods described in this disclosure can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium may also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the table column width adjustment method shown in the above embodiments.
[0214] A portion of this disclosure can be applied to computer program products, such as computer program instructions, which, when executed by a computer, can invoke or provide methods and / or technical solutions according to this disclosure through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, and installation package files. Accordingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions; the computer compiling the instructions and then executing the corresponding compiled program; the computer reading and executing the instructions; or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0215] Although embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for adjusting column width in a table, characterized in that, The method includes: Obtain the header data and content data of each column of the source table, as well as the document scene identifier and layout parameters of the target document. Determine the available width of the table based on the layout parameters, and determine the column width boundaries based on the document scene identifier and the layout parameters. The semantic category of each column is determined based on the header data. The business theme of the source table is determined based on the header data and the content data of each column. The semantic base width parameter corresponding to the semantic category of each column is corrected based on the business theme to obtain the theme correction width parameter of each column. And multiple content statistical features are determined based on the content data of each column. Obtain the target statistical feature weights corresponding to the document scene identifier from the parameter library, wherein each set of statistical feature weights in the parameter library is updated according to the historical user column width adjustment records under the corresponding document scene; weight multiple content statistical features of each column according to the target statistical feature weights to obtain the content correction parameters of each column, and use the content correction parameters of each column to correct the corresponding topic correction width parameters to obtain the width requirement weight of each column. Based on the proportion of each column's width requirement weight in the total width requirement weight of all columns, the initial column width of each column is allocated within the available width of the table; columns whose initial column width exceeds the corresponding column width boundary are fixed to the column width boundary and removed from the set of columns to be allocated; the remaining available width is re-allocated proportionally according to the width requirement weight of the remaining columns until the column width of each column meets the corresponding column width boundary; and a table is generated in the target document according to the column width of each column.
2. The method according to claim 1, characterized in that, The step of determining the column semantic category based on the header data includes: The header data of each column is matched with the semantic rule base to obtain the rule classification results and rule classification confidence of each column; When the confidence level of the rule classification is not lower than the confidence level threshold, the rule classification result is determined as the column semantic category of the corresponding column, and the rule classification confidence level is determined as the semantic classification confidence level of the corresponding column. When the confidence score of the rule classification is lower than the confidence score threshold, semantic classification input data is generated based on the header data and content data of the corresponding column. The semantic classification input data is processed by a semantic recognition model to obtain the model classification result and the model classification confidence score. The header data and content data of the corresponding column are vector-encoded to obtain the target semantic vector. The target semantic vector is matched with the typical header vectors in the semantic vector index library to obtain the vector classification result and the vector classification confidence score. Based on the rule classification result, the model classification result, the vector classification result, and the corresponding classification confidence score, the column semantic category and semantic classification confidence score of the column are determined. Wherein, the semantic base width parameter is the sum of the preset neutral width parameter and the confidence correction amount, and the confidence correction amount is the product of the difference between the category base width parameter corresponding to the semantic category of the corresponding column and the preset neutral width parameter and the semantic classification confidence.
3. The method according to claim 1, characterized in that, The step of adjusting the semantic base width parameter corresponding to the semantic category of each column according to the business theme to obtain the theme-adjusted width parameter of each column includes: Obtain the topic offset parameter corresponding to the business topic and the column semantic category of each column; The corresponding semantic base width parameter is adjusted according to the topic offset parameter to obtain the topic correction width parameter for each column.
4. The method according to claim 1, characterized in that, The determination of multiple content statistical features based on the content data of each column includes: Based on the character length of the content data in each column, determine the average content length and target quantile length of each column, and normalize the average content length of each column relative to the maximum value of the average content length of all columns to obtain the normalized average length of each column; The absolute length statistical characteristics of each column are determined based on the ratio between the target quantile length and the average content length of each column, as well as the normalized average length. Determine the number of content rendering rows and the natural boundary line break ratio for each column under the candidate column width, and determine the row height complexity statistical characteristics of each column based on the number of content rendering rows and the natural boundary line break ratio; The multiple content statistical features include the absolute length statistical feature and the line complexity statistical feature.
5. The method according to claim 4, characterized in that, Determining the number of content rendering rows and the natural margin wrapping ratio for each column under the candidate column width includes: The candidate column width for each column is determined based on the semantic base width parameter corresponding to the column semantic category. Select content samples from the content data of each column, and simulate the layout of the content samples according to the candidate column widths of the corresponding columns; The natural boundary line break ratio is obtained by statistically analyzing the number of lines rendered in the simulated typesetting of the content sample and the proportion of line breaks at natural text boundaries in the total number of line breaks.
6. The method according to claim 1, characterized in that, Before obtaining the target statistical feature weights corresponding to the document scene identifier from the parameter library, the method further includes: Get the column width before adjustment, column width after adjustment, and document scenario identifier for user column width adjustment operations performed on historically generated tables; Based on the direction and amount of change of the adjusted column width relative to the original column width, a preference training sample is constructed, and the preference training sample is associated with the corresponding document scene identifier to obtain the historical user column width adjustment record; The preference training samples are grouped according to the document scene identifier, and the statistical feature weights associated with the corresponding document scene identifier in the parameter library are updated according to each group of preference training samples.
7. The method according to claim 3, characterized in that, The step of adjusting the corresponding semantic base width parameter according to the topic offset parameter to obtain the topic correction width parameter for each column includes: Based on the document scenario identifier, the business theme, and the column semantic category of each column, a target historical case is determined from the historical column width case library, wherein the target historical case includes the historical column width configuration of each column in the historical table; Based on the historical column width configuration corresponding to the column semantic category in the target historical case, the corresponding semantic basic width parameters are corrected to obtain the empirical initial width parameters of each column. The corresponding empirical initial width parameters are adjusted based on the topic offset parameters of each column to obtain the topic correction width parameters of each column.
8. The method according to claim 1, characterized in that, The process of generating a table in the target document according to the column widths of each column includes: When it is determined that the source table spans multiple pages based on the effective content area of the target document and the expected row height of each row in the source table, the pagination position of the source table is determined. The source table is divided into multiple sub-tables according to the pagination position, and the table header data is added to the sub-table data of the corresponding continuation page. The available width of each sub-table is determined based on the layout parameters of the page corresponding to the data of each sub-table, and the column width of each sub-table is allocated within the available width of the corresponding sub-table according to the width requirement weight of each column. For the sub-table data of the corresponding continuation page, the column width of the sub-table belonging to the long text category is reduced according to the continuation page width correction parameter. The width released by reducing the column width of the sub-table belonging to the long text category is proportionally allocated according to the width requirement weight of the column belonging to the numerical or identifier category. The difference in column width between adjacent sub-tables of the same column is not greater than the width change threshold. Based on the data of each sub-table and its corresponding column width, independent physical sub-tables are generated in the target document.
9. A table column width adjustment device, characterized in that, The device includes: The data acquisition module is used to acquire the header data and content data of each column of the source table, as well as the document scene identifier and layout parameters of the target document, determine the available width of the table based on the layout parameters, and determine the column width boundaries based on the document scene identifier and the layout parameters. The feature analysis module is used to determine the semantic category of each column based on the header data, determine the business theme of the source table based on the header data and the content data of each column, correct the semantic base width parameter corresponding to the semantic category of each column based on the business theme to obtain the theme correction width parameter of each column, and determine the corresponding multiple content statistical features based on the content data of each column. The weight determination module is used to obtain the target statistical feature weights corresponding to the document scene identifier from the parameter library. The statistical feature weights in the parameter library are updated according to the historical user column width adjustment records under the corresponding document scene. The module weights multiple content statistical features of each column are weighted according to the target statistical feature weights to obtain the content correction parameters of each column. The content correction parameters of each column are then used to correct the corresponding topic correction width parameters to obtain the width requirement weight of each column. The column width allocation module is used to allocate the initial column width of each column within the available width of the table according to the proportion of the width requirement weight of each column in the total width requirement weight of all columns; fix the columns whose initial column width exceeds the corresponding column width boundary to the column width boundary and remove them from the set of columns to be allocated; reallocate the remaining available width proportionally according to the width requirement weight of the remaining columns until the column width of each column meets the corresponding column width boundary; and generate a table in the target document according to the column width of each column.
10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the table column width adjustment method as described in any one of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the table column width adjustment method as described in any one of claims 1 to 8.