A step-by-step programming teaching method and system based on a deep learning model

By constructing a text structure tree and an abstract syntax tree from a deep learning model, and combining them with a pre-trained UniXcoder model, the problem of matching text and code in programming tutorial writing is solved, improving the efficiency and consistency of programming tutorial writing.

CN119088374BActive Publication Date: 2025-10-24ZHEJIANG UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411084763.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2025-10-24
Estimated Expiration
2044-08-08

AI Technical Summary

Technical Problem

Writing high-quality step-by-step programming tutorials requires a cumbersome workflow, and existing technologies struggle to effectively combine text and code, resulting in low writing efficiency and difficulty in ensuring consistency.

Method used

We construct a text structure tree and abstract syntax tree based on a deep learning model. Through feature extraction, mapping, and similarity matching, we assist users in writing programming tutorials. We also use a pre-trained UniXcoder model to perform text-code association and provide code snippet recommendations for programming needs.

Benefits of technology

It enables users to quickly locate the connection between text and code when writing programming tutorials, reducing cognitive burden, improving tutorial writing efficiency, and ensuring consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088374B_ABST
    Figure CN119088374B_ABST
Patent Text Reader

Abstract

The application discloses a step-by-step programming teaching method based on a deep learning model, which comprises the following steps: constructing a text structure tree and an abstract syntax tree; constructing a deep learning model based on the text structure tree and the abstract syntax tree as a constraint framework, wherein the deep learning model comprises a feature extraction module, a feature mapping module and a prediction module; inputting text content of a programming requirement into the deep learning model to obtain a code piece corresponding to the programming requirement when the deep learning model is used; and the application further provides a step-by-step programming teaching system. The method provided by the application provides a tutorial content writing prompt and guidance for a user, so that the user can quickly and easily write a step-by-step programming tutorial in a programming tutorial.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of teaching aids, and particularly relates to a step-by-step programming teaching method and system based on a deep learning model. BACKGROUND

[0002] A programming tutorial is a document used to impart programming skills and how to solve programming problems to learners. Many programmers disseminate their programming knowledge in the form of tutorials. As the demand for learning programming continues to expand, the number of tutorial authors (such as program developers, computer science educators, data scientists, etc.) also increases, and research on improving the writing experience and workflow of programming tutorials also increases. Among the types of programming tutorials, step-by-step programming tutorials are relatively common and easy to understand.

[0003] However, writing a high-quality step-by-step programming tutorial is still a tedious task. A high-quality tutorial should include concise code, step-by-step solutions, and highlights, etc. In a typical workflow, creating a step-by-step programming tutorial requires organizing the structure and writing prose explanations. Clear and easy-to-understand code explanations require the author to have extensive experience and a thorough understanding of the code. The author usually views the code in a programming tool (such as Visual Studio Code) and then edits it in a text editor. This requires switching between the programming tool and the text editor to ensure the correctness of the content structure description. After completing the tutorial, the author also needs to verify their consistency, which makes writing a tutorial a laborious task.

[0004] Patent document CN116151132A discloses an intelligent code completion method and system for a programming learning scenario, and a storage medium. The source code is input into a transformer deep neural network model that has been trained to output a predicted result after the source code is completed. The intelligent code completion method and system preprocess a unique data set and select different recommendation algorithms according to user feedback to continuously improve the quality of recommended code in the intelligent code completion function. The abstract syntax tree generated by the source code is split and reconstructed, capturing more semantic information of the code, thereby improving the accuracy of code completion. The invention uses a deep learning method for code completion prompts, but cannot understand user text input and problem requirements. At the same time, its method completely relies on the trained data set, and the generalization ability of the model is poor.

[0005] Patent document CN116974541A discloses a programming assistance method based on LLM, specifically including the following steps: deploying a programming assistance model as an interface service, using a protocol and data format for interface access; wherein the programming assistance model is a large language model; establishing a programming management platform, and connecting the programming assistance model interface to the programming management platform; and interacting with the programming assistance model using the programming management platform to complete programming assistance work. The invention does not perform specialized training on the syntax of graphical programming languages, and cannot well complete the generation and visualization of graphical programming languages. SUMMARY

[0006] The present application aims to provide a step-by-step programming teaching method and system based on a deep learning model, which provides tutorial content writing prompts and guidance for users, allowing them to quickly and easily write step-by-step programming tutorials in programming tutorials.

[0007] To achieve the first object of the present application, the following technical solution is provided: a step-by-step programming teaching method based on a deep learning model, comprising the following steps:

