Rich text file display method and device, electronic equipment and readable storage medium

By obtaining user characteristics and historical file characteristics, and using layout style generation model to determine the target layout style, the problem that the existing technology cannot meet users' personalized needs and improve user experience.

CN119720940APending Publication Date: 2025-03-28DINGDAO ZHILIAN (BEIJING) TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411805154.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The prior art cannot meet users' personalized needs for rich text file layout styles, resulting in poor user experience.

Method used

By receiving instructions for the user to open a rich text file, obtain user feature information and historical file feature information, use the preset layout style generation model to determine the target layout style, and display the rich text file in this style.

Benefits of technology

It realizes dynamic adjustment of the layout style of rich text files according to user personalized needs and historical operating habits, thereby improving user experience and satisfaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720940A_ABST
    Figure CN119720940A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a rich text file display method and device, electronic equipment and a readable storage medium, relates to the technical field of computer application, and aims to meet personalized requirements of users. The method comprises the following steps: receiving an opening instruction of opening a rich text file by a user; in response to the opening instruction, obtaining feature information of the user and feature information of a historical rich text file; according to a preset layout style generation model, the feature information of the user and the feature information of the historical rich text file, determining a target layout style; and displaying the rich text file in the target layout style. The method is suitable for displaying the rich text file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer application technology, and in particular to a rich text file display method, device, electronic device and readable storage medium. Background Art

[0002] With the development of science and technology, people's living standards are constantly improving, and the continuous development of electronic devices is constantly enriching people's lives. In related technologies, users can use electronic devices or personal computers to open and browse and read rich text files.

[0003] When displaying a rich text file to a user, in the prior art, a server sends a unified layout style to a client, so that the client displays the rich text file in a unified layout style. However, each user may have personalized needs for the layout style of the rich text. Thus, the prior art of displaying rich text files in a unified layout style cannot meet the personalized needs of users. Summary of the invention

[0004] In view of this, the embodiments of the present application provide a rich text file display method, device, electronic device and readable storage medium, which can better meet the personalized needs of users.

[0005] In a first aspect, an embodiment of the present application provides a method for displaying a rich text file, comprising: receiving an opening instruction from a user to open a rich text file; in response to the opening instruction, obtaining characteristic information of the user and characteristic information of historical rich text files; determining a target layout style based on a preset layout style generation model, the characteristic information of the user and the characteristic information of the historical rich text files; and displaying the rich text file in the target layout style.

[0006] According to a specific implementation method of an embodiment of the present application, the target layout style is determined according to a preset layout style generation model, the characteristic information of the user, and the characteristic information of the historical rich text file, including: generating multiple candidate layout styles according to the preset layout style generation model, the characteristic information of the user, and the characteristic information of the historical rich text file; respectively calculating comprehensive scores of the multiple candidate layout styles; and determining the candidate layout style corresponding to the highest comprehensive score among the multiple comprehensive scores as the target layout style.

[0007] According to a specific implementation method of an embodiment of the present application, the multiple candidate layout styles include a first layout style; wherein, calculating the comprehensive score of the multiple candidate layout styles includes: determining at least two layout indicators of the first layout style; and calculating the comprehensive score of the first layout style based on the at least two layout indicators of the first layout style.

[0008] According to a specific implementation method of an embodiment of the present application, the determining of at least two layout indicators of the first layout style includes: determining at least two indicators of the first layout style: information density, aesthetic score, and information display weight; wherein the information density is used to indicate the density of characters and words of each element in the first layout style on a display page where the first layout style is located; the aesthetic score is used to indicate the aesthetic degree of the layout of each element in the first layout style; and the information display weight is used to indicate the importance of each element in the first layout style and the importance of the position of each element in the display page.

[0009] According to a specific implementation of the embodiment of the present application, determining the information density of the first layout pattern includes: determining the information density of the first layout pattern according to the following formula:

[0010] ,

[0011] is the information density of the first layout style, is the total number of words, is the total number of characters, is the area of ​​the display page where the first layout style is located;

[0012] Determines the aesthetic score for the first layout style, including:

[0013] The aesthetic score of the first layout style is determined according to the following formula:

[0014] ,

[0015] in, is the aesthetic score of the first layout style, is the horizontal and vertical alignment of each element in the first layout style, for uniformity between elements in the first layout style, is the color contrast of adjacent elements in the first layout style, is the preset alignment weight, is the preset uniformity weight, The weight of the preset color contrast;

[0016] Determine the information display weight of the first layout style, including:

[0017] The information display weight of the first layout style is determined according to the following formula:

[0018] ,

[0019] in, The information display weight for the first layout style, is the total number of elements in the first layout style, is greater than or equal to 1 and less than or equal to integer, For the The importance weight of the element, For the The position weight of the element, For preset The weight of For preset The weight of .

[0020] According to a specific implementation manner of the embodiment of the present application, the calculating the comprehensive score of the first layout style based on the at least two layout indicators of the first layout style includes:

[0021] The comprehensive score of the first layout style is calculated based on the following formula:

[0022] ,

[0023] is the comprehensive score of the first layout style, is the information density, is the aesthetic score, To display weight for said information, For preset The weight of For preset The weight of For preset The weight of .

[0024] According to a specific implementation manner of the embodiment of the present application, the characteristic information of the user includes inherent attribute information of the user and operation information of the user on historical rich text files.

[0025] According to a specific implementation method of an embodiment of the present application, the inherent attribute information of the user includes the user's age, gender, occupation and / or region; the user's operation information on historical rich text files includes the user's click operations, browsing time and / or browsing depth on historical rich text files; the characteristic information of the historical rich text files includes the content and / or type of the historical rich text files.

[0026] According to a specific implementation method of an embodiment of the present application, after displaying the rich text file in the target layout style, the method further includes: obtaining the user's operation information on the rich text file; training the preset layout style generation model according to the user's inherent attribute information, the user's operation information on the rich text file, the feature information of the rich text file, and the target layout style to obtain a trained layout style generation model.

