An automatic programming method based on human-computer interaction
Through human-computer interaction and programming knowledge graph technology, errors in the natural language description input by users are identified and corrected, and the problems of code generation quality and language applicability are solved, and high-quality, multi-language code generation is achieved.
Patent Information
- Application Number
- CN202210899063.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-28
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-07-28
AI Technical Summary
The prior art fails to effectively deal with the problems of unclear expression, incomplete content and poor logic in the natural language descriptions input by users, resulting in a decline in the quality of generated code and its application scope is limited to specific programming languages.
Multiple rounds of interaction are carried out through human-computer interaction, identify and correct text errors, build programming knowledge graphs, and generate executable code based on user intentions, supporting multiple programming languages.
Improves the quality and fault tolerance of generated code and expands the application scope to multiple programming languages.
Smart Images

Figure CN115185497B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of human-computer interaction, and particularly to an automatic programming method based on human-computer interaction. Background Art
[0002] Generating code from an encoded logic text described in natural language is a subclass task of program synthesis and a key link in realizing software automated development. The fault tolerance of the code itself is extremely low, and any deviation may cause losses due to vulnerabilities, etc. Therefore, the encoded logic text itself must be complete, clear, logically rigorous, and unambiguous, etc. Otherwise, it will greatly affect the quality of the generated code. The current mainstream technologies do not consider the disadvantages that the user input text may be colloquial and the expression is not complete and clear enough, and do not correct the user input text through text detection, combining user feedback information, etc., resulting in a great reduction in the quality of code generation. The present invention combines human-computer interaction technology, obtains the correction information feedback by the user through multiple rounds of interaction with the user, and uses this information to gradually correct and improve the generation result, improving the quality of the generated code. Summary of the Invention
[0003] The purpose of the present invention is to overcome the above-mentioned disadvantages and deficiencies of the prior art, and provide an automatic programming method based on human-computer interaction. The present invention corrects the missing information in the text through human-computer interaction, improving the quality of programming code.
[0004] The present invention is realized through the following technical solutions:
[0005] An automatic programming method based on human-computer interaction, comprising the following steps:
[0006] Step 1: Perform error detection on the user input text, identify the error text and its error type, and further combine the text error type and use multiple rounds of human-computer interaction to intelligently guide the user to feedback correction information to correct the text error;
[0007] Step 2: For the text obtained after error detection and correction, use a text matching-based method to judge the user's intention;
[0008] Step 3: Identify programming entities in the text, such as variable entities, function entities, etc., based on the designed logical specifications, and combine templates to judge the missing information of the programming entities, and feedback it to the user for supplementation;
[0009] Step 4: Identify the logical relationships between programming entities, construct a programming knowledge graph with the programming entities and their logical relationships, and perform logical checks on the graph in combination with logical specifications, and feedback the places with logical errors to the user for correction;
[0010] Step 5: Combine the user's intention to convert the programming knowledge graph into corresponding executable code.
[0011] More specifically, the error detection of the text in step 1) is as follows: preprocess the text input by the user, encode and vectorize it, and input it into a model improved based on BERT (Bidirectional Encoder Representation from Transformers) and the idea of the exclusion method to obtain the text classification result. There are 6 categories in total for the text classification result, namely the irrelevant category, the definition category, the calculation category, the judgment category, the loop category, and the function category. The text classified as the irrelevant category is fed back to the user for correction. The irrelevant text mainly consists of some explanatory statements that do not contain coding logic.
[0012] More specifically, in step 2), the user intention is judged based on text matching. The user intention is obtained by matching keywords. If the matching fails, the user feedback is obtained through human-computer interaction to get the user intention for subsequent code generation.
[0013] More specifically, in step 3), the programming entities in the text are recognized based on the designed logical specifications. The boundaries of the programming entities are recognized and marked by using Chinese-English boundary features, programming syntax keywords, entity context information, etc. Further, the associated information of the entities is detected according to the template designed based on the information dependence of the programming entities, and the programming entities lacking information are fed back to the user to supplement the information.
[0014] More specifically, in step 4), the logical relationship between programming entities is recognized. By using information such as the context of programming entities and the types of programming entities, the relationship between programming entities is obtained by inputting into a relationship extraction model trained based on historical data. Then, according to the programming entities, the logical relationship between programming entities, text positions, etc., a knowledge graph is constructed, and the knowledge graph is logically checked, and the incorrect parts are fed back to the user for correction and improvement; the programming knowledge graph is a multi-way tree, and the tree makes its time complexity of addition, deletion, query, and modification linearly related to the height of the tree through maintaining a global index structure; the programming knowledge graph is independent of a specific programming language and can generate corresponding executable code by combining with the syntax of a specific programming language such as C++, Java, Python, etc.
[0015] More specifically, in step 5), combining the user intention, the programming knowledge graph is converted into corresponding executable code according to the intention of the programming language that the user needs to convert. The programming knowledge graph obtained in step 4 is converted into executable code according to specific rules and the syntax of the corresponding programming language, and the final result is fed back to the user.
[0016] The present invention has the following advantages and effects compared with the prior art:
[0017] The present invention identifies and feedbacks to the user for correction the errors such as unclear expression, incomplete content, and loose logic in the encoded logic text described in natural language by combining the human-computer interaction method, thereby improving the quality of the generated code. The fault tolerance of programming code is extremely low, and any deviation may cause vulnerabilities and losses. The current mainstream methods do not take into account the disadvantages that the user input text may be colloquial and the expression is not complete and clear enough, and do not correct the user input text through methods such as text detection and combining user feedback information, resulting in great potential vulnerabilities in the generated code;
[0018] The present invention is designed according to the user's habit of correcting text and combines deep learning technology. By interacting with the user in multiple rounds, the errors existing in the encoded logic text are gradually corrected, further improving the quality of the generated code. At the same time, the current mainstream methods are often designed for a specific programming language, and the application scope is also limited to that language. In order to expand the application scope, the present invention designs and implements a programming knowledge graph structure independent of a specific programming language. This programming knowledge graph can further generate corresponding code by combining the syntax of different programming languages, thus greatly expanding the application scope of this method. Brief Description of the Drawings
[0019] Figure 1 It is a flowchart of the automatic programming method based on human-computer interaction of the present invention. Detailed Embodiments
[0020] The present invention will be further described in detail below with reference to specific embodiments.
[0021] As Figure 1 shown, the present invention discloses an automatic programming method based on human-computer interaction, which is implemented through the following steps:
[0022] 1) Perform error detection on the user input text, identify the error text and its error type, and further combine the text error type and use the multi-round human-computer interaction method to intelligently guide the user to feedback correction information to correct the text errors. The error detection first preprocesses, encodes the user input text, and inputs it into a model improved based on the BERT and the idea of elimination method to obtain the text classification result. There are 6 types of text classification results, namely irrelevant category, definition category, calculation category, judgment category, loop category, and function category. Then, the text classified as the irrelevant category is feedback to the user for correction, and the irrelevant text is mainly some explanatory statements that do not contain encoding logic.
[0023] 2) For the text obtained after error detection and correction, the user intention is judged using a text matching-based method. To judge the user intention by the text matching-based method, the user intention is obtained by matching keywords. If the matching fails, the user feedback is obtained through human-computer interaction to get the user intention, which is further used for subsequent code generation.
[0024] 3) Based on the designed logical specifications, the programming entities in the text are identified, and the missing information of the programming entities is judged in combination with templates and fed back to the user for supplementation. Based on the designed logical specifications, the programming entities in the text are identified. By using the boundary features of Chinese and English, programming syntax keywords, entity context information, etc., the boundaries of the programming entities are identified, the types of the programming entities are marked, and the positions in the text are marked. Further, in combination with the templates designed based on the information dependencies of the programming entities, the associated information of the entities is detected, and the programming entities with missing information are fed back to the user to supplement the information.
[0025] 4) Identify the logical relationships between programming entities, construct a programming knowledge graph with the programming entities and their logical relationships, and perform logical checks on the graph in combination with the logical specifications, and feedback the places with logical errors to the user for correction. By using information such as the context of the programming entities and the types of the programming entities, the logical relationships between the programming entities are input into a relationship extraction model trained based on historical data. The types of logical relationships are limited to three types: defined relationship, calculation relationship, and affiliated relationship. Further, according to the programming entities, the logical relationships between the programming entities, and information such as the text positions, a knowledge graph is constructed, and the knowledge graph is logically checked, and the incorrect places are fed back to the user for correction and improvement. The types of programming logic errors are definition errors, calculation errors, conflict errors, and reference errors.
[0026] The above programming knowledge graph is a multi-way tree, and the tree makes the time complexity of its addition, deletion, query, and modification linearly related to the height of the tree by maintaining a global index structure; the programming knowledge graph is independent of a specific programming language and can generate corresponding executable code by combining with the syntax of specific programming languages such as C++, Java, Python, etc.
[0027] 5) Combine the user intention and convert the programming knowledge graph into corresponding executable code. According to the user intention obtained in step 2) and in combination with the programming knowledge graph obtained in step 4), the programming knowledge graph is converted into executable code according to the programming knowledge graph composition rules and the programming language syntax, and the final result is fed back to the user.
[0028] As described above, the present invention can be preferably implemented.
[0029] The embodiments of the present invention are not limited by the above embodiments. Any other changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be equivalent replacement methods and are all included within the protection scope of the present invention.
Claims
1. An automatic programming method based on human-computer interaction, characterized in that, Including the following steps: Step 1: Perform error detection on the user input text, identify the error text and its error type. Further, combine the text error type and use the multi-round human-computer interaction method to intelligently guide the user to feedback correction information to correct the text error; Step 2: For the text obtained after error detection and correction, use the text matching method to judge the user's intention; Step 3: Identify the programming entities in the text based on the designed logical specification, combine with the template to judge the missing information of the programming entities, and feedback to the user for supplementation; Step 4: Identify the logical relationship between programming entities, construct a programming knowledge graph with the programming entities and their logical relationships, and combine the logical specification to perform logical checking on the graph, and feedback the places with logical errors to the user for correction; Step 5: Combine the user's intention to transform the programming knowledge graph into corresponding executable code; The error detection of the user input text described in Step 1, identify the error text and its error type. Further, combine the text error type and use the multi-round human-computer interaction method to intelligently guide the user to feedback correction information to correct the text error; Specifically: In text error detection, vectorize the text and input it into a text classification model improved by combining the idea of exclusion method to obtain the text classification result, and feedback the text classified as the irrelevant category to the user for confirmation and correction, where the irrelevant text includes the explanatory statements that do not contain coding logic; The text obtained after error detection and correction described in Step 2, use the text matching method to judge the user's intention; Specifically: Using the text matching method to judge the user's intention is to obtain the user's intention by matching keywords. If the matching fails, obtain the user's feedback through the human-computer interaction method to get the user's intention for subsequent code generation; The identification of programming entities in the text based on the designed logical specification described in Step 3, combine with the template to judge the missing information of the programming entities, and feedback to the user for supplementation; Specifically: Identifying the programming entities in the text based on the designed logical specification is to identify the boundaries of the programming entities and label them by using the Chinese and English boundary features, programming syntax keywords, and entity context information. Further, detect the associated information of the entities according to the template designed based on the information dependence of the programming entities and feedback the programming entities with missing information to the user to supplement the information.
2. The automatic programming method based on human-computer interaction according to claim 1, wherein: The identification of the logical relationship between programming entities described in Step 4, construct a programming knowledge graph with the programming entities and their logical relationships, and combine the logical specification to perform logical checking on the graph, and feedback the places with logical errors to the user for correction; Specifically: Identifying the logical relationship between programming entities, obtain the relationship between programming entities by inputting the context of the programming entities and the programming entity type information into the relationship extraction model trained based on historical data. Further, construct a knowledge graph according to the programming entities and the logical relationships between programming entities and the text position information, and perform logical checking on the knowledge graph, and feedback the incorrect places to the user for correction and improvement.
3. The automatic programming method based on human-computer interaction according to claim 2, wherein: The programming knowledge graph is a multi-way tree, and the multi-way tree maintains a global index structure such that the time complexity of its insertion, deletion, query, and modification is linearly related to the height of the multi-way tree; the programming knowledge graph is independent of a specific programming language, and the irrelevant text includes explanatory statements that do not contain coding logic; The specific programming language is C++, Java, or Python.
4. The automatic programming method based on human-computer interaction according to claim 2, wherein: In step 5, combining the user intention, the programming knowledge graph is converted into corresponding executable code; specifically: combining the user intention, the programming knowledge graph obtained in step 4 is converted into executable code according to specific rules and the syntax of the corresponding programming language, and the final result is fed back to the user.
Citation Information
Patent Citations
Intention recognition method and device capable of on-line error correction update
CN109508376A
A method and deviceapparatus for generating codes
CN109614111A
Automatic program correction method based on knowledge graph
CN112486568A