Document generation method, electronic device and storage medium

By determining the characteristics of page elements and optimizing the layout strategy, the problem that document generation in the existing technology is difficult to handle personalized design is solved, efficient and personalized document generation is achieved, and computing costs are reduced.

CN118133775BActive Publication Date: 2024-09-13IND FULIAN (HANGZHOU) DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410562666.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-08
Publication Date
2024-09-13
Estimated Expiration
2044-05-08

AI Technical Summary

Technical Problem

Existing document generation technologies are difficult to handle highly personalized or innovatively designed documents and have high computational costs.

Method used

By determining the characteristics of the page elements in the document to be laid out, the layout strategy is determined based on user preference rules and preset rules, and the initial document is optimized based on quantitative parameters to generate the target document and reduce reliance on existing templates and model learning.

Benefits of technology

It improves the personalization, diversity and innovation of documents, reduces computing costs, enables a better understanding of document content and design requirements, and enhances the coordination and professionalism of page layout.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118133775B
    Figure CN118133775B
Patent Text Reader

Abstract

The present application relates to the field of computer technology, and provides a document generation method, electronic device and storage medium, the method comprising: determining a first element feature of a page element in a document to be laid out; based on the first element feature and a layout strategy, performing page layout on the document to be laid out to obtain an initial document, wherein the layout strategy is determined based on user preference rules and / or preset rules; optimizing the page layout of the initial document based on preset constraints and corresponding quantitative parameters to obtain a target document, wherein the element feature of the page element in the initial document is used as a second element feature, and the quantitative parameter is used to quantify the page layout performance of the second element feature. The method can better understand the nature and composition of the document content without relying on existing templates. Moreover, the method performs flexible page layout on the document to be laid out based on the layout strategy, and no longer relies on model learning, thereby reducing the reliance on a large amount of high-quality training data and saving computing costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology and relates to document processing technology, and in particular to a document generation method, electronic device and storage medium. Background Art

[0002] With the development of computer technology and users' demand for improved office efficiency, automated office technology has been widely used and developed. For example, automated document generation technology can significantly reduce the time and manpower required to adjust document generation and improve work efficiency. In the process of document generation, in order to create a more coordinated, beautiful and professional document, it is necessary to consider the page layout of the document, such as the layout of the text, graphics, color, etc. designed in the document page.

[0003] Document generation solutions in related technologies usually rely too much on existing templates, and perform page layout for the document that currently needs to be laid out based on the layout information of existing templates or historical typesetting pages. This approach may cause the generated documents to be relatively standardized and lack personalization, resulting in insufficient ability to handle highly personalized or innovatively designed documents. In addition, for some document generation solutions that can improve the personalization and diversity of generated documents, it is often necessary to process a large amount of training data, based on model learning algorithms or image feature analysis to achieve document page layout, which has a high computational cost. Summary of the invention

[0004] In view of this, the present application provides a document generation method, an electronic device and a storage medium to solve the problem that the document generation solutions in the related art are insufficient in processing highly personalized or innovatively designed documents or have high computing costs.

[0005] A first aspect of an embodiment of the present application provides a document generation method, which includes: determining a first element feature of a page element in a document to be laid out; performing page layout on the document to be laid out based on the first element feature and a layout strategy to obtain an initial document, wherein the layout strategy is determined based on user preference rules and / or preset rules; optimizing the page layout of the initial document based on preset constraints and corresponding quantitative parameters to obtain a target document, wherein the element feature of the page element in the initial document is used as a second element feature, and the quantitative parameter is used to quantify the page layout performance of the second element feature.

[0006] In some embodiments, the layout strategy includes a multi-level strategy, strategies at different levels in the multi-level strategy are interrelated, and the content of each level strategy is determined based on the user preference rule and / or the preset rule.

[0007] In some embodiments, the quantitative parameters include an objective function, and the page layout of the initial document is optimized based on preset constraints and corresponding quantitative parameters to obtain a target document, including: determining the preset constraints based on the layout strategy and / or user instructions; determining the weight coefficient and element feature variable corresponding to the second element feature according to the layout strategy; generating the objective function according to the weight coefficient and the element feature variable; optimizing the page layout of the initial document based on the preset constraints and the objective function to obtain the target document.

[0008] In some embodiments, the page layout of the initial document is optimized based on the preset constraints and the objective function to obtain the target document, including: determining the optimal solution of the objective function through a preset linear programming algorithm, wherein the optimal solution satisfies all the preset constraints; and optimizing the initial document based on the optimal solution to obtain the target document.

[0009] In some embodiments, the initial document is optimized based on the optimal solution to obtain the target document, including: if the deviation between the feature value of the second element feature and the corresponding optimal solution is not within a preset deviation range, determining that the page element corresponding to the second element feature does not comply with the layout strategy, and optimizing the initial document according to the optimal solution to obtain the target document.

[0010] In some embodiments, the quantitative parameters include overlapping parameters, and the page layout of the initial document is optimized based on preset constraints and corresponding quantitative parameters to obtain a target document, including: determining the preset constraints corresponding to the second element feature based on the layout strategy and / or user instructions, and determining the feature parameter range corresponding to the preset constraints; obtaining the parameter feature value of the second element feature corresponding to the overlapping parameter; if the parameter feature value is not within the feature parameter range, determining that the page element corresponding to the second element feature does not comply with the layout strategy, and optimizing the second element feature according to the feature parameter range to optimize the page layout of the initial document to obtain a target document.