[0008] Obtain a set of text segments related to programming step descriptions in the programming tutorial, and construct a corresponding text structure tree with each text segment as a node and the programming steps as edges;

[0009] According to the programming code collection involved in the programming teaching, construct a corresponding abstract syntax tree with code segments as nodes and the running relationship of the code as edges;

[0010] Based on the text structure tree and the abstract syntax tree as a constraint framework, construct a deep learning model, which includes a feature extraction module, a feature mapping module, and a prediction module;

[0011] The feature extraction module is used to extract the first text features of the input natural language text and the second text features of the code segments in the programming code collection;

[0012] The feature mapping module is used to project the first text features and the second text features into a vector space simultaneously to obtain corresponding first feature vectors and second feature vectors;

[0013] The prediction module uses the first feature vectors and the second feature vectors for similarity matching to output a matching result, which includes the top K highest similarity code segments matched by the input natural language text;

[0014] Input the code phrase input by the user into the deep learning model to visually output the code segments related to the code phrase;

[0015] In use, the text content of the programming requirement is input into the deep learning model to obtain a code segment corresponding to the programming requirement.

[0016] The application matches the text-code association based on the connection engine of the deep learning model and the user interaction history. The deep learning model of natural language processing embeds the code and the text in the same vector space to detect the vector similarity. Meanwhile, the abstract syntax tree and the text structure tree are introduced to constrain the matching method, so as to ensure that the matching result is a valid code segment and the order is consistent with the description text.

[0017] Specifically, in the text structure tree, the main step and the sub-step are regarded as the parent node and the child node, and the sibling steps are regarded as the sibling nodes.

[0018] Specifically, the abstract syntax tree recursively traverses from the root node and deletes the nodes that do not meet the requirements to retain the relevant nodes and branches.

[0019] Specifically, the prediction module follows the validity principle and the consistency principle in the process of similarity matching.

[0020] Specifically, the validity principle refers to that the code segment corresponding to the second feature vector is structurally complete, and is specifically set as follows: the abstract syntax tree is set as A, and for any node , if , then ; the code segment can be represented as the sequence of AST sub-trees: ; wherein, represents the sub-tree with the root node , and are continuous child nodes of the same parent node.

[0021] Specifically, the consistency principle refers to that the natural language text corresponding to the first feature vector is consistent with the structure of the code segment corresponding to the second feature vector.

[0022] Specifically, the network framework of the deep learning model adopts the pre-trained UniXcoder.

[0023] Specifically, the similarity matching is calculated by using the cosine similarity calculation formula.

[0024] In order to achieve the second object of the application, the following technical scheme is provided: a step-by-step programming teaching system, which is realized by the above-mentioned step-by-step programming teaching method based on the deep learning model, comprising:

[0025] An input module is configured to input the text content of the programming requirement.

[0026] A correlation analysis module is configured to output a relevant code segment according to input text content;

[0027] A source code display module is configured to display programming tutorial content corresponding to the code segment.

[0028] Compared with the prior art, the present application has the following advantages:

[0029] By extracting the structural association between the text and the code, the user can intuitively understand the relationship between the current text content and the code, quickly locate the two, use the entry as a subsequent further efficient writing and modification tutorial, and reduce the cognitive burden.

[0030] Meanwhile, the deep learning model is used to match the similarity between the text and the code, which assists the user in verifying the current content and is beneficial to subsequent tutorial writing. BRIEF DESCRIPTION OF DRAWINGS

[0031] Figure 1 A flowchart of the step-by-step programming teaching method provided by the present embodiment;

[0032] Figure 2 A schematic diagram of the effectiveness principle provided by the present embodiment;

[0033] Figure 3 A schematic diagram of the consistency principle provided by the present embodiment;

[0034] Figure 4 An interface display diagram of the step-by-step programming teaching system provided by the present embodiment. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. The components of the embodiments of the present application described and shown in the drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of the present application.

[0036] As shown in Figure 1 A step-by-step programming teaching method based on a deep learning model provided by the present application includes the following steps:

[0037] A set of text segments related to programming step descriptions in a programming tutorial is obtained, and a corresponding text structure tree is constructed with each text segment as a node and the programming steps as edges.

[0038] An abstract syntax tree is constructed with code segments as nodes and code running relationships as edges according to a set of programming codes involved in the programming teaching.

[0039] A deep learning model is constructed based on the text structure tree and the abstract syntax tree as a constraint framework, and the deep learning model includes a feature extraction module, a feature mapping module, and a prediction module.