[0027] In a second aspect, an embodiment of the present application provides a rich text display device, which is applied to a client and includes: a receiving module, used to receive an opening instruction from a user to open a rich text file; an acquisition module, used to obtain characteristic information of the user and characteristic information of historical rich text files in response to the opening instruction; a determination module, used to determine a target layout style based on a preset layout style generation model, the characteristic information of the user and the characteristic information of the historical rich text files; and a display module, used to display the rich text file in the target layout style.

[0028] According to a specific implementation method of an embodiment of the present application, the determination module includes: a production sub-module, used to generate multiple candidate layout styles according to a preset layout style generation model, the characteristic information of the user and the characteristic information of the historical rich text file; a calculation sub-module, used to respectively calculate the comprehensive scores of the multiple candidate layout styles; and a determination sub-module, used to determine the alternative layout style corresponding to the highest comprehensive score among the multiple comprehensive scores as the target layout style.

[0029] According to a specific implementation method of an embodiment of the present application, the multiple alternative layout styles include a first layout style; wherein the calculation submodule includes: a determination unit, used to determine at least two layout indicators of the first layout style; and a calculation unit, used to calculate a comprehensive score of the first layout style based on the at least two layout indicators of the first layout style.

[0030] According to a specific implementation method of an embodiment of the present application, the determination unit includes: a determination subunit, used to determine at least two indicators of the information density, aesthetic score, and information display weight of the first layout style; wherein the information density is used to indicate the density of characters and words of each element in the first layout style on the display page where the first layout style is located; the aesthetic score is used to indicate the aesthetic degree of the layout of each element in the first layout style; and the information display weight is used to indicate the importance of each element in the first layout style and the importance of the position of each element in the display page.

[0031] According to a specific implementation of the embodiment of the present application, the determining subunit is specifically used to: determine the information density of the first layout style according to the following formula:

[0032] ,

[0033] is the information density of the first layout style, is the total number of words, is the total number of characters, is the area of ​​the display page where the first layout style is located;

[0034] The determining subunit is specifically used for:

[0035] The aesthetic score of the first layout style is determined according to the following formula:

[0036] ,

[0037] in, is the aesthetic score of the first layout style, is the horizontal and vertical alignment of each element in the first layout style, for uniformity between elements in the first layout style, is the color contrast of adjacent elements in the first layout style, is the preset alignment weight, is the preset uniformity weight, The weight of the preset color contrast;

[0038] The determining subunit is further specifically used for:

[0039] The information display weight of the first layout style is determined according to the following formula:

[0040] ,

[0041] in, The information display weight for the first layout style, is the total number of elements in the first layout style, is greater than or equal to 1 and less than or equal to integer, For the The importance weight of the element, For the The position weight of the element, For preset The weight of For preset The weight of .

[0042] According to a specific implementation of the embodiment of the present application, the computing unit is specifically used to:

[0043] The comprehensive score of the first layout style is calculated based on the following formula:

[0044] ,

[0045] is the comprehensive score of the first layout style, is the information density, is the aesthetic score, To display weight for said information, For preset The weight of For preset The weight of For preset The weight of .

[0046] According to a specific implementation manner of the embodiment of the present application, the characteristic information of the user includes inherent attribute information of the user and operation information of the user on historical rich text files.

[0047] According to a specific implementation method of an embodiment of the present application, the inherent attribute information of the user includes the user's age, gender, occupation and / or region; the user's operation information on historical rich text files includes the user's click operations, browsing time and / or browsing depth on historical rich text files; the characteristic information of the historical rich text files includes the content and / or type of the historical rich text files.

[0048] According to a specific implementation method of an embodiment of the present application, the device is also used to: obtain the user's operation information on the rich text file after the display module displays the rich text file in the target layout style; train the preset layout style generation model according to the user's inherent attribute information, the user's operation information on the rich text file, the feature information of the rich text file, and the target layout style to obtain a trained layout style generation model.

[0049] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a housing, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the housing, and the processor and the memory are arranged on the circuit board; a power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the rich text file display method described in any of the aforementioned implementation methods.

[0050] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the rich text file display method described in any of the aforementioned implementation methods.

[0051] The rich text file display method, device, electronic device and readable storage medium of the present embodiment, in response to a user's opening instruction to open a rich text file, obtains the user's characteristic information and the characteristic information of historical rich text files, determines the target layout style according to a preset layout style generation model, the user's characteristic information and the characteristic information of historical rich text files, and displays the rich text file in the target layout style, uses the preset layout style generation model, the user's characteristic information and the characteristic information of historical rich text files to determine the target layout style, that is, when determining the target layout style, combines the user's characteristic information and the characteristic information of rich text files historically operated by the user, so that the rich text file displayed in the target layout style can better meet the user's personalized needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art 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 creative work.

[0053] Figure 1 A flowchart of a rich text file display method provided in one embodiment of the present application; Figure 2 A schematic diagram of the structure of a rich text display device provided in one embodiment of the present application; Figure 3 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0054] The embodiments of the present application are described in detail below in conjunction with the accompanying drawings. It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] In order to enable those skilled in the art to better understand the technical concept, implementation plan and beneficial effects of the embodiments of the present application, specific embodiments are described in detail below.

[0056] Figure 1 A flowchart of a rich text file display method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the rich text file display method of this embodiment may include: S101, receiving an opening instruction from a user to open a rich text file.

[0057] Rich text files refer to files that can use multiple formats in the document, such as text formats with elements such as font colors, images, tables, videos, hyperlinks, etc. Rich text files can contain various fonts, colors, sizes, images, links, tables, videos, etc., making the text more vivid and interesting.

[0058] S102: In response to the opening instruction, obtain characteristic information of the user and characteristic information of the historical rich text file.

