Website article typesetting and layout method and device and medium

By combining natural language processing and machine learning technology, automatically selecting and filling the layout templates, the problem of difficult to ensure the time and quality of manual layout is solved, and efficient and beautiful article layout is achieved.

CN119623445AInactive Publication Date: 2025-03-14ANRUI DIGITAL INFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411626528.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2025-03-14
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, article layout is manual, time-consuming and labor-intensive, and aesthetics and accuracy are difficult to guarantee.

Method used

The pre-trained BERT model is used for text analysis, and the layout template is selected in combination with the neural network model, and the content is automatically filled through Jinja2 template engine technology, and finally converted to rich text format through Web technology.

Benefits of technology

It realizes automatic layout of articles, greatly improves layout efficiency, saves labor costs, and ensures the aesthetics and accuracy of layout.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119623445A_ABST
    Figure CN119623445A_ABST
Patent Text Reader

Abstract

The invention discloses a typesetting and layout method and device for website articles and a medium. The method comprises the following steps: performing text extraction and format extraction on a website article to be typeset, and determining text information and format information of the website article to be typeset; performing text analysis on the text information by adopting a pre-trained BERT model to obtain feature information of the text information; performing template selection on the to-be-typeset website article according to the feature information and the format information by utilizing a neural network model, and determining a typesetting template of the to-be-typeset website article; filling the text information into a typesetting template by adopting a Jinja2 template engine technology to generate an initial typesetting website article; and converting the typesetting website article into a rich text format through a web technology, generating a final typesetting website article, and copying the final typesetting website article to a to-be-arranged website background for publishing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of article typesetting and layout, and more specifically, to a typesetting and layout method, device and medium for website articles. Background Art

[0002] At present, more and more articles are displayed on different websites, but different websites have different article layouts. Currently, article layout is done manually through the rich text of the system background. Employees need to adjust the format little by little. In addition, there are many articles and they are long, which takes a long time and seriously wastes manpower costs. In addition, manual layout may not be beautiful and the content may not be accurate. Summary of the invention

[0003] In view of the deficiencies in the prior art, the present invention provides a method, device and medium for typesetting and laying out website articles.

[0004] According to one aspect of the present invention, a method for typesetting and laying out a website article is provided, comprising:

[0005] Extract text and format of the website articles to be typeset, and determine the text information and format information of the website articles to be typeset;

[0006] Use the pre-trained BERT model to perform text analysis on text information and obtain feature information of the text information;

[0007] Using a neural network model to select a template for the website article to be typeset based on feature information and format information, and determine the typeset template for the website article to be typeset;

[0008] Use Jinja2 template engine technology to fill text information into the typesetting template to generate the initial typesetting website article;

[0009] Convert the typeset website articles into rich text format through web technology, generate the final typeset website articles, and copy the final typeset website articles to the backend of the website to be arranged for publishing.

[0010] Optionally, text extraction and format extraction are performed on the website article to be typeset to determine the text information and format information of the website article to be typeset, including:

[0011] An intelligent document parsing library is used to interpret and extract data from website articles to be typeset, and to determine the text information and format information of the website articles to be typeset, wherein the format information includes font, size, color, and paragraph style.

[0012] Optionally, a neural network model is used to select a template for the website article to be typeset according to the feature information and the format information to determine the typeset template of the website article to be typeset, including:

[0013] Use the labeled article-template pairing sample set to train a convolutional neural network or a recurrent neural network, and optimize the model parameters by minimizing the difference between the predicted template and the actual template to generate a neural network model;

[0014] A neural network model is used to select a template for the website article to be typeset according to feature information and format information, and to determine the typeset template for the website article to be typeset.

[0015] Optionally, Jinja2 template engine technology is used to fill text information into the typesetting template to generate an initial typesetting website article, including:

[0016] Design Jinja2 templates for standalone files or strings;

[0017] Use the Template environment class provided by Jinja2 to create a template environment for the Jinja2 template;

[0018] Use the template environment to load the Jinja2 template and compile the Jinja2 template into an executable template object;

[0019] Match the variables in the text information with the placeholders in the Jinja2 template, define global variables and local variables based on the matching results, pass the variables in the text information to the Jinja2 template, and generate template variables;

[0020] Use the template object to fill the template variables into the layout template to generate the initial layout website article.