[0011] In some embodiments, the document generation method also includes: acquiring the visual features of the document to be laid out, and determining visual design principles based on the visual features; performing page layout on the document to be laid out based on the visual design principles, the first element features and the layout strategy to obtain the initial document.

[0012] In some embodiments, the document generation method also includes: optimizing the target document in response to the user's optimization operation; updating the user portrait of the user according to the user's optimization operation; optimizing the user preference rules according to the updated user portrait; updating the layout strategy according to the optimized user preference rules; and optimizing the target document based on the first element feature and the updated layout strategy.

[0013] A second aspect of an embodiment of the present application provides a document generation device, which includes: a determination module, used to determine a first element feature of a page element in a document to be laid out; a layout module, used to perform page layout on the document to be laid out based on the first element feature and a layout strategy to obtain an initial document, wherein the layout strategy is determined based on user preference rules and / or preset rules; an optimization module, used to optimize the page layout of the initial document based on preset constraints and corresponding quantitative parameters to obtain a target document, wherein the element feature of the page element in the initial document is used as a second element feature, and the quantitative parameter is used to quantify the page layout performance of the second element feature.

[0014] A third aspect of an embodiment of the present application provides an electronic device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the above-mentioned document generation method when executing the computer-readable instructions.

[0015] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed by a processor, the above-mentioned document generation method is implemented.

[0016] In the document generation method provided by the embodiment of the present application, after obtaining the document to be laid out, the first element feature of the page element in the document to be laid out is determined. The layout strategy corresponding to the document to be laid out is determined based on the user preference rule and / or the preset rule. The document to be laid out is laid out based on the first element feature and the layout strategy to obtain an initial document. In order to improve the coordination, beauty and professionalism of the document layout, and to correct the page elements that do not conform to the layout strategy, the electronic device can quantify the page layout performance of the element features of the page elements in the initial document to obtain quantitative parameters, and determine the corresponding preset constraints based on the layout strategy. The page layout of the initial document is optimized based on the preset constraints and the corresponding quantitative parameters to obtain a target document. This method analyzes the element features of the page elements in the document to be laid out, and performs page layout based on the element features and the layout strategy, so as to better understand the nature and composition of the document content without relying on the existing template. Moreover, this method determines the layout strategy corresponding to the document to be laid out based on the user preference rule and / or the preset rule, so as to better capture the user's specific style, creative intention and design preference, etc., and can flexibly adjust and innovate the page layout, thereby improving the personalization, diversity, flexibility and innovation of the generated document. In addition, this method performs flexible page layout on layout documents based on layout strategies and no longer relies on model learning, thereby reducing dependence on a large amount of high-quality training data and saving computing costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] Figure 1 It is a flow chart for implementing the document generation method provided in the embodiment of the present application.

[0019] Figure 2 It is a flow chart for implementing the feature determination method provided in the embodiment of the present application.

[0020] Figure 3 It is a flow chart for implementing the document optimization method provided in the embodiment of the present application.

[0021] Figure 4 It is a structural diagram of the document generation device provided in an embodiment of the present application.

[0022] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] It should be noted that the terms "first" and "second" in the specification, claims and drawings of the present application are used to distinguish similar objects rather than to describe a specific order or sequence.

[0024] It should also be noted that the method disclosed in the embodiments of the present application or the method shown in the flowchart includes one or more steps for implementing the method. Without departing from the scope of the claims, the execution order of multiple steps can be interchanged with each other, and some of the steps can also be deleted.

[0025] Some embodiments will be described below in conjunction with the accompanying drawings. In the absence of conflict, the following embodiments and features in the embodiments may be combined with each other.

[0026] In the related art, the page layout of the document is performed based on image feature analysis to generate recommended documents. For example, an unsupervised coding model is used to analyze the image features of the document page to be generated. The document image features and similar page layouts in the resource pool are matched according to the analysis results, and then the page layout of the document to be generated is realized according to the matching results. This document generation method mainly relies on image feature analysis to perform page layout of the document to be generated, which may result in the generated document being unable to fully reflect deeper design requirements and key points, and because this method relies on existing templates and styles, it may produce relatively standardized and lack of personalized presentations, which may not be effective when dealing with highly personalized or innovative designs.

[0027] To solve the above problems, the present application determines a layout strategy based on user preference rules and / or preset rules, and determines the first element features of the page elements in the document to be laid out, and based on the first element features of the page elements and the layout strategy, performs page layout on the document to be laid out to obtain an initial document. By combining user preference rules with feature analysis of page elements for page layout, it is possible to better understand deep-level design requirements and key points without relying on existing templates and styles, and to increase the personalization of layout documents. Furthermore, the electronic device can use the element features of the page elements in the initial document as the second element features, and obtain quantitative parameters for the page layout performance of the quantified second element features. By optimizing the page layout of the initial document based on preset constraints and corresponding quantitative parameters to obtain a target document, the fit between the document after page layout and the design requirements can be further increased, and there is no need to rely on a large amount of training data for data processing, saving computing resources.