[0059] After receiving an opening instruction for opening a rich text file, characteristic information of the user and characteristic information of the historical rich text file are obtained.

[0060] It can be understood that the historical rich text files in this embodiment are rich text files that have been opened and operated by the user.

[0061] In some examples, the user's characteristic information includes the user's inherent attribute information and the user's operation information on the historical rich text file. The user's inherent attribute information includes the user's age, gender, occupation and / or region, and the user's operation information on the historical rich text file includes the user's click operation on the historical rich text file, browsing time and / or browsing depth, wherein the browsing depth is the pull-down operation on the historical rich text file to obtain more content. The user's operation information on the historical rich text file may also include the operation time, such as whether the operation is performed at night or during the day, etc.

[0062] The characteristic information of the historical rich text file includes the content and / or type of the historical rich text file, wherein the type of the historical rich text file includes news, entertainment, finance, etc.

[0063] S103: Determine a target layout style according to a preset layout style generation model, user feature information, and feature information of historical rich text files.

[0064] The target layout style can be obtained by using the characteristic information of the user and the characteristic information of the historical rich text file acquired in step S102 as inputs of a preset layout style generation model.

[0065] The target layout style may specifically be description information of a graphical interface (UI).

[0066] The preset layout style generation model in this embodiment can be generated by the server and sent to the client, or it can be a model obtained by retraining based on the model sent by the server.

[0067] The preset layout style generation model is a model in ONNX (Open Neural Network Exchange) format. The model in ONNX format can be seamlessly migrated and deployed between different environments and platforms. In addition, the preset layout style generation model in this embodiment is a model based on the attention mechanism.

[0068] S104. Display the rich text file in the target layout style.

[0069] The rich text file corresponding to the opening instruction in step S101 is displayed in the target layout style.

[0070] In this embodiment, in response to an opening instruction of a user to open a rich text file, characteristic information of the user and characteristic information of historical rich text files are obtained, a target layout style is determined according to a preset layout style generation model, the characteristic information of the user and the characteristic information of historical rich text files, and the rich text file is displayed in the target layout style. The target layout style is determined using the preset layout style generation model, the characteristic information of the user and the characteristic information of historical rich text files. That is, when determining the target layout style, the characteristic information of the user and the characteristic information of the rich text files historically operated by the user are combined. In this way, the rich text file displayed in the target layout style can better meet the personalized needs of the user and can improve the user experience.

[0071] In the rich text display process, in order to provide users with a layout style that is more in line with their personalized needs and more beautiful, step S103 determines the target layout style based on the preset layout style generation model, the user's feature information, and the feature information of the historical rich text file, including: S103a, generating a plurality of candidate layout styles according to a preset layout style generation model, characteristic information of the user, and characteristic information of historical rich text files.

[0072] S103b, respectively calculating comprehensive scores of a plurality of candidate layout styles.

[0073] In this embodiment, the comprehensive score of each candidate layout style is used to indicate the aesthetics of the layout style. The higher the comprehensive score, the more aesthetically pleasing it is.

[0074] S103c: Determine the candidate layout style corresponding to the highest comprehensive score among the multiple comprehensive scores as the target layout style.

[0075] The alternative layout style with the highest comprehensive score, that is, the most beautiful layout style among multiple alternative layout styles, is used as the target layout style. In this way, the target layout style can not only better meet the personalized needs of users, but also be more beautiful, further improving the user experience.

[0076] When calculating the comprehensive scores of the candidate layout styles, multiple methods may be used. To improve calculation efficiency, the comprehensive scores of the candidate layout styles are determined according to the layout indicators of the candidate layout styles. Specifically, in some examples, the multiple candidate layout styles include the first layout style; wherein the calculating the comprehensive scores of the multiple candidate layout styles in step S103b includes: A1. Determine at least two layout indicators of a first layout style.

[0077] A2. Calculate a comprehensive score of the first layout style based on at least two layout indicators of the first layout style.

[0078] In some examples, determining at least two layout indicators of the first layout style in step A1 includes: A11. Determine at least two indicators of the first layout style: information density, aesthetic score, and information display weight.

[0079] Among them, information density is used to indicate the density of characters and words of each element in the first layout style on the display page where the first layout style is located; aesthetic score is used to indicate the aesthetics of the layout of each element in the first layout style; information display weight is used to indicate the importance of each element in the first layout style and the importance of the position of each element in the display page.

[0080] The elements are title, author, date, text and / or image.

[0081] In some examples, determining the information density of the first layout style includes:

[0082] The information density of the first layout style is determined according to the following formula:

[0083] ,

[0084] is the information density of the first layout style, is the total number of words, is the total number of characters, is the area of ​​the display page where the first layout style is located.

[0085] Determines the aesthetic score for the first layout style, including:

[0086] The aesthetic score of the first layout style is determined according to the following formula:

[0087] ,

[0088] in, is the aesthetic score of the first layout style, is the horizontal and vertical alignment of each element in the first layout style, for uniformity between elements in the first layout style, is the color contrast of adjacent elements in the first layout style, is the preset alignment weight, is the preset uniformity weight, The weight of the preset color contrast.

[0089] Alignment can be calculated by calculating the degree of alignment of elements in the horizontal and vertical directions. The higher the value, the better the alignment. The value of alignment can be between 0 and 1. If all elements are completely aligned, it is 1; if they are not aligned at all, it is 0; if they are partially aligned, it is a value greater than 0 and less than 1. For example, if the alignment ratio of each element is 50%, the alignment is 0.5; if the alignment ratio of each element is 70%, the alignment is 0.7.

[0090] The uniformity value calculates the standard deviation of the spacing between elements, with lower values ​​indicating better uniformity.

[0091] The value of color contrast can be used to calculate the contrast of adjacent element colors. A higher value indicates a stronger contrast. The contrast can be represented by the ratio of the pixel values ​​of adjacent element colors.