[0040] The feature extraction module is configured to extract first text features of an input natural language text and second text features of code segments in a set of programming codes.

[0041] The feature mapping module is configured to project the first text features and the second text features to a vector space simultaneously to obtain corresponding first feature vectors and second feature vectors.

[0042] The prediction module is configured to perform similarity matching on the first feature vectors and the second feature vectors to output a matching result, and the matching result includes the top K highest similarity code segments matched with the input natural language text.

[0043] A code phrase input by a user is input into the deep learning model to visually output code segments related to the code phrase.

[0044] In use, a text content of a programming requirement is input into the deep learning model to obtain a code piece corresponding to the programming requirement.

[0045] More specifically, in the text structure tree, the main steps and the sub-steps are regarded as parent nodes and child nodes, and the sibling steps are regarded as sibling nodes.

[0046] The abstract syntax tree is recursively traversed from the root node, and nodes that do not meet the requirements are deleted to retain relevant nodes and branches.

[0047] After obtaining the abstract syntax tree, the type of each node (such as function, statement, variable, etc.) can be known, and in order to improve the matching efficiency, the nodes need to be filtered first. According to the type attribute of the node, only nodes not lower than the statement are retained. Here, the specific method is to recursively traverse from the root node, and if a node of a type attribute that does not meet the requirements (such as a variable, etc.) is accessed, a deletion operation is performed until the traversal is completed.

[0048] Using the text structure tree and abstract syntax tree as a foundation, the next step is to determine the legal code scope of the code snippets that may match the current step, based on the user's current writing process. This is done by filtering based on established text-code associations. For example, if the current step is a child of the previous step, the code described must be a child of the node bound to the previous step in the abstract syntax tree.

[0049] Among them, text nodes can correspond to code snippets , which is obtained from the code From the beginning of the row to The code consists of a sequence of lines of code statements.

[0050] The matching code snippet must be valid and consistent with the text structure. Therefore, the code snippet to be matched with the new text There are two constraints on the candidate: Figure 2 As shown in FIG, the definition of the validity principle provided for this embodiment is: the validity of a code snippet needs to be verified in the abstract syntax tree (AST). If the code snippet structure is incomplete, it is considered invalid.

[0051] F3 is invalid because it only contains half of a "while" loop. We set the constraints as follows: Let the abstract syntax tree be A, for any node ,if ,but . Thus, a code snippet can be represented as a sequence of AST subtrees: ;in, Indicates that the root node is The subtree of are consecutive child nodes of the same parent node.

[0052] like Figure 3 As shown in the figure, the definition of the consistency principle provided in this embodiment imposes the following constraints on the code fragment F: for The parent node of Included in Otherwise, if the new step is the next step that immediately follows the previous step, then in Should be middle The adjacent sibling nodes of .

[0053] In the candidate code snippets, the part that best matches the user's input natural language text needs to be found. A pre-trained deep learning model UniXcoder is used here, which can embed text and code snippets into the same vector space. For each step description, we input t and {F} into the model to get their embedding vectors vt and vF. The similarity between text and code is measured by cos(vt,vF). Therefore, it can be concluded that the construction of text-code connections will be ranked according to this index.

[0054] The embodiment also provides a step-by-step programming teaching system, which is implemented by the step-by-step programming teaching method based on a deep learning model provided in the above embodiment.

[0055] It comprises an input module for inputting text content of programming requirements;

[0056] A correlation analysis module outputs relevant code snippets according to the input text content;

[0057] A source code display module is configured to display programming tutorial content corresponding to the code snippets.

[0058] More specifically, as shown in Figure 4 The user first inputs the target code for writing tutorial description in the code editor, and can write the step-by-step tutorial content in the document editor. After inputting the content, the connection engine in the system extracts the hierarchical structure of the text and code, obtains the abstract syntax tree and the text structure tree, filters the legal range, and then presents the recommended text-code association to the user after processing by the natural language processing model. The user can connect each step description with the corresponding code snippet. The connection engine will continuously maintain the established connection, and based on these associations, it will provide step guidance and phrase writing functions, which can be used for subsequent tutorial writing workflow.

[0059] The specific functions of the system include: when the user writes a new step, the code editor will highlight the recommended code start line of the description to indicate the part of the code that the user should describe in detail.

[0060] During the writing process, the user can bind the association between the text segment and the code segment at any time, which is used for the system to further automatically recommend for subsequent tutorial writing.

[0061] When the user describes a variable in the code with a certain phrase, the system will provide a recommended variable matching list for the user to establish an association between the phrase and the variable. Among them, the variables that have not been bound have a higher priority, and the established association is highlighted in the code editor and the document editor.