[0021] According to another aspect of the present invention, there is provided a device for typesetting and laying out a website article, comprising:

[0022] An extraction module is used to extract text and format of the website article to be typeset, and determine the text information and format information of the website article to be typeset;

[0023] An analysis module is used to perform text analysis on text information using a pre-trained BERT model to obtain feature information of the text information;

[0024] A selection module is used to select a template for the website article to be typeset based on feature information and format information using a neural network model, and determine a typeset template for the website article to be typeset;

[0025] Filling module, used to fill text information into the typesetting template using Jinja2 template engine technology to generate the initial typesetting website article;

[0026] The generation module is used to convert the typeset website articles into rich text format through web technology, generate the final typeset website articles, and copy the final typeset website articles to the backend of the website to be arranged for publication.

[0027] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the method described in any one of the above aspects of the present invention.

[0028] According to another aspect of the present invention, an electronic device is provided, comprising: a processor; a memory for storing instructions executable by the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the method described in any one of the above aspects of the present invention.

[0029] Therefore, the present invention combines natural language processing, machine learning, automation technology and advanced template engine technology Jinja2 to realize automatic typesetting of articles, which can greatly improve the efficiency of employees' article typesetting. The original cumbersome typesetting work is directly achieved through the automated process, which not only saves labor costs but also ensures the beauty and quality of typesetting. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] A more complete understanding of exemplary embodiments of the present invention may be obtained by referring to the following drawings:

[0031] Figure 1 It is a flow chart of a method for typesetting and laying out a website article provided by an exemplary embodiment of the present invention;

[0032] Figure 2 It is a structural schematic diagram of a typesetting layout device for website articles provided by an exemplary embodiment of the present invention;

[0033] Figure 3 This is a structure of an electronic device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0034] Below, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described here.

[0035] It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.

[0036] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present invention are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.

[0037] It should also be understood that, in the embodiments of the present invention, “plurality” may refer to two or more than two, and “at least one” may refer to one, two or more than two.

[0038] It should also be understood that any component, data or structure mentioned in the embodiments of the present invention can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.

[0039] In addition, the term "and / or" in the present invention is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects before and after are in an "or" relationship.

[0040] It should also be understood that the description of the various embodiments of the present invention focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.

[0041] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0042] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.

[0043] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.

[0044] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0045] Embodiments of the present invention can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.

[0046] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.

[0047] Exemplary Methods

[0048] Figure 1 FIG. 1 is a flow chart of a method for typesetting and laying out a website article provided by an exemplary embodiment of the present invention. This embodiment can be applied to electronic devices, such as Figure 1 As shown, the layout method 100 for website articles includes the following steps:

[0049] Step 101, extracting text and format of the website article to be typeset, and determining text information and format information of the website article to be typeset;

[0050] Step 102, using a pre-trained BERT model to perform text analysis on the text information to obtain feature information of the text information;

[0051] Step 103, using a neural network model to select a template for the website article to be typeset according to feature information and format information, and determining a typeset template for the website article to be typeset;

[0052] Step 104, using Jinja2 template engine technology to fill the text information into the layout template to generate an initial layout website article;

[0053] Step 105, converting the layout website article into a rich text format through web technology to generate a final layout website article, and copying the final layout website article to the backend of the website to be arranged for publishing.

[0054] Specifically, the present invention realizes automatic typesetting of articles by combining natural language processing, machine learning, automation technology and advanced template engine technology Jinja2. The present invention can intelligently select the most suitable template for typesetting according to the content and format of the article, rather than simply copying and pasting the format and content. Specific implementation steps:

[0055] 1. First, extract text and format: Use the intelligent document parsing library python-docx to interpret the document and extract data. This library can accurately extract text and its related format attributes from Word documents, such as font, size, color, paragraph style, etc. This automated process reduces manual errors and greatly improves processing efficiency.

[0056] 2. After the extraction is completed, text analysis will be performed: After obtaining the text data, the advanced natural language processing (NLP) technology - deep learning model BERT is used to deeply analyze and understand the content of the article. This technology can extract deep features from the article, such as themes, emotions, keywords, etc., which are difficult to achieve with traditional methods.