[0028] The document generation method provided in the embodiment of the present application is applied to electronic devices. The electronic devices include but are not limited to any one or more of mobile phones, tablet computers, computers, servers, etc. Figure 1As shown, it is a flow chart for implementing the document generation method provided in an embodiment of the present application, and the method includes the following steps.

[0029] S11: Determine the first element feature of the page element in the document to be laid out.

[0030] In some embodiments, the page elements in the document to be laid out include, but are not limited to, geometric figures, charts, text boxes, tables, pictures, etc. The first element feature represents the element features of the page elements in the document to be laid out, such as the element type of the page element, the area ratio of the page element in the document, and the color attributes, such as color contrast, shape, etc. The page elements correspond to the first element features.

[0031] See also Figure 2 As shown, it is a flowchart of the implementation of the feature determination method provided in the embodiment of the present application. Figure 2 As shown, the electronic device can determine the first element feature of the page element in the document to be laid out according to the feature determination method provided in steps S21 to S24.

[0032] S21: Obtain the document to be laid out.

[0033] In some embodiments, the document to be laid out represents a document that needs to be laid out. The document to be laid out can be created by a user through an electronic device. Or the electronic device generates the document to be laid out based on the user input text using any one or more of natural language processing, machine learning, template matching, and adaptive layout technologies. The embodiment of the present application does not limit the method of obtaining the document to be laid out.

[0034] S22: Obtain page elements in the document to be laid out.

[0035] In some embodiments, the electronic device can identify page elements in the document to be laid out through image recognition and computer vision technology. For example, through image segmentation and recognition technology, object recognition technology, deep learning and machine learning technology, the electronic device can identify page elements such as text boxes, pictures, icons, etc. The embodiment of the present application does not limit the method of identifying the elements of the page in the document to be laid out.

[0036] In the related art, page elements are determined by image feature analysis or by user interaction. The image feature analysis method cannot accurately understand the document content, while the user interaction method requires a large amount of user interaction, which reduces the user experience. Based on this, in some embodiments of the present application, the electronic device identifies and carefully classifies the page elements before performing page layout on the document to be laid out, which can not only more accurately understand the document content, but also reduce the user's manual input and adjustment, thereby improving the user experience.

[0037] S23: Classify page elements.

[0038] In this embodiment, in order to facilitate subsequent page layout of the document to be laid out based on the page elements in the document to be laid out, the electronic device classifies the page elements in the document to be laid out after identifying the page elements in the document to be laid out, for example, the page elements are divided into multiple categories such as text boxes, pictures, and charts according to the types of the page elements. By classifying the page elements, the electronic device can better understand the nature and composition of the page content in the document to be laid out, and thus facilitate more accurate layout of the page elements.

[0039] S24: Determine the first element feature of the page element.

[0040] In some embodiments, considering that in the process of page layout of the document to be laid out, the size, color, distance between elements, etc. of the page elements may need to be adjusted, the electronic device can obtain the element features of each page element after identifying the page elements in the document to be laid out.

[0041] In some embodiments, the electronic device may obtain the first element feature of the page element in the document to be laid out by feature extraction. The embodiment of the present application does not limit the method of obtaining the first element feature.

[0042] S12: Based on the first element feature and the layout strategy, the document to be laid out is laid out to obtain an initial document, wherein the layout strategy is determined based on a user preference rule and / or a preset rule.

[0043] In some embodiments, the user preference rules reflect the user's personalized design requirements for the page layout of the layout document. The user preference rules can be created based on the specific needs of the user. For example, marketing personnel pay more attention to the display of brand elements (such as brand logos), then the marketing personnel can set the user preference rules to give priority to the display of brand elements, or highlight the color, font, etc. of brand elements. For another example, educators may pay more attention to the readability of the text, then educators can set the user preference rules to evaluate the text size, font selection and color contrast in the document to ensure that the text in the document is easy to read.

[0044] In other embodiments, the electronic device may obtain user needs and / or user portraits, and generate user preference rules based on the user needs and / or user portraits. For example, the user portrait may include a document design theme, a user occupation, a target brand, etc. Taking the user portrait as the document design theme as an example, if the document design theme is a business presentation, the corresponding user preference rules may be set to ensure that the hierarchy of text, images and other elements in the document is clear and emphasizes key data. Taking the user portrait as the user occupation as an example, if the user occupation is a data analyst, the corresponding user preference rules may be set to ensure the clarity and accuracy of the data display. Taking the user portrait as the target brand as an example, if the page layout of the document needs to comply with the style guide of the target brand, the corresponding user preference rules may be set to give priority to displaying the colors, fonts and other visual elements of the target brand, etc. The embodiment of the present application does not limit the method for generating user preference rules.

[0045] In other embodiments, the user portrait may also include the user's preferences for the color of page elements in the document, font selection, layout style (e.g., simple, dynamic, or professional), element arrangement, text-to-image ratio, use of dynamic effects, interactive elements (e.g., links, buttons, etc.), user feedback, and the user's modification history of the document.