[0062] Based on the bound variable, the system will provide automatic completion reminders for the content the user is inputting; at the same time, when the user wants to uniformly modify the expression of a variable described in the full text, the system can help the user to realize one-key replacement.

[0063] In summary, the present application is a web-based programming tutorial writing system, which is committed to assisting users in extracting corresponding text-code associations and presenting them to users when writing tutorials, to help users quickly understand the association between the current writing content and the code, while providing tutorial writing prompts and guidance, which is conducive to user understanding, maintenance and verification of tutorial content, so as to achieve the purpose of more efficient programming tutorial writing.

[0064] In addition, the terms "upper", "lower", "inner", "outer", "front", "back" are only for description purposes, and cannot be understood as indicating or implying relative importance. Unless otherwise specified, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present application.

[0065] Of course, the above only describes specific embodiments of the present application, and is not intended to limit the scope of the present application. Any equivalent changes or modifications made to the structure, features and principles described in the patent application scope of the present application shall be included in the patent application scope of the present application.

[0066] Finally, it should be noted that the above-described embodiments are only specific implementations of the present application, and are used to illustrate the technical solutions of the present application, but are not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can make equivalent changes or modifications to the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present application, or easily think of changes, or replace some technical features with equivalents; and these changes, modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A step-by-step programming teaching method based on a deep learning model, characterized in that, The method comprises the following steps: obtaining a set of text segments describing programming steps in a programming tutorial, taking each text segment as a node and the programming steps as edges to construct a corresponding text structure tree; constructing an abstract syntax tree based on a set of programming codes involved in the programming tutorial, taking each code segment as a node and the running relationship of the codes as edges; constructing a deep learning model based on the text structure tree and the abstract syntax tree as constraint frameworks, the deep learning model comprising a feature extraction module, a feature mapping module and a prediction module; the feature extraction module is configured to extract first text features of an input natural language text and second text features of code segments in the set of programming codes; the feature mapping module is configured to project the first text features and the second text features to a vector space simultaneously to obtain corresponding first feature vectors and second feature vectors; the prediction module is configured to perform similarity matching using the first feature vectors and the second feature vectors to output a matching result, the matching result comprising the top K highest similarity code segments matched with the input natural language text; inputting a code phrase input by a user into the deep learning model to visually output code segments related to the code phrase; in the text structure tree, main steps and sub-steps are regarded as parent nodes and child nodes, and steps at the same level are regarded as sibling nodes. 2.The deep learning model-based stepwise programming teaching method of claim 1, wherein, The abstract syntax tree is recursively traversed from the root node, and nodes that do not meet the requirements are deleted to retain relevant nodes and branches. 3.The deep learning model-based stepwise programming teaching method of claim 1, wherein, The prediction module follows the validity principle and the consistency principle in the process of similarity matching. 4.The deep learning model-based stepwise programming teaching method of claim 1, wherein, The consistency principle means that the natural language text corresponding to the first feature vector is structurally consistent with the code segment corresponding to the second feature vector. 5.The deep learning model-based stepwise programming teaching method according to claim 4, wherein, The effectiveness principle indicates that the code segment structure corresponding to the second feature vector is complete, and is specifically set as follows: set the abstract syntax tree as A, and for any node , if , then ; the code segment can be represented as a sequence of AST sub-trees: ; wherein, indicates that the root node is a sub-tree, and are continuous child nodes of the same parent node. 6.The deep learning model-based stepwise programming teaching method according to claim 4, wherein, The network framework of the deep learning model adopts a pre-trained UniXcoder. 7.The deep learning model-based stepwise programming teaching method according to claim 1, wherein, The similarity matching adopts a cosine similarity calculation formula. 8.The deep learning model-based stepwise programming teaching method of claim 1, wherein, The step-by-step programming teaching method based on the deep learning model is implemented by the method of any one of claims 1-8, comprising:

9. A step-by-step programming teaching system characterized by comprising: an input module configured to input text content of a programming requirement; a correlation analysis module configured to output relevant code segments based on the input text content; a source code display module configured to display programming tutorial content corresponding to the code segments. ​

Citation Information

Patent Citations

  • Intelligent code completion method and system for programming learning scene and storage medium

    CN116151132A

  • LLM-based programming auxiliary method

    CN116974541A

  • Code snippet recommendation method and device based on deep neural network

    CN111142850A

  • Method and device for deploying edge AI and constructing visual AI programming platform, and electronic equipment

    CN114675830A