[0057] The specific algorithm innovations are as follows: 1) Use the Transformer model as the language model, capture the long-distance dependencies in the text through the self-attention mechanism, and improve the ability to capture grammatical structure and semantic information; 2) Use the pre-trained BERT model for semantic role labeling and entity recognition, and use its language representation learned on large-scale text data to improve the understanding of entities and relationships; 3) Based on the generative model of variational autoencoder (VAE), it automatically generates text content that meets the requirements according to the typesetting requirements, thereby improving the personalization of automatic article typesetting.

[0058] 3. Then, the program will select the template: according to the feature data and format of the article content, the machine learning algorithm - neural network (NN) is used to automatically select the most suitable template. The innovation in this process is to transform the template selection problem into a machine learning problem, making the template selection more intelligent and accurate.

[0059] The specific algorithm innovations are as follows: 1) Neural network model design: The innovative algorithm uses a neural network model for template selection. Structures such as convolutional neural networks (CNN) or recurrent neural networks (RNN) can be used to learn the complex relationship between article features and template selection; 2) Training process: Use labeled article-template pairing samples to train the neural network model. The model parameters are optimized by minimizing the difference between the predicted template and the actual template. This training process enables the model to accurately predict the most appropriate template; 3) Template selection: The trained neural network model can infer the characteristics of new unknown articles and automatically select the most appropriate template. The model can accurately match the appropriate template based on the content characteristics of the article.

[0060] 4. Next, the template will be filled: the template engine technology - Jinja2 will be used to automatically fill the article content into the selected template. This step uses advanced template language and engine, which can automatically complete the layout according to the preset rules and styles, greatly improving efficiency.

[0061] Template engine technology - Jinja2 method steps are as follows:

[0062] 1) Define a template: First, you need to define a Jinja2 template, which can be a separate file or a string. The template uses specific tags and syntax to identify replaceable parts and logical structures.

[0063] 2) Create a template environment: Use the Template environment class provided by Jinja2 to create a template environment instance. The template environment is a container that contains all template-related configurations and is used to manage template loading, caching, filters, global variables, etc.

[0064] 3) Load template: Use the template environment to load a template file or string and compile it into an executable template object. When loading a template, you can specify the path or name of the template.

[0065] 4) Define template variables: During the filling process, you need to match the variables in the article data with the placeholders in the template. Pass the variables of the article data to the template by defining global variables or local variables in the template environment.

[0066] 5) Fill the template: Use the render method of the template object to fill the article data into the placeholder position in the template. In the template, you can use double curly braces "{{}}" to identify the position of the variable, such as {{title}}, {{content}}.

[0067] 6) Apply filters: Jinja2 also supports the application of filters to format or convert variables. By using the vertical bar "|" and the filter name syntax after the variable, a series of operations can be performed on the variable, such as {{title|capitalize}} to capitalize the first letter of the title.

[0068] 7) Control structure: Jinja2 also supports some control structures, such as conditional statements, loop statements, etc., which are used to perform certain operations according to different conditions or repeatedly. By using specific control structure tags, such as {% if %}, {% for %}, etc., more complex logic control can be implemented in the template.

[0069] 8) Rendering the template: Finally, use the render method of the template object to render the template filled with data. The template engine will generate the final layout result based on the instructions in the template and the data filled in.

[0070] 5. Finally, generate rich text: Use Web technology to convert the filled template into rich text format HTML. Employees can then directly copy the rich text content to the system background to complete the article layout.

[0071] Therefore, the present invention combines natural language processing, machine learning, automation technology and advanced template engine technology Jinja2 to realize automatic typesetting of articles, which can greatly improve the efficiency of employees' article typesetting. The original cumbersome typesetting work is directly achieved through the automated process, which not only saves labor costs but also ensures the beauty and quality of typesetting.

[0072] Exemplary Devices

[0073] Figure 2 FIG. 1 is a schematic diagram of a layout device for website articles provided by an exemplary embodiment of the present invention. Figure 3 As shown, the device 300 includes:

[0074] An extraction module 210 is used to extract text and format of the website article to be typeset, and determine the text information and format information of the website article to be typeset;

[0075] An analysis module 220 is used to perform text analysis on the text information using a pre-trained BERT model to obtain feature information of the text information;

[0076] A selection module 230 is used to select a template for the website article to be typeset according to the feature information and the format information using a neural network model, and determine a typeset template for the website article to be typeset;