[0046] In some embodiments, in order to enhance the coordination, aesthetics and professionalism of the document, the layout design of the document can generally follow some professional visual design strategies. The visual design strategy can include visual design parameter standards determined in the practice of page layout design of the document. For example, visual design parameters such as visual hierarchy, color contrast, and layout symmetry.

[0047] In some embodiments, the electronic device may determine the preset rules based on a professional visual design strategy. The specific content of the preset rules is not limited in the embodiments of the present application.

[0048] In some embodiments, the layout strategy can be determined based on user preference rules and preset rules. By combining user preferences to determine the layout strategy, the user's specific style or creative intent can be captured more comprehensively, thereby improving the personalization and innovation of the generated document.

[0049] In this embodiment, the electronic device can better understand and apply complex page layout designs by determining the layout strategy based on user preference rules and / or preset rules, and performing page layout on the layout document based on the first element feature and the layout strategy. For example, visual balance and emphasis. At the same time, it can support users to edit and redefine the layout strategy to meet specific page layout requirements. In addition, when this embodiment is used in an application scenario where a document is generated based on text input by a user, it can intelligently understand the user preference rules based on the text input by the user, and generate a document that better meets the user's expectations, adding a more complex and detailed control level to the automated layout.

[0050] In some embodiments, if the document to be laid out includes multiple pages, for each page, the electronic device can determine the first element feature of the page element in the page, and perform page layout on the page based on the first element feature and the layout strategy. After the electronic device completes page layout for all pages in the document to be laid out, an initial document is obtained.

[0051] In some embodiments of the present application, the layout strategy includes a multi-level strategy, in which strategies at different levels are interrelated, and the content of each level strategy is determined based on user preference rules and / or preset rules.

[0052] In the process of page layout of a document, the same page element may correspond to multiple layout strategies. For example, for text, the corresponding layout strategy may include that the display priority of text is higher than all images, the more text content, the lower the display priority of text, and the larger the proportion of text on the page, the lower the display priority of text. In order to facilitate the adjustment of the element characteristics of the corresponding page elements based on the layout strategy, thereby realizing the page layout of the layout document, the electronic device can design the layout strategy as a multi-level strategy. The strategies of different levels in the multi-level strategy are interrelated and can be used to limit the design rules of the same type of page elements, and the content of each level strategy can be determined based on user preference rules and / or preset rules.

[0053] In some embodiments, for example, the layout strategy includes two layers of strategies, the two layers of strategies include a primary strategy and a secondary strategy, the primary strategy and the secondary strategy are mutually related, and the content of the primary strategy and the secondary strategy can be determined based on user preference rules and / or preset rules. For example, the primary strategy is that the display priority of text is higher than that of all images; the secondary strategy associated with the primary strategy can be that the more text content, the higher the display priority of the text; and the larger the proportion of the text page, the higher the display priority of the text.

[0054] In some embodiments, each layer of strategy may include one or more design rules, and the design rules corresponding to each layer of strategy may be determined based on user preference rules and / or preset rules. Accordingly, the multi-level strategy includes a single rule mode and a multiple rule mode. Among them, in the single rule mode, each layer of strategy in the multi-level strategy can only contain one design rule. In the multiple rule mode, each layer of strategy in the multi-level strategy can contain one or more design rules. Taking the layout strategy including two layers of strategies as an example, the two layers of strategies include a primary strategy and a secondary strategy. In the single rule mode, the primary strategy can be "the display priority of text is higher than all images", and the secondary strategy can be "the more text content, the lower the display priority of text", and the primary strategy and the secondary strategy can only contain one design rule. In the multiple rule mode, the primary strategy can be that the display priority of text is higher than all images; the secondary strategy can be that the more text content, the lower the display priority of text; and the larger the proportion of text page, the lower the display priority of text.

[0055] In some embodiments, the electronic device can generate a layout strategy of a single rule mode and a layout strategy of a multiple rule mode based on user preference rules and / or preset rules. The user can select a layout strategy of a single rule mode or a layout strategy of a multiple rule mode through the electronic device. The electronic device determines the layout strategy based on the user's selection, and performs page layout on the document to be laid out based on the layout strategy and the first element feature of the corresponding page element.

[0056] In some embodiments, the electronic device may predetermine that in this embodiment, by hierarchizing the layout strategies, the diversity of the page layouts may be increased.

[0057] In some embodiments of the present application, the electronic device can obtain the visual features of the document to be laid out, and determine the visual design principles based on the visual features; perform page layout on the document to be laid out based on the visual design principles, the first element features and the layout strategy to obtain an initial document.

[0058] In some embodiments, visual features include, but are not limited to, the use of colors (e.g., primary colors and color combinations), text size, text font selection, text color, image resolution and quality, element hierarchy, dynamic effects, and transition effects. Accordingly, the visual design principles determined based on the visual features of the document to be laid out may include ensuring that the use of colors complies with design principles and corresponding brand guidelines; evaluating the text size, text font selection, and text color of the document to be laid out to ensure that the text is easy to read; ensuring that the image is well displayed in the document based on the resolution and quality of the image; ensuring that important information is displayed first based on the relationship between text, images, and other elements in the document to be laid out; ensuring that dynamic effects and transition effects can enhance the presentation effect rather than distract the attention of document viewers, etc.

