Deep learning-based output text-oriented template code modification method and system

Through the output text-oriented template code modification method based on deep learning, the two-stage two-way framework is used to achieve automatic synchronization between output text editing and template code, solving the problem of cumbersome and error-prone existing template development methods, and improving development efficiency and intelligence level.

CN120215912AActive Publication Date: 2025-06-27LONGYAN UNIV
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510701075.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-28
Publication Date
2025-06-27
Estimated Expiration
2045-05-28

AI Technical Summary

Technical Problem

Existing template development methods are difficult to meet the needs of efficiency and intuitiveness. Developers need to frequently switch template code and output text, manually track logic and run code repeatedly, which is cumbersome and error-prone.

Method used

Using the output text-oriented template code modification method based on deep learning, a two-stage two-way framework containing deep learning modules is built to realize structured mapping and automatic synchronization between output text editing and template code.

Benefits of technology

The template development process has been greatly simplified, the development efficiency, accuracy and intelligence level has been improved, the error rate has been reduced, and intelligent modifications in complex template scenarios have been supported.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120215912A_ABST
    Figure CN120215912A_ABST
Patent Text Reader

Abstract

The invention discloses an output text guiding type template code modification method and system based on deep learning, and relates to the technical field of computer software engineering.The method comprises the steps that semantic standardization processing is conducted on template codes to be modified, and core language representation is generated; construction and reduction of the structured intermediate representation are completed in the two-stage bidirectional framework; and generating an update instruction based on an editing operation of a user on an output text, predicting and fusing a structured update instruction through a deep learning module in combination with metadata information of the structured intermediate representation, and finally reducing the structured update instruction into a grammar-compliant template code through a back propagation stage. According to the method, the deep learning model is introduced, so that end-to-end mapping from output text editing to code updating is realized, and the intelligence and interactivity level of template code modification is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer software engineering, and particularly to an output text-oriented template code modification method and system based on deep learning. Background Art

[0002] In modern software development, template technology is widely used to automate the generation of various artifacts to improve development efficiency and consistency. Templates are not only widely adopted in model-driven development frameworks such as Acceleo and Xtend, but also play a key role in user interface design tools (such as Vue, React, and Angular), document generation tools (such as Markdown, LaTeX, and Pandoc), and configuration file generation tools (such as Dhall). These template technologies greatly simplify the development process and improve the productivity of software engineering.

[0003] Although template code is usually short, typically consisting of only a few hundred lines of code, it contains various control structures internally, such as variable binding, conditional statements, assignments, and function calls. In traditional template development, developers rely on a repetitive workflow: after writing or modifying the template code, they execute the code to generate the output text and verify the correctness of the template by checking the output result. If the output does not meet expectations, they need to return to the template code, locate the problem and make adjustments, and then run it again to confirm the modification effect. Since the correspondence between the template code and the generated output text is not always intuitive, locating and fixing errors becomes a complex and time-consuming task. For example, in Mustache templates, variable assignments and uses may be far apart, making it necessary to trace back multiple variable bindings when modifying specific output content, thus increasing the complexity of debugging. Especially when the template involves nested conditions or multi-layer loops, tracking changes in variables and control structures is time-consuming and error-prone.

[0004] In summary, the current template development methods are difficult to meet the requirements of high efficiency and intuitiveness. Developers need to frequently switch between the template code and the output, manually trace the logic and run the code repeatedly, which is a cumbersome and error-prone process. Therefore, there is an urgent need to propose a template code modification method based on deep learning, which is output text-oriented and supports developers to directly edit the output text generated by the template, so as to greatly simplify the template development process and improve the efficiency, accuracy, and intelligence level of development. Summary of the Invention

[0005] To solve the above problems, the present invention proposes an output text-oriented template code modification method based on deep learning. Centering on the output text, a two-stage bidirectional framework containing a deep learning module is constructed to achieve a structured mapping and automatic synchronization between the output text editing and the template code, improving the intelligence and automation of template development.

[0006] The specific solution is as follows:

[0007] An output text-oriented template code modification method based on deep learning, comprising:

[0008] S1, perform semantic normalization processing on the template code to be modified through a template code conversion module to obtain a core language representation with semantic norms;