[0092] , and They represent the importance of alignment, uniformity, and color contrast respectively.

[0093] Determine the information display weight of the first layout style, including:

[0094] The information display weight of the first layout style is determined according to the following formula:

[0095] ,

[0096] in, The information display weight for the first layout style, is the total number of elements in the first layout style, is greater than or equal to 1 and less than or equal to integer, For the The importance weight of the element, For the The position weight of the element, For preset The weight of For preset The weight of .

[0097] For example, the importance of the title is greater than the importance of the author, and correspondingly, the importance weight of the title is greater than the importance weight of the author; the importance of the text is greater than the importance of other elements, and correspondingly, the importance weight of the text is greater than the importance weight of other elements. The importance weight of each element is determined according to the preset correspondence between the element and the importance weight.

[0098] The position weight is determined based on the visual priority. Specifically, the position weight of the title and the image is higher than the position weight of other elements. The importance weight of each element is determined based on the preset correspondence between the element and the position weight.

[0099] In some examples, calculating a comprehensive score of the first layout style based on at least two layout indicators of the first layout style includes:

[0100] The comprehensive score of the first layout style is calculated based on the following formula:

[0101] ,

[0102] is the comprehensive score of the first layout style, is the information density, is the aesthetic score, To display weight for information, For preset The weight of For preset The weight of For preset The weight of .

[0103] , and The value of can be determined based on the user's inherent attribute information. In a specific example, for older users, The value of is larger; for female users, younger users, etc., The value of is larger; for professionals, The value of is larger.

[0104] The personalized needs of users may change. To better meet the personalized needs of users, the layout style generation model may be continuously trained on the client. In some examples, after displaying the rich text file in the target layout style, the method of this embodiment further includes: S105: Obtaining user operation information on the rich text file.

[0105] When a user opens a rich text file and operates the rich text file, the user's operation information is collected.

[0106] S106. According to the inherent attribute information of the user, the operation information of the user on the rich text file, the feature information of the rich text file, and the target layout style, a preset layout style generation model is trained to obtain a trained layout style generation model.

[0107] The preset layout style generation model is trained using the inherent attribute information of the user who operates the rich text file, the user's operation information on the rich text file, the characteristic information of the rich text file operated by the user, and the target layout style used to display the rich text file, so as to adjust the weights in the preset layout style generation model and obtain the trained layout style generation model. The next time the user opens a rich text file, the trained layout style generation model can be used to determine the corresponding target layout style, and the rich text file can be displayed using the corresponding target layout style. When the user's personalized needs change, it will be reflected in the operation behavior of the rich text. In this way, when displaying rich text to the user, the model is continuously used, and then the model is continuously trained and learned. The model can learn the user's operation behavior, and then the target layout style for displaying rich text files generated by the model can adapt to the user's personalized needs.

[0108] After the client trains the preset layout style generation model, the weights in the trained layout style generation model are new weights, and the new weights are sent to the server, so that the server can globally optimize the model according to the new weights. In addition, the new weights are sent to the server. While the server uses the new weights for global optimization, the risk of leaking user information is avoided.

[0109] The solution of the present application is described in detail below with a specific embodiment.

[0110] Step 1: Quantify the beauty of the rich text layout style.

[0111] Study the problem of rich text layout style through examples: Suppose there is a mixed text and picture content, the title is 12 Chinese characters, the author and date are on the same line, the author is 3 Chinese characters, the date is yyyy-mm-dd, the text length is 587 Chinese characters, the picture height is 200, the width is 300, and the unit is pixels. Use TailwindCSS to control and optimize the style, and generate the corresponding skeleton diagram to preview the final article display effect.

[0112] <script>const title = "这是一个12字的标题";const author = "作者名";const date = "2024-06-07";const content = "这里是正文内容,共587个汉字。" + "这里是正文内容,共587个汉字。".repeat(29); / / 模拟587个汉字const imageUrl = "https: / / via.placeholder.com / 300x200"; / / 示例图片链接< / script> <!-- Article Title --> <h1 class="text-2xl font-bold mb-2"> {title}< / h1> <!-- Author and Date --> {author} {date} <!-- Picture --> <!-- Main Text Content --> {content} <style>.skeleton {background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%,rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);background-size: 200% 100%;animation: skeleton 1.5s infinite;}@keyframes skeleton {0% {background-position: 200% 0;}100% {background-position: -200% 0;}}< / style> <!-- Skeleton diagram --> By analyzing the rendering results, we can find that a good rich text includes the optimization of layout style and content.

[0113] Optimization of layout style should include: simplifying structure, color matching, fonts and layout, icons and pictures.

[0114] Among them, simplify the structure: divide the content into smaller sections or modules, and let each module focus on one topic. This will avoid information overload. Use color and spacing to distinguish different sections or modules.

[0115] Color matching: Use fewer colors and keep them consistent. Choose one main color and a few secondary colors. Use colors to distinguish different areas or themes instead of using multiple different colors, which can reduce visual fatigue.

[0116] Fonts and typography: Use consistent font styles and sizes. Different levels of content such as titles, body text, and notes can use different font sizes and styles, but keep them consistent. Increase line spacing and paragraph spacing to make the content easier to read.

[0117] Icons and images: Use icons to represent different modules or content to make it more intuitive. Make sure all icons and images are consistent in style to avoid confusion.

[0118] The content optimization part should include: clarifying the theme, reducing the amount of text, reducing the amount of text, highlighting key points, and visual hierarchy.

[0119] Among them, make sure each module or section has a clear title or theme. Make sure the content under each theme is relevant and logical.

[0120] Reduce the amount of text: Use clear and concise language and avoid lengthy sentences. Present information in bullet points or list format for quick scanning.

[0121] Highlight key points: Use bold, color, or other visual effects to highlight key points or important information.