[0059] In some embodiments, the electronic device can obtain visual features of the document to be laid out through image processing and computer vision technology, for example, using a color analysis algorithm to identify the main color tone, color scheme and color matching in a file (for example, MICROSOFTTM Office PowerPoint, PPT); using an image quality assessment algorithm to evaluate the resolution, clarity, contrast, etc. of the image to determine the quality of the image; using image segmentation technology to identify different elements in the PPT file, such as text boxes, pictures, shapes, etc., and determine their location and hierarchy.

[0060] In other embodiments, the electronic device may also obtain the element features of the document to be laid out by machine learning, file structure and metadata analysis, etc. The embodiment of the present application does not limit the method of obtaining visual features.

[0061] In some embodiments, the electronic device can integrate design tools and APIs, such as Adobe's Creative Cloud, Sketch, etc., to obtain professional design suggestions and best practices as visual design principles. In another embodiment, the visual design principles corresponding to the visual features can also be pre-customized, and the embodiment of the present application does not limit the method of obtaining the visual design principles and the content of the visual design principles.

[0062] In some embodiments, the electronic device may store visual features and visual design principles in correspondence. When it is necessary to perform page layout on the document to be laid out, the visual features of the document to be laid out are obtained, the corresponding visual design principles are determined according to the visual features, and the page layout of the document to be laid out is performed based on the visual design principles, the first element features, and the layout strategy to obtain an initial document.

[0063] In this embodiment, the electronic device combines visual design principles, first element characteristics and layout strategies to perform page layout on the layout document, which can not only visually enhance the attractiveness of the page layout, but also ensure the clear expression and effective communication of the document content, thereby providing users with higher quality and personalized presentation documents.

[0064] In other embodiments, the electronic device may also obtain page attributes of the document to be laid out, such as page border size, page background style, etc. The electronic device may perform page layout on the document to be laid out based on the page attributes of the document to be laid out, the first element feature, the visual design principle, and the layout strategy to obtain the initial document.

[0065] S13: Optimizing the page layout of the initial document based on preset constraints and corresponding quantitative parameters to obtain a target document.

[0066] In some embodiments, the second element feature represents an element feature of a page element in the initial document, for example, the element type of the page element, the area ratio of the page element in the document, color attributes, such as color contrast, etc. The page element and the second element feature correspond to each other.

[0067] In some embodiments, the quantization parameter is used to quantify the page layout performance of the second element feature. For example, the quantization parameters 0 and 1 are used to indicate whether the text box and the image box overlap. If the text box and the image box overlap, the quantization parameter is set to 1; if the text box and the image box do not overlap, the quantization parameter is set to 0. Quantization parameters include but are not limited to global layout parameters (such as objective functions), overlap parameters, color parameters, etc. Quantization parameters can be in the form of feature parameter ranges, feature values, functions, etc. The embodiments of the present application do not limit the expression form of quantization parameters.

[0068] In some embodiments, the preset constraint condition is used to characterize the degree of optimization of the page layout of the initial document. The preset constraint condition corresponds to the quantitative parameter. Taking the quantitative parameter as the overlap parameter as an example, the quantitative parameters 0 and 1 are used to indicate whether the text box and the image frame overlap. If the text box and the image frame overlap in the initial document, the overlap parameter is set to 1; if the text box and the image frame do not overlap in the initial document, the overlap parameter is set to 0. The preset constraint condition can be set to that the text box and the image frame do not overlap. At this time, if it is determined that the overlap parameter is set to 1, it indicates that the text box and the image frame in the initial document overlap, which does not meet the preset constraint condition, and the electronic device needs to optimize the corresponding text box and image frame so that the overlap parameter is set to 0.

[0069] In some embodiments, the preset constraints may be determined based on a layout strategy and / or a user instruction.

[0070] In this embodiment, by determining the preset constraints of the page elements in the initial document, and quantifying the page layout performance of the corresponding second element features of the page elements, the corresponding quantitative parameters are determined, and the page layout of the initial document is optimized based on the preset constraints and the corresponding quantitative parameters. Compared with complex machine learning algorithms, computing resources can be utilized more efficiently.

[0071] In some embodiments of the present application, the quantitative parameter includes an objective function, and the page layout of the initial document is optimized based on the preset constraints and the corresponding quantitative parameter to obtain a target document, including: Figure 3 The process shown includes steps S31 to S34.

[0072] S31: Determine preset constraint conditions based on layout strategy and / or user instructions.

[0073] In some embodiments, the electronic device may determine preset constraints based on layout strategies and / or user instructions. For example, the preset constraints may include minimizing blank areas between elements, page boundary restrictions, element sizes being minimum or maximum, and the like.

[0074] S32: Determine a weight coefficient and an element feature variable corresponding to the second element feature according to the layout strategy.

[0075] In some embodiments, the element feature variable represents the corresponding variable of the page layout performance of the second element feature. For example, when the second element feature is the position of the page element, the corresponding element feature variable can be a variable such as the coordinates of the element. When the second element feature is the size feature of the page element, the corresponding element feature variable can be a variable such as the width and height of the page element.