[0009] S2, input the core language representation with semantic norms into the forward calculation stage of the two-stage bidirectional framework. Through forward calculation, convert the core language representation with semantic norms into an initial structured intermediate representation, convert the variable declarations and assignment expressions in the initial structured intermediate representation into a functional structure, generate a final structured intermediate representation based on the functional structure, and record the metadata information of the final structured intermediate representation; convert the final structured intermediate representation into an output text;

[0010] S3, receive an editing operation on the output text, obtain the edited output text, generate an editing instruction based on the edited output text, and parse the editing instruction into a corresponding update operation; the update operation includes the content of the edited output text and the operation type;

[0011] S4, input the content of the edited output text, the operation type, and the metadata information into the deep learning module, predict a structured update instruction through the deep learning module, and fuse the structured update instruction into the structured intermediate representation to obtain a fused structured intermediate representation;

[0012] S5, through the backward propagation stage of the two-stage bidirectional framework, perform a functional structure expansion process on the fused structured intermediate representation to obtain a restored structured intermediate representation, perform a de-evaluation process on the restored structured intermediate representation to obtain a restored core language representation, and convert the restored core language representation into a finally modified template code.

[0013] The S1 specifically includes:

[0014] S11, receive the template code to be modified;

[0015] S12, perform syntax analysis and structure parsing operations on the template code, and identify and extract variable declarations, assignment statements, and control structures in the template code; the control structures include conditional judgments and loop bodies;

[0016] S13. Convert variable declarations, assignment statements, and control structures into a standardized core language representation. Add variable binding information and scope markers to the core language representation to clarify the variable's lifecycle and visible scope, and output the core language representation with semantic specifications.

[0017] Further, the S2 specifically includes:

[0018] S21. Perform line-by-line parsing on the core language representation with semantic specifications to obtain an initial structured intermediate representation and record execution trace information. The execution trace information includes the code execution order, conditional branch paths, and loop unrolling situations. During the line-by-line parsing process, extract and establish the static code structure and dynamic execution paths of the core language representation. The dynamic execution paths include the actual flow paths of conditional judgments and loops. Convert the variable declarations and assignment statements in the initial structured intermediate representation into a functional structure with semantic tags, and record the binding relationships between variables and the semantic side effect information that will be triggered.

[0019] S22. Generate a final structured intermediate representation based on the static code structure and dynamic execution paths. The final structured intermediate representation includes function calls, variable usage, and control structures.

[0020] S23. Embed control flow markers in the final structured intermediate representation and record the metadata information in the structured intermediate representation. The metadata information includes the variable's lifecycle, scope, expression type, and semantic tags. The control flow markers are used to identify the logical start and end positions, conditional expressions, and branch jump relationships of each control structure in the structured intermediate representation.

[0021] S24. Perform a destructuring operation on the structured intermediate representation to obtain the output text. The output text supports editing operations.

[0022] Further, the S3 specifically includes:

[0023] S31. Receive the editing operations made by the user based on the output text. The editing operations include inserting text, deleting text, and replacing text.

[0024] S32. Determine the number of editing operations. If the number is equal to one, use the received editing operation as input, parse and convert it into a structured update operation, and extract and record the corresponding operation type, target position, and operation content. If there are more than one, parse and convert multiple editing instructions into structured update operations, perform semantic consistency verification and sequential relationship analysis at the same time, and perform batch fusion processing based on the analysis results to generate an ordered set of update operations.

[0025] Further, the S4 specifically includes:

[0026] S41. Use the content of the output text to be edited, the operation type, and the metadata information recorded in the structured intermediate representation as multi-source inputs, and input them into the deep learning module. The deep learning module is constructed based on the Transformer architecture and adopts an encoder-decoder structure. Among them, the encoder performs semantic encoding on the multi-source inputs, and the decoder generates corresponding structured update instructions according to the context. The structured update instructions include modifications to variable assignments, adjustments to loop structures, replacement or deletion of control statements.

[0027] S42. Incorporate the structured update instructions into the structured intermediate representation. During the incorporation process, introduce a functional structure with attached semantic tags to ensure the structural consistency of the binding relationships between variables and semantic side effect information during the incorporation process. At the same time, refer to the control flow markers embedded in the structured intermediate representation to locate and verify the control structures corresponding to the structured update instructions, ensuring the integrity of the control structure and the consistency of the execution path in the incorporation result, and obtaining the incorporated structured intermediate representation.

[0028] Further, in S5, through the backward propagation stage in the two-stage bidirectional framework, perform a functional structure unfolding process on the incorporated structured intermediate representation to obtain the restored structured intermediate representation, and perform a de-evaluation process on the restored structured intermediate representation to obtain the restored core language representation, specifically including:

[0029] S51. Receive the incorporated structured intermediate representation as input, and through performing a functional structure unfolding process, restore the semantic tag forms used to represent variable assignments and dependency relationships in the structured intermediate representation to explicit variable declaration statements and assignment statements. During the restoration process, eliminate nested syntactic structures through a structure flattening operation to generate a restored structured intermediate representation with a syntax-compliant result.

[0030] S52. Perform a de-evaluation process on the explicit variable declaration statements and assignment statements in the restored structured intermediate representation. According to the execution trace information recorded in the forward calculation stage, combined with the control flow markers embedded in the structured intermediate representation, restore the calculation structures of each declaration statement and assignment statement, and reconstruct the conditional judgment statements and loop structures in the control flow, and output the restored core language representation.

[0031] Further, convert the restored core language representation into the finally modified template code, specifically including:

[0032] Restore the control structures represented in the restored core language to the corresponding conditional branch statements and loop statements in the surface language, map the variable declarations and assignment operations in the restored core language to the syntactic forms with corresponding semantics in the surface language, and generate the final template code output based on the conditional branch statements, loop statements, variable declarations, and assignment operations transformed into the surface language

[0033] On the other hand, an output text-oriented template code modification system based on deep learning includes:

[0034] A semantic normalization module for performing semantic normalization processing on the template code to be modified through the template code conversion module to obtain a core language representation with semantic norms;

[0035] An output text conversion module for inputting the core language representation with semantic norms into the forward calculation stage of the two-stage bidirectional framework, converting the core language representation with semantic norms into an initial structured intermediate representation through forward calculation, converting the variable declarations and assignment expressions in the initial structured intermediate representation into a functional structure, generating a final structured intermediate representation based on the functional structure, and recording the metadata information of the final structured intermediate representation; converting the final structured intermediate representation into an output text;

[0036] An update operation acquisition module for receiving an editing operation on the output text, obtaining the edited output text, generating an editing instruction based on the edited output text, and parsing the editing instruction into a corresponding update operation; the update operation includes the content of the edited output text and the operation type;

[0037] A fusion module for inputting the content of the edited output text, the operation type, and the metadata information into the deep learning module, predicting a structured update instruction through the deep learning module, and fusing the structured update instruction into the structured intermediate representation to obtain a fused structured intermediate representation;

[0038] A template code modification module for performing a functional structure expansion process on the fused structured intermediate representation through the backward propagation stage in the two-stage bidirectional framework to obtain a restored structured intermediate representation, performing a de-evaluation process on the restored structured intermediate representation to obtain a restored core language representation, and converting the restored core language representation into a finally modified template code.

[0039] The present invention adopts the above technical solutions and has the following beneficial effects:

[0040] (1) The present invention normalizes the template code represented in the surface language into a core language representation through the template code conversion module, unifies its semantic structure and control logic, and effectively reduces the complexity of subsequent in-depth analysis and processing;

[0041] (2) The present invention adopts the forward calculation stage in the two-stage bidirectional framework, generates a structured intermediate representation by simulating the evaluation process of the template code, and embeds metadata information such as control structures and variable bindings, providing precise context support for structured update operations;

[0042] (3) The present invention introduces a deep learning module based on the Transformer architecture, utilizes its multi-source information modeling and context understanding capabilities, and converts the user's editing instructions on the output text into structured update instructions, significantly improving the intelligent conversion efficiency and accuracy from natural editing behavior to code structure modification;

[0043] (4) In the backpropagation stage, the present invention unfolds through a functional structure and performs de-evaluation processing, restores the structured update results predicted by deep learning to the core language code, and supports the semantic reconstruction of variable declarations, assignment statements, and control flow structures, realizing high-fidelity modification and synchronization of the template code;

[0044] (5) The present invention finally restores the modified core language representation to the surface language template code, ensuring that the output result conforms to the syntax specifications and engineering environment requirements of the original template language, thereby simplifying the template editing process, improving development efficiency, reducing error rates, and meeting the intelligent modification requirements in complex template scenarios. Description of the Drawings

[0045] Figure 1 is a flowchart of the method for modifying output text-oriented template code based on deep learning according to an embodiment of the present invention;

[0046] Figure 2 is a system diagram of the method for modifying output text-oriented template code based on deep learning according to an embodiment of the present invention;

