Software content layout data processing method and device
By working together with the template analysis engine and the rule engine, the problems of inconsistent template structure and dynamic content adaptation have been solved, achieving intelligent layout and visual consistency of Xiaohongshu templates, and improving the efficiency and quality of template generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-04-03
AI Technical Summary
Existing template-based content generation tools cannot effectively solve the problems of diverse template sources, inconsistent annotation methods, complex nesting levels, high demand for dynamic content, difficulty in ensuring visual consistency when reusing templates, and low batch processing efficiency, which makes it difficult to improve the efficiency and quality of Xiaohongshu template layout.
The template analysis engine identifies the annotation type and structure, the rule engine performs normalization preprocessing, and the template preprocessing engine is combined to restore annotation information, correct spacing deviations, and adjust layout, thereby achieving the standardization and optimization of the template structure.
It improves the efficiency and quality of Xiaohongshu template layout, supports the adaptation of dynamic content and visual consistency, reduces operating costs, and realizes intelligent batch processing and automated layout adjustment of templates.
Smart Images

Figure CN121787388A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, specifically to a method and apparatus for processing software content layout data. Background Technology
[0002] In the current field of digital content creation and dissemination, template-based content generation has become an important means to improve efficiency and ensure quality. Especially on social media platforms like Xiaohongshu, attractive posters and image / text templates play a crucial role in attracting user attention and enhancing content dissemination. However, in practical applications, template-based content generation faces numerous technical challenges and business pain points, which severely restrict the efficiency and effectiveness of content creation.
[0003] Specifically, the generation of templated content faces four major technical challenges and business pain points: First, templates come from diverse sources, and the structures and annotation methods of templates generated by different design tools and designers are inconsistent, with complex nesting levels, making it difficult to process them in batches directly. Second, there is a high demand for dynamic content, as the same template needs to adapt to different numbers and lengths of content items, which traditional systems struggle to adapt intelligently, easily leading to text overflow or layout chaos. Third, when reusing templates, content changes often disrupt visual consistency, affecting dissemination effectiveness and increasing operational costs. Fourth, there is a high demand for batch processing, but manual layout adjustments are costly and inefficient, and automatically adjusting text attributes to adapt to different scenarios becomes a challenge when dealing with templates with non-standard designs.
[0004] While some template layout tools exist in the market, they often fail to fully address the aforementioned business pain points. Therefore, there is an urgent need for a software-based content layout data processing method that can improve the efficiency and quality of Xiaohongshu template layout. Summary of the Invention
[0005] To address the problems in the existing technology, this application provides a software content layout data processing method and apparatus, which can improve the efficiency and quality of Xiaohongshu template layout.
[0006] To solve at least one of the above problems, this application provides the following technical solution: Firstly, this application provides a software content layout data processing method, including: The system receives template data, annotation data, and configuration data of a preset software template. Based on the template analysis engine, it performs annotation recognition, structural analysis, and spacing analysis operations on the template data in parallel to determine the corresponding template structure analysis results. Based on the configuration data, it initializes the rule engine to determine the corresponding configured rule engine instance. It inputs the template structure analysis results and the rule engine instance into the template preprocessing engine to perform normalization preprocessing on the template structure of the software template to determine the corresponding normalized template structure. Based on the standardized template structure and the labeled data, the template content is replaced to determine the corresponding replaced template content; Based on the annotation identification information and spacing information saved in the template structure analysis results, the replacement template content is subjected to annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation in sequence to determine the corresponding final optimized template structure. The final optimized template structure is serialized, and the template data after data serialization is uploaded to the storage service to determine the corresponding usage template for user use.
[0007] Furthermore, the annotation and recognition operation includes: Traverse the template elements, identify the annotation type of each template element according to the preset annotation prefix, establish the mapping relationship between annotation elements and annotation data, and determine the corresponding annotation mapping table; Traverse the template elements, identify the labeled pairing relationships, and determine the corresponding pairing relationship table.
[0008] Furthermore, the structural analysis operation includes: Identify the group structure of the template data, analyze the hierarchical relationship of each group structure, determine the corresponding nesting relationship, and calculate the absolute position of each template element, taking into account the position offset of the parent container. The corresponding list of background elements and list of decorative elements are determined based on the element attributes of the template element. The background element attributes include type, transparency, layer, size, and spatial relationship, while the decorative element attributes include spatial position, size ratio, and visual characteristics.
[0009] Furthermore, the spacing analysis operation includes: Identify the annotation groups containing titles and body text in the template data, calculate the vertical spacing between adjacent annotation groups, and determine the corresponding reference position and standard spacing parameters; Extract the boundary information of the background elements and determine the corresponding background boundary values.
[0010] Further, the step of performing normalization preprocessing on the template structure of the software template to determine the corresponding normalized template structure includes: Apply nesting rules to flatten the nested group structure in the template structure; Apply grouping rules to create separate groups for labeled elements with backgrounds, merge paired elements into the same group, and merge related paired groups into supergroups, and perform normalization processing through index mapping. The deletion rules are applied to identify the annotation elements that need to be removed from the annotation data. The annotation elements that need to be removed and their associated background elements and decorative elements are deleted. The annotation elements that need to be removed include annotation elements that do not exist in the annotation data and annotation elements that are not paired. Apply layout rules to insert new annotation groups as needed, and center the main title.
[0011] Furthermore, the step of sequentially performing annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations on the replaced template content includes: For the replaced template content, the annotation information is rewritten into the corresponding elements according to the annotation mapping table to determine the corresponding restored annotation template structure; For the restored template structure, the reference position and the standard spacing parameter are used to correct the spacing deviation between the annotation groups, and the corresponding template structure after spacing repair is determined.
[0012] Furthermore, the step of sequentially performing the annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation on the replaced template content also includes: For the template structure after the spacing is repaired, the rule-exceeding detection is applied to process the annotation groups that exceed the container boundary. The processing includes creating a new canvas and recursively adjusting the annotation elements to determine the corresponding template structure containing the new canvas. For the template structure containing the new canvas, apply layout rules to perform final layout adjustments and bounding box updates to determine the corresponding final optimized template structure.
[0013] Secondly, this application provides a software content layout data processing apparatus, comprising: The template analysis and preprocessing module is used to receive template data, annotation data, and configuration data of a preset software template, perform annotation recognition, structural analysis, and spacing analysis operations on the template data in parallel according to the template analysis engine, determine the corresponding template structure analysis results, initialize the rule engine according to the configuration data, determine the corresponding configured rule engine instance, input the template structure analysis results and the rule engine instance into the template preprocessing engine, perform normalization preprocessing on the template structure of the software template, and determine the corresponding normalized template structure. The content replacement module is used to replace the template content according to the standardized template structure and the annotation data, and determine the corresponding replaced template content. The layout repair and optimization module is used to perform annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations on the replaced template content in sequence based on the annotation identification information and spacing information saved in the template structure analysis results. It determines the corresponding final optimized template structure, serializes the data of the final optimized template structure, uploads the serialized template data to the storage service, and determines the corresponding template for use by the user.
[0014] Thirdly, this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the software content layout data processing method.
[0015] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the software content layout data processing method described above.
[0016] Fifthly, this application provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the software content layout data processing method.
[0017] As can be seen from the above technical solution, this application provides a software content layout data processing method and apparatus. It receives template data, annotation data, and configuration data of a preset software template; performs structural analysis on the template data using a template analysis engine to determine the structural analysis results; initializes the configuration data using a rule engine to determine a rule engine instance; and, based on the structural analysis results and the rule engine instance, performs standardized preprocessing on the template data using a template preprocessing engine to determine a standardized template structure. It then replaces the template content of the standardized template structure based on the annotation data and performs annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations in sequence based on the replaced template to obtain the final template structure for user use. This improves the efficiency and quality of Xiaohongshu template layout. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is one of the flowcharts illustrating the software content layout data processing method in the embodiments of this application; Figure 2 This is a structural diagram of the software content layout data processing device in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the electronic device in the embodiments of this application.
[0020] Figure label: Electronic device 9600, central processing unit 9100, memory 9140, communication module 9110, input unit 9120, audio processor 9130, display 9160, power supply 9170, buffer memory 9141, application / function storage unit 9142, data storage unit 9143, driver storage unit 9144, antenna 9111, speaker 9131, microphone 9132. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] The acquisition, storage, use, and processing of data in this application all comply with relevant laws and regulations.
[0023] Considering the current difficulty in adapting templated content to different design tools, sources, and inconsistent annotation methods, this application provides a software content layout data processing method and apparatus. It receives template data, annotation data, and configuration data from a preset software template. A template analysis engine performs structural analysis on the template data to determine the analysis results. A rule engine instance is determined based on the initialization configuration data. Based on the structural analysis results and the rule engine instance, a template preprocessing engine performs standardized preprocessing on the template data to determine a standardized template structure. The template content of the standardized template structure is replaced according to the annotation data. Based on the replaced template, annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations are performed sequentially to obtain the final template structure for user use. This improves the efficiency and quality of Xiaohongshu template layout.
[0024] To improve the efficiency and quality of Xiaohongshu template layout, this application provides an embodiment of a software content layout data processing method, see [link to embodiment]. Figure 1 The software content layout data processing method specifically includes the following: Step S101: Receive template data, annotation data, and configuration data of a preset software template; perform annotation recognition, structural analysis, and spacing analysis operations in parallel on the template data according to the template analysis engine to determine the corresponding template structure analysis results; initialize the rule engine according to the configuration data to determine the corresponding configured rule engine instance; input the template structure analysis results and the rule engine instance into the template preprocessing engine to perform normalization preprocessing on the template structure of the software template to determine the corresponding normalized template structure; Optionally, this embodiment begins with a background introduction. In templated content generation scenarios, the following business pain points exist: 1. Diverse Template Sources: Templates may originate from different design tools and designers, resulting in inconsistent template structures, varying annotation methods, and complex nesting levels. This makes direct batch processing impossible. Therefore, technically, it's necessary to process the diverse template data into a unified format and resolve the hierarchical issues between different templates. 2. Dynamic Content Requirements: Business needs require dynamically generating content based on data. The same template needs to adapt to different numbers of content items (such as product lists and news items), and the length and quantity of content are dynamically changing. Technically, this requires recognizing text background and decorative elements, determining whether text exceeds background elements, calculating edges, and dynamically adapting the height of the padded text. 3. Template reuse scenario: The same template needs to be used multiple times, with different content each time, but visual consistency must be maintained to avoid layout chaos due to content changes. 4. Batch Processing Requirements: A large number of templates need to be processed in batches. Manually adjusting the layout is costly and inefficient, necessitating automated processing capabilities. Due to inconsistent design within the templates, it's necessary to center or left-align text, and to set text for different application scenarios. A significant challenge lies in automatically processing text attributes to adapt the text to the template and achieve better results under varying templates and text positions.
[0025] Based on these business pain points, this technical solution achieves intelligent layout of template content through the collaborative work of a template analysis engine, a template preprocessing engine, and a rules engine. The system adopts a two-layer optimization mechanism: performing template structure analysis and standardization before content replacement, and performing layout repair and overflow handling after content replacement.
[0026] Core functionalities include: automatic identification and classification of labeled elements; assisted element identification based on element attributes and spatial relationships; flattening of multi-layered nested structures; automatic extraction and standardization of element spacing parameters; addition, deletion, and layout restructuring of dynamic elements; automatic pagination when content exceeds the container; and automatic detection and correction of element position deviations. The system features high automation, configurable rules, strong fault tolerance, and optimized performance, making it suitable for scenarios such as batch template replacement, dynamic content generation, adaptive layout, multi-canvas processing, and intelligent typesetting on Xiaohongshu (Little Red Book).
[0027] The specific process of layout optimization includes three stages: the first stage is template analysis and preprocessing (before content replacement), the second stage is content replacement, and the third stage is layout repair and optimization (after content replacement).
[0028] In this embodiment, this step involves the first stage: template analysis and preprocessing (before content replacement).
[0029] Step 1: Data input and initialization.
[0030] The system receives template data (including layout structure, element information, and metadata), annotation data (annotation content to be replaced), and configuration data (annotation prefixes, spacing parameters, function switches, etc.) as input. The system initializes three core components: the template analysis engine, the template preprocessing engine, and the rule engine, preparing for subsequent processing. This step resolves the initialization issues of the system components, ensuring that each engine can correctly receive and process data.
[0031] Step 2: The template analysis engine performs the analysis task.
[0032] The template analysis engine receives template data and executes three analysis tasks in parallel.
[0033] The annotation recognition and analysis task traverses all elements of the template, recursively accesses elements within a group, extracts annotation information from the metaInfo field of the elements, identifies four annotation types (main title, subtitle, subheading, and body text) based on the annotation prefix, establishes a mapping relationship between annotation elements and annotation data, identifies annotation pairing relationships (subheading N corresponds to body text N), and outputs an annotation mapping table and a pairing relationship table.
[0034] The structural analysis task identifies the group structure in the template, analyzes the hierarchical relationship of the groups, recursively analyzes multi-level nested group structures, calculates the absolute position of each element (considering the position offset of all parent containers), identifies background elements based on element attributes (type, transparency, hierarchy, size, spatial relationship), and identifies decorative elements based on spatial position, size ratio, and visual features. The output structural analysis results include group structure information, nesting relationship, absolute position of elements, list of background elements, and list of decorative elements.
[0035] The spacing analysis task identifies all annotation groups containing titles and body text from the template, calculates the vertical spacing between adjacent annotation groups, extracts the positional information of the first annotation group as a reference position, calculates the standard spacing parameters (using the first valid spacing value or the default value), and extracts the boundary information (top and bottom boundaries) of background elements. The output spacing information includes the standard spacing value, reference position, and background boundary information. These three analysis tasks address the problem of template structure understanding, providing foundational data for subsequent structure standardization and layout optimization.
[0036] Step 3: Loading and configuring the rules engine.
[0037] The rule engine receives configuration data as input, loads and initializes various layout rules, and sets annotation prefixes, spacing parameters, and function switches based on the configuration data. It provides six types of layout rules: group rules, spacing rules, layout rules, overflow rules, deletion rules, and nesting rules. The output is a configured rule engine instance containing all available layout rules. This step resolves the rule configuration issue, ensuring the system can process templates according to predefined rules.
[0038] Step 4: The template preprocessing engine performs structure normalization.
[0039] The template preprocessing engine receives the analysis results from step 2 and the rule engine from step 3 as inputs, and performs the structure normalization operation in sequence.
[0040] First, the nesting rules are applied to flatten the structure. All nested group structures are recursively traversed, nested groups containing labeled elements are identified, labeled elements in nested groups are extracted to the parent level, the absolute position of the extracted elements is calculated (element position + sum of the positions of all parent groups), empty groups after flattening are deleted, the original order of elements is maintained, and the flattened template structure is output.
[0041] Then, grouping rules are applied to automatically group elements, creating separate groups containing background and decoration for annotation elements with backgrounds, merging paired heading and body elements into the same group, merging related heading and body groups into supergroups, maintaining the original order of elements through index mapping, and outputting the normalized group structure.
[0042] Next, the deletion rules are applied to clean up the elements, identify the annotation elements that do not exist in the annotation data, identify the unpaired annotation elements (missing paired titles or body text), delete these elements and their associated background and decorative elements, delete the entire group if all annotation elements in the group are deleted, calculate the layout compensation amount after deletion, and output the cleaned template structure.
[0043] Then, the layout rules are applied to dynamically add elements, identify the new annotation pairs that need to be added (existing in the annotation data but not in the template), copy the complete structure of the last annotation group (including background and decorative elements), update the annotation information of the elements in the group, calculate the insertion position of the new group based on the layout rules (last group position + last group height + standard spacing), insert the new group into the layout, and output the template structure containing the new elements.
[0044] Finally, layout rules are applied to adjust the main title's position. This involves identifying the main title element and its position, finding background elements of similar size, calculating the main title's center position, adjusting the main title's position to be centered within the background elements, and outputting the adjusted template structure. This step resolves the issue of inconsistent template structures, unifying various non-standard template structures into a standard structure, thus preparing for content replacement.
[0045] Step S102: Replace the template content according to the standardized template structure and the annotation data, and determine the corresponding replaced template content; Optionally, in this embodiment, this step involves the second stage: content replacement.
[0046] Step 5: Perform content replacement. The system receives the standardized template structure and annotation data output from Step 4 as input, calls the content replacement module, and replaces the content in the annotation data into the corresponding template elements. This replaces the text content of text elements, the image address of image elements, and the relevant attributes of other types of elements. The system outputs the template structure after content replacement, but the annotation information of elements may be cleared during the replacement process. This step solves the content replacement problem by filling the template with the actual content from the annotation data.
[0047] Step S103: Based on the annotation identification information and spacing information saved in the template structure analysis results, perform annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation in sequence on the replaced template content to determine the corresponding final optimized template structure, serialize the data of the final optimized template structure, and upload the template data after data serialization to the storage service to determine the corresponding usage template for user use.
[0048] Optionally, in this embodiment, this step involves the third stage, where the template preprocessing engine performs layout optimization.
[0049] The template preprocessing engine receives the template structure after the content is replaced by the output of step 5, the annotation information and spacing information saved in step 2 as input, and performs layout optimization operations in sequence.
[0050] First, restore the annotation information. Restore the annotation mapping relationship from the annotation information saved in the first stage, rewrite the annotation information into the corresponding elements, ensure that the restored annotation information corresponds correctly with the elements, and output the template structure after restoring the annotations.
[0051] Then, the spacing rules are applied to repair the group spacing. The reference position of the first annotation group is obtained. Starting from the second group, the expected position is calculated according to the standard spacing rules (the position of the previous group + the height of the previous group + the standard spacing). The deviation between the actual position and the expected position of each group is detected. If the deviation exceeds the tolerance threshold, the position of the group is automatically corrected to ensure that the spacing between all annotation groups is consistent. The template structure after spacing repair is output.
[0052] Next, exceedance rules are applied for exceedance detection and processing. The container boundary is determined (the background element boundary is used first, and the canvas boundary is used if there is no background). Each annotation group is checked to see if it exceeds the container (the bottom position of the element is greater than the bottom position of the container). The exceedance element and its associated background and decorative elements are identified. A new canvas is created and the exceedance element is moved to the new canvas. Standard layout rules are applied in the new canvas (using the reference position as the starting position and accumulating according to the standard spacing). The case of exceedance again in the new canvas is recursively processed (up to 3 levels of recursion). The template structure containing the new canvas is output.
[0053] Finally, layout rules are applied for final adjustments, updating the bounding box information of all groups (traversing all elements within a group and calculating the minimum bounding rectangle), correcting element position deviations, handling dynamically deleted annotation elements (if they do not exist in the annotation data), performing final layout adjustments and optimizations, and outputting the final optimized template structure. This step resolves the layout chaos issue after content replacement, ensuring layout consistency and aesthetics.
[0054] Step 7: Output the processed template. The system receives the final optimized template structure from Step 6 as input, serializes the processed template data, uploads it to the storage service, and returns the processed template URL. The processed template URL is then output for user use. This step resolves the issue of outputting the result, providing the processed template to the user.
[0055] The advantages of this embodiment are: 1. With its unique processing scheme and logic for structured templates, it can support dynamic layout optimization and adaptation to different AI content outputs in AI scenarios, ultimately assisting in the generation of AI posters.
[0056] 2. Visual specifications for Xiaohongshu scene templates, achieving visual effects layout and rule capabilities, reducing the problem of operations constantly adding and designing templates.
[0057] This example demonstrates how this embodiment achieves intelligent layout of template content through the collaborative work of the template analysis engine, template preprocessing engine, and rule engine.
[0058] As described above, the software content layout data processing method provided in this application embodiment can receive template data, annotation data, and configuration data of a preset software template, perform structural analysis on the template data according to a template analysis engine to determine the structural analysis results, initialize configuration data according to a rule engine to determine a rule engine instance, perform normalization preprocessing on the template data through a template preprocessing engine based on the structural analysis results and the rule engine instance to determine a normalized template structure, replace the template content of the normalized template structure according to the annotation data, and perform annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation according to the order of the replaced template to obtain the final template structure for user use, thereby improving the efficiency and quality of Xiaohongshu template layout.
[0059] In one embodiment of the software content layout data processing method of this application, it may further include the following: Step S201: Traverse the template elements, identify the annotation type of each template element according to the preset annotation prefix, establish the mapping relationship between annotation elements and annotation data, and determine the corresponding annotation mapping table; Step S202: Traverse the template elements, identify the labeled pairing relationships, and determine the corresponding pairing relationship table.
[0060] Optionally, in this embodiment, this step is used to systematically identify replaceable content areas and their associated structures in the template.
[0061] First, the system iterates through all visual elements in the template, checking each element for predefined annotation information. This annotation information is stored in the element's metadata field as a specific prefix (e.g., "maintitle_", "subtitle_"). The system distinguishes different annotation types based on these prefixes, such as "main title," "subtitle," and "body text." After identification, the system creates an annotation mapping table that records the association between each annotated element and its corresponding entry in the external content data source, thus providing accurate location data for subsequent content replacement.
[0062] Next, the system further analyzes the logical pairing relationships between elements. Certain tag types have semantic or layout correspondences; for example, a subheading needs to be paired with the following body text. By analyzing the tag naming rules, the spatial order of elements in the template, or the hierarchical structure, the system automatically identifies these pairing relationships and generates a pairing relationship table. This table clarifies which elements belong to the same content unit in terms of layout, laying the foundation for subsequent grouping operations and overall layout adjustments.
[0063] Suppose we have a Xiaohongshu (Little Red Book) store visit poster template, which includes: One main title (labeled as main_title) One subtitle (labeled as sub_title) Three sets of "subheading + body text" pairs (labeled as title_1, content_1, title_2, content_2, title_3, and content_3 respectively). Background elements and decorative elements (such as lines, icons, etc.) Image placeholder (labeled image_1) The annotation data to be replaced is as follows: json { "main_title": "A Retro Cafe in a City Corner", "subtitle": "A Healing Space Hidden in a Hutong", "title_1": "Recommended Dishes", "content_1": "Hand-drip latte, matcha latte, coconut milk iced Americano", "title_2": "Environmental Features", "content_2": "Retro decor, quiet and comfortable, surrounded by greenery, a perfect spot for taking photos", "title_3": "Average Consumption" "content_3": "Approximately 35-50 yuan", "image_1": "https: / / example.com / coffee_shop.jpg" } The system iterates through the template elements and identifies, according to the preset prefix rules, that "main_title" belongs to the "main title" type and "content" belongs to the "body text" type. Then, it creates two records in the annotation mapping table, mapping these two elements to the "title" field and "body text description" field in the content data source, respectively.
[0064] Next, the system identifies a pairing relationship between the two elements based on their spatial location (adjacent) and semantic association (titles and descriptions usually appear in pairs). The pairing table records "title_main" and "content" as a pair; in subsequent processing, they will be treated as an inseparable content group and subjected to unified position adjustments or overall migration.
[0065] Through step S202, this embodiment successfully understands the association relationship of the template data, records the mapping relationship and pairing relationship, and lays the foundation for subsequent intelligent processing of the template content.
[0066] In one embodiment of the software content layout data processing method of this application, it may further include the following: Step S301: Identify the group structure of the template data, analyze the hierarchical relationship of each group structure, determine the corresponding nesting relationship, and calculate the absolute position of each template element, taking into account the position offset of the parent container. Step S302: Determine the corresponding list of background elements and list of decorative elements based on the element attributes of the template elements. The background element attributes include type, transparency, layer, size, and spatial relationship, while the decorative element attributes include spatial position, size ratio, and visual characteristics.
[0067] Optionally, in this embodiment, the system first parses the template data to identify the various "groups" defined within it. A group is a container structure that logically aggregates multiple design elements (such as text boxes, image boxes, shapes, etc.) to achieve complex nested layouts. This step requires recursively traversing all groups, analyzing their parent-child hierarchical relationships, and thus constructing a tree representing the complete nested structure of the template. For example, a product card group may contain a product image group and a product information group, and the product information group may contain nested text elements: product title and product description.
[0068] After clarifying the nesting relationships, the system calculates the "absolute position" of each basic element in the template (i.e., leaf nodes that no longer contain child elements). The absolute position refers to the element's coordinates (usually including X and Y coordinates) relative to the origin at the top left corner of the entire template canvas. During calculation, the element's own position offset and the position offsets of all its ancestor groups (parent containers) must be accumulated. For example, if a text element's relative position within its own group is (10, 20), and its parent group's absolute position on the canvas is (100, 50), then the text element's absolute position is (110, 70).
[0069] After accurately determining the absolute position and hierarchical relationship of all elements, the system further classifies them into content elements, background elements, and decorative elements based on their attributes, which is crucial for subsequent intelligent layout.
[0070] Background element identification: The system filters out elements that visually may serve as a background for other elements. The criteria include: the element's type (e.g., a shape defined as "rectangle" or "background"), its low transparency (close to opaque), its low position in the layer hierarchy, its large enough to cover an area, and its spatial position indicating inclusion or overlap with other content elements. The system adds all elements matching these characteristics to the background element list.
[0071] Decorative element identification: Decorative elements refer to those elements used to beautify the layout but do not carry core content, such as lines, icons, and small patterns. The system mainly identifies them through spatial relationships and visual features: checking whether the element is closely adjacent to or attached to content elements such as titles and body text; analyzing whether its size is smaller than adjacent content elements; and determining whether it has simple geometric shapes or repetitive pattern features. Identified decorative elements are added to the decorative element list.
[0072] Taking a poster template as an example, step S301 identifies that the template contains a top-level "Main Visual Area" group, which nests a "Product Image" group and a "Text Area" group. The "Text Area" group contains three independent text elements: "Main Title," "Subtitle," and "Price Tag." The system recursively calculates the absolute position of the "Price Tag" text. In step S302, the system detects an opaque, rounded rectangle of matching size below the "Text Area," whose layer is below all text elements. Therefore, it is identified as a background element of the "Text Area" and added to the background list. Simultaneously, the system notices a small star icon to the left of the "Main Title" text, which is very small and close to the text; therefore, it is identified as a decorative element and added to the decoration list.
[0073] These analytical results provide crucial structured data for subsequent standardized typesetting (such as centering text in the background and moving decorative elements with the text).
[0074] Through step S302, this embodiment successfully analyzed the hierarchical structure and element positions of the template, laying the foundation for subsequent intelligent processing of the template content.
[0075] In one embodiment of the software content layout data processing method of this application, it may further include the following: Step S401: Identify the annotation groups containing titles and body text in the template data, calculate the vertical spacing between adjacent annotation groups, and determine the corresponding reference position and standard spacing parameters; Step S402: Extract the boundary information of the background elements and determine the corresponding background boundary values.
[0076] Optionally, in this embodiment, this step aims to automatically extract key layout parameters from the template data.
[0077] First, the system iterates through all elements of the template, identifying sets of elements that share specific markers (such as "heading" and "body text") and are interconnected, forming a single content unit. These sets are called "annotation groups." Next, the system focuses on the spatial arrangement of these annotation groups, specifically calculating the spacing between two adjacent annotation groups in the vertical direction. The first effective spacing value calculated is adopted by the system and set as the "standard spacing parameter" for the entire template layout. Simultaneously, the system records the coordinates of the first annotation group's position on the canvas and establishes it as the "baseline position" for subsequent layout calculations. This process transforms the visual design intuition about spacing into quantifiable and reusable rule-based data.
[0078] Next, the background elements in the template are processed. The positions of their top, bottom, left, and right boundary lines are calculated based on their attributes (such as size and coordinates). The top and bottom boundaries (i.e., the top and bottom Y coordinates) are particularly crucial, as they collectively define a vertical "container" area. The extent of this container is recorded, serving as the core basis for subsequent judgments regarding whether content "exceeds" or for "centering" alignment. By extracting this boundary information, the system transforms the visual container in the design draft into mathematical constraints that the program can recognize.
[0079] For example, suppose the top position of the first group (product A) has a Y-coordinate of 100 pixels. The system measures the vertical distance between the top of the first group and the top of the second group (product B) and finds it to be 60 pixels. Therefore, the system sets 60 pixels as the standard spacing parameter and records the starting position of the first group (Y=100) as the reference position.
[0080] Next, it was identified that the three groups were placed within a uniform light gray background. The top Y-coordinate of this background was calculated to be 90 pixels, and the bottom Y-coordinate to be 450 pixels. Therefore, these two values, 90 and 450, were extracted as the background boundary values, meaning that all content should be constrained within this area with a height of 360 pixels.
[0081] Through step S402, this embodiment successfully obtained layout rules and visual boundary constraints, providing an accurate data foundation for subsequent automated content filling and layout adjustment.
[0082] In one embodiment of the software content layout data processing method of this application, it may further include the following: Step S501: Apply nesting processing rules to flatten the nested group structure in the template structure; Step S502: Apply grouping rules to create separate groups for labeled elements with backgrounds, merge paired elements into the same group, and merge related paired groups into supergroups again, and perform normalization processing through index mapping. Step S503: Apply deletion rules to identify the annotation elements that need to be removed in the annotation data, and delete the annotation elements that need to be removed and their associated background elements and decorative elements. The annotation elements that need to be removed include annotation elements that do not exist in the annotation data and annotation elements that are not paired. Step S504: Apply layout rules to insert the new annotation group that needs to be added, and adjust the position of the main title to be centered.
[0083] Optionally, in this embodiment, this step is the process by which the preprocessing engine processes the template structure according to preset rules.
[0084] Specifically, the nested structure is flattened. The system first traverses all group structures in the template, identifying groups with multiple levels of nesting. For each nested group containing annotation elements, the system extracts all annotation elements within that nested group into its direct parent. During extraction, the system accumulates the position offsets of all parent containers of the annotation element to calculate its absolute position in the parent coordinate system. After extraction, the system deletes the original nested groups that have become empty, but maintains the original visual order of all elements. This step aims to simplify the template's hierarchy, allowing subsequent operations to be performed directly on a flat, clear hierarchy.
[0085] Specifically, related elements are standardized into groups. Based on the interpreted visual attributes and spatial relationships of the elements, the system logically reorganizes the flattened elements. First, it creates an independent group for each background-enabled element (such as a title box with a background), encapsulating its background and decorative elements together. Second, according to preset pairing logic (such as "Subheading 1" corresponding to "Body Text 1"), the system merges paired title and body text elements into the same group. Finally, the system identifies multiple closely related groups (such as a series of product introduction items) and merges these groups again into a "supergroup" for unified batch layout management. Throughout the process, the system maintains an index mapping to ensure that the element order remains consistent.
[0086] Specifically, invalid element cleanup involves comparing the list of annotation elements in the current template with the list of annotation data to be replaced. Annotation elements that are not present in the annotation data, or those that are "isolated" due to a lack of matching objects (such as having only "Subheading 3" without a corresponding "Body 3"), are identified as invalid elements that need to be removed. During cleanup, not only are these invalid annotation elements themselves deleted, but their associated background and decorative elements are also intelligently identified and deleted. If all annotation elements in a group are deleted, the entire group is removed. After cleanup, the system calculates the layout blanking caused by the deletions, providing a basis for possible subsequent layout compensation.
[0087] Specifically, dynamic addition and visual alignment are implemented. To adapt to dynamic content, the system identifies annotation items present in the annotation data but missing from the current template. For these newly added content items, the system copies the complete structure of the last valid annotation group (including its background, decoration style, and layout relationships) as a template. Then, the new content is filled into the copied structure, and the precise insertion position of the new group is calculated according to rules (usually based on the position, height, and preset standard spacing of the previous group), adding it to the layout flow. Simultaneously, the system specifically handles key elements such as the "main title," finding adjacent background elements of matching size (such as the banner at the top of a poster) and automatically calculating and adjusting the position of the main title to achieve horizontal and vertical centering within the range of the background element, ensuring the standardization of the visual focus.
[0088] Through step S504, this embodiment successfully standardized the template structure, which is helpful for subsequent template content replacement.
[0089] In one embodiment of the software content layout data processing method of this application, it may further include the following: Step S601: For the replaced template content, the annotation information is rewritten into the corresponding elements according to the annotation mapping table to determine the corresponding template structure after the annotation is restored; Step S602: For the restored template structure, apply the reference position and the standard spacing parameter to correct the spacing deviation between the annotation groups, and determine the corresponding template structure after spacing repair.
[0090] Optionally, in this embodiment, during the content replacement stage, the original annotation information (i.e., metadata used to identify element types and relationships) may be cleared or overwritten, causing the system to be unable to identify the element type and grouping relationship in subsequent processing. This step aims to solve this problem.
[0091] The system first calls the "annotation mapping table" saved in the first stage (template analysis), whose core key-value pairs are "unique element identifier" and "the original annotation information corresponding to the element (such as annotation type, pairing relationship, etc.)". The system traverses all elements in the template structure after content replacement and reads the unique identifier of each element. Then, the system uses this identifier as a "key" to look up the corresponding original annotation information in the "annotation mapping table". Once found, the system rewrites (or appends) this information (for example, marking the element as "subheading-1" and associating it with "body-1") into the element's attribute data. After this operation, all important elements in the template have restored their initial "identity" and "social relationship" (pairing), laying the data foundation for rule-based precise layout repair.
[0092] Next, perform visual alignment and standardization. Ensure that the vertical spacing of all content groups (such as the heading-body text group) strictly follows the design guidelines, eliminating inconsistencies caused by dynamic changes in content (such as different line counts).
[0093] First, two key parameters are extracted from the analysis results saved in the first stage: the baseline position (the starting Y-coordinate of the first content group on the canvas) and the standard spacing parameter (the uniform vertical spacing between content groups). The repair process iteratively processes the content group starting from the second content group. For the Nth group currently being processed, the system calculates its expected position: Expected position Y = Y-coordinate of the bottom edge of the (N-1)th group + standard spacing parameter. Then, the system compares the actual Y-coordinate of the group with the calculated expected position, calculating a position deviation value. The system presets a tolerance threshold (e.g., 2 pixels). If the deviation value exceeds this threshold, the system determines that the group's position has a "deviation" and automatically performs a correction: the entire group (including all its internal child elements, such as background frames, text, and decorative icons) is translated vertically so that its Y-coordinate is exactly equal to the expected position. This process is sequentially executed for all subsequent content groups, ultimately ensuring that all groups are evenly distributed from top to bottom with consistent spacing.
[0094] Through step S602, this embodiment successfully performed annotation repair and spacing repair on the replaced template content, thereby achieving layout optimization of the replaced content.
[0095] In one embodiment of the software content layout data processing method of this application, it may further include the following: Step S701: For the template structure after spacing repair, apply the rule to detect and process the annotation groups that exceed the container boundary. The processing includes creating a new canvas and recursively adjusting the annotation elements to determine the corresponding template structure containing the new canvas. Step S702: Apply layout rules to the template structure containing the new canvas to perform final layout adjustments and bounding box updates, and determine the corresponding final optimized template structure.
[0096] Optionally, in this embodiment, after the template structure has undergone spacing repair, the system will enter the boundary detection and processing stage. This ensures that all elements can be reasonably contained within the preset visual container. If the content exceeds the container's range, the system will automatically create a new layout area to accommodate the overflowing content, while maintaining the integrity and standardization of the visual structure in the process.
[0097] First, the scope of the current valid container is determined based on the boundaries of the background elements or the canvas. Next, all annotation groups are traversed, and each group's bottom position is calculated to see if it exceeds the bottom boundary of the container. If an annotation group is detected to be completely or partially overflowing, the system performs an "overflow migration" operation: automatically creating a new canvas (i.e., a new, independent layout area) and migrating the overflowing annotation group and its associated background and decorative elements to the new canvas. Within the new canvas, the system reapplies standard layout rules, such as rearranging all migrated elements from top to bottom according to standard spacing, starting from a preset baseline position. If the content in the new canvas overflows again after rearranging, the system supports recursive processing, i.e., creating the next level canvas within the new canvas. This process can have a maximum recursion depth (e.g., a maximum of three levels) to avoid infinite loops. Finally, the system outputs a template structure that may contain multiple levels of canvases, with the content within each canvas arranged in an orderly manner within its respective container.
[0098] Optionally, in this embodiment, after the overflow processing is completed, the system performs final layout adjustments and visual calibration on the template structure containing one or more canvases.
[0099] First, the bounding box information of all element groups (including groups in the original canvas and newly created canvases) is updated. This involves recalculating the minimum bounding rectangle of each group by iterating through the position and size of all elements within the group. Then, the system fine-tunes the layout based on preset rules, such as pixel-level alignment correction of element positions, eliminating localized blank spaces caused by dynamically deleted elements, and ensuring a consistent overall visual rhythm across the canvas. Finally, the system outputs a fully optimized, stable, and visually standardized template structure that can be directly used for content rendering or export.
[0100] Through step S702, this embodiment successfully performs overflow processing and layout planning on the replaced template content, thereby achieving layout optimization of the replaced content.
[0101] To improve the efficiency and quality of Xiaohongshu template layout, this application provides an embodiment of a software content layout data processing apparatus for implementing all or part of the aforementioned software content layout data processing method. See [link to embodiment]. Figure 2 The software content layout data processing device specifically includes the following components: The template analysis and preprocessing module 10 is used to receive template data, annotation data and configuration data of a preset software template, perform annotation recognition operation, structural analysis operation and spacing analysis operation on the template data in parallel according to the template analysis engine, determine the corresponding template structure analysis result, initialize the rule engine according to the configuration data, determine the corresponding configured rule engine instance, input the template structure analysis result and the rule engine instance into the template preprocessing engine, perform normalization preprocessing on the template structure of the software template, and determine the corresponding normalized template structure. The content replacement module 20 is used to replace the template content according to the standardized template structure and the annotation data, and determine the corresponding replaced template content. The layout repair and optimization module 30 is used to perform annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations on the replaced template content in sequence based on the annotation identification information and spacing information stored in the template structure analysis results, determine the corresponding final optimized template structure, serialize the data of the final optimized template structure, upload the template data after data serialization to the storage service, and determine the corresponding template for use by the user.
[0102] As described above, the software content layout data processing device provided in this application embodiment can receive template data, annotation data, and configuration data of a preset software template, perform structural analysis on the template data according to the template analysis engine, determine the structural analysis results, initialize the configuration data according to the rule engine, determine the rule engine instance, perform normalization preprocessing on the template data through the template preprocessing engine based on the structural analysis results and the rule engine instance, determine the normalized template structure, replace the template content of the normalized template structure according to the annotation data, and perform annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation according to the order of the replaced template to obtain the final template structure for user use, thereby improving the efficiency and quality of Xiaohongshu template layout.
[0103] From a hardware perspective, in order to improve the efficiency and quality of Xiaohongshu template layout, this application provides an embodiment of an electronic device for implementing all or part of the software content layout data processing method, wherein the electronic device specifically includes the following: The system comprises a processor, memory, a communications interface, and a bus; wherein the processor, memory, and communications interface communicate with each other via the bus; the communications interface is used to realize information transmission between the software content layout data processing method and core business systems, user terminals, and related databases and other related devices; the logic controller can be a desktop computer, tablet computer, or mobile terminal, etc., and this embodiment is not limited to these. In this embodiment, the logic controller can be implemented with reference to the embodiments of the software content layout data processing method in the present embodiment, and the content of the embodiments of the software content layout data processing method is incorporated herein, and repeated parts will not be described again.
[0104] It is understood that the user terminal may include smartphones, tablet computers, network set-top boxes, portable computers, desktop computers, personal digital assistants (PDAs), in-vehicle devices, smart wearable devices, etc. Among these, the smart wearable devices may include smart glasses, smartwatches, smart bracelets, etc.
[0105] In practical applications, the software content layout data processing method can be executed on the electronic device side as described above, or all operations can be completed on the client device. The choice can be made based on the processing power of the client device and the limitations of the user's usage scenario. This application does not impose any limitations on this. If all operations are completed on the client device, the client device may further include a processor.
[0106] The aforementioned client device may have a communication module (i.e., a communication unit) that can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side; in other implementation scenarios, it may also include a server on an intermediate platform, such as a server on a third-party server platform that has a communication link with the task scheduling center server. The server may include a single computer device, a server cluster consisting of multiple servers, or a distributed server structure.
[0107] Figure 3 This is a schematic block diagram illustrating the system configuration of the electronic device 9600 according to an embodiment of this application. Figure 3 As shown, the electronic device 9600 may include a central processing unit 9100 and a memory 9140; the memory 9140 is coupled to the central processing unit 9100. It is worth noting that... Figure 3 This is an example; other types of structures can also be used to supplement or replace this structure to achieve telecommunications functions or other functions.
[0108] In one embodiment, the software content layout data processing method function can be integrated into the central processing unit 9100. The central processing unit 9100 can be configured to perform the following control: Step S101: Receive template data, annotation data, and configuration data of a preset software template; perform annotation recognition, structural analysis, and spacing analysis operations in parallel on the template data according to the template analysis engine to determine the corresponding template structure analysis results; initialize the rule engine according to the configuration data to determine the corresponding configured rule engine instance; input the template structure analysis results and the rule engine instance into the template preprocessing engine to perform normalization preprocessing on the template structure of the software template to determine the corresponding normalized template structure; Step S102: Replace the template content according to the standardized template structure and the annotation data, and determine the corresponding replaced template content; Step S103: Based on the annotation identification information and spacing information saved in the template structure analysis results, perform annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation in sequence on the replaced template content to determine the corresponding final optimized template structure, serialize the data of the final optimized template structure, and upload the template data after data serialization to the storage service to determine the corresponding usage template for user use.
[0109] As described above, the electronic device provided in this application embodiment receives template data, annotation data, and configuration data of a preset software template. It then performs structural analysis on the template data using a template analysis engine to determine the structural analysis results. Based on the initialization configuration data of the rule engine, it determines a rule engine instance. Based on the structural analysis results and the rule engine instance, it performs standardized preprocessing on the template data using a template preprocessing engine to determine a standardized template structure. It then replaces the template content of the standardized template structure based on the annotation data. Finally, it performs annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations based on the replaced template sequence to obtain the final template structure for user use. This improves the efficiency and quality of Xiaohongshu template layout.
[0110] In another embodiment, the software content layout data processing method can be configured separately from the central processing unit 9100. For example, the software content layout data processing method can be configured as a chip connected to the central processing unit 9100, and the software content layout data processing method function can be implemented through the control of the central processing unit.
[0111] like Figure 3As shown, the electronic device 9600 may further include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is worth noting that the electronic device 9600 does not necessarily need to include these components. Figure 3 All components shown; in addition, the electronic device 9600 may also include Figure 3 For components not shown, please refer to existing technologies.
[0112] like Figure 3 As shown, the central processing unit 9100, sometimes also referred to as a controller or operating control, may include a microprocessor or other processor device and / or logic device, which receives inputs and controls the operation of various components of the electronic device 9600.
[0113] The memory 9140 may be, for example, one or more of a cache, flash memory, hard drive, removable media, volatile memory, non-volatile memory, or other suitable devices. It may store the aforementioned failure-related information, and also store a program for executing that information. The central processing unit 9100 may execute the program stored in the memory 9140 to perform information storage or processing, etc.
[0114] Input unit 9120 provides input to central processing unit 9100. Input unit 9120 may be, for example, a keypad or touch input device. Power supply 9170 provides power to electronic device 9600. Display 9160 displays images and text. Display may be, for example, an LCD display, but is not limited thereto.
[0115] The memory 9140 can be a solid-state memory, such as a read-only memory (ROM), random access memory (RAM), a SIM card, etc. It can also be a memory that retains information even when power is off, can be selectively erased, and contains more data; examples of this type of memory are sometimes referred to as EPROMs. The memory 9140 can also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application / function storage unit 9142 for storing application programs and function programs or processes for executing the operation of the electronic device 9600 via the central processing unit 9100.
[0116] The memory 9140 may also include a data storage unit 9143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 9144 of the memory 9140 may include various drivers for the electronic device for communication functions and / or for performing other functions of the electronic device (such as messaging applications, address book applications, etc.).
[0117] The communication module 9110 is a transmitter / receiver that sends and receives signals via the antenna 9111. The communication module 9110 is coupled to the central processing unit 9100 to provide input signals and receive output signals, which is the same as in a conventional mobile communication terminal.
[0118] Based on different communication technologies, multiple communication modules 9110 can be configured in the same electronic device, such as cellular network modules, Bluetooth modules, and / or wireless LAN modules. The communication module 9110 is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide audio output via the speaker 9131 and receive audio input from the microphone 9132, thereby realizing typical telecommunications functions. The audio processor 9130 may include any suitable buffer, decoder, amplifier, etc. Furthermore, the audio processor 9130 is also coupled to a central processing unit 9100, enabling on-device recording via the microphone 9132 and on-device playback of stored sound via the speaker 9131.
[0119] Embodiments of this application also provide a computer-readable storage medium capable of implementing all steps of the software content layout data processing method with a server or client as the execution subject in the above embodiments. The computer-readable storage medium stores a computer program that, when executed by a processor, implements all steps of the software content layout data processing method with a server or client as the execution subject in the above embodiments. For example, when the processor executes the computer program, it implements the following steps: Step S101: Receive template data, annotation data, and configuration data of a preset software template; perform annotation recognition, structural analysis, and spacing analysis operations in parallel on the template data according to the template analysis engine to determine the corresponding template structure analysis results; initialize the rule engine according to the configuration data to determine the corresponding configured rule engine instance; input the template structure analysis results and the rule engine instance into the template preprocessing engine to perform normalization preprocessing on the template structure of the software template to determine the corresponding normalized template structure; Step S102: Replace the template content according to the standardized template structure and the annotation data, and determine the corresponding replaced template content; Step S103: Based on the annotation identification information and spacing information saved in the template structure analysis results, perform annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation in sequence on the replaced template content to determine the corresponding final optimized template structure, serialize the data of the final optimized template structure, and upload the template data after data serialization to the storage service to determine the corresponding usage template for user use.
[0120] As described above, the computer-readable storage medium provided in this application embodiment receives template data, annotation data, and configuration data of a preset software template. It then performs structural analysis on the template data using a template analysis engine to determine the structural analysis results. Based on the rule engine initialization configuration data, it determines a rule engine instance. Based on the structural analysis results and the rule engine instance, it performs standardized preprocessing on the template data using a template preprocessing engine to determine a standardized template structure. It then replaces the template content of the standardized template structure based on the annotation data. Finally, it performs annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations based on the replaced template sequence to obtain the final template structure for user use. This improves the efficiency and quality of Xiaohongshu template layout.
[0121] Embodiments of this application also provide a computer program product capable of implementing all steps of the software content layout data processing method with a server or client as the execution subject in the above embodiments. When executed by a processor, this computer program / instruction implements the steps of the software content layout data processing method. For example, the computer program / instruction implements the following steps: Step S101: Receive template data, annotation data, and configuration data of a preset software template; perform annotation recognition, structural analysis, and spacing analysis operations in parallel on the template data according to the template analysis engine to determine the corresponding template structure analysis results; initialize the rule engine according to the configuration data to determine the corresponding configured rule engine instance; input the template structure analysis results and the rule engine instance into the template preprocessing engine to perform normalization preprocessing on the template structure of the software template to determine the corresponding normalized template structure; Step S102: Replace the template content according to the standardized template structure and the annotation data, and determine the corresponding replaced template content; Step S103: Based on the annotation identification information and spacing information saved in the template structure analysis results, perform annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation in sequence on the replaced template content to determine the corresponding final optimized template structure, serialize the data of the final optimized template structure, and upload the template data after data serialization to the storage service to determine the corresponding usage template for user use.
[0122] As described above, the computer program product provided in this application embodiment receives template data, annotation data, and configuration data of a preset software template. It performs structural analysis on the template data using a template analysis engine to determine the structural analysis results. It initializes the configuration data using a rule engine to determine a rule engine instance. Based on the structural analysis results and the rule engine instance, it performs normalization preprocessing on the template data using a template preprocessing engine to determine a normalized template structure. It replaces the template content of the normalized template structure based on the annotation data and performs annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations in sequence based on the replaced template to obtain the final template structure for user use. This improves the efficiency and quality of Xiaohongshu template layout.
[0123] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0124] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (devices), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0125] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0126] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0127] Specific embodiments have been used to illustrate the principles and implementation methods of this invention. The descriptions of the embodiments above are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.
Claims
1. A method for processing software content layout data, characterized in that, The method includes: The system receives template data, annotation data, and configuration data of a preset software template. Based on the template analysis engine, it performs annotation recognition, structural analysis, and spacing analysis operations on the template data in parallel to determine the corresponding template structure analysis results. Based on the configuration data, it initializes the rule engine to determine the corresponding configured rule engine instance. It inputs the template structure analysis results and the rule engine instance into the template preprocessing engine to perform normalization preprocessing on the template structure of the software template to determine the corresponding normalized template structure. Based on the standardized template structure and the labeled data, the template content is replaced to determine the corresponding replaced template content; Based on the annotation identification information and spacing information saved in the template structure analysis results, the replacement template content is subjected to annotation information restoration operation, spacing deviation repair operation, excess detection operation, and layout adjustment operation in sequence to determine the corresponding final optimized template structure. The final optimized template structure is serialized, and the template data after data serialization is uploaded to the storage service to determine the corresponding usage template for user use.
2. The software content layout data processing method according to claim 1, characterized in that, The annotation and recognition operation includes: Traverse the template elements, identify the annotation type of each template element according to the preset annotation prefix, establish the mapping relationship between annotation elements and annotation data, and determine the corresponding annotation mapping table; Traverse the template elements, identify the labeled pairing relationships, and determine the corresponding pairing relationship table.
3. The software content layout data processing method according to claim 2, characterized in that, The structural analysis operation includes: Identify the group structure of the template data, analyze the hierarchical relationship of each group structure, determine the corresponding nesting relationship, and calculate the absolute position of each template element, taking into account the position offset of the parent container. The corresponding list of background elements and list of decorative elements are determined based on the element attributes of the template elements. The background element attributes include type, transparency, layer, size, and spatial relationship, while the decorative element attributes include spatial position, size ratio, and visual characteristics.
4. The software content layout data processing method according to claim 3, characterized in that, The spacing analysis operation includes: Identify the annotation groups containing titles and body text in the template data, calculate the vertical spacing between adjacent annotation groups, and determine the corresponding reference position and standard spacing parameters; Extract the boundary information of the background elements and determine the corresponding background boundary values.
5. The software content layout data processing method according to claim 1, characterized in that, The step of performing normalization preprocessing on the template structure of the software template to determine the corresponding normalized template structure includes: Apply nesting rules to flatten the nested group structure in the template structure; Apply grouping rules to create separate groups for labeled elements with backgrounds, merge paired elements into the same group, and merge related paired groups into supergroups, and perform normalization processing through index mapping. The deletion rules are applied to identify the annotation elements that need to be removed from the annotation data. The annotation elements that need to be removed and their associated background elements and decorative elements are deleted. The annotation elements that need to be removed include annotation elements that do not exist in the annotation data and annotation elements that are not paired. Apply layout rules to insert new annotation groups as needed, and center the main title.
6. The software content layout data processing method according to claim 4, characterized in that, The step of sequentially performing annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations on the replaced template content includes: For the replaced template content, the annotation information is rewritten into the corresponding elements according to the annotation mapping table to determine the corresponding restored annotation template structure; For the restored template structure, the reference position and the standard spacing parameter are used to correct the spacing deviation between the annotation groups, and the corresponding template structure after spacing repair is determined.
7. The software content layout data processing method according to claim 6, characterized in that, The step of sequentially performing annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations on the replaced template content also includes: For the template structure after the spacing is repaired, the rule-exceeding detection is applied to process the annotation groups that exceed the container boundary. The processing includes creating a new canvas and recursively adjusting the annotation elements to determine the corresponding template structure containing the new canvas. For the template structure containing the new canvas, apply layout rules to perform final layout adjustments and bounding box updates to determine the corresponding final optimized template structure.
8. A software content layout data processing device, characterized in that, The device includes: The template analysis and preprocessing module is used to receive template data, annotation data, and configuration data of a preset software template, perform annotation recognition, structural analysis, and spacing analysis operations on the template data in parallel according to the template analysis engine, determine the corresponding template structure analysis results, initialize the rule engine according to the configuration data, determine the corresponding configured rule engine instance, input the template structure analysis results and the rule engine instance into the template preprocessing engine, perform normalization preprocessing on the template structure of the software template, and determine the corresponding normalized template structure. The content replacement module is used to replace the template content according to the standardized template structure and the annotation data, and determine the corresponding replaced template content. The layout repair and optimization module is used to perform annotation information restoration, spacing deviation repair, excess detection, and layout adjustment operations on the replaced template content in sequence based on the annotation identification information and spacing information saved in the template structure analysis results. It determines the corresponding final optimized template structure, serializes the data of the final optimized template structure, uploads the serialized template data to the storage service, and determines the corresponding template for use by the user.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the software content layout data processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the software content layout data processing method according to any one of claims 1 to 7.