Code recommendation method, device and equipment and computer readable storage medium
By automatically repairing the generated candidate code, the problem of syntax or semantic errors in code generation is solved, and the accuracy and development efficiency of the code are improved.
Patent Information
- Application Number
- CN202311787695.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-10-11
- Filing Date
- 2023-12-21
- Publication Date
- 2025-04-11
AI Technical Summary
In existing code generation technology, the generated code may contain syntax or semantic errors, resulting in low accuracy of the code in programming tasks and affecting development efficiency.
By obtaining code generation information, generating candidate codes, and automatically repairing candidate codes with errors in them, providing repaired candidate codes and unrepaired candidate codes to improve the accuracy of the code.
Improves the accuracy of generated code, enhances the possibility of leveraging generated code in programming tasks, and shortens the time for code repair and recommendation.
Smart Images

Figure CN119806625A_ABST
Abstract
Description
[0001] This application claims priority to Chinese patent application No. 202311311251.7 filed on October 11, 2023, with invention name “Model semantic error repair method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of artificial intelligence technology, and in particular to a code recommendation method, device, equipment and computer-readable storage medium. Background Art
[0003] With the development of artificial intelligence (AI) technology, AI can play a role in more and more application scenarios. Taking the code large language model (Code LLM) in the field of AI as an example, during the project development phase, the developer inputs the code requirements involved in the project, Code LLM generates code based on the input code requirements, and recommends the generated code to the developer, so that the developer can continue project development based on the obtained code. Summary of the invention
[0004] The present application provides a code recommendation method, apparatus, device and computer-readable storage medium for recommending codes to meet coding requirements. The technical solution is as follows:
[0005] In a first aspect, a code recommendation method is provided, the method comprising: obtaining code generation information, the code generation information being used to describe a programming task of the code; generating at least one candidate code according to the code generation information, the at least one candidate code satisfying the programming task described by the code generation information; determining a candidate code to be repaired from the at least one candidate code, the candidate code to be repaired comprising erroneous parameters, the erroneous parameters not satisfying at least one of grammatical constraints or semantic constraints of a programming language corresponding to the programming task; repairing the erroneous parameters included in the candidate code to be repaired to obtain the repaired candidate code, and recommending a code generation result, the code generation result comprising the repaired candidate code and an unrepaired candidate code in at least one candidate code, the unrepaired candidate code being different from the candidate code to be repaired.
[0006] In this method, after generating the candidate code, the candidate code with errors in the candidate code, that is, the candidate code to be repaired, will be automatically repaired, and the repaired candidate code and the unrepaired code that is different from the candidate code to be repaired will be provided. By repairing the candidate code to be repaired into a code with higher accuracy, the accuracy of the generated code is improved. Since the code used in the programming task is accurate code, the higher the accuracy of the code, the more likely it is to use the code in the programming task. By improving the accuracy of the generated code, the possibility of using the generated code in the programming task is further improved.
[0007] In a possible implementation, determining a candidate code to be repaired from at least one candidate code includes: detecting each candidate code in at least one candidate code to obtain the detection results of each candidate code; when the detection result of any candidate code in at least one candidate code indicates that any candidate code has an error, determining the error type of any candidate code to obtain the error type of each candidate code with an error; matching the error type and reference type of each candidate code with an error, and determining the candidate code to be repaired from the candidate code with an error according to the matching results of each candidate code, wherein the reference type indicates the error type that supports repair. After detecting a candidate code with an error, the error type of the candidate code will also be judged to determine whether the error type of the candidate code can be repaired, so as to avoid performing repair operations on candidate codes with error types that cannot be repaired, resulting in invalid work and waste of resources. Moreover, the error type screening can be achieved by matching the reference type, and the screening process is simple and efficient.
[0008] In a possible implementation, each candidate code in at least one candidate code is detected, including at least one of the following: for any candidate code, any candidate code is parsed, and whether any candidate code has a syntax error is determined according to the parsing result; or, any candidate code is run in the compilation environment of any candidate code, and whether any candidate code has a runtime error is determined according to the running result. Since this method does not limit the detection method of the candidate code, it can detect a variety of error situations. For candidate codes including erroneous parameters, whether there is a syntax error or a runtime error, different detection methods can be used to detect it, which is highly flexible and widely applicable.
[0009] In a possible implementation, the candidate code to be repaired is determined from the candidate codes with errors according to the matching results of each candidate code, including: for any candidate code with errors, when the error type of any candidate code matches the reference type successfully, the repair method corresponding to any candidate code is determined according to the error type of any candidate code; when the repair method of any candidate code meets the repair condition, any candidate code is determined as the candidate code to be repaired. By limiting the repair condition and repairing the candidate code that meets the repair condition, the number of candidate codes to be repaired is effectively controlled, the code repair efficiency is improved, and the waiting time for the recommended code generation result is further shortened.
[0010] In a possible implementation, the reference type includes at least one of an undefined parameter, a code type error, or a call to an undefined method. The method does not limit the error types that can be repaired and has wide versatility.
[0011] In a possible implementation, the erroneous parameters included in the candidate code to be repaired are repaired to obtain the repaired candidate code, including: obtaining a reference code corresponding to the candidate code to be repaired, the code similarity between the reference code and the candidate code to be repaired being greater than a similarity threshold; matching the reference code and the candidate code to be repaired, and selecting parameters from the reference code to replace the erroneous parameters included in the candidate code to be repaired according to the matching result, to obtain the repaired candidate code. The candidate code can be repaired by replacing parameters between similar reference codes, and the repair process has low operation complexity and high repair efficiency.
[0012] In a possible implementation, obtaining a reference code corresponding to a candidate code to be repaired includes: obtaining a code knowledge base, the code knowledge base including a plurality of original codes; and retrieving a reference code from the plurality of original codes included in the code knowledge base based on the candidate code to be repaired. The reference code can be obtained by performing code retrieval in the code knowledge base, and the acquisition process is simple and the operation time is short.
[0013] In a possible implementation, obtaining a code knowledge base includes: obtaining multiple original codes and construction information corresponding to each original code; determining code features of each original code according to the multiple original codes and the construction information of each original code; determining the correspondence between each original code according to the code features of each original code and the usage impact relationship between each original code; and constructing a code knowledge base including multiple original codes according to the correspondence between each original code. The original codes are stored based on the correspondence between each original code, and in the subsequent code retrieval process, similar codes can be quickly located based on the constructed correspondence, thereby improving the code retrieval efficiency.
[0014] In a possible implementation, the recommended code generation result includes: determining the code repair position corresponding to the repaired candidate code, marking the code repair position; and recommending the marked repaired candidate code and the unrepaired candidate code. By marking the code repair position, it is convenient to quickly understand the repair status of the candidate code, and then judge whether the repaired candidate code meets the code generation requirements according to the repair status, thereby improving the judgment efficiency of the candidate code.
[0015] In a possible implementation, after the code generation result is recommended, the method further includes: obtaining at least one error repair method corresponding to the candidate code after repair; and recommending at least one error repair method corresponding to the candidate code after repair, wherein the at least one error repair method is used to assist in repairing the candidate code to be repaired corresponding to the candidate code after repair. By recommending at least one error repair method for selection, the candidate code to be repaired is assisted in being repaired, thereby shortening the time for repairing the candidate code and improving efficiency.
[0016] In a possible implementation, the erroneous parameters are repaired based on the reference code, and before the erroneous parameters included in the candidate code to be repaired are repaired, the method further includes: obtaining a modified code obtained by modifying the recommended first code, where the first code is repaired based on the second code before recommendation; extracting modification features of the modified code, and updating the second code according to the extracted modification features to obtain a reference code. The second code used to modify the first code is updated based on the modification of the first code, and the obtained reference code is more suitable for the programming task, and the candidate code repaired based on the reference code is more suitable for the programming task.
[0017] In a second aspect, a code recommendation device is provided, the device comprising: an acquisition module, used to acquire code generation information, the code generation information is used to describe a programming task of the code; a generation module, used to generate at least one candidate code according to the code generation information, the at least one candidate code satisfies the programming task described by the code generation information; a determination module, used to determine a candidate code to be repaired from at least one candidate code, the candidate code to be repaired includes an erroneous parameter, the erroneous parameter does not satisfy at least one of the grammatical constraints or semantic constraints of a programming language corresponding to the programming task; a recommendation module, used to repair the erroneous parameter included in the candidate code to be repaired, obtain the repaired candidate code, and recommend a code generation result, the code generation result includes the repaired candidate code and an unrepaired candidate code in at least one candidate code, the unrepaired candidate code is different from the candidate code to be repaired.
[0018] In one possible implementation, a determination module is used to detect each candidate code in at least one candidate code to obtain detection results of each candidate code; when the detection result of any candidate code in at least one candidate code indicates that any candidate code has an error, determine the error type of any candidate code to obtain the error type of each candidate code with an error; match the error type and reference type of each candidate code with an error, and determine the candidate code to be repaired from the candidate code with an error according to the matching results of each candidate code, and the reference type indicates the error type that supports repair.
[0019] In one possible implementation, a determination module is used to execute at least one of the following: for any candidate code, perform syntax analysis on any candidate code, and determine whether any candidate code has a syntax error based on the analysis result; or, run any candidate code in the compilation environment of any candidate code, and determine whether any candidate code has a runtime error based on the runtime result.
[0020] In one possible implementation, a determination module is used to determine, for any candidate code with an error, a repair method corresponding to any candidate code according to the error type of any candidate code when the error type of any candidate code matches a reference type successfully; and to determine any candidate code as a candidate code to be repaired when the repair method of any candidate code meets a repair condition.
[0021] In a possible implementation, the reference type includes at least one of an undefined parameter, a code type error, or a call to an undefined method.
[0022] In one possible implementation, a recommendation module is used to obtain a reference code corresponding to a candidate code to be repaired, wherein a code similarity between the reference code and the candidate code to be repaired is greater than a similarity threshold; the reference code and the candidate code to be repaired are matched, and parameters are selected from the reference code according to the matching results to replace erroneous parameters included in the candidate code to be repaired, so as to obtain a repaired candidate code.
[0023] In a possible implementation, the recommendation module is used to obtain a code knowledge base including a plurality of original codes; and retrieve a reference code from the plurality of original codes included in the code knowledge base based on the candidate code to be repaired.
[0024] In a possible implementation, a recommendation module is used to obtain multiple original codes and construction information corresponding to each original code; determine the code features of each original code based on the multiple original codes and the construction information of each original code; determine the correspondence between each original code based on the code features of each original code and the usage impact relationship between each original code; and construct a code knowledge base including multiple original codes based on the correspondence between each original code.
[0025] In a possible implementation, the recommendation module is used to determine the code repair position corresponding to the repaired candidate code, identify the code repair position; and recommend the identified repaired candidate code and the unrepaired candidate code.
[0026] In one possible implementation, the acquisition module is also used to acquire at least one error repair method corresponding to the repaired candidate code; the recommendation module is also used to recommend at least one error repair method corresponding to the repaired candidate code, and the at least one error repair method is used to assist in correcting the candidate code to be repaired corresponding to the repaired candidate code.
[0027] In one possible implementation, the erroneous parameters are repaired based on a reference code, and the acquisition module is also used to obtain a modified code obtained by modifying a recommended first code, where the first code is repaired based on the second code before recommendation; the device also includes: an update module, which is used to extract modification features of the modified code, and update the second code according to the extracted modification features to obtain a reference code.
[0028] In a third aspect, a computing device cluster is provided, which includes at least one computing device, each computing device including a processor and a memory; the processor of at least one computing device is used to execute instructions stored in the memory of at least one computing device, so that the computing device cluster executes any one of the code recommendation methods of the first aspect above.
[0029] In a fourth aspect, a computer-readable storage medium is provided, the computer-readable storage medium comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes any one of the code recommendation methods in the first aspect.
[0030] In a fifth aspect, a computer program (product) comprising instructions is provided. When the instructions are executed by a computing device cluster, the computing device cluster executes any one of the code recommendation methods of the first aspect.
[0031] In a sixth aspect, a communication device is provided, the device comprising: a transceiver, a memory, and a processor. The transceiver, the memory, and the processor communicate with each other through an internal connection path, the memory is used to store instructions, the processor is used to execute the instructions stored in the memory to control the transceiver to receive signals and control the transceiver to send signals, and when the processor executes the instructions stored in the memory, the processor executes the method in the first aspect or any possible implementation of the first aspect.
[0032] Optionally, there are one or more processors and one or more memories.
[0033] Optionally, the memory may be integrated with the processor, or the memory may be provided separately from the processor.
[0034] In the specific implementation process, the memory can be a non-transitory memory, such as a read-only memory (ROM), which can be integrated with the processor on the same chip or can be set on different chips. This application does not limit the type of memory and the setting method of the memory and the processor.
[0035] In a seventh aspect, a chip is provided, comprising a processor for calling and executing instructions stored in a memory from the memory, so that a communication device equipped with the chip executes the methods in the above aspects.
[0036] In an eighth aspect, another chip is provided, comprising: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the methods in the above aspects.
[0037] It should be understood that the beneficial effects achieved by the technical solutions of the second to eighth aspects of the present application and the corresponding possible implementation methods can be referred to the above-mentioned technical effects of the first aspect and its corresponding possible implementation methods, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of an implementation environment provided for an embodiment of the present application;
[0039] Figure 2 A flowchart of a code recommendation method provided in an embodiment of the present application;
[0040] Figure 3 A page schematic diagram provided for an embodiment of the present application;
[0041] Figure 4A statistical diagram of code errors provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram of a code generation process provided by an embodiment of the present application;
[0043] Figure 6 A schematic diagram of another code generation process provided in an embodiment of the present application;
[0044] Figure 7 Another page schematic diagram provided for an embodiment of the present application;
[0045] Figure 8 A schematic diagram of the structure of a code recommendation device provided in an embodiment of the present application;
[0046] Fig. 9 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0047] Fig.10 A connection diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The terms used in the implementation method of this application are only used to explain the specific embodiments of this application, and are not intended to limit this application. In order to make the purpose, technical solution and advantages of this application clearer, the implementation method of this application will be further described in detail below with reference to the accompanying drawings.
[0049] With the development of artificial intelligence technology, more and more mature code generation technology can be used to generate and recommend code, thereby improving programming efficiency. For example, a large code language model is used to generate code based on the input code generation information, and the generated code is recommended. Among them, the large code language model is a large neural network model used in the field of natural language processing (NLP) and computer program generation, usually based on deep learning technology, with millions to billions of parameters. The code generation information input to the large code language model can be text, and the large code language model infers the program code based on the input text, or generates a specific code segment.
[0050] The present application embodiment provides a code recommendation method for recommending codes to complete programming tasks. Figure 1, which shows a schematic diagram of the implementation environment of the code recommendation method provided in the embodiment of the present application, the implementation environment is a computing device cluster 10, and the computing device cluster 10 includes at least one processing device for providing cloud services. When there are multiple processing devices, the processing devices can be connected to each other by means of a wired or wireless network. Optionally, the code generation method can be independently executed by a processing device. For example, the processing device obtains code generation information, generates at least one candidate code according to the code generation information, repairs the candidate code to be repaired that has errors in the candidate code, obtains the repaired candidate code, and uses the repaired candidate code and at least one candidate code that is different from the candidate code to be repaired and has not been repaired as the code generation result, and recommends the code generation result. The above-mentioned code recommendation process can also be interactively executed by multiple processing devices included in the computing device cluster 10. The embodiment of the present application does not limit the number of processing devices included in the computing device cluster 10. Figure 1 Only two processing devices are used as examples for illustration.
[0051] Exemplarily, the processing device included in the computing device cluster 10 may be a server, such as a central server, an edge server, or a local server in a local data center. The server may be a physical server or a cloud server that provides cloud computing services. In some embodiments, the processing device included in the computing device cluster 10 may also be a terminal device such as a desktop, a laptop, or a smart phone involved in the cloud service.
[0052] The present application embodiment provides a code recommendation method, which can be applied to the above Figure 1 The implementation environment shown in FIG. 1 is shown in FIG. 1 , and the method can be executed by a processing device included in the computing device cluster 10. The flowchart of the method is shown in FIG. Figure 2 As shown, including S201-S204.
[0053] S201, obtaining code generation information, where the code generation information is used to describe a programming task of the code.
[0054] The embodiments of the present application do not limit the determination scenario of the programming task, nor do they limit the process by which the processing device obtains code generation information based on the programming task. In one possible implementation, the programming task may be determined during the project development process. For example, since the operation of the target project depends on the code, in the process of developing the target project, there is a programming task that requires writing the code of the target project, and the processing device obtains code generation information based on the development of the target project. Among them, the target project is, for example, any project with development needs such as video playback or image cropping. Optionally, the programming task can also be determined during the code detection process. For example, the processing device detects the acquired code and finds that the acquired code includes a fault code that needs to be rewritten. The processing device thus determines that the programming task is a code that needs to be written with the same function as the fault code, and obtains code generation information based on the programming task.
[0055] In addition to determining the code generation information according to the detected programming task as shown in the above embodiment, the processing device can also obtain the code generation information based on the interaction with the code user object. For example, the user object is an object of the development target project. The user object determines the code to be written based on the development requirements of the development target project, thereby determining the code generation information, and sends the code generation information to the processing device based on the interaction with the processing device. The processing device can be a terminal of the user object, or a device that establishes a communication connection with the terminal of the user object.
[0056] In the case where the processing device is a terminal of a user object, the terminal provides an information input control, and the user object inputs code generation information through the information input control, and the terminal thereby obtains the code generation information. The embodiment of the present application does not limit the manner in which the terminal provides the information input control, and the information input control may be provided by a local code editor of the terminal, such as a software developer tool (visual studio code, VSCode), an integrated development environment (integrated development environment, IDE) plug-in, a code automatic generation tool, a source code editor, or an auxiliary program of a cloud development environment. In a possible implementation, the terminal may also provide code generation services through a cloud service in the form of an application programming interface (application programming interface, API) structure to provide information input controls to the user object.
[0057] Figure 3 A schematic diagram of a page display provided in an embodiment of the present application, Figure 3 The figure shows the IDE interface displayed to the user by the terminal when the IDE plug-in is used for project development. Figure 3(1) is the initial page. During the usage phase, the user can right-click the mouse at the editing location, select "Generate Code", and then enter the code generation information in the information input control provided at the editing location.
[0058] The embodiments of the present application do not limit the code generation information. The code generation information can be any information that can describe the programming task. The code generation information can be a natural language text that describes the role of the code. For example, the posture is estimated based on the measured acceleration and angular velocity. The programming task is to write a posture estimation function that calculates the posture based on the acceleration and angular velocity. The code generation information is to generate the posture estimation function. The input parameters of the function are acceleration and angular velocity, and the output parameter of the function is the posture. Alternatively, a search is performed through website A, and a page of search results is displayed. The programming task is to write a code that calls website A for search and page display. The code generation information is to generate a search code. The input parameter of the search code is the website name, and the output parameter of the search code is the parameter for rendering the website page. The code generation information can also be a code context that requires code to connect, or a code execution log, a requirement document, or a comment, etc.
[0059] In one possible case, when the processing device is a device connected to the terminal, the processing device receives the code generation information sent by the terminal. For example, the processing device is a data processing center including multiple servers. Since the data processing efficiency of the data processing center is higher than that of a single terminal, after receiving the code generation information input by the user object, the terminal will send the code generation information to the data processing center based on the communication connection with the data processing center, so as to generate the code faster through the data processing center, and the data processing center as the processing device thereby obtains the code generation information.
[0060] S202, generating at least one candidate code according to the code generation information, wherein the at least one candidate code satisfies the programming task described by the code generation information.
[0061] Exemplarily, after obtaining the code generation information to determine the programming task, the processing device can use any code generation model to generate candidate codes according to the code generation information to complete the programming task. Among them, the code generation model can be an encoder-decoder model based on a sequence model (Transformer) architecture that relies on an attention mechanism, a generative pre-trained transformer model (GPT), a language model trained on source code and natural language text (StarCoder), a large language model for programming (WizardCoder), a large language model that can generate code using text prompts (Code Llama), and other large code models.
[0062] Optionally, when the code generation information is the natural language text illustrated in S201, the processing device first performs language understanding on the natural language text and converts the natural language text into an intermediate representation that can be understood by the machine, such as using a bidirectional encoder representation from transformers (BERT) model, a GPT model, etc. to encode the natural language text, and use the encoded result as the intermediate representation. Afterwards, the code language large model is used to generate the corresponding code structure and grammar according to the intermediate representation to obtain the candidate code.
[0063] In one possible case, the processing device may generate multiple candidate codes in the process of generating candidate codes according to the code generation information. Continuing with the example of the code generation information in the above embodiment being a natural language text, when the processing device encodes the same natural language text in different ways, different intermediate representations will be obtained, and the code language large model may have different understandings according to different intermediate representations, thereby generating candidate codes with different code structures or grammars. However, no matter what the candidate code generated by the processing device is, any candidate code satisfies the programming task described by the code generation information. For example, the candidate code can realize the function described by the code generation information, or can connect to the input code context to realize the loading of the code.
[0064] S203: Select a candidate code to be repaired from at least one candidate code, where the candidate code to be repaired includes an erroneous parameter, and the erroneous parameter does not satisfy at least one of a grammatical constraint or a semantic constraint of a programming language corresponding to the programming task.
[0065] In one possible case, the candidate code generated by the processing device may be wrong. For example, because the deep learning model does not master at least one of the grammatical constraints or semantic constraints of the programming language, it generates erroneous parameters that do not satisfy at least one of the grammatical constraints or semantic constraints. Among them, the programming language is the language corresponding to the programming task. When the programming task is the code in the target project, the programming language is the computer language used to develop the target project. The grammatical constraints refer to the rules and structures that need to be followed in the process of writing code, which are used to indicate the symbols, keywords, operators, etc. that should be used when writing code, as well as the organization and nesting relationship of symbols, keywords, operators, etc. in the code. The semantic constraints refer to the actual meaning and execution results of the code, which describe the logic and functions expressed by the code at runtime, and are used to specify the interaction mode and behavior between different elements in the code, as well as the corresponding execution results.
[0066] Exemplarily, code errors caused by incorrect parameters in the candidate code include, but are not limited to, syntax errors, semantic errors, and functional errors. Among them, syntax errors refer to statements in the candidate code that do not comply with grammatical regulations, errors that appear during the compilation process, and incorrect parameters in syntax errors are, for example, parameters with incorrect uppercase and lowercase letters, or punctuation marks that do not use English symbols. Functional errors refer to errors that may occur in the program during the running of the candidate code, errors that appear during the running process, and incorrect parameters in functional errors are, for example, parameters with out-of-bounds subscripts and parameters with stack overflows, etc. Semantic errors refer to logical errors. Although there is no error in the compilation and no exception is thrown during the running process, the output result is incorrect. Incorrect parameters in semantic errors are, for example, incorrect formula parameters, or incorrect conditional parameters in the conditional statement in the candidate code. Figure 4 A statistical diagram of code errors provided in an embodiment of the present application is shown in FIG. Figure 4 ,Through the analysis of 305 code snippets generated by two code ,large models, the number of error types of the 305 code snippets generated are ,36% functional errors, 37% syntax errors, and 27% semantic errors.
[0067] In the case where there are errors in the candidate code, the processing device needs to repair the candidate code after generating the candidate code, correct the errors in the candidate code, and thus provide a code with a higher accuracy rate. In one possible implementation, the process of the processing device selecting the candidate code to be repaired includes: detecting each candidate code in at least one candidate code to obtain the detection results of each candidate code; in the case where the detection result of any candidate code in at least one candidate code indicates that any candidate code has an error, determining the error type of any candidate code to obtain the error type of each candidate code with an error; matching the error type of each candidate code with an error and the reference type, and determining the candidate code to be repaired from the candidate code with an error according to the matching results of each candidate code, and the reference type indicates the error type that the processing device supports repairing.
[0068] The embodiment of the present application does not limit the process of the processing device detecting the candidate code. Taking any candidate code as an example, the detection can be performed by including but not limited to the following two optional methods. Optional method 1, the processing device performs grammatical analysis on any candidate code, and determines whether any candidate code has a grammatical error based on the analysis result. Exemplarily, the processing device obtains a grammatical rule, which can be a grammatical constraint that needs to be followed when writing a code based on experience or an implementation environment, and the implementation environment is, for example, the target project to which the code is applied. Afterwards, the processing device analyzes and parses any candidate code according to the grammatical rules to determine whether the candidate code satisfies the grammatical rules. The above analysis and parsing can be performed by a context-free grammar (CFG) represented by the grammatical rules. When the candidate code satisfies the grammatical rules, it means that there is no grammatical error in the candidate code. Exemplarily, when the candidate code does not meet the grammatical rules, it means that there is a grammatical error in the candidate code.
[0069] Optional method 2: The processing device runs any candidate code in the compilation environment of any candidate code, and determines whether any candidate code has a running error based on the running result. Among them, the compilation environment of the candidate code can be constructed by the processing device or obtained by other means. The absence of a running error means that the candidate code does not show an error during the running process, and the running result is correct. The existence of a running error includes at least one of an error showing during the running process or an incorrect running result. By running any candidate code in the compilation environment, it is determined whether any candidate code has a functional error based on whether an error is shown during the running process, and whether any candidate code has a semantic error based on whether the running result is correct. The processing device can select any one of optional methods 1 or optional method 2 to detect the candidate code. For example, in the case where the semantic error of the candidate code needs to be repaired, the processing device selects optional method 2 to detect the candidate code to determine the candidate code with a semantic error. Alternatively, the processing device can choose to execute optional method 1 and optional method 2 to detect the candidate code to achieve a comprehensive detection of the candidate code.
[0070] After the processing device determines that there is an erroneous candidate code according to the detection result, it can further determine the error type of the candidate code. For example, the processing device obtains the usage relationship defined according to the candidate code. If there is a parameter that is only used but not defined, it is determined that the parameter is an undefined parameter, thereby determining that the error type of the candidate code is an undefined parameter. After determining the error type of the candidate code, the processing device can match the error type and the reference type to determine whether the processing device currently supports repairing the error type. The reference type can be set based on experience. For example, before using the processing device for code generation, the object defines some error types that can be repaired as reference types. The reference type can be a more common error type in the code generated by the deep learning model. Taking the processing device for repairing semantic types as an example, the reference type can be a semantic type, including but not limited to at least one of undefined parameters, code type errors, or calls to undefined methods. Code type errors can be parameter number / type mismatches, and undefined methods are, for example, undeclared APIs.
[0071] Exemplarily, the processing device matches the error type and the reference type, and when the error type is any error type included in the reference type, it is determined that the error type and the reference type are matched successfully. The processing device can achieve the matching of the error type and the reference type by defining the error type included in the semantic error as shown above. The processing device can also determine the category to which the error type belongs, and when the category is the reference type, it is determined that the error type and the reference type are matched successfully. Continuing with the example of the reference type being a semantic error, the processing device determines that the error type of the candidate code is an undefined parameter during the process of detecting the candidate code. Since the category of the undefined parameter is a semantic error, that is, both the category and the reference type indicate a semantic error, the processing device thus determines that the error type and the reference type of the candidate code are matched successfully.
[0072] Optionally, the processing device may directly determine the candidate code as a candidate code to be repaired and repair the candidate code if the error type of the candidate code matches the reference type successfully. In one possible case, the processing device may also determine the repair method corresponding to any candidate code according to the error type of any candidate code if the error type of any candidate code with an error matches the reference type successfully; and determine any candidate code as a candidate code to be repaired if the repair method of any candidate code meets the repair condition.
[0073] In one possible case, the repair condition is determined based on the repair method adopted by the processing device. Since the processing device searches for similar codes based on the code knowledge base in the process of repairing the candidate code. Therefore, the processing device can determine the repair condition as whether to call the code knowledge base, or determine the repair condition as whether similar codes are needed. In the case where the processing device adopts other repair methods to repair the candidate code, the processing device can also flexibly set the repair condition according to the repair method adopted. Optionally, the processing device determines the repair method corresponding to the error type of the candidate code according to the error type of the candidate code, for example, determines at least one of the code segment that needs to be modified and the error logic that needs to be corrected according to the error type of the candidate code, and determines whether the code knowledge base needs to be called according to at least one of the determined code segment and error logic. When the repair method indicates that the code knowledge base needs to be called, the candidate code is determined to meet the repair condition, that is, the candidate code to be repaired. On the contrary. When the repair method indicates that the code knowledge base does not need to be called, the candidate code is determined to be a candidate code that does not meet the repair condition and does not need to be repaired.
[0074] For example Figure 5As shown, after the processing device gives an inferred code result based on the code generation information, that is, generates at least one candidate code, it will determine whether the processing device can automatically repair it according to the error type of the candidate code. If it can be automatically repaired, it will analyze the repair method to determine whether a code knowledge base is needed. When the code knowledge base is not needed, it will trigger an exit to end the repair of the candidate code. When the code knowledge base is needed, it will determine that the candidate code needs to be repaired.
[0075] S204, repairing the erroneous parameters included in the candidate code to be repaired, obtaining a repaired candidate code, and recommending a code generation result, wherein the code generation result includes the repaired candidate code and at least one unrepaired candidate code in the candidate code, and the unrepaired candidate code is different from the candidate code to be repaired.
[0076] Regardless of the method by which the processing device determines the candidate code to be repaired from at least one candidate code, the candidate code to be repaired can be repaired. Exemplarily, the processing device obtains a reference code corresponding to the candidate code to be repaired, and the code similarity between the reference code and the candidate code to be repaired is greater than a similarity threshold; the reference code and the candidate code to be repaired are matched, and parameters are selected from the reference code according to the matching result to replace the parameters of the candidate code to be repaired, so as to obtain the repaired candidate code. In one possible case, the reference code with a high similarity to the candidate code to be repaired can also be called a similar code, and the repair process based on the similar code can be as follows. Figure 5 This is called semantic bug fixing based on similar code.
[0077] Among them, code similarity includes semantic similarity and structural similarity. Semantic similarity refers to the similarity between the function and meaning of the reference code and the candidate code to be repaired, and structural similarity refers to the similarity between the structure and form of the reference code and the candidate code to be repaired. The similarity threshold can be set based on experience and implementation environment. In the case where code similarity includes semantic similarity and structural similarity, the semantic similarity and structural similarity between the reference code and the candidate code to be repaired are both greater than the corresponding similarity thresholds. In addition, the similarity threshold corresponding to the semantic similarity and the similarity threshold corresponding to the structural similarity can be the same or different.
[0078] In a possible implementation, the processing device may determine a reference code similar to the candidate code to be repaired through a code knowledge base, that is, Figure 5The code knowledge base is retrieved to obtain reference code for repair. Exemplarily, the processing device obtains a code knowledge base, which includes multiple original codes; based on the candidate code to be repaired, the reference code is retrieved from the multiple original codes included in the code knowledge base. The code knowledge base can be an existing knowledge base including a large number of original codes, or it can be a code knowledge base currently constructed by the processing device.
[0079] The process of constructing a code knowledge base by a processing device includes but is not limited to: obtaining multiple original codes and construction information corresponding to each original code; determining code features of each original code based on the multiple original codes and the construction information of each original code; determining the correspondence between each original code based on the code features of each original code and the usage impact relationship between each original code; and constructing a code knowledge base including multiple original codes based on the correspondence between each original code.
[0080] The present application embodiment does not limit the process of the processing device obtaining the original code and the construction information. Figure 6 , the processing device can access any of the target project library and the open source / closed source project library, use the project code in the accessed project library as the original code, and use the supporting documents of the project library as the build information, which is used to describe the relevant configuration when building the project, including but not limited to the project name, project function and project format, etc. Among them, the supporting documents include the code schematic of the project code, that is, the distributed representation of the code, which is used to describe the build information of the project. In one possible case, the candidate code is applied to the target project, and the target project itself has some code implementation. For example, the target project code signature and annotations are written based on the development requirements of the target project, and the written code signatures and annotations are stored in the target project library as the project code of the target project. The open source project library refers to a code library that stores a large amount of project code and does not restrict visitors. In some cases, the closed source project library can be called an internal endogenous project library, which refers to a non-open source project library with access rights based on business needs. The endogenous project library can be a company's internal code library, which is used to store project codes developed by the company over the years.
[0081] The processing device may randomly select a project library to collect the original code, or may determine the project library that needs to be accessed based on the interaction with the use object. Figure 7 This is a page display example diagram provided in the embodiment of the present application, see Figure 7 When the processing device is the terminal of the object to be used, the terminal displays the following Figure 7 The initial page shown in the figure above can be changed by right-clicking the mouse at the editing position. Figure 7 The above picture is switched to Figure 7, select the code source for building the knowledge base. When using an object to trigger the selection control for this project, the terminal selects the project code of the target project as the original code and the project document of the target project as the build information. When using an object to trigger the selection control for an internal source project, the terminal obtains the project code in the internal source project library as the original code and the supporting documents of the internal source project library as the build information. When using an object to trigger the selection control for an open source project, the terminal selects the project code in the open source project library as the original code and the supporting documents of the open source project library as the build information. Figure 7 In the example, two concentric circles are used as selection controls. The user can select and trigger one or more controls based on programming requirements, and click the OK button after triggering. The terminal then obtains the original code and build information. Figure 7 A cancel control is also included, which is used to cancel the selection of the code source and exit the selection page.
[0082] In a possible implementation, the processing device can also access a function code library, which includes implementation codes of multiple functions and components. For example, implementation codes of image processing functions such as image filters, cropping and rotation. The implementation code in the function code library can be reused during the project development process, so that when the developed project involves related functions and components, the implementation code in the function code library can be directly called to avoid repeated code writing. In a possible case, the function code library can be called a third-party library, and the third-party library provides implementation code in the form of a computer file format (JAR), a binary archive file (android archive, AAR) of an Android library project, or a virtual machine-based build tool (Gradle). Optionally, the third-party library also includes a dynamic link library and a static link library. The processing device can access the function code library, obtain the implementation code in the function code library, and use the obtained implementation code as the original code for building the code knowledge base, and the processing device will also obtain the code information of the function code library as the project build information of the code, and the code information describes how to call the code in the function code library.
[0083] Similar to the selection process of the project code described above, the processing device can choose to obtain the original code and the build information of the original code from one or more of the project library or the functional code library. Afterwards, the code features of each original code are determined based on the respective original codes and the build information of each original code. For example, the abstract syntax tree (AST) of the collected original code is analyzed, and a node on the tree represents a structure that appears in the original code, thereby obtaining the structural features of the original code. In addition, the processing device can also extract the package name, class attributes, type declarations, and definitions in the build information as descriptive features of the original code, and obtain code features including descriptive features and structural features.
[0084] In one possible case, the processing device also obtains the usage impact relationship between the original codes, such as the calling relationship that code A needs to call code B, or the restriction relationship that code C and code D are in conflict and code D cannot be loaded on the basis of loading code C. The processing device can analyze the construction information of each original code to determine the usage impact relationship between each original code, and after determining the usage impact relationship, build the knowledge graph of each original code according to the code features and the usage impact relationship. The concept of the original code in the physical world and the correspondence between the original codes are structuredly described through the knowledge graph, and a triple in the form of <code, relationship, code> is obtained. Exemplarily, the processing device can build a control flow graph (CFG) and other structures of the original code according to the code features of the original code, and then establish edges according to the usage impact relationship to obtain the knowledge graph of the original code.
[0085] After obtaining the knowledge graph that can represent the correspondence between the original codes, the processing device can build a code knowledge base based on the knowledge graph. For example, the CFG is connected to the control flow graph inside the function / method in the original code, and the definition of the method / function, type definition, and global variable definition in the original code are determined to obtain the global graph information. Afterwards, the knowledge graph algorithm is used for training based on the global graph information and the connected control flow graph to obtain the representation of nodes and edges. A node represents an original code, and an edge represents the correspondence between the original codes. The representation is used to measure the similarity of the nodes. The nodes and edges are stored based on the representation to achieve the storage of multiple original codes according to the correspondence.
[0086] Regardless of the method used by the processing device to obtain the code knowledge base, it can search the code knowledge base based on the candidate code to be repaired. For example, the processing device extracts the method name, parameter list, and type of the candidate code to be repaired, and extracts the associated code context of the candidate code to be repaired, and constructs a code representation based on the extracted associated code context, method name, parameter list, and type, and searches the code knowledge base through the code representation. After retrieving the representation of similar code, the retrieved representation is restored to code, that is, reference code. In some cases, the reference code retrieved from the code knowledge base can be as follows: Figure 6 The shown are called similar codes retrieved in the code knowledge base.
[0087] Since the reference code has a similar structure to the candidate code to be repaired and can provide similar functions to the candidate code to be repaired. For example, the function of the candidate code to be repaired is to call website A to search for keyword A and display the search page, while the function of the reference code is to call website A to search for keyword B and display the search page. Therefore, Figure 6 As shown, the candidate code to be repaired is repaired through the reference code to realize automatic repair of the error code. The repair process is, for example, matching the reference code and the candidate code to be repaired, selecting parameters from the reference code according to the matching results to replace the erroneous parameters included in the candidate code to be repaired, and obtaining the repaired candidate code. Exemplarily, the processing device matches the structure and variables of the reference code and the candidate code to be repaired, so as to determine the parameters corresponding to the parameters in the reference code included in the candidate code to be repaired, and replace the parameters required to be repaired included in the candidate code to be repaired with the corresponding parameters in the reference code. The above matching process can be performed according to the minimum edit distance (MED) or by context similarity.
[0088] The replacement may refer to a one-to-one replacement, for example, the wrong parameter in the candidate code to be repaired is parameter A, and the parameter corresponding to parameter A in the reference code is parameter B, and parameter B is replaced with parameter A. Alternatively, the replacement may refer to a many-to-one replacement, in which case the replacement may refer to adding the corresponding parameter in the reference code to the candidate code to be repaired, for example Figure 3 As shown, Figure 3 In (3), the variable type of the candidate code to be repaired is wrong, and the processing device repairs the variable type by supplementing parameters in the candidate code to be repaired. The supplemented parameters are the parameters marked with a rectangular box in the recommended code after repair. Alternatively, replacement can refer to a one-to-many replacement, that is, the erroneous parameters in the candidate code to be repaired do not have corresponding parameters in the reference code, but because the reference code can also run normally in the absence of the erroneous parameters, the processing device determines that the erroneous parameters can be deleted. For example, based on the matching results between the reference code and the candidate code to be repaired, it is determined that there are duplicate codes in the reference code, and the processing device deletes the duplicate codes to repair the candidate code.
[0089] After the processing device repairs the candidate code to obtain the repaired candidate code, it can recommend the repaired candidate code and other unrepaired candidate codes as code generation results. Taking the code generation information as the input of the user object as an example, the processing device can return the code to the user object, for example, by displaying the repaired candidate code and other unrepaired candidate codes through the user object's terminal, thereby recommending the code generation result to the user object. Since the process of terminal recommending code is similar whether the processing device returns the code to the user object through the communication connection control terminal or the processing device returns the code as the user object's terminal, the following takes the terminal operated by the processing device as an example to illustrate the interaction process between the processing device and the user object.
[0090] Optionally, when displaying the code generation result including multiple candidate codes, the terminal will sort the multiple candidate codes. Figure 5 As shown, the terminal determines whether the repaired candidate code has errors that need to be automatically repaired. If there are errors, the repair process of the above candidate code is repeated. If not, the repaired candidate code and other candidate codes in the given inference code result are displayed as code generation results. The given inference code result is at least one candidate code generated in the above embodiment. The terminal adds the code generation result to the candidate code list, extracts the code features of the code included in the code generation result, searches the code knowledge base according to the code features, obtains the similarity between each code and the original code in the code knowledge base, and sorts each code according to the similarity of each code. Since the original code in the code knowledge base is the correct code, the higher the similarity between the original code in the code knowledge base and the code in the code generation result, the closer the code is to the correct original code, that is, the higher the accuracy. After the terminal realizes the preliminary sorting according to the accuracy through similarity, it will further determine whether the code has errors, and further adjust the sorting according to the number of errors in each code. For example, the code with fewer errors is displayed in the front of the terminal. The code generation result is returned through sorting, so as to achieve the following. Figure 6 The effect of recommending codes with fewer errors after inferring candidate codes through the code big model is shown.
[0091] Exemplarily, in the process of displaying the code included in the code generation result, the terminal can also identify the repaired candidate code. For example, the terminal determines the code repair position corresponding to the repaired candidate code, identifies the code repair position, and provides the identified repaired candidate code and the unmodified candidate code. The code repair position is also the context of the changed parameters, such as the replaced parameters, or the increased parameters, or the reduced parameters in the above embodiment. The embodiment of the present application does not limit the process of identifying the code repair position, and the code repair position can be highlighted, or the code repair position can be underlined or bolded.
[0092] In addition, the terminal can identify the repaired candidate code in the code display page including multiple codes, and can also identify the repaired candidate code in the modification page of the repaired candidate code. For example, after obtaining multiple codes, the user determines that the repaired candidate code needs to be modified, and clicks the error control of the repaired candidate code based on the modification requirements. The error control is, for example, Figure 3 The "×" in (2) is based on the click of the error control, and the terminal expands Figure 3In the modification page shown in (3), the code repair position is highlighted during the display of the modification page. The highlight color can be green, yellow, or any bright color that is different from the page. By marking the code repair position, the user can quickly understand the repair status of the candidate code after repair. Figure 3 (2) provides multiple interactive controls, including a correct control and an Accept control in addition to the error control in the above embodiment. When the user is satisfied with the displayed code, the Accept control is triggered. When the user determines that the displayed code is correct, the correct control is triggered. The correct control, for example, Figure 3 The “√” in (2) of the figure.
[0093] After the terminal determines that the code that needs to be repaired by the object being used is triggered by the error control in the interactive control, it can provide an error repair method for the code. Taking the code that needs to be repaired as the candidate code after repair as an example, in a possible implementation method, the terminal obtains at least one error repair method corresponding to the candidate code after repair; and provides at least one error repair method, and at least one error repair method is used to assist in correcting the candidate code after repair. Exemplarily, the terminal determines at least one error repair method that can repair the candidate code as at least one error repair method corresponding to the candidate code after repair based on the correspondence between the error type and the error repair method before the candidate code is repaired. Taking the error type as an undefined parameter as an example, the error repair method may be to change the parameter, or to redefine the parameter, etc. Since the error repair method corresponding to the repaired candidate code is the repair method for the candidate code before the repair, when the user needs to modify the repaired candidate code, it means that the user is not satisfied with the repair method of the current candidate code and needs to use other repair methods to correct the candidate code before the repair. Therefore, the terminal can selectively provide the error repair method adopted by the repaired candidate code when providing at least one error repair method, that is, at least one error repair method may include the error repair method adopted by the repaired candidate code, and may not include the error repair method adopted by the repaired candidate code. The embodiments of the present application do not limit this.
[0094] After the terminal displays the error repair method, the user can repair it based on the error repair method displayed by the terminal, or repair the displayed code based on experience. Figure 3(3), the modification page displayed by the terminal includes the error code to be repaired, similar codes in the code knowledge base, and provides a drop-down list for the user to select the cause of the error. After selecting the cause of the error, the user enters the result of the manual repair into the code input box of "Recommended Repaired Code". Similar to the process of displaying the repaired candidate code in the above embodiment, the terminal can also mark the repair position in the repaired code input by the user, so that the user can quickly determine the modified location, which is convenient for the user to check the modification of the code.
[0095] In a possible implementation, after the object inputs the modified modification code, the modification code can be sent to the terminal, for example, the object triggers Figure 3 The update control in (3) uploads the modification code to the terminal, and the terminal thereby obtains the modification code returned by the object. In one possible case, the terminal can extract the modification features of the modification code, and update the reference code according to the extracted modification features. The reference code is the code used in the process of repairing the candidate code to obtain the repaired candidate code. Among them, the modification features can be structural features or descriptive features of the modification position in the modification code, such as parameter names and parameter types. The terminal updates the reference code stored in the code knowledge base according to the modification features to implement the update in the code knowledge base. In the case where the terminal also returns an error repair method, the terminal can also update the error repair method corresponding to the error type according to the modification features.
[0096] The above process of updating the reference code can be performed after recommending the candidate code after the repair, e.g. Figure 5 As shown, after checking the candidate code after repair, the user as the user object realizes the correction of the candidate code by supplementing the data, and the terminal updates the code knowledge base according to the modified code fed back by the user, and updates the error repair method corresponding to the error type according to the error repair method fed back by the user. Optionally, the process of updating the code according to the modified code can also be performed before repairing the candidate code to be repaired. For the case where the parameters of the error included in the candidate code to be repaired based on the reference code in the above embodiment are repaired, the terminal can obtain the modified code obtained by modifying the recommended first code, and the first code is repaired based on the second code before recommendation; extract the modification features of the modified code, and update the second code according to the extracted modification features to obtain the reference code. Among them, the first code is the code displayed by the terminal to the user object, the modified code is the code after the user object modifies the first code, and the second code is the original code stored in the code knowledge base and similar to the first code before modification. After obtaining the modified code of the user object, the terminal updates the second code stored in the code knowledge base according to the modified code to obtain the reference code.
[0097] In addition to returning the updated modification code to the terminal, the object can also trigger the page exit control to switch the page from the modification page to the display page of multiple codes. The modification page also includes a page exit control, which is used to trigger the terminal from Figure 3 The modification page of (3) is switched to Figure 3 The display page in (2) of this page can be Figure 3 The Cancel button and the Confirm button in (3) of FIG. The Confirm button means saving the modification to the displayed code and closing the page, and the Cancel button means abandoning the modification to the displayed code and closing the page.
[0098] In summary, the code recommendation method provided by the embodiment of the present application is that after the processing device generates the candidate code, it will automatically repair the erroneous code therein, thereby providing the repaired candidate code and the unrepaired candidate code that is different from the candidate code to be repaired, thereby improving the accuracy of the generated code. In addition, based on the interaction of the usage object, the code knowledge base used in the code repair process will be automatically updated according to the modified code returned by the usage object, thereby improving the repair effect based on the updated code knowledge base. Constructing a code knowledge base including a large amount of original code increases the scale of code retrieval, and by expanding the search scope to other projects outside the target project, the matching probability of similar codes is increased, thereby improving the success rate of code repair.
[0099] The above describes the code recommendation method of the embodiment of the present application. Corresponding to the above method, the embodiment of the present application also provides a code recommendation device. Figure 8 This is a schematic diagram of the structure of a code recommendation device provided in an embodiment of the present application. Figure 8 As shown in the following multiple modules, the Figure 8 The code recommendation device shown can perform the above Figure 2 It should be understood that the device may include more additional modules than the modules shown or omit some of the modules shown, and the embodiments of the present application are not limited to this. Figure 8 As shown, the device comprises:
[0100] An acquisition module 801 is used to acquire code generation information, where the code generation information is used to describe a programming task of the code;
[0101] A generating module 802, configured to generate at least one candidate code according to the code generation information, wherein the at least one candidate code satisfies the programming task described by the code generation information;
[0102] A determination module 803 is used to determine a candidate code to be repaired from at least one candidate code, where the candidate code to be repaired includes an erroneous parameter, and the erroneous parameter does not satisfy at least one of a grammatical constraint or a semantic constraint of a programming language corresponding to the programming task;
[0103] The recommendation module 804 is used to repair the erroneous parameters included in the candidate code to be repaired, obtain the repaired candidate code, and recommend the code generation result. The code generation result includes the repaired candidate code and at least one unrepaired candidate code in the candidate code, and the unrepaired candidate code is different from the candidate code to be repaired.
[0104] In one possible implementation, the determination module 803 is used to detect each candidate code in at least one candidate code to obtain the detection results of each candidate code; when the detection result of any candidate code in at least one candidate code indicates that any candidate code has an error, determine the error type of any candidate code to obtain the error type of each candidate code with an error; match the error type and reference type of each candidate code with an error, and determine the candidate code to be repaired from the candidate code with an error according to the matching results of each candidate code, and the reference type indicates the error type that supports repair.
[0105] In one possible implementation, the determination module 803 is used to execute at least one of the following: for any candidate code, perform syntax analysis on any candidate code, and determine whether any candidate code has a syntax error based on the analysis result; or, run any candidate code in the compilation environment of any candidate code, and determine whether any candidate code has a runtime error based on the runtime result.
[0106] In one possible implementation, the determination module 803 is used to determine, for any candidate code with an error, a repair method corresponding to any candidate code according to the error type of any candidate code when the error type of any candidate code matches the reference type successfully; and to determine any candidate code as a candidate code to be repaired when the repair method of any candidate code meets the repair condition.
[0107] In a possible implementation, the reference type includes at least one of an undefined parameter, a code type error, or a call to an undefined method.
[0108] In one possible implementation, the recommendation module 804 is used to obtain a reference code corresponding to a candidate code to be repaired, wherein the code similarity between the reference code and the candidate code to be repaired is greater than a similarity threshold; the reference code and the candidate code to be repaired are matched, and parameters are selected from the reference code according to the matching results to replace erroneous parameters included in the candidate code to be repaired, so as to obtain a repaired candidate code.
[0109] In a possible implementation, the recommendation module 804 is configured to obtain a code knowledge base including a plurality of original codes; and retrieve a reference code from the plurality of original codes included in the code knowledge base based on the candidate code to be repaired.
[0110] In one possible implementation, the recommendation module 804 is used to obtain multiple original codes and construction information corresponding to each original code; determine the code features of each original code based on the multiple original codes and the construction information of each original code; determine the correspondence between each original code based on the code features of each original code and the usage impact relationship between each original code; and construct a code knowledge base including multiple original codes based on the correspondence between each original code.
[0111] In a possible implementation, the recommendation module 804 is used to determine the code repair position corresponding to the repaired candidate code, identify the code repair position, and recommend the identified repaired candidate code and the unrepaired candidate code.
[0112] In one possible implementation, the acquisition module 801 is also used to acquire at least one error repair method corresponding to the repaired candidate code; the recommendation module 804 is also used to recommend at least one error repair method corresponding to the repaired candidate code, and the at least one error repair method is used to assist in correcting the candidate code to be repaired corresponding to the repaired candidate code.
[0113] In one possible implementation, the erroneous parameters are repaired based on the reference code, and the acquisition module 801 is also used to obtain the modified code obtained by modifying the recommended first code, where the first code is repaired based on the second code before recommendation; the device also includes: an updating module, which is used to extract modification features of the modified code, and update the second code according to the extracted modification features to obtain the reference code.
[0114] After generating the candidate code, the above-mentioned device will automatically repair the candidate code with errors in the candidate code, and provide the repaired candidate code and the unrepaired candidate code that is different from the candidate code to be repaired. By repairing the candidate code to be repaired into a repaired candidate code with higher accuracy, the accuracy of the generated code is improved. Since the code used in the programming task is an accurate code, the higher the accuracy of the code, the more likely it is to use the code in the programming task. By improving the accuracy of the generated code, the possibility of using the generated code in the programming task is further improved.
[0115] Among them, the acquisition module 801, the generation module 802, the determination module 803 and the recommendation module 804 can all be implemented by software, or can be implemented by hardware. Exemplarily, the generation module 802 is taken as an example to introduce the implementation of the generation module 802. Similarly, the implementation of the acquisition module 801, the determination module 803 and the recommendation module 804 can refer to the implementation of the generation module 802.
[0116] As an example of a software functional unit, the generation module 802 may include code running on a computing instance. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned computing instance may be one or more. For example, the generation module 802 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region (region) or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0117] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0118] As an example of a hardware functional unit, the generation module 802 may include at least one computing device, such as a server, etc. Alternatively, the generation module 802 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
[0119] The multiple computing devices included in the generation module 802 can be distributed in the same region or in different regions. The multiple computing devices included in the generation module 802 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the generation module 802 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0120] It should be noted that, in other embodiments, the acquisition module 801, the generation module 802, the determination module 803 or the recommendation module 804 can be used to execute any step in the code recommendation method, and the steps that the acquisition module 801, the generation module 802, the determination module 803 or the recommendation module 804 is responsible for implementing can be specified as needed. The full functions of the code recommendation device are realized by respectively implementing different steps in the code recommendation method through the acquisition module 801, the generation module 802, the determination module 803 or the recommendation module 804.
[0121] The present application also provides a computing device 900. Fig. 9 As shown, the computing device 900 includes: a bus 902, a processor 904, a memory 906, and a communication interface 908. The processor 904, the memory 906, and the communication interface 908 communicate through the bus 902. The computing device 900 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 900.
[0122] The bus 902 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 The bus 902 may include a path for transmitting information between various components of the computing device 900 (eg, the memory 906, the processor 904, and the communication interface 908).
[0123] The processor 904 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0124] The memory 906 may include a volatile memory, such as a random access memory (RAM). The processor 904 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0125] The memory 906 stores executable program codes, and the processor 904 executes the executable program codes to respectively implement the functions of the acquisition module, the generation module, the determination module or the recommendation module, thereby implementing the code recommendation method. That is, the memory 906 stores instructions for executing the code recommendation method.
[0126] The communication interface 908 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 900 and other devices or communication networks.
[0127] The embodiment of the present application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0128] Optionally, the structure of at least one computing device included in the computing device cluster can be found in Fig. 9 The computing device 900 shown. The memory 906 in one or more computing devices 900 in the computing device cluster may store the same instructions for executing the code recommendation method.
[0129] In some possible implementations, the memory 906 of one or more computing devices 900 in the computing device cluster may also store partial instructions for executing the code recommendation method. In other words, the combination of one or more computing devices 900 may jointly execute instructions for executing the code recommendation method.
[0130] It should be noted that the memory 906 in different computing devices 900 in the computing device cluster may store different instructions, which are respectively used to execute part of the functions of the code recommendation device. That is, the instructions stored in the memory 906 in different computing devices 900 may implement the functions of one or more modules among the acquisition module, the generation module, the determination module or the recommendation module.
[0131] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Fig.10 A possible implementation is shown. Fig.10 As shown, two computing devices 1000A and 1000B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, computing devices 1000A and 1000B include a bus 1002, a processor 1004, a memory 1006, and a communication interface 1008. The memory 1006 in the computing device 1000A stores instructions for executing the functions of the acquisition module and the generation module. At the same time, the memory 1006 in the computing device 1000B stores instructions for executing the functions of the determination module and the recommendation module.
[0132] Fig.10 The connection method between the computing device clusters shown may be based on the interactive intention that the code recommendation method provided in the present application requires feedback on the code generation results, and therefore it is considered that the functions implemented by the determination module and the recommendation module are handed over to the computing device 1000A for execution.
[0133] It should be understood that Fig.10 The functions of the computing device 1000A shown in FIG. 1000A may also be completed by multiple computing devices 1000. Similarly, the functions of the computing device 1000B may also be completed by multiple computing devices 1000.
[0134] The embodiment of the present application also provides a communication device, which includes: a transceiver, a memory, and a processor. The transceiver, the memory, and the processor communicate with each other through an internal connection path, the memory is used to store instructions, and the processor is used to execute the instructions stored in the memory to control the transceiver to receive signals and control the transceiver to send signals, and when the processor executes the instructions stored in the memory, the processor executes the code recommendation method.
[0135] It should be understood that the above processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the advanced RISC machines (ARM) architecture.
[0136] Further, in an optional embodiment, the memory may include a read-only memory and a random access memory, and provide instructions and data to the processor. The memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type.
[0137] The memory may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memory. Among them, the nonvolatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM) and direct memory bus random access memory (DR RAM).
[0138] The embodiment of the present application also provides a computer program (product) containing instructions. The computer program (product) may be software or a program (product) containing instructions that can be run on a computing device or stored in any available medium. When the computer program (product) is run on at least one computing device, the at least one computing device executes the code recommendation method.
[0139] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the code recommendation method.
[0140] An embodiment of the present application also provides a chip, including a processor, for calling and executing instructions stored in a memory from the memory, so that a communication device equipped with the chip executes any of the code recommendation methods described above.
[0141] An embodiment of the present application also provides another chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute any of the code recommendation methods described above.
[0142] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in this application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk), etc.
[0143] In order to clearly illustrate the interchangeability of hardware and software, the steps and components of each embodiment have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person of ordinary skill in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0144] The computer program code for realizing the method for the embodiment of the present application can be written in one or more programming languages. These computer program codes can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable rule-finding device, so that the program code, when executed by a computer or other programmable rule-finding device, causes the function / operation specified in the flow chart and / or block diagram to be implemented. The program code can be executed completely on a computer, partially on a computer, as an independent software package, partially on a computer and partially on a remote computer or completely on a remote computer or server.
[0145] In the context of the embodiments of the present application, computer program codes or related data may be carried by any appropriate carrier to enable a device, apparatus or processor to perform the various processes and operations described above. Examples of carriers include signals, computer readable media, etc. Examples of signals may include electrical, optical, radio, acoustic or other forms of propagation signals, such as carrier waves, infrared signals, etc.
[0146] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0147] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, or it can be an electrical, mechanical or other form of connection.
[0148] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0149] In addition, each functional module in each embodiment of the present application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0150] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the code generation information involved in this application is obtained with full authorization.
[0151] In this application, the terms "first", "second", etc. are used to distinguish between identical or similar items with substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is the quantity and execution order limited. It should also be understood that although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of the various described examples, a first link may be referred to as a second link, and similarly, a second link may be referred to as a first link.
[0152] It should also be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0153] The term "at least one" in this application means one or more, and the term "multiple" in this application means two or more, for example, multiple second messages means two or more second messages. The terms "system" and "network" are often used interchangeably herein.
[0154] It should be understood that the terms used in the description of the various examples herein are only for describing specific examples and are not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0155] It should also be understood that the term “comprise” (also known as “includes,” “including,” “comprises” and / or “comprising”) when used in this specification specifies the presence of stated features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0156] It should also be understood that, depending on the context, the phrase “if it is determined that…” or “if [stated condition or event] is detected” may be interpreted to mean “upon determining that…” or “in response to determining that…” or “upon detecting [stated condition or event]” or “in response to detecting [stated condition or event]”.
[0157] It should be understood that determining B based on A does not mean determining B only based on A. B can also be determined based on A and / or other information.
[0158] It should also be understood that the references to "one embodiment", "an embodiment", or "a possible implementation" throughout the specification mean that specific features, structures, or characteristics related to the embodiment or implementation are included in at least one embodiment of the present application. Therefore, the references to "in one embodiment" or "in an embodiment", or "a possible implementation" throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present application.
Claims
1. A code recommendation method, characterized in that: The method comprises: Obtaining code generation information, wherein the code generation information is used to describe a programming task of the code; generating at least one candidate code according to the code generation information, wherein the at least one candidate code satisfies the programming task described by the code generation information; Determining a candidate code to be repaired from the at least one candidate code, the candidate code to be repaired includes an erroneous parameter, and the erroneous parameter does not satisfy at least one of a grammatical constraint or a semantic constraint of a programming language corresponding to the programming task; Repair the erroneous parameters included in the candidate code to be repaired to obtain a repaired candidate code, and recommend a code generation result, wherein the code generation result includes the repaired candidate code and an unrepaired candidate code among the at least one candidate code, and the unrepaired candidate code is different from the candidate code to be repaired.
2. The method according to claim 1, characterized in that: The determining of a candidate code to be repaired from the at least one candidate code comprises: Detecting each candidate code in the at least one candidate code to obtain detection results of each candidate code; When the detection result of any candidate code among the at least one candidate code indicates that the any candidate code has an error, determining the error type of the any candidate code, and obtaining the error type of each candidate code having an error; Match the error type and reference type of each candidate code with errors, determine the candidate code to be repaired from the candidate code with errors according to the matching results of the candidate codes, and the reference type indicates the error type that supports repair.
3. The method according to claim 2, characterized in that The detecting each candidate code in the at least one candidate code includes at least one of the following: For any candidate code, perform syntax analysis on the candidate code, and determine whether any candidate code has a syntax error according to the analysis result; Alternatively, any candidate code is run in the compilation environment of any candidate code, and whether any candidate code has a running error is determined according to the running result.
4. The method according to claim 2 or 3, characterized in that: The step of determining a candidate code to be repaired from the candidate codes with errors according to the matching results of the candidate codes includes: For any candidate code with an error, if the error type of the candidate code successfully matches the reference type, determining a repair method corresponding to the candidate code according to the error type of the candidate code; In the case that the repair method of any candidate code meets the repair condition, the any candidate code is determined as the candidate code to be repaired.
5. The method according to any one of claims 2 to 4, characterized in that: The reference type includes at least one of an undefined parameter, a code type error, or a call to an undefined method.
6. The method according to any one of claims 1 to 5, characterized in that: The step of repairing the erroneous parameters included in the candidate code to be repaired to obtain the repaired candidate code includes: Acquire a reference code corresponding to the candidate code to be repaired, wherein a code similarity between the reference code and the candidate code to be repaired is greater than a similarity threshold; The reference code and the candidate code to be repaired are matched, and according to the matching result, parameters are selected from the reference code to replace erroneous parameters included in the candidate code to be repaired, so as to obtain the repaired candidate code.
7. The method according to claim 6, characterized in that The obtaining a reference code corresponding to the candidate code to be repaired includes: Acquire a code knowledge base, wherein the code knowledge base includes a plurality of original codes; The reference code is retrieved from a plurality of original codes included in the code knowledge base based on the candidate code to be repaired.
8. The method according to claim 7, characterized in that The step of acquiring a code knowledge base includes: Obtain multiple original codes and the building information corresponding to each original code; Determining a code feature of each original code according to the plurality of original codes and construction information of each original code; Determining the correspondence between the original codes according to the code features of the original codes and the usage impact relationship between the original codes; A code knowledge base including the plurality of original codes is constructed according to the corresponding relationship between the various original codes.
9. The method according to any one of claims 1 to 8, characterized in that: The recommended code generation result includes: Determine a code repair position corresponding to the repaired candidate code, and mark the code repair position; The repaired candidate codes and the unrepaired candidate codes after recommendation identification.
10. The method according to any one of claims 1 to 9, characterized in that: After the recommendation code generates a result, it also includes: Obtaining at least one error repair method corresponding to the repaired candidate code; At least one error repair method corresponding to the repaired candidate code is recommended, and the at least one error repair method is used to assist in correcting the candidate code to be repaired corresponding to the repaired candidate code.
11. The method according to any one of claims 1 to 10, characterized in that: The erroneous parameters are repaired based on the reference code, and before repairing the erroneous parameters included in the candidate code to be repaired, the method further includes: Obtaining a modified code obtained by modifying a recommended first code, where the first code is repaired based on the second code before recommendation; The modification feature of the modification code is extracted, and the second code is updated according to the extracted modification feature to obtain the reference code.
12. A code recommendation device, characterized in that: The device comprises: An acquisition module, used for acquiring code generation information, wherein the code generation information is used for describing a programming task of a code; A generating module, configured to generate at least one candidate code according to the code generating information, wherein the at least one candidate code satisfies the programming task described by the code generating information; a determination module, configured to determine a candidate code to be repaired from the at least one candidate code, wherein the candidate code to be repaired includes an erroneous parameter, and the erroneous parameter does not satisfy at least one of a grammatical constraint or a semantic constraint of a programming language corresponding to the programming task; A recommendation module is used to repair erroneous parameters included in the candidate code to be repaired, obtain a repaired candidate code, and recommend a code generation result, wherein the code generation result includes the repaired candidate code and an unrepaired candidate code in at least one candidate code, and the unrepaired candidate code is different from the candidate code to be repaired.
13. The device according to claim 12, characterized in that The determination module is configured to detect each candidate code in the at least one candidate code to obtain the detection results of each candidate code; when the detection result of any candidate code in the at least one candidate code indicates that the any candidate code has an error, determine the error type of the any candidate code to obtain the error type of each candidate code with an error; Match the error type and reference type of each candidate code with errors, determine the candidate code to be repaired from the candidate code with errors according to the matching results of the candidate codes, and the reference type indicates the error type that supports repair.
14. The device according to claim 13, characterized in that The determination module is used to perform at least one of the following: for any candidate code, perform syntax analysis on the any candidate code, and determine whether any candidate code has a syntax error according to the analysis result; Alternatively, any candidate code is run in the compilation environment of any candidate code, and whether any candidate code has a running error is determined according to the running result.
15. The device according to claim 13 or 14, characterized in that The determination module is used to determine, for any candidate code with an error, a repair method corresponding to the candidate code according to the error type of the candidate code if the error type of the candidate code successfully matches the reference type; In the case that the repair method of any candidate code meets the repair condition, the any candidate code is determined as the candidate code to be repaired.
16. The device according to any one of claims 13 to 15, characterized in that: The reference type includes at least one of an undefined parameter, a code type error, or a call to an undefined method.
17. The device according to any one of claims 12 to 16, characterized in that: The recommendation module is used to obtain a reference code corresponding to the candidate code to be repaired, wherein the code similarity between the reference code and the candidate code to be repaired is greater than a similarity threshold; The reference code and the candidate code to be repaired are matched, and according to the matching result, parameters are selected from the reference code to replace erroneous parameters included in the candidate code to be repaired, so as to obtain the repaired candidate code.
18. The device according to claim 17, characterized in that The recommendation module is used to obtain a code knowledge base, which includes a plurality of original codes; and retrieve the reference code from the plurality of original codes included in the code knowledge base based on the candidate code to be repaired.
19. The device according to claim 18, characterized in that The recommendation module is used to obtain multiple original codes and construction information corresponding to each original code; determine the code features of each original code based on the multiple original codes and the construction information of each original code; determine the correspondence between the original codes based on the code features of each original code and the usage impact relationship between the original codes; and construct a code knowledge base including the multiple original codes based on the correspondence between the original codes.
20. The device according to any one of claims 12 to 19, characterized in that: The recommendation module is used to determine the code repair position corresponding to the repaired candidate code and mark the code repair position; The repaired candidate codes and the unrepaired candidate codes after recommendation identification.
21. The device according to any one of claims 12 to 20, characterized in that: The acquisition module is further used to acquire at least one error repair method corresponding to the repaired candidate code; the recommendation module is further used to recommend at least one error repair method corresponding to the repaired candidate code, and the at least one error repair method is used to assist in correcting the candidate code to be repaired corresponding to the repaired candidate code.
22. The device according to any one of claims 12 to 21, characterized in that: The erroneous parameters are repaired based on a reference code, and the acquisition module is further used to obtain a modified code obtained by modifying a recommended first code, where the first code is repaired based on the second code before recommendation; the device also includes: an update module, used to extract modification features of the modified code, and update the second code according to the extracted modification features to obtain the reference code.
23. A computing device cluster, characterized in that: The computing device cluster includes at least one computing device, each computing device includes a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the code recommendation method as described in any one of claims 1-11.
24. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the code recommendation method according to any one of claims 1 to 11.
25. A chip, characterized in that: The chip includes a processor, and the processor is used to run program instructions or codes, so that a device including the chip executes the code recommendation method as described in any one of claims 1-11.
Citation Information
Cited By
Code recommendation method and apparatus, and device and computer-readable storage medium
EP4787157A1
Code recommendation method and apparatus, and device and computer-readable storage medium
WO2025077224A1