[0047] Figure 3 is a two-stage bidirectional framework diagram of the method for modifying output text-oriented template code based on deep learning according to an embodiment of the present invention. Detailed Embodiment

[0048] The present invention will be further described in detail below in conjunction with the embodiments and the drawings, but the embodiments of the present invention are not limited thereto. As Figure 1 shown, the method for modifying output text-oriented template code based on deep learning of the present invention includes:

[0049] S1, performing semantic normalization processing on the template code to be modified through a template code conversion module to obtain a core language representation with semantic specifications.

[0050] Specifically, the S1 specifically includes:

[0051] S11, receiving the template code to be modified as input;

[0052] S12. Perform syntax analysis and structure parsing operations on the template code to identify and extract variable declarations, assignment statements, and control structures in the template code; the control structures include conditional judgments and loops.

[0053] S13. Convert variable declarations, assignment statements, and control structures into a standardized core language representation, add variable binding information and scope markers to the core language representation to clarify the life cycle and visible scope of variables, and output a semantically standardized core language representation.

[0054] S2. Input the semantically standardized core language representation into the forward calculation stage of the two-stage bidirectional framework, obtain a structured intermediate representation of the core language representation through forward calculation, and record the metadata information of the structured intermediate representation; convert the structured intermediate representation into output text.

[0055] Specifically, S2 specifically includes:

[0056] S21. Perform line-by-line parsing on the semantically standardized core language representation to obtain an initial structured intermediate representation, and record the execution trace information; the execution trace information includes the code running order, conditional branch paths, and loop unrolling situations; during the line-by-line parsing process, extract and establish the static code structure and dynamic execution path of the core language representation, and the dynamic execution path includes the actual flow paths of conditional judgments and loops; convert the variable declarations and assignment statements in the initial structured intermediate representation into a functional structure with semantic tags, and record the binding relationships between variables and the semantic side effect information that will be triggered.

[0057] S22. Generate a final structured intermediate representation based on the static code structure and dynamic execution path; the final structured intermediate representation includes function calls, variable uses, and control structures.

[0058] S23. Embed control flow markers in the final structured intermediate representation, and record the metadata information in the structured intermediate representation; the metadata information includes the life cycle of variables, scope range, expression type, and semantic tags; the control flow markers are used to identify the logical start and end positions, conditional expressions, and branch jump relationships of each control structure in the structured intermediate representation.

[0059] S24. Perform a destructuring operation on the structured intermediate representation to obtain output text; the output text supports editing operations.

[0060] S3. Receive an editing operation on the output text to obtain the edited output text, generate an editing instruction based on the edited output text, and parse the editing instruction into a corresponding update operation; the update operation includes the content of the edited output text and the operation type.

[0061] Specifically, step S3 specifically includes:

[0062] S31, receiving an editing operation made by the user based on the output text, where the editing operation includes inserting text, deleting text, and replacing text;

[0063] S32, judging the number of editing operations; if the number is equal to one, using the received editing operation as input, parsing and converting it into a structured update operation, extracting and recording the corresponding operation type, target position, and operation content; if there are more than one, parsing and converting multiple editing instructions into structured update operations, simultaneously performing semantic consistency verification and sequential relationship analysis, and performing batch fusion processing based on the analysis results to generate an ordered set of update operations.

[0064] S4, inputting the content of the edited output text, operation type, and metadata information into the deep learning module, predicting a structured update instruction through the deep learning module, and fusing the structured update instruction into the structured intermediate representation to obtain a fused structured intermediate representation.

[0065] Specifically, step S4 specifically includes:

[0066] S41, inputting the content of the edited output text, operation type, and metadata information recorded in the structured intermediate representation into the deep learning module; the deep learning module is constructed based on the Transformer architecture and adopts an encoder-decoder structure. Among them, the encoder performs semantic encoding on multi-source inputs, and the decoder generates corresponding structured update instructions according to the context; the structured update instructions include modifications to variable assignments, adjustments to loop structures, replacement or deletion of control statements; among them, the encoder consists of several layers of multi-head attention mechanisms and feed-forward neural networks, and the input is the text content to be edited, operation type, and metadata information, and vector representation fusion is performed through positional encoding; the decoder also consists of multiple layers of attention and feed-forward networks, and generates corresponding structured update instructions based on the context through self-attention and cross-attention mechanisms with the encoder output;