[0076] S33: Generate an objective function according to the weight coefficient and the element characteristic variable.

[0077] In this embodiment, in the process of establishing the objective function, the electronic device can determine the weight coefficient and element feature variable corresponding to the second element feature of the page element according to the layout strategy, and generate the objective function according to the weight coefficient and element feature variable.

[0078] In some embodiments, the electronic device may establish an objective function for quantifying the page layout performance of element features such as the position and size of page elements in the initial document. The page layout of the initial document is optimized based on the preset constraints and the objective function to obtain a target document.

[0079] S34: Optimizing the page layout of the initial document based on preset constraints and the objective function to obtain a target document.

[0080] In some embodiments, a set of equations or inequality equations may be determined according to preset constraints and an objective function. The electronic device may obtain the optimal solution of the equations or inequality equations by calculation, determine the optimal layout performance of the second element feature, and then, the electronic device may optimize the page layout of the initial document according to the optimal layout performance of the second element feature and the layout performance of the second element feature in the initial document.

[0081] In some embodiments, the electronic device may calculate and obtain the optimal solution of the equality equation or inequality equation through a linear programming algorithm. The linear programming algorithm may be an interior point method, a simplex method, etc. By using linear programming to optimize the page layout, computing resources can be used more efficiently than complex machine learning methods.

[0082] In some embodiments of the present application, the electronic device optimizes the page layout of the initial document based on preset constraints and the objective function to obtain a target document, including: determining the optimal solution of the objective function through a preset linear programming algorithm, and the optimal solution satisfies all preset constraints; optimizing the initial document based on the optimal solution to obtain the target document.

[0083] In some embodiments, the preset linear programming algorithm may be an interior point method, a simplex method, etc. The embodiment of the present application does not limit the type of the preset linear programming algorithm.

[0084] In some embodiments, the electronic device may determine the optimal solution of the objective function through a preset linear programming algorithm. Since the optimal solution satisfies all preset constraints, the electronic device may compare the optimal solution with the characteristic value of the second element characteristic corresponding to the objective function, optimize the initial document according to the comparison result, and obtain the target document. For example, if the characteristic value of the second element characteristic matches the corresponding optimal solution, it is determined that the page element corresponding to the second element characteristic complies with the corresponding layout strategy; if the characteristic value of the second element characteristic does not match the corresponding optimal solution, it is determined that the page element corresponding to the second element characteristic complies with the corresponding layout strategy;

[0085] In some embodiments of the present application, the initial document is optimized based on the optimal solution to obtain a target document, including: if the deviation between the feature value of the second element feature and the corresponding optimal solution is not within a preset deviation range, determining that the page element corresponding to the second element feature does not comply with the layout strategy, and optimizing the initial document according to the optimal solution to obtain the target document.

[0086] In some embodiments, the preset deviation range can be custom set.

[0087] In some embodiments, the electronic device can calculate the deviation between the characteristic value of the second element feature and the corresponding optimal solution, and determine whether the page element corresponding to the second element feature complies with the corresponding layout strategy by judging whether the deviation is within a preset deviation range. If the deviation between the characteristic value of the second element feature and the corresponding optimal solution is within the preset deviation range, it is determined that the page element corresponding to the second element feature complies with the corresponding layout strategy. If the deviation between the characteristic value of the second element feature and the corresponding optimal solution is not within the preset deviation range, it is determined that the page element corresponding to the second element feature does not comply with the corresponding layout strategy, and the initial document is optimized according to the optimal solution to obtain the target document.

[0088] In some embodiments of the present application, the quantitative parameters include overlapping parameters, and the page layout of the initial document is optimized based on preset constraints and corresponding quantitative parameters to obtain a target document, including: determining the preset constraints corresponding to the second element feature based on the layout strategy and / or user instructions, and determining the feature parameter range corresponding to the preset constraints; obtaining the parameter characteristic value of the second element feature corresponding to the overlapping parameter; if the parameter characteristic value is not within the feature parameter range, determining that the page element corresponding to the second element feature does not comply with the layout strategy, and optimizing the second element feature according to the feature parameter range to optimize the page layout of the initial document to obtain the target document.

[0089] In some embodiments, the page layout expression of the second element feature includes the overlapping state of the text box and the image box. In order to analyze whether the overlapping state of the text box and the image box meets the requirements (for example, meets the layout strategy, user needs, etc.), or whether the overlapping state of the text box and the image box needs to be optimized, the electronic device can quantify the overlapping state of the text box and the image box to obtain an overlapping parameter, and use the overlapping parameter to characterize the overlapping state of the text box and the image frame. For example, the overlapping parameter includes 0 and 1, and the overlapping parameter of 0 represents that the text box and the image frame do not overlap, and the overlapping parameter of 1 represents that the text box and the image frame overlap.