[0122] Visual hierarchy: Use different font sizes, colors, icons, etc. to create visual hierarchy so that readers can grasp the key information at a glance.

[0123] In order to make the implementation simpler, we abstract the above content to a certain extent: information density, aesthetic score and information display weight. By defining whether the typesetting and layout style of rich text content is beautiful from these three dimensions, we can make subjective issues objective and use quantifiable indicators to examine and analyze the typesetting and layout style.

[0124] Step 2: Mathematical modeling of information density, aesthetic score, and information display weight

[0125] 1. Information density calculation

[0126] Information density can be quantified by counting the number of characters, words, pictures, etc. in each block element. The specific calculation formula is as follows:

[0127] ,

[0128] is the information density of the first layout style, is the total number of words, is the total number of characters, is the area of ​​the display page where the first layout style is located.

[0129] 2. Aesthetic score calculation

[0130] The aesthetic score can be calculated using the following formula, which takes into account factors such as element alignment, spacing, color contrast, etc.:

[0131] ,

[0132] in, is the aesthetic score of the first layout style, is the horizontal and vertical alignment of each element in the first layout style, for uniformity between elements in the first layout style, is the color contrast of adjacent elements in the first layout style, is the preset alignment weight, is the preset uniformity weight, The weight of the preset color contrast;

[0133] Alignment is obtained by calculating the degree of alignment of elements in the horizontal and vertical directions. The higher the alignment value, the better the alignment. Uniformity: calculates the standard deviation of the spacing between elements. The lower the value, the more uniform the spacing. Color contrast: calculates the contrast of the colors of adjacent elements. The higher the value, the stronger the contrast.

[0134] , and It can be adjusted according to actual needs.

[0135] 3. Information display weight calculation

[0136] Information display weight is calculated based on the importance of the element and its position on the page. The following formula can be used:

[0137] ,

[0138] in, The information display weight for the first layout style, is the total number of elements in the first layout style, is greater than or equal to 1 and less than or equal to integer, For the The importance weight of the element, For the The position weight of the element, For preset The weight of For preset The weight of .

[0139] 4. Comprehensive scoring formula

[0140] Taking into account information density, aesthetic score and information display weight, the following comprehensive optimization formula can be used:

[0141] ,

[0142] is the comprehensive score of the first layout style, is the information density, is the aesthetic score, To display weight for said information, For preset The weight of For preset The weight of For preset The weight of .

[0143] , and It is the weight used to adjust the proportion of information density, aesthetic density and information display weight in the comprehensive score.

[0144] The calculation of the comprehensive score is specifically described below with a specific embodiment.

[0145] Suppose there is a mixed text and image layout, including title, author and date, text and image, as follows:

[0146] Title: 12 Chinese characters

[0147] Author: 3 Chinese characters

[0148] Date: yyyy-mm-dd (10 characters)

[0149] Text: 587 Chinese characters

[0150] Image: 300px width, 200px height

[0151] 1. Information density calculation:

[0152] (date characters are not taken into account)

[0153]

[0154] Image area + text area

[0155] So the information density

[0156] 2. Aesthetic score calculation

[0157] Alignment: Assume alignment is 0.8; Spacing uniformity: Assume spacing uniformity is 0.7; Color contrast: Assume color contrast is 0.9. Assume the weight of alignment is 0.4, the weight of uniformity is 0.3, and the weight of color contrast is 0.3.

[0158] Aesthetic score

[0159] 3. Calculation of information display weight

[0160] Assume that the importance weights of title, author, date, text and image are 0.3, 0.1, 0.1, 0.4, 0.1 respectively. The position weights are assumed to be 0.4, 0.1, 0.1, 0.3, 0.1 respectively according to visual priority.

[0161] Information display weight

[0162] 4. Calculation of comprehensive score

[0163] Assumptions =0.5, =0.3, =0.2.

[0164] Overall Rating .

[0165] Through this model, we can quantify the comprehensive score of the mixed text and image layout to help optimize the information density, aesthetic score and information display weight. This model can further adjust the weight coefficient and calculation formula to better adapt to specific application scenarios and needs.

[0166] Step 3: Model Design In order to design an ONNX-based end-side training model for performing a posteriori machine learning based on user ratings and understanding the user's personalized layout style preferences, the model building includes the following steps: 1. Model Architecture The model consists of an input layer, a hidden layer, and an output layer Among them, the input layer is used to input context features, which include the type of content, user's historical preferences, etc.

[0167] The hidden layer package includes convolutional layers (Conv Layers) and fully connected layers (Fully Connected Layers).

[0168] The convolutional layer is used to process image features if the image part of the mixed image and text needs to be considered.

[0169] Fully connected layers are used to process all layout and context features.

[0170] The output layer is used for layout style prediction.

[0171] 2. Data Collection Layout style data: Collect feature data of different layout styles.

[0172] User contextual data: Collects the user's inherent attributes, preferences, and historical data.

[0173] 3. Feature extraction Layout features: Extract numerical representations of various layout attributes, such as the RGB value of color, the numerical value of font size, etc.

[0174] Contextual features: Extract user’s inherent attributes, preferences, and historical data and represent them numerically.

[0175] 4. Data preprocessing Normalization: Normalize numerical features.

[0176] Categorical encoding: One-Hot Encoding or Label Encoding is performed on categorical features.

[0177] 5. Model training Initial training: Perform initial training on the server to generate initial model weights.

[0178] 6. Display rich text based on the model on the client side The model is deployed to the user's device, and the target layout style is generated according to the user's inherent attribute information, the user's operation information on the rich text, the feature information of the rich text, and the deployed model. The target layout style is used to display the rich text that the user wants to open.

[0179] 7. Incremental learning (training) of the model on the client side The user's operation information on the rich text displayed in step 6, the user's inherent attribute information, and the current layout style are collected, and the model is trained to obtain a trained model.