[0067] S42, fusing the structured update instruction into the structured intermediate representation, introducing a functional structure with attached semantic tags during the fusion process to ensure the structural consistency of variable binding relationships and semantic side effect information during the fusion process, and at the same time referring to the control flow markers embedded in the structured intermediate representation to locate and verify the control structure corresponding to the structured update instruction to ensure the integrity of the fusion result in the control structure and the consistency of the execution path, and obtaining a fused structured intermediate representation.

[0068] The functional structure with attached semantic tags introduced in this embodiment can be understood as a tagged Lambda application, which is used to represent variable declarations and assignments to achieve consistent control of side effects. Subsequently, the updated computational structured output is subjected to de-Lambda application (unfolding of the functional structure) and de-evaluation processing, and then the core language representation is reconstructed, and finally converted into the modified template program code.

[0069] S5. Through the backward propagation stage in the two-phase bidirectional framework, perform functional structure unfolding processing on the fused structured intermediate representation to obtain the restored structured intermediate representation, perform de-evaluation processing on the restored structured intermediate representation to obtain the restored core language representation, and convert the restored core language representation into the finally modified template code.

[0070] Specifically, in S5, through the backward propagation stage in the two-phase bidirectional framework, perform functional structure unfolding processing on the fused structured intermediate representation to obtain the restored structured intermediate representation, and perform de-evaluation processing on the restored structured intermediate representation to obtain the restored core language representation, which specifically includes:

[0071] S51. Receive the fused structured intermediate representation as input, and through performing functional structure unfolding processing, restore the semantic tag forms in the structured intermediate representation that represent variable assignments and dependencies to explicit variable declaration statements and assignment statements; during the restoration process, eliminate nested syntax structures through structure flattening operations to generate a restored structured intermediate representation that conforms to the syntax specification.

[0072] S52. Perform de-evaluation processing on the explicit variable declaration statements and assignment statements in the restored structured intermediate representation. According to the execution trace information recorded in the forward calculation stage, combined with the control flow tags embedded in the structured intermediate representation, restore the calculation structures of each declaration statement and assignment statement, and reconstruct the conditional judgment statements and loop structures in the control flow, and output the restored core language representation.

[0073] Specifically, converting the restored core language representation into the finally modified template code specifically includes:

[0074] Restore the control structure of the restored core language representation to the corresponding conditional branch statements and loop statements in the surface language, map the variable declarations and assignment operations in the restored core language to the syntactic forms with corresponding semantics in the surface language, and generate the final template code output based on the conditional branch statements, loop statements, variable declarations, and assignment operations converted into the surface language.

[0075] Specifically, the conversion process of the template program in this embodiment can be executed in the following manner: Receive the input template program. Parse logical elements such as variable declarations and control structures in the template program. Propagate the parsing result into a core language representation, and describe the semantics of the template program using standardized terms (such as constants, declarations, assignments, conditions, and loops). Add variable bindings and scope markers to ensure semantic consistency of the core language representation. The process of forward calculation and generating plain text output based on the above method includes: Execute the core language program and record the program execution trace. Convert variable declarations and assignments into tagged Lambda application forms, and record variable binding and side effect information. Generate an intermediate representation containing control flow markers. Perform destructuring on the computed structured output (the computed structured output is the structured intermediate representation) to generate the final plain text output. The subsequent process of receiving and parsing text editing instructions includes: Receive the user's editing instructions for the plain text output, and the instructions include inserting new text, deleting specified text, or replacing existing text; Parse the editing instructions into update operations, and record the operation type, target position, and operation content. Perform fusion processing on batch editing instructions to generate an ordered set of update operations. Then the reverse propagation and reverse translation process includes: According to the target position and content of the editing operation, use the fusion algorithm to propagate it to the corresponding part of the computed structured output. Perform de-Lambda application processing on the updated computed structured output (de-Lambda application processing is the functional structure expansion processing), restore the tagged Lambda application to variable declarations or assignment statements, and eliminate nested sequences through flattening. Perform de-evaluation processing, restore the declaration and assignment calculation structures according to the execution trace of the forward calculation, and reconstruct conditional statements and loop structures to generate the updated core language representation. Finally, restore the control structures of the core language to conditional branches and loop instructions in the surface language. Convert variable declarations and assignments into the corresponding syntax of the surface language. Modify the corresponding template program code.