[0077] A filling module 240 is used to fill the text information into the typesetting template using Jinja2 template engine technology to generate an initial typesetting website article;

[0078] The generation module 250 is used to convert the typesetting website article into a rich text format through web technology, generate a final typesetting website article, and copy the final typesetting website article to the backend of the website to be arranged for publication.

[0079] Optionally, the extraction module 210 includes:

[0080] The extraction submodule is used to interpret and extract data from the website article to be typeset using an intelligent document parsing library, and determine the text information and format information of the website article to be typeset, wherein the format information includes font, size, color and paragraph style.

[0081] Optionally, the selection module 230 includes:

[0082] A training submodule, for training a convolutional neural network or a recurrent neural network using a labeled article-template pairing sample set, and optimizing model parameters by minimizing the difference between the predicted template and the actual template to generate the neural network model;

[0083] The selection submodule is used to use the neural network model to select a template for the website article to be typeset according to the feature information and the format information, and determine the typeset template of the network article to be typeset.

[0084] Optionally, the filling module 240 includes:

[0085] Design submodules for designing Jinja2 templates for independent files or strings;

[0086] Create a submodule for creating a template environment of the Jinja2 template using the Template environment class provided by Jinja2;

[0087] A compiling submodule, used to load the Jinja2 template using the template environment and compile the Jinja2 template into an executable template object;

[0088] A matching submodule, used for matching the variables in the text information with the placeholders in the Jinja2 template, defining global variables and local variables according to the matching results, passing the variables in the text information to the Jinja2 template, and generating template variables;

[0089] The filling submodule is used to use the template object to fill the template variables into the typesetting template to generate the initial typesetting website article.

[0090] Exemplary Electronic Devices

[0091] Figure 3 This is a structure of an electronic device provided by an exemplary embodiment of the present invention. Figure 3 As shown, the electronic device 30 includes one or more processors 31 and a memory 32 .

[0092] The processor 31 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.

[0093] The memory 32 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 31 may run the program instructions to implement the methods of the software programs of the various embodiments of the present invention described above and / or other desired functions. In one example, the electronic device may also include: an input device 33 and an output device 34, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown).

[0094] In addition, the input device 33 may also include, for example, a keyboard, a mouse, and the like.

[0095] The output device 34 can output various information to the outside. The output device 34 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto.

[0096] Of course, to simplify, Figure 3 Only some of the components related to the present invention in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application conditions, the electronic device may also include any other appropriate components.

[0097] Exemplary computer program products and computer-readable storage media

[0098] In addition to the above-mentioned methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the method according to various embodiments of the present invention described in the above-mentioned "Exemplary Method" section of this specification.

[0099] The computer program product may be written in any combination of one or more programming languages ​​to write program code for performing the operations of the embodiments of the present invention, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0100] In addition, an embodiment of the present invention may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enables the processor to execute the steps of the method for information mining of historical change records according to various embodiments of the present invention described in the above “Exemplary Method” section of this specification.

[0101] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, system or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0102] The basic principle of the present invention is described above in conjunction with specific embodiments. However, it should be pointed out that the advantages, strengths, effects, etc. mentioned in the present invention are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. must be possessed by each embodiment of the present invention. In addition, the specific details disclosed above are only for the purpose of illustration and facilitation of understanding, rather than limitation, and the above details do not limit the present invention to being implemented by adopting the above specific details.

[0103] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0104] The block diagrams of the devices, systems, equipment, and systems involved in the present invention are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, systems, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The word "such as" used here refers to the phrase "such as but not limited to", and can be used interchangeably with it.

[0105] The method and system of the present invention may be implemented in many ways. For example, the method and system of the present invention may be implemented by software, hardware, firmware or any combination of software, hardware, firmware. The above order of steps for the method is only for illustration, and the steps of the method of the present invention are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present invention may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.

[0106] It should also be noted that in the system, device and method of the present invention, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. The above description of the disclosed aspects is provided to enable any technician in the field to make or use the present invention. Various modifications to these aspects are very obvious to those skilled in the art, and the general principles defined here can be applied to other aspects without departing from the scope of the present invention. Therefore, the present invention is not intended to be limited to the aspects shown here, but in accordance with the widest range consistent with the principles and novel features disclosed here.