[0180] During the client-side training process, you can use mini-batch SGD or other optimization algorithms to update the model weights based on the newly collected data.

[0181] Later, when users need to open rich text, they can use the trained model to predict the target layout style and display the rich text file.

[0182] 8. Model Update The weights in the updated model are periodically synchronized back to the server for global optimization.

[0183] Step 4: Implementation details 1. Feature processing (using PyTorch examples) import torch import torch.nn as nn import torch.optim as optim from torch.utils.data import Dataset, DataLoader Modular feature processor class FeatureProcessor: def __init__(self): self.embeddings = nn.ModuleDict({ 'user_identity': nn.Embedding(num_embeddings=100, embedding_dim=10), 'time_of_day': nn.Embedding(num_embeddings=24, embedding_dim=5), 'location': nn.Embedding(num_embeddings=50, embedding_dim=8), 'device_type': nn.Embedding(num_embeddings=10, embedding_dim=3), # Add Embeddings for other categorical features... }) def process(self, features): processed_features = [] for feature_name, feature_value in features.items(): if feature_name in self.embeddings: embedded_feature = self.embeddings[feature_name](torch.tensor([feature_value processed_features.append(embedded_feature.squeeze(0)) else: processed_features.append(torch.tensor([feature_value], dtype=torch.float32 return torch.cat(processed_features) # Create a sample dataset class LayoutDataset(Dataset): def __init__(self, data, feature_processor): self.data = data self.feature_processor = feature_processor def __len__(self): return len(self.data) def __getitem__(self, idx): features = self.data[idx]['features'] label = self.data[idx]['label'] processed_features = self.feature_processor.process(features) return processed_features, torch.tensor(label, dtype=torch.float32) # Example data data = [ {'features': {'user_identity': 5, 'time_of_day': 14, 'location': 3, 'device_type': 1, 'font_size' : 2 {'features': {'user_identity': 7, 'time_of_day': 20, 'location': 5, 'device_type': 2, 'font_size' : 2 # More data... ] # Create feature processors and datasets feature_processor = FeatureProcessor() dataset = LayoutDataset(data, feature_processor) dataloader = DataLoader(dataset, batch_size=2, shuffle=True) # View the processed feature examples for features, label in dataloader: print('Processed Features:') print(features) print('Labels:') print(label) break # Print only one batch of examples 2. Model Definition # Define the attention mechanism class Attention(nn.Module): def __init__(self, input_dim): super(Attention, self).__init__() self.input_dim = input_dim self.attention_weights = nn.Parameter(torch.randn(input_dim)) def forward(self, x): attention_scores = torch.matmul(x, self.attention_weights) # Ensure attention_scores has correct shape: (batch_size, num_features) attention_weights = torch.softmax(attention_scores, dim=-1) # softmax along the last dimension # Expand attention_weights to match the last dimension of x attention_weights = attention_weights.unsqueeze(-1) # Multiply x by attention_weights element-wise x = x * attention_weights return x # Define the layout preference model class LayoutPreferenceModel(nn.Module): def __init__(self, input_dim): super(LayoutPreferenceModel, self).__init__() It should be noted that in line 28, the original `x × attention_weights` is likely a multiplication operation in the original code's tensor operation style, which is translated as `x * attention_weights` in Python's `torch` library. Also, the 7-digit tags ` ` etc. are preserved as they are as per the requirement. self.fc1 = nn.Linear(input_dim, 128) self.fc2 = nn.Linear(128, 64) self.fc3 = nn.Linear(64, 1) self.attention = Attention(input_dim) def forward(self, x): x = self.attention(x) x = torch.relu(self.fc1(x)) x = torch.relu(self.fc2(x)) x = self.fc3(x) return x # Initialize the model input_dim = sum(embedding.embedding_dim for embedding in feature_processor. embeddings.valus. model = LayoutPreferenceModel(input_dim) # Define loss function and optimizer criterion = nn.MSELoss() optimizer = optim.Adam(model.parameters(), lr=0.001) 3. Model training # Example training process def train(model, dataloader, criterion, optimizer, num_epochs=100): model.train() for epoch in range(num_epochs): for batch in dataloader: features, label = batch[0], batch[1] # Assume that each batch is a list, the first element is the feature and the second element is the style optimizer.zero_grad() outputs = model(features) outputs = outputs.squeeze() # Remove extra dimensions to ensure matching with label shape loss = criterion(outputs, label) loss.backward() optimizer.step() if (epoch + 1) % 10 == 0: print(f'Epoch [{epoch + 1} / {num_epochs}], Loss: {loss.item():.4f}') # Start training train(model, dataloader, criterion, optimizer) 4. Export ONNX model import onnx import onnxruntime as ort # Export the model to ONNX format dummy_input = torch.randn(1, input_dim) torch.onnx.export(model, dummy_input, "layout.onnx", # Output file path verbose=True, # Whether to print detailed information input_names=['input'], # Input name, usually input output_names=['output']) # Output name, usually output 5. Incremental learning on the client side (using ONNX Runtime) import numpy as np # Step 2: Incremental learning using ONNX Runtime # Load ONNX model for incremental learning def incremental_train_onnx(model_path, updated_data, feature_processor): # Load the original ONNX model original_model = onnx.load(model_path) # Create updated model file name updated_model_path = "layout.onnx" # Prepare data features = [feature_processor.process(data['features']) for data inupdated_data] labels = [data['label'] for data in updated_data] # Perform incremental learning on the client side to update the model weights for features_batch, label in zip(features, labels): ort_inputs = {original_model.graph.input[0].name: features_batch.unsqueeze(0).detach ort_labels = np.array([label], dtype=np.float32) # Create ONNX SessionOptions options = ort.SessionOptions() options.log_severity_level = 3 # Set detailed log level # Load the updated model ort_session = ort.InferenceSession(updated_model_path, options) # Train the model ort_outputs = ort_session.run(None, ort_inputs) # Calculate the loss (this can be modified as needed, here it is simplified to the MSE loss of a single sample) loss = np.mean(np.square(ort_outputs[0] - ort_labels)) # Print training log print(f'Loss: {loss:.4f}') # Save the updated model (this step is optional) onnx.save_model(original_model, updated_model_path) print(f"Updated model saved to {updated_model_path}") # Create feature processor feature_processor = FeatureProcessor() # New data example updated_data = [ {'features': {'user_identity': 8, 'time_of_day': 10, 'location': 1, 'device_type': 3, 'font_size' : 2 # More new data... ] # Start incremental learning incremental_train_onnx("layout.onnx", updated_data, feature_processor) So far, this solution implements an ONNX-based end-side training model for a posteriori machine learning based on user ratings to understand the user's personalized layout style preferences. This method can not only improve the personalization and accuracy of the model, but also reduce the burden on the server through end-side training, and achieve more efficient model updates and deployment. Although, due to time constraints, this is just a sample code, I have tested the code on my local machine, and the framework and logic should be correct.

[0184] Figure 2A schematic diagram of the structure of a rich text display device provided in an embodiment of the present application, such as Figure 2 As shown, the rich text display device of this embodiment includes: a receiving module 11, used to receive an opening instruction from a user to open a rich text file; an acquisition module 12, used to obtain the characteristic information of the user and the characteristic information of the historical rich text files in response to the opening instruction; a determination module 13, used to determine the target layout style according to a preset layout style generation model, the characteristic information of the user and the characteristic information of the historical rich text files; a display module 14, used to display the rich text file in the target layout style.

[0185] The device of this embodiment can be used to perform Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.

[0186] The device of this embodiment, in response to a user's opening instruction to open a rich text file, obtains the user's characteristic information and the characteristic information of historical rich text files, determines the target layout style according to a preset layout style generation model, the user's characteristic information and the characteristic information of historical rich text files, and displays the rich text file in the target layout style. The target layout style is determined using the preset layout style generation model, the user's characteristic information and the characteristic information of historical rich text files. That is, when determining the target layout style, the user's characteristic information and the characteristic information of rich text files historically operated by the user are combined. In this way, the rich text file displayed in the target layout style can better meet the user's personalized needs and improve the user experience.

[0187] As an optional implementation, the determination module includes: a production submodule, used to generate multiple candidate layout styles based on a preset layout style generation model, the user's characteristic information and the characteristic information of the historical rich text file; a calculation submodule, used to respectively calculate the comprehensive scores of the multiple candidate layout styles; and a determination submodule, used to determine the alternative layout style corresponding to the highest comprehensive score among the multiple comprehensive scores as the target layout style.

[0188] As an optional implementation, the multiple alternative layout styles include a first layout style; wherein the calculation submodule includes: a determination unit, used to determine at least two layout indicators of the first layout style; and a calculation unit, used to calculate a comprehensive score of the first layout style based on the at least two layout indicators of the first layout style.

[0189] As an optional implementation, the determination unit includes: a determination subunit, used to determine at least two indicators of the first layout style's information density, aesthetic score, and information display weight; wherein the information density is used to indicate the density of characters and words of each element in the first layout style on a display page where the first layout style is located; the aesthetic score is used to indicate the aesthetics of the layout of each element in the first layout style; and the information display weight is used to indicate the importance of each element in the first layout style and the importance of the position of each element in the display page.

[0190] As an optional implementation manner, the determining subunit is specifically used for:

[0191] The information density of the first layout style is determined according to the following formula:

[0192] ,

[0193] is the information density of the first layout style, is the total number of words, is the total number of characters, is the area of ​​the display page where the first layout style is located;

[0194] The determining subunit is specifically used for:

[0195] The aesthetic score of the first layout style is determined according to the following formula:

[0196] ,

[0197] in, is the aesthetic score of the first layout style, is the horizontal and vertical alignment of each element in the first layout style, for uniformity between elements in the first layout style, is the color contrast of adjacent elements in the first layout style, is the preset alignment weight, is the preset uniformity weight, The weight of the preset color contrast;

[0198] The determining subunit is further specifically used for:

[0199] The information display weight of the first layout style is determined according to the following formula:

[0200] ,

[0201] in, The information display weight for the first layout style, is the total number of elements in the first layout style, is greater than or equal to 1 and less than or equal to integer, For the The importance weight of the element, For the The position weight of the element, For preset The weight of For preset The weight of .

[0202] As an optional implementation manner, the computing unit is specifically configured to:

[0203] The comprehensive score of the first layout style is calculated based on the following formula:

[0204] ,

[0205] is the comprehensive score of the first layout style, is the information density, is the aesthetic score, To display weight for said information, For preset The weight of For preset The weight of For preset The weight of .

[0206] As an optional implementation manner, the user's characteristic information includes the user's inherent attribute information and the user's operation information on historical rich text files.

[0207] As an optional implementation, the inherent attribute information of the user includes the user's age, gender, occupation and / or region; the user's operation information on historical rich text files includes the user's click operations, browsing time and / or browsing depth on historical rich text files; the characteristic information of historical rich text files includes the content and / or type of historical rich text files.

[0208] As an optional implementation, the device is also used to: obtain the user's operation information on the rich text file after the display module displays the rich text file in the target layout style; train the preset layout style generation model according to the user's inherent attribute information, the user's operation information on the rich text file, the feature information of the rich text file, and the target layout style to obtain a trained layout style generation model.

[0209] The device of the above embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.

[0210] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, it may include: a shell 61, a processor 62, a memory 63, a circuit board 64 and a power supply circuit 65, wherein the circuit board 64 is arranged inside the space enclosed by the shell 61, and the processor 62 and the memory 63 are arranged on the circuit board 64; the power supply circuit 65 is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory 63 is used to store executable program codes; the processor 62 runs the program corresponding to the executable program code by reading the executable program code stored in the memory 63, so as to execute any one of the rich text file display methods provided in the aforementioned embodiments, and thus can also achieve corresponding beneficial technical effects, which have been described in detail in the previous text and will not be repeated here.

[0211] The above electronic devices exist in many forms, including but not limited to: (1) Mobile communication devices: These devices are characterized by their mobile communication functions and their main purpose is to provide voice and data communications. These terminals include: smart phones (such as iPhone), multimedia phones, feature phones, and low-end phones.

[0212] (2) Ultra-mobile personal computer devices: These devices fall into the category of personal computers and have computing and processing capabilities, and generally also have mobile Internet access features. These terminals include: PDAs, MIDs, and UMPC devices, such as the iPad.

[0213] (3) Portable entertainment devices: These devices can display and play multimedia content. They include audio and video players (such as iPods), handheld game consoles, e-books, as well as smart toys and portable car navigation devices.

[0214] (4) Server: A device that provides computing services. The server consists of a processor, hard disk, memory, system bus, etc. The server is similar to a general-purpose computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.

[0215] (5) Other electronic devices with data interaction functions.

[0216] Correspondingly, an embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement any rich text file display method provided by the aforementioned embodiments, thereby also being able to achieve the corresponding technical effects, which have been described in detail above and will not be repeated here.

[0217] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0218] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0219] In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0220] For the convenience of description, the above device is described by dividing the functions into various units / modules. Of course, when implementing the present application, the functions of each unit / module can be implemented in the same or multiple software and / or hardware.