[0076] Generally speaking, in the forward calculation stage, the core language program is evaluated to generate a computed structured output. The computed structured output serves as an intermediate representation, retaining the execution traces and control structure markers of the template program, including the expansion information of conditional branches and loops; Subsequently, perform destructuring on the computed structured output, and the output is plain text. In the reverse propagation stage, parse the user's editing instructions for the plain text output into update operations, propagate the update operations to the computed structured output through the fusion algorithm to generate the updated computed structured output; Perform de-Lambda application and de-evaluation processing on the updated computed structured output to restore the declaration and assignment calculation structures and reconstruct the updated core language representation. The computed structured output supports the precise propagation of update operations by capturing the program execution trace and control statement markers, and can restore the elements lost in the evaluation stage during the de-evaluation process, such as alternative paths of conditional branches.

[0077] Specifically, the core of the output text-oriented template code modification method based on deep learning proposed in this embodiment lies in constructing a two-way transformation mechanism that supports reverse mapping from the output text and automatically updates the template code. For example, in web design, the traditional method requires directly modifying the template code to adjust the web content, which is complex and error-prone. With this method, developers are allowed to directly edit the content displayed on the web page, such as modifying text, adjusting list items, etc. The system can automatically identify these changes and intelligently update the corresponding template code to achieve synchronous modification of the output content and the template code. For example, in the scenario of using Mustache templates to generate README documents, the template may contain variables such as version = "2.0.0" and an API list endpoints = ["add_attachment"]. After running the template, the README displayed shows "Installation version: 2.0.0" and "API: add_attachment". When the user wants to modify them to "2.1.5" and "add_details", the traditional method requires returning to the template to manually locate and modify the corresponding variables or list content. However, this invention supports the user to directly modify the above content in the generated README text, and the system can automatically identify the changes, locate the relevant code positions in the template, and complete the synchronous update of the template code, thus greatly simplifying the operation process and improving the efficiency and reliability of template maintenance.

[0078] As Figure 2 shown, this embodiment also discloses an output text-oriented template code modification system based on deep learning, including:

[0079] A semantic normalization module 21, configured to perform semantic normalization processing on the template code to be modified through the template code conversion module to obtain a core language representation with semantic norms;

[0080] An output text conversion module 22, configured to input the core language representation with semantic norms into the forward calculation stage of the two-stage bidirectional framework, convert the core language representation with semantic norms into an initial structured intermediate representation through forward calculation, convert the variable declarations and assignment expressions in the initial structured intermediate representation into a functional structure, generate a final structured intermediate representation based on the functional structure, and record the metadata information of the final structured intermediate representation; convert the final structured intermediate representation into output text;

[0081] An update operation acquisition module 23, configured to receive an edit operation on the output text, obtain the edited output text, generate an edit instruction based on the edited output text, and parse the edit instruction into a corresponding update operation; the update operation includes the content of the edited output text and the operation type;

[0082] A fusion module 24, configured to input the edited output text content, operation type, and metadata information into a deep learning module, predict a structured update instruction through the deep learning module, fuse the structured update instruction into a structured intermediate representation, and obtain a fused structured intermediate representation;

[0083] A template code modification module 25, configured to perform a functional structure expansion process on the fused structured intermediate representation through a backpropagation stage in a two-stage bidirectional framework, obtain a restored structured intermediate representation, perform a de-evaluation process on the restored structured intermediate representation, obtain a restored core language representation, and convert the restored core language representation into a finally modified template code.

[0084] In addition, as Figure 3 shown, this embodiment also discloses a two-stage bidirectional framework diagram of an output text-oriented template code modification method based on deep learning. The two-stage bidirectional framework includes two main stages: a forward calculation stage and a backpropagation stage.

[0085] In the forward calculation stage, a structured intermediate representation is generated using a core language representation, which includes control flow markers and metadata information for preserving code semantics; meanwhile, variable declarations and assignment expressions in the structured intermediate representation are converted into a functional structure. On this basis, a preliminary output text is generated through a de-structuring process.

[0086] The output text can be edited by the user to obtain an edited output text; the editing content during the editing process, together with the editing operation type and its related metadata information, is input into the deep learning module. This module generates a structured update instruction based on the above information to update the structured intermediate representation and form a fused structured intermediate representation.