[0107] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present invention to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. A layout method for website articles, characterized in that: include: Perform text extraction and format extraction on the website article to be typeset, and determine the text information and format information of the website article to be typeset; Using a pre-trained BERT model to perform text analysis on the text information to obtain feature information of the text information; Using a neural network model to select a template for the website article to be typeset according to the feature information and the format information, and determining a typeset template for the website article to be typeset; Using Jinja2 template engine technology to fill the text information into the typesetting template to generate an initial typesetting website article; The typeset website article is converted into a rich text format through web technology to generate a final typeset website article, and the final typeset website article is copied to the backend of the website to be arranged for publication.

2. The method according to claim 1, characterized in that Performing text extraction and format extraction on the website article to be typeset to determine the text information and format information of the website article to be typeset includes: An intelligent document parsing library is used to interpret and extract data from the website article to be typeset, and the text information and format information of the website article to be typeset are determined, wherein the format information includes font, size, color and paragraph style.

3. The method according to claim 1, characterized in that Using a neural network model to select a template for the website article to be typeset according to the feature information and the format information, and determining a typeset template for the website article to be typeset, including: Using the labeled article-template pairing sample set to train a convolutional neural network or a recurrent neural network, and optimizing the model parameters by minimizing the difference between the predicted template and the actual template to generate the neural network model; The neural network model is used to select a template for the website article to be typeset according to the feature information and the format information, so as to determine a typeset template for the website article to be typeset.

4. The method according to claim 1, characterized in that: The text information is filled into the typesetting template using Jinja2 template engine technology to generate an initial typesetting website article, including: Design Jinja2 templates for standalone files or strings; Use the Template environment class provided by Jinja2 to create a template environment for the Jinja2 template; Using the template environment to load the Jinja2 template, compiling the Jinja2 template into an executable template object; Matching the variables in the text information with the placeholders in the Jinja2 template, defining global variables and local variables according to the matching results, passing the variables in the text information to the Jinja2 template, and generating template variables; The template object is used to fill the template variables into the layout template to generate the initial layout website article.

5. A layout device for website articles, characterized in that: include: An extraction module is used to extract text and format of the website article to be typeset, and determine the text information and format information of the website article to be typeset; An analysis module, used to perform text analysis on the text information using a pre-trained BERT model to obtain feature information of the text information; A selection module, for selecting a template for the website article to be typeset according to the feature information and the format information using a neural network model, and determining a typeset template for the website article to be typeset; A filling module is used to fill the text information into the typesetting template using Jinja2 template engine technology to generate an initial typesetting website article; The generation module is used to convert the typesetting website article into a rich text format through web technology, generate a final typesetting website article, and copy the final typesetting website article to the backend of the website to be arranged for publication.

6. The device according to claim 5, characterized in that Extraction modules, including: The extraction submodule is used to interpret and extract data from the website article to be typeset using an intelligent document parsing library, and determine the text information and format information of the website article to be typeset, wherein the format information includes font, size, color and paragraph style.

7. The device according to claim 5, characterized in that Select modules including: A training submodule, for training a convolutional neural network or a recurrent neural network using a labeled article-template pairing sample set, and optimizing model parameters by minimizing the difference between the predicted template and the actual template to generate the neural network model; The selection submodule is used to use the neural network model to select a template for the website article to be typeset according to the feature information and the format information, and determine the typeset template of the network article to be typeset.

8. The device according to claim 5, characterized in that Filling modules, including: Design submodules for designing Jinja2 templates for independent files or strings; Create a submodule for creating a template environment of the Jinja2 template using the Template environment class provided by Jinja2; A compiling submodule, used to load the Jinja2 template using the template environment and compile the Jinja2 template into an executable template object; A matching submodule, used for matching the variables in the text information with the placeholders in the Jinja2 template, defining global variables and local variables according to the matching results, passing the variables in the text information to the Jinja2 template, and generating template variables; The filling submodule is used to use the template object to fill the template variables into the typesetting template to generate the initial typesetting website article.

9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is used to execute the method according to any one of claims 1 to 4.

10. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the method described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Template-based intelligent format checking method aiming at Word document

    CN101706771A

  • Web page interface construction method and system, and data processing method

    CN109388759A

  • Typesetting method and device for text content in document

    CN112784562A