[0221] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0222] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A rich text file display method, characterized in that: Applied to the client, including: Receive an opening instruction from a user to open a rich text file; In response to the opening instruction, acquiring characteristic information of the user and characteristic information of the historical rich text file; Determine a target layout style according to a preset layout style generation model, characteristic information of the user, and characteristic information of the historical rich text file; The rich text file is displayed in the target layout style.

2. The method according to claim 1, characterized in that The step of generating a target layout style according to a preset layout style generation model, the characteristic information of the user, and the characteristic information of the historical rich text file comprises: Generate a plurality of candidate layout styles according to a preset layout style generation model, characteristic information of the user, and characteristic information of the historical rich text file; Calculating comprehensive scores of the multiple candidate layout styles respectively; The candidate layout style corresponding to the highest comprehensive score among the multiple comprehensive scores is determined as the target layout style.

3. The method according to claim 2, characterized in that The plurality of candidate layout styles include a first layout style; The step of calculating the comprehensive scores of the multiple candidate layout styles includes: Determining at least two layout indicators of a first layout style; Based on the at least two layout indicators of the first layout style, a comprehensive score of the first layout style is calculated.

4. The method according to claim 3, characterized in that The at least two layout indicators of the first layout style are determined, including: Determine at least two indicators of the first layout style: information density, aesthetic score, and information display weight; The information density is used to indicate the density of characters and words of each element in the first layout style on the display page where the first layout style is located; The aesthetic score is used to indicate the aesthetic level of the layout of each element in the first layout style; The information display weight is used to indicate the importance of each element in the first layout style and the importance of the position of each element in the display page.