[0087] In the backpropagation stage, by performing a functional structure expansion process on the fused structured intermediate representation, the functional structure used to represent variable declarations, assignment semantics, and their dependencies in the forward calculation stage is restored, so as to restore it to explicit variable declaration statements and assignment statements; then, based on the expanded structured intermediate representation, a de-evaluation process is performed, and according to the execution trace information and control flow markers recorded in the forward stage, the calculation structure of each statement is restored, and conditional statements and loop structures in the control flow are reconstructed, finally generating a restored core language representation.

[0088] The specific implementation of the output text-oriented template code modification system based on deep learning is the same as that of the output text-oriented template code modification method based on deep learning, and this embodiment will not repeat the description.

[0089] Although the present invention has been specifically shown and described in connection with preferred embodiments, those skilled in the art should understand that various changes may be made to the present invention in form and detail without departing from the spirit and scope of the present invention as defined by the appended claims, and all such changes are within the scope of protection of the present invention.

Claims

1. An output text-oriented template code modification method based on deep learning, characterized in that, Including: S1. Perform semantic normalization processing on the template code to be modified through a template code conversion module to obtain a core language representation with semantic specification; S2. Input the core language representation with semantic specification into the forward calculation stage of the two-stage bidirectional framework. Through forward calculation, convert the core language representation with semantic specification into an initial structured intermediate representation, convert the variable declarations and assignment expressions in the initial structured intermediate representation into a functional structure, generate a final structured intermediate representation based on the functional structure, and record the metadata information of the final structured intermediate representation; Convert the final structured intermediate representation into an output text; S3. Receive an editing operation on the output text, obtain the edited output text, generate an editing instruction based on the edited output text, and parse the editing instruction into a corresponding update operation; the update operation includes the content of the edited output text and the operation type; S4. Input the content of the edited output text, the operation type, and the metadata information into a deep learning module, predict a structured update instruction through the deep learning module, and fuse the structured update instruction into the structured intermediate representation to obtain a fused structured intermediate representation; S5. Through the backward propagation stage in the two-stage bidirectional framework, perform a functional structure expansion process on the fused structured intermediate representation to obtain a restored structured intermediate representation, perform a de-evaluation process on the restored structured intermediate representation to obtain a restored core language representation, and convert the restored core language representation into a final modified template code.

2. The method for modifying template code oriented to output text based on deep learning according to claim 1, characterized in that The S1 specifically includes: S11. Receive the template code to be modified; S12. Perform syntax analysis and structure parsing operations on the template code, and identify and extract variable declarations, assignment statements, and control structures in the template code; the control structures include conditional judgments and loop bodies; S13. Convert the variable declarations, assignment statements, and control structures into a standardized core language representation, add variable binding information and scope markers to the core language representation to clarify the life cycle and visible range of variables, and output the core language representation with semantic specification.

3. The method for modifying template code oriented to output text based on deep learning according to claim 1, wherein The S2 specifically includes: S21. Perform line-by-line parsing on the core language representation with semantic specification to obtain an initial structured intermediate representation, and record the execution trace information; the execution trace information includes the code running order, conditional branch paths, and loop unrolling situations; during the line-by-line parsing process, extract and establish the static code structure and dynamic execution path of the core language representation, and the dynamic execution path includes the actual flow paths of conditional judgments and loops; convert the variable declarations and assignment statements in the initial structured intermediate representation into a functional structure with semantic tags, and record the binding relationships between variables and the semantic side effect information that will be caused; S22. Generate a final structured intermediate representation based on the static code structure and dynamic execution path; the final structured intermediate representation includes function calls, variable uses, and control structures; S23. Embed control flow markers in the final structured intermediate representation and record the metadata information in the structured intermediate representation; the metadata information includes the life cycle, scope, expression type, and semantic tags of variables; the control flow markers are used to identify the logical start and end positions, conditional expressions, and branch jump relationships of each control structure in the structured intermediate representation. S24. Perform a destructuring operation on the structured intermediate representation to obtain an output text; the output text supports editing operations.

4. The method for modifying template code oriented to output text based on deep learning according to claim 1, wherein The S3 specifically includes: S31. Receive the editing operations made by the user based on the output text, and the editing operations include inserting text, deleting text, and replacing text. S32. Determine the number of editing operations; if the number is equal to one, use the received editing operation as input, parse and convert it into a structured update operation, and extract and record the corresponding operation type, target position, and operation content; if there are more than one, parse and convert multiple editing instructions into structured update operations, perform semantic consistency verification and sequential relationship analysis at the same time, perform batch fusion processing based on the analysis results, and generate an ordered set of update operations.