[0090] In some embodiments, to determine whether the overlapping state of the text box and the image box meets the requirements, the electronic device can determine the preset constraint corresponding to the second element feature based on the layout strategy and / or the user instruction. For example, the preset constraint is determined to be the overlapping state of the text box and the image frame based on the layout strategy and / or the user instruction. Taking the overlapping parameter including 0 and 1, the overlapping parameter is 0 to indicate that the text box and the image frame do not overlap, and the overlapping parameter is 1 to indicate that the text box and the image frame overlap, the feature parameter range corresponding to the preset constraint is 0. Then, the electronic device can obtain the parameter feature value of the second element feature corresponding to the overlapping parameter in the initial document. Compare the parameter feature value with the feature parameter range. If the parameter feature value is within the feature parameter range, for example, the feature parameter range is 0, and the parameter feature value is also 0, indicating that the parameter feature value is within the feature parameter range, the electronic device can determine that the page element corresponding to the second element feature meets the layout strategy. If the parameter feature value is not within the feature parameter range, it is determined that the page element corresponding to the second element feature does not meet the layout strategy. At this time, the electronic device can optimize the second element feature according to the feature parameter range to optimize the page layout of the initial document to obtain the target document.

[0091] In other embodiments, the electronic device may also quantify the page layout representation of element features of other page elements in the initial document, for example, quantify the color features of text or images to obtain color parameters, etc. The embodiment of the present application does not limit the type of quantized parameters.

[0092] In some embodiments of the present application, the electronic device optimizes the target document in response to the user's optimization operation. The user's user portrait is updated according to the user's optimization operation; the user preference rule is optimized according to the updated user portrait; the layout strategy is updated according to the optimized user preference rule; and the target document is optimized based on the first element feature and the updated layout strategy.

[0093] In some embodiments, considering that some page elements in the target document obtained after the electronic device performs page layout and optimization on the layout document based on the layout strategy and the element features of the page elements may not accurately conform to the user preference rules and / or preset rules, after the electronic device generates the target document, the user can optimize the target document through the electronic device. For example, adjust the color and size of the text. In response to the user's optimization operation, the electronic device can further optimize the target document.

[0094] Furthermore, the electronic device can update the user's user profile according to the user's optimization operation and continuously learn the user's preference settings. Then, the updated user profile is used to optimize the user preference rules, the layout strategy is updated according to the optimized user preference rules, and the target document is optimized based on the first element feature and the updated layout strategy.

[0095] In this embodiment, the electronic device can more accurately meet the user's needs and optimize the layout design in real time by continuously learning and applying the user's preference settings. When the user creates a new document through the electronic device, the electronic device can generate a more personalized layout recommendation based on the saved preference settings, thereby improving the user experience and work efficiency.

[0096] In some embodiments of the present application, the electronic device may utilize the above steps S11 to S13 and the document generation method provided in the corresponding embodiments to perform page layout and optimization on each page of the document to be laid out, thereby obtaining a target document.

[0097] In the document generation method provided by the embodiment of the present application, after obtaining the document to be laid out, the first element feature of the page element in the document to be laid out is determined. The layout strategy corresponding to the document to be laid out is determined based on the user preference rule and / or the preset rule. The document to be laid out is laid out based on the first element feature and the layout strategy to obtain an initial document. In order to improve the coordination, beauty and professionalism of the document layout, and to correct the page elements that do not conform to the layout strategy, the electronic device can quantify the page layout performance of the element features of the page elements in the initial document to obtain quantitative parameters, and determine the corresponding preset constraints based on the layout strategy. The page layout of the initial document is optimized based on the preset constraints and the corresponding quantitative parameters to obtain a target document. This method analyzes the element features of the page elements in the document to be laid out, and performs page layout based on the element features and the layout strategy, so as to better understand the nature and composition of the document content without relying on the existing template. Moreover, this method determines the layout strategy corresponding to the document to be laid out based on the user preference rule and / or the preset rule, so as to better capture the user's specific style, creative intention and design preference, etc., and can flexibly adjust and innovate the page layout, thereby improving the personalization, diversity, flexibility and innovation of the generated document. In addition, this method performs flexible page layout on layout documents based on layout strategies and no longer relies on model learning, thereby reducing dependence on a large amount of high-quality training data and saving computing costs.

[0098] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0099] In one embodiment of the present application, a document generation device 10 is provided, and the functions that can be implemented by the document generation device 10 correspond to the document generation method in the above embodiment. Figure 4 As shown, the document generation device 10 includes a determination module 11, a layout module 12 and an optimization module 13. The functional modules are described in detail as follows: the determination module 11 is used to determine the first element feature of the page element in the document to be laid out; the layout module 12 is used to perform page layout on the document to be laid out based on the first element feature and the layout strategy to obtain an initial document, and the layout strategy is determined based on user preference rules and / or preset rules; the optimization module 13 is used to optimize the page layout of the initial document based on preset constraints and corresponding quantitative parameters to obtain a target document, wherein the element feature of the page element in the initial document is used as the second element feature, and the quantitative parameter is used to quantify the page layout performance of the second element feature.

[0100] For the specific definition of the document generation device 10, please refer to the definition of the document generation method above, which will not be repeated here. Each module in the above document generation device 10 can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0101] See also Figure 5 , which is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 100 includes but is not limited to any one or more of a mobile phone, a tablet computer, a computer, a server, etc. The network in which the electronic device 100 is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0102] like Figure 5 As shown, the electronic device 100 includes a communication module 101, a memory 102, a processor 103, an input / output (I / O) interface 104 and a bus 105. The processor 103 is coupled to the communication module 101, the memory 102 and the I / O interface 104 through the bus 105.