5. The method according to claim 4, characterized in that Determine the information density of the first layout style, including: The information density of the first layout style is determined according to the following formula: , is the information density of the first layout style, is the total number of words, is the total number of characters, is the area of ​​the display page where the first layout style is located; Determines the aesthetic score for the first layout style, including: The aesthetic score of the first layout style is determined according to the following formula: , in, is the aesthetic score of the first layout style, is the horizontal and vertical alignment of each element in the first layout style, for uniformity between elements in the first layout style, is the color contrast of adjacent elements in the first layout style, is the preset alignment weight, is the preset uniformity weight, The weight of the preset color contrast; Determine the information display weight of the first layout style, including: The information display weight of the first layout style is determined according to the following formula: , in, The information display weight for the first layout style, is the total number of elements in the first layout style, is greater than or equal to 1 and less than or equal to integer, For the The importance weight of the element, For the The position weight of the element, For preset The weight of For preset The weight of .

6. The method according to claim 5, characterized in that The calculating a comprehensive score of the first layout style based on the at least two layout indicators of the first layout style includes: The comprehensive score of the first layout style is calculated based on the following formula: , is the comprehensive score of the first layout style, is the information density, is the aesthetic score, To display weight for said information, For preset The weight of For preset The weight of For preset The weight of .

7. The method according to claim 1, characterized in that The user's characteristic information includes the user's inherent attribute information and the user's operation information on historical rich text files.

8. The method according to claim 7, characterized in that The inherent attribute information of the user includes the user's age, gender, occupation and / or region; the user's operation information on historical rich text files includes the user's click operations, browsing time and / or browsing depth on historical rich text files; the characteristic information of historical rich text files includes the content and / or type of historical rich text files.

9. The method according to claim 7, characterized in that: After presenting the rich text file in the target layout style, the method further includes: Obtaining operation information of the user on the rich text file; The preset layout style generation model is trained according to the inherent attribute information of the user, the operation information of the user on the rich text file, the feature information of the rich text file, and the target layout style to obtain a trained layout style generation model.

10. A rich text display device, characterized in that: Applied to the client, including: A receiving module, used for receiving an opening instruction from a user to open a rich text file; An acquisition module, configured to acquire characteristic information of the user and characteristic information of the historical rich text file in response to the opening instruction; A determination module, used to determine a target layout style according to a preset layout style generation model, characteristic information of the user, and characteristic information of the historical rich text file; A display module is used to display the rich text file in the target layout style.

Citation Information

Cited By

  • Method for replacing business card style based on information synchronization and electronic equipment

    CN120409451A