5. The method for modifying template code oriented to output text based on deep learning according to claim 1, wherein The S4 specifically includes: S41. Use the content of the edited output text, operation type, and metadata information recorded in the structured intermediate representation as multi-source input and input it into the deep learning module; the deep learning module is built based on the Transformer architecture and adopts an encoder-decoder structure, where the encoder performs semantic encoding on the multi-source input, and the decoder generates corresponding structured update instructions according to the context; the structured update instructions include modifications to variable assignments, adjustments to loop structures, replacement or deletion of control statements. S42. Integrate the structured update instructions into the structured intermediate representation. During the integration process, introduce a functional structure with attached semantic tags to ensure the structural consistency of the binding relationship between variables and semantic side effect information during the integration process. At the same time, refer to the control flow markers embedded in the structured intermediate representation, locate and verify the control structures corresponding to the structured update instructions, and ensure the integrity of the control structure and the consistency of the execution path in the integration result to obtain the integrated structured intermediate representation.

6. The method for modifying template code oriented to output text based on deep learning according to claim 2, characterized in that, In S5, through the backward propagation stage in the two-stage bidirectional framework, perform a functional structure unfolding process on the integrated structured intermediate representation to obtain the restored structured intermediate representation, and perform a de-evaluation process on the restored structured intermediate representation to obtain the restored core language representation, specifically including: S51. Receive the integrated structured intermediate representation as input, and through performing a functional structure unfolding process, restore the semantic marker forms used to represent variable assignments and dependency relationships in the structured intermediate representation to explicit variable declaration statements and assignment statements; during the restoration process, eliminate nested syntax structures through structure flattening operations to generate a restored structured intermediate representation with a result conforming to the syntax specification. S52 performs de-evaluation processing on the explicit variable declaration statements and assignment statements in the restored structured intermediate representation. According to the execution trace information recorded in the forward calculation stage, combined with the control flow markers embedded in the structured intermediate representation, it restores the calculation structures of each declaration statement and assignment statement, and reconstructs the conditional judgment statements and loop structures in the control flow, and outputs the restored core language representation.

7. The method for modifying template code oriented by output text based on deep learning according to claim 6, wherein Convert the restored core language representation into the finally modified template code, specifically including: Restore the control structures of the restored core language representation to the corresponding conditional branch statements and loop statements in the surface language, map the variable declarations and assignment operations in the restored core language to the syntactic forms with corresponding semantics in the surface language, and generate the final template code output based on the conditional branch statements, loop statements, variable declarations, and assignment operations converted into the surface language.

8. An output text-oriented template code modification system based on deep learning, characterized in that, Including: A semantic normalization module for performing semantic normalization processing on the template code to be modified through the template code conversion module to obtain a semantically normalized core language representation; An output text conversion module for inputting the semantically normalized core language representation into the forward calculation stage of the two-stage bidirectional framework, converting the semantically normalized core language representation into an initial structured intermediate representation through forward calculation, converting the variable declarations and assignment expressions in the initial structured intermediate representation into a functional structure, generating a final structured intermediate representation based on the functional structure, and recording the metadata information of the final structured intermediate representation; Convert the final structured intermediate representation into output text; An update operation acquisition module for receiving the editing operation on the output text, obtaining the edited output text, generating an edit instruction based on the edited output text, and parsing the edit instruction into a corresponding update operation; the update operation includes the content of the edited output text and the operation type; A fusion module for inputting the content of the edited output text, the operation type, and the metadata information into the deep learning module, predicting a structured update instruction through the deep learning module, and fusing the structured update instruction into the structured intermediate representation to obtain a fused structured intermediate representation; A template code modification module for performing functional structure expansion processing on the fused structured intermediate representation through the backward propagation stage in the two-stage bidirectional framework to obtain a restored structured intermediate representation, performing de-evaluation processing on the restored structured intermediate representation to obtain a restored core language representation, and converting the restored core language representation into the finally modified template code.

Citation Information

Patent Citations

  • Data processing system capable of maintaining dependency relationship in advanced language program data flow diagram extraction

    CN102508689A

  • A model-based computer software development method

    CN109375904A

  • Java method annotation instant automatic updating method based on data flow analysis and attention mechanism

    CN115826988A

  • Code generation modification method and device based on large-scale pre-training model, equipment and storage medium

    CN117591118A

  • Software development management method based on artificial intelligence

    CN118295640A