[0103] The communication module 101 may be a wireless communication module or a mobile communication module. The wireless communication module may provide wireless communication solutions including wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., applied to the electronic device 100. The mobile communication module may provide wireless communication solutions including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100.

[0104] The memory 102 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM). The random access memory can be directly read and written by the processor 103, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data. The random access memory may include static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM, for example, the fifth generation DDR SDRAM is generally called DDR5 SDRAM), etc.

[0105] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 103. The non-volatile memory may include a disk storage device and a flash memory.

[0106] The memory 102 is used to store one or more computer programs. The one or more computer programs are configured to be executed by the processor 103. The one or more computer programs include multiple instructions, and when the multiple instructions are executed by the processor 103, the document generation method executed on the electronic device 100 can be implemented.

[0107] In other embodiments, the electronic device 100 further includes an external memory interface for connecting to an external memory to expand the storage capacity of the electronic device 100 .

[0108] The processor 103 may include one or more processing units, for example, the processor 103 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0109] The processor 103 provides computing and control capabilities. For example, the processor 103 is used to execute a computer program stored in the memory 102 to implement the above-mentioned document generation method.

[0110] The I / O interface 104 is used to provide a channel for user input or output. For example, the I / O interface 104 can be used to connect various input and output devices, such as a mouse, keyboard, touch device, display screen, etc., so that the user can enter information or visualize information.

[0111] The bus 105 is at least used to provide a channel for mutual communication among the communication module 101 , the memory 102 , the processor 103 , and the I / O interface 104 in the electronic device 100 .

[0112] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0113] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the document generation method in the above-mentioned embodiments of the present application.

[0114] The computer-readable storage medium may be an internal memory of the electronic device described in the above embodiment, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device.

[0115] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc.

[0116] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.

Claims

1. A document generation method, characterized in that: The document generation method comprises: Determine a first element feature of a page element in a document to be laid out; Based on the first element feature and the layout strategy, performing page layout on the document to be laid out to obtain an initial document, wherein the layout strategy is determined based on a user preference rule and / or a preset rule; The page layout of the initial document is optimized based on preset constraints and corresponding quantitative parameters to obtain a target document, including: if the quantitative parameter is an overlapping parameter, based on the layout strategy and / or user instructions, determining the preset constraints corresponding to the second element feature, and determining the feature parameter range corresponding to the preset constraints, wherein the second element feature is an element feature of a page element in the initial document, and the quantitative parameter is used to quantify the page layout performance of the second element feature; obtaining a parameter feature value of the second element feature corresponding to the overlapping parameter; if the parameter feature value is not within the feature parameter range, determining that the page element corresponding to the second element feature does not comply with the layout strategy, and optimizing the second element feature according to the feature parameter range to optimize the page layout of the initial document to obtain the target document.

2. The document generation method according to claim 1, characterized in that: The layout strategy includes a multi-level strategy, in which strategies at different levels are interrelated, and the content of each level strategy is determined based on the user preference rule and / or the preset rule.

3. The document generation method according to claim 1, characterized in that: The quantitative parameters include an objective function, and the page layout of the initial document is optimized based on the preset constraint conditions and the corresponding quantitative parameters to obtain a target document, including: Determining the preset constraint condition based on the layout strategy and / or user instructions; Determining a weight coefficient and an element feature variable corresponding to the second element feature according to the layout strategy; Generate the objective function according to the weight coefficient and the element characteristic variable; The page layout of the initial document is optimized based on the preset constraint conditions and the objective function to obtain the target document.

4. The document generation method according to claim 3, characterized in that: The optimizing the page layout of the initial document based on the preset constraint condition and the objective function to obtain the target document includes: Determine the optimal solution of the objective function by a preset linear programming algorithm, wherein the optimal solution satisfies all the preset constraints; The initial document is optimized based on the optimal solution to obtain the target document.

5. The document generation method according to claim 4, characterized in that: The step of optimizing the initial document based on the optimal solution to obtain the target document includes: If the deviation between the feature value of the second element feature and the corresponding optimal solution is not within a preset deviation range, it is determined that the page element corresponding to the second element feature does not comply with the layout strategy, and the initial document is optimized according to the optimal solution to obtain the target document.

6. The document generation method according to any one of claims 1 to 5, characterized in that: The document generation method further includes: Acquiring visual features of the document to be laid out, and determining visual design principles according to the visual features; The document to be laid out is page-laid out based on the visual design principle, the first element feature and the layout strategy to obtain the initial document.

7. The document generation method according to any one of claims 1 to 5, characterized in that: The document generation method further includes: In response to the user's optimization operation, optimizing the target document; updating the user profile of the user according to the optimization operation of the user; Optimizing the user preference rules according to the updated user portrait; Updating the layout strategy according to the optimized user preference rule; The target document is optimized based on the first element feature and the updated layout strategy.

8. An electronic device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, characterized in that: When the computer-readable instructions are executed by the processor, the document generation method according to any one of claims 1 to 7 is implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the document generation method according to any one of claims 1 to 7 is implemented.