Code recommendation method and apparatus, and device and computer-readable storage medium
Patent Information
- Application Number
- PCT/CN2024/097117
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-21
- Filing Date
- 2024-06-03
- Publication Date
- 2025-04-17
AI Technical Summary
In existing code generation technologies, the generated code often contains syntax errors, semantic errors or functional errors, resulting in low accuracy of code in programming tasks and it is difficult to effectively utilize the generated code.
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, ensures that the code used in programming tasks is more accurate, and increases the possibility of utilizing generated code in programming tasks.
Smart Images

Figure CN2024097117_17042025_PF_FP_ABST
Abstract
Description
Code recommendation method, device, equipment and computer-readable storage medium
[0001] This application claims priority to Chinese patent application No. 202311311251.7, filed on October 11, 2023, entitled “Model semantic error repair method, apparatus, device and storage medium”, and claims priority to Chinese patent application No. 202311787695.8, filed on December 21, 2023, entitled “Code recommendation method, apparatus, device and computer-readable storage medium”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] The present application relates to the field of artificial intelligence technology, and in particular to a code recommendation method, apparatus, device, and computer-readable storage medium. Background Art
[0003] With the development of artificial intelligence (AI) technology, AI is being applied in an increasing number of application scenarios. For example, in the AI field, the Code Large Language Model (LLM) is used. During the project development phase, developers input their project code requirements. The LLM generates code based on the input and recommends the generated code to the developer, allowing them to continue project development based on the code they received.
[0004] Summary of the Invention
[0005] This 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:
[0006] 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 including erroneous parameters, the erroneous parameters not satisfying at least one of the 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 a repaired candidate code, and recommending a code generation result, the code generation result including the repaired candidate code and an unrepaired candidate code from the at least one candidate code, the unrepaired candidate code being different from the candidate code to be repaired.
[0007] In this method, after generating candidate codes, candidate codes with errors in the candidate codes, that is, candidate codes to be repaired, are automatically repaired. What is provided is the repaired candidate codes and the codes that are not repaired and are different from the candidate codes to be repaired. By repairing the candidate codes to be repaired into codes with higher accuracy, the accuracy of the generated codes is improved. Since the codes used in the programming tasks are accurate codes, the higher the accuracy of the codes, the more likely it is that the codes will be used in the programming tasks. By improving the accuracy of the generated codes, the possibility of using the generated codes in the programming tasks is further improved.
[0008] In one possible implementation, determining a candidate code to be repaired from at least one candidate code includes: detecting each candidate code in the at least one candidate code to obtain a detection result for each candidate code; when the detection result of any candidate code in the 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 a reference type, and determining a candidate code to be repaired from the candidate code with an error based on the matching results of each candidate code, wherein the reference type indicates an 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, thereby avoiding performing repair operations on candidate codes with error types that cannot be repaired, resulting in ineffective work and waste of resources. Moreover, error type screening can be achieved through matching of reference types, and the screening process is simple and efficient.
[0009] In one possible implementation, each candidate code in at least one candidate code is tested, including at least one of the following: performing a syntax analysis on each candidate code and determining whether any candidate code has a syntax error based on the analysis result; or running each candidate code in a compilation environment of the candidate code and determining whether any candidate code has a runtime error based on the runtime result. Because this method does not limit the detection method for the candidate code, it can detect a variety of error conditions. For candidate codes containing incorrect parameters, whether they contain syntax errors or runtime errors, different detection methods can be used to detect them, resulting in high flexibility and wide versatility.
[0010] In one possible implementation, candidate codes to be repaired are determined from among the candidate codes with errors based on the matching results of each candidate code. This includes: for any candidate code with an error, if the error type of any candidate code matches a reference type, determining a corresponding repair method for that candidate code based on the error type of that candidate code; and if the repair method for any candidate code meets a repair condition, determining that candidate code as the candidate code to be repaired. By limiting the repair condition and repairing the candidate codes that meet the repair condition, the number of candidate codes to be repaired is effectively controlled, improving code repair efficiency and further shortening the waiting time for generating recommended code results.
[0011] In one possible implementation, the reference type includes at least one of an undefined parameter, a code type error, or a call to an undefined method. This method does not limit the error types that can be repaired and has wide versatility.
[0012] In one possible implementation, repairing erroneous parameters included in a candidate code to be repaired to obtain a repaired candidate code includes: obtaining a reference code corresponding to the candidate code to be repaired, where the code similarity between the reference code and the candidate code to be repaired is greater than a similarity threshold; matching the reference code with the candidate code to be repaired, and selecting parameters from the reference code based on the matching result to replace the erroneous parameters included in the candidate code to obtain the repaired candidate code. By replacing parameters between similar reference codes, the candidate code can be repaired, and the repair process has low operational complexity and high repair efficiency.
[0013] In one 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 multiple original codes; and retrieving a reference code from the multiple original codes included in the code knowledge base based on the candidate code to be repaired. The reference code can be obtained by searching the code knowledge base, making the acquisition process simple and time-saving.
[0014] In one 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 based on the multiple original codes and the construction information of each original code; determining correspondences between the original codes based on the code features of each original code and the usage impact relationships between the original codes; and constructing a code knowledge base including the multiple original codes based on the correspondences between the original codes. The original codes are stored based on the correspondences between the original codes. Subsequently, during code retrieval, similar codes can be quickly located based on the constructed correspondences, thereby improving code retrieval efficiency.
[0015] In one possible implementation, recommending code generation results includes: determining the code repair location corresponding to the repaired candidate code, marking the code repair location, and recommending the marked repaired candidate code and the unrepaired candidate code. By marking the code repair location, it is easier to quickly understand the repair status of the candidate code, and then determine whether the repaired candidate code meets the code generation requirements based on the repair status, thereby improving the efficiency of candidate code determination.
[0016] In one possible implementation, after the recommended code generates a result, the process 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, where 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 process assists in repairing the candidate code to be repaired, shortening the time required to repair the candidate code and improving efficiency.
[0017] In one possible implementation, the erroneous parameters are repaired based on reference code. Before repairing the erroneous parameters included in the candidate code to be repaired, the method further includes: obtaining a modified code obtained by modifying the recommended first code, where the first code was repaired based on the second code before recommendation; extracting modification features of the modified code, and updating the second code based on 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, so that the resulting reference code is more suitable for the programming task, and the candidate code obtained by repairing the reference code is more suitable for the programming task.
[0018] In a second aspect, a code recommendation device is provided, which includes: an acquisition module for acquiring code generation information, where the code generation information is used to describe a programming task of the code; a generation module for generating at least one candidate code based on the code generation information, where the at least one candidate code satisfies the programming task described by the code generation information; a determination module for determining a candidate code to be repaired from the at least one candidate code, where the candidate code to be repaired includes erroneous parameters, where the erroneous parameters do not satisfy at least one of the grammatical constraints or semantic constraints of the programming language corresponding to the programming task; a recommendation module for repairing the erroneous parameters included in the candidate code to be repaired, obtaining the repaired candidate code, and recommending a code generation result, where the code generation result includes the repaired candidate code and an unrepaired candidate code from at least one candidate code, where the unrepaired candidate code is different from the candidate code to be repaired.
[0019] In one possible implementation, a determination module is used to detect each candidate code in at least one candidate code to obtain a detection result 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 based on the matching result of each candidate code, and the reference type indicates the error type that supports repair.
[0020] In one possible implementation, the determination module is used to execute at least one of the following: for any candidate code, perform syntax parsing on any candidate code, and determine whether any candidate code has a syntax error based on the parsing 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 running result.
[0021] 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 based on the error type of any candidate code if the error type of any candidate code successfully matches the reference type; and to determine any candidate code as a candidate code to be repaired if the repair method of any candidate code meets the repair condition.
[0022] 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.
[0023] In one possible implementation, a recommendation module is used to obtain a reference code corresponding to a candidate code to be repaired, where 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.
[0024] In a possible implementation, the recommendation module 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.
[0025] In one possible implementation, a recommendation module is used to obtain multiple original codes and construction information corresponding to each original code; determine 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.
[0026] In a possible implementation, the recommendation module is configured to determine a code repair location corresponding to a repaired candidate code, identify the code repair location, and recommend the identified repaired candidate code and unrepaired candidate code.
[0027] In one possible implementation, the acquisition module is further used to obtain 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.
[0028] In one possible implementation, 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 the 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 a reference code.
[0029] 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 in the above-mentioned first aspect.
[0030] In a fourth aspect, a computer-readable storage medium is provided, which includes 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.
[0031] 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.
[0032] In a sixth aspect, a communication device is provided, comprising: a transceiver, a memory, and a processor. The transceiver, the memory, and the processor communicate with each other via an internal connection path. The memory is configured to store instructions, and the processor is configured to execute the instructions stored in the memory to control the transceiver to receive signals and to control the transceiver to transmit signals. When the processor executes the instructions stored in the memory, the processor performs the method according to the first aspect or any possible implementation of the first aspect.
[0033] Optionally, there are one or more processors and one or more memories.
[0034] Optionally, the memory may be integrated with the processor, or the memory may be provided separately from the processor.
[0035] In the specific implementation process, the memory can be a non-transitory memory, such as a read-only memory (ROM), which can be integrated on the same chip as the processor or be set on different chips. This application does not limit the type of memory and the setting method of the memory and the processor.
[0036] In a seventh aspect, a chip is provided, comprising a processor for calling and executing instructions stored in a memory, so that a communication device equipped with the chip executes the methods in the above aspects.
[0037] 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 through 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.
[0038] It should be understood that the beneficial effects achieved by the technical solutions of the second to eighth aspects of this application and the corresponding possible implementation methods can be referred to the technical effects of the first aspect and its corresponding possible implementation methods mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] FIG1 is a schematic diagram of an implementation environment provided by an embodiment of the present application;
[0040] FIG2 is a flowchart of a code recommendation method provided in an embodiment of the present application;
[0041] FIG3 is a schematic diagram of a page provided in an embodiment of the present application;
[0042] FIG4 is a statistical diagram of code errors provided in an embodiment of the present application;
[0043] FIG5 is a schematic diagram of a code generation process provided by an embodiment of the present application;
[0044] FIG6 is a schematic diagram of another code generation process provided by an embodiment of the present application;
[0045] FIG7 is another schematic diagram of a page provided in an embodiment of the present application;
[0046] FIG8 is a schematic diagram of the structure of a code recommendation device provided in an embodiment of the present application;
[0047] FIG9 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0048] FIG10 is a connection diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] The terms used in the embodiments of this application are only used to explain the specific embodiments of this application and are not intended to limit this application. To make the purpose, technical solutions and advantages of this application clearer, the embodiments of this application will be further described in detail below with reference to the accompanying drawings.
[0050] With the development of artificial intelligence technology, it is possible to generate and recommend code through increasingly mature code generation technology, thereby improving programming efficiency. For example, a code language large model generates code based on the input code generation information and recommends the generated code. Among them, the code language large 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 code language large model can be text, and the code language large model infers the program code based on the input text, or generates a specific code segment.
[0051] The embodiment of the present application provides a code recommendation method for recommending code to complete a programming task. Please refer to Figure 1, which shows a schematic diagram of the implementation environment of the code recommendation method provided by 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 recommendation method can be independently executed by a processing device. For example, the processing device obtains code generation information, generates at least one candidate code based on 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 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 takes two processing devices as an example for illustration.
[0052] For example, the processing devices included in the computing device cluster 10 can be servers, such as central servers, edge servers, or local servers in a local data center. The servers can be physical servers or cloud servers that provide cloud computing services. In some embodiments, the processing devices included in the computing device cluster 10 can also be terminal devices such as desktop computers, laptop computers, or smartphones involved in cloud services.
[0053] An embodiment of the present application provides a code recommendation method, which can be applied to the implementation environment shown in Figure 1 above. The method can be executed by a processing device included in the computing device cluster 10. The flowchart of the method is shown in Figure 2, including S201-S204.
[0054] S201, obtaining code generation information, where the code generation information is used to describe a programming task of the code.
[0055] 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 code for the target project, and the processing device obtains code generation information based on the development of the target project. 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 to write code that has the same function as the fault code, and obtains code generation information based on the programming task.
[0056] In addition to determining code generation information based on a detected programming task as described in the above embodiments, the processing device may also obtain code generation information based on interactions with a code user. For example, the user may be an object developing a target project. The user may determine the code to be written based on the development requirements of the target project, thereby determining the code generation information, and transmit the code generation information to the processing device based on interactions with the processing device. The processing device may be a terminal of the user or a device that establishes a communication connection with the terminal of the user.
[0057] 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 can be provided through a local code editor of the terminal, such as a software developer tool (visual studio code, VSCode), an 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 one possible implementation, the terminal can also provide code generation services through a cloud service in the form of an application programming interface (API) structure to provide information input controls to the user object.
[0058] FIG3 is a schematic diagram of a page display provided by an embodiment of the present application. FIG3 shows the IDE interface displayed by the terminal to the user when the IDE plug-in is used for project development. Among them, FIG3 (1) is the initial page. During the use phase, the user can right-click the edit location and select "Generate Code". Then, the user can enter the code generation information in the information input control provided in the edit location.
[0059] 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 function of the code. For example, if 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, if a search is performed through website A and a page of search results is displayed, the programming task is to write 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 the code context that requires code to connect, or a code execution log, requirement document or annotation, etc.
[0060] In one possible scenario, when the processing device is a device connected to a terminal, the processing device receives code generation information transmitted by the terminal. For example, the processing device may be a data processing center integrated with multiple servers. Because the data processing efficiency of a data processing center is higher than that of a single terminal, after receiving the code generation information input by the user object, the terminal transmits the code generation information to the data processing center based on the communication connection with the data processing center, so that the data processing center can generate code more quickly. The data processing center, as the processing device, thus obtains the code generation information.
[0061] S202 , generating at least one candidate code according to the code generation information, where the at least one candidate code satisfies the programming task described by the code generation information.
[0062] For example, after obtaining code generation information to determine a programming task, the processing device can use any code generation model to generate candidate codes based on the code generation information to complete the programming task. 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.
[0063] Optionally, when the code generation information is a natural language text as exemplified in S201, the processing device first performs language understanding on the natural language text and converts it into an intermediate representation that can be understood by the machine. For example, a bidirectional encoder representation from transformers (BERT) model or GPT model is used to encode the natural language text, and the encoded result is used as the intermediate representation. Subsequently, a large code language model is used to generate the corresponding code structure and syntax based on the intermediate representation to obtain a candidate code.
[0064] 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. The code language large model may have different understandings based on 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 implement the function described by the code generation information, or can connect to the input code context to realize code loading.
[0065] S203: Select a candidate code to be repaired from at least one candidate code, where the candidate code to be repaired includes an incorrect parameter, and the incorrect parameter does not satisfy at least one of a grammatical constraint or a semantic constraint of a programming language corresponding to the programming task.
[0066] In one possible scenario, the candidate code generated by the processing device may contain errors. 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. 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.
[0067] Exemplarily, code errors caused by incorrect parameters in the candidate code include but are not limited to grammatical errors, semantic errors and functional errors. Among them, grammatical errors refer to statements in the candidate code that do not conform to grammatical regulations, errors that appear during the compilation process, and erroneous parameters in grammatical 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 execution of the candidate code, errors that appear during the execution process, and erroneous 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 execution, the output result is incorrect. Erroneous parameters in semantic errors are, for example, incorrectly written formula parameters, or incorrectly written conditional parameters in the conditional statements in the candidate code. Figure 4 is a statistical diagram of code errors provided in an embodiment of the present application. Referring to Figure 4, 305 code snippets were generated by analyzing two large code models. The number of error types of the 305 code snippets generated was 36% for functional errors, 37% for grammatical errors, and 27% for semantic errors.
[0068] In the case where errors exist in the candidate code, the processing device needs to repair the candidate code after generating the candidate code, correcting the errors in the candidate code, thereby providing 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; 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 of each candidate code with a reference type, and determining the candidate code to be repaired from the candidate code with an error based on the matching results of each candidate code, wherein the reference type indicates the error type that the processing device supports repairing.
[0069] The embodiments of the present application do not limit the process of the processing device detecting the candidate code. Taking any candidate code as an example, the detection can be carried out by including but not limited to the following two optional methods. Optional method one, 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. 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 meets 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 meets 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.
[0070] 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 runtime error based on the running result. The compilation environment of the candidate code can be constructed by the processing device or obtained by other means. The absence of a runtime error means that the candidate code does not show an error during the running process, and the running result is correct. The presence of a runtime 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 shows 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 either Optional Method 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.
[0071] After the processing device determines that there is an erroneous candidate code based on the detection results, 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 determines 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. A code type error can be a mismatch in the number / type of parameters. An undefined method is, for example, an undeclared API.
[0072] 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, the category and the reference type both indicate a semantic error, the processing device thus determines that the error type and the reference type of the candidate code are matched successfully.
[0073] Optionally, if the error type of the candidate code successfully matches the reference type, the processing device may directly determine the candidate code as a candidate code to be repaired and repair the candidate code. In one possible scenario, if the error type of any candidate code with an error successfully matches the reference type, the processing device may determine a corresponding repair method for any candidate code based on the error type of any candidate code; if the repair method of any candidate code meets the repair condition, the processing device may determine any candidate code as a candidate code to be repaired.
[0074] In one possible scenario, the repair condition is determined based on the repair method adopted by the processing device. Because the processing device searches for similar code within a code knowledge base when repairing candidate code, the processing device can determine the repair condition as whether to call the code knowledge base or whether similar code is required. If the processing device adopts other repair methods to repair candidate code, the processing device can also flexibly set the repair condition based on the repair method adopted. Optionally, the processing device determines the repair method corresponding to the error type of the candidate code. For example, based on the error type of the candidate code, the processing device determines at least one of a code segment that needs to be modified and an erroneous logic that needs to be corrected, and then determines whether to call the code knowledge base based on at least one of the determined code segment and erroneous 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 and is, therefore, the candidate code to be repaired. Conversely, when the repair method indicates that the code knowledge base does not need to be called, the candidate code is determined to not meet the repair condition and does not need to be repaired.
[0075] For example, as shown in FIG5 , after the processing device gives an inferred code result based on the code generation information, that is, generates at least one candidate code, it determines whether the processing device can automatically repair the code based on the error type of the candidate code. If the code can be automatically repaired, the processing device analyzes the repair method to determine whether a code knowledge base is required. If the code knowledge base is not required, the processing device triggers an exit to end the repair of the candidate code. If the code knowledge base is required, the processing device determines that the candidate code needs to be repaired.
[0076] 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.
[0077] 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 results to replace the parameters of the candidate code to be repaired, thereby obtaining 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 called a semantic error repair based on the similar code as shown in FIG5 .
[0078] Code similarity includes semantic similarity and structural similarity. Semantic similarity refers to the degree of similarity between the function and meaning of the reference code and the candidate code to be repaired, while structural similarity refers to the degree of 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 the 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 semantic similarity and the similarity threshold corresponding to structural similarity can be the same or different.
[0079] In one possible implementation, the processing device can determine reference codes similar to the candidate code to be repaired from a code knowledge base, as shown in FIG5 , by retrieving the reference code from the code knowledge base for repair. Exemplarily, the processing device retrieves a code knowledge base containing multiple original codes and retrieves the reference code from the multiple original codes in the code knowledge base based on the candidate code to be repaired. The code knowledge base can be an existing knowledge base containing a large amount of original code, or it can be a code knowledge base currently being constructed by the processing device.
[0080] 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.
[0081] The embodiment of the present application does not limit the process of the processing device obtaining the original code and build information. Referring to 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. The build information is used to describe the relevant configuration when building the project, including but not limited to the project name, project function and project format. Among them, the supporting documents include a code schematic of the project code, that is, a 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 comments are written based on the development requirements of the target project. The written code signature and comments are stored in the target project library as the project code of the target project. An open source project library refers to a code library that stores a large amount of project code and does not restrict access. A closed source project library can be called an internal internal source project library in some cases, which refers to a project library that is not open source and has access rights based on business needs. The internal source project library can be a company's internal code library used to store project codes developed by the company over the years.
[0082] The processing device can randomly select a project library to collect the original code, or it can determine the project library that needs to be accessed based on the interaction with the user object. Figure 7 is a page display example diagram provided by an embodiment of the present application. Referring to Figure 7, when the processing device is the terminal of the user object, the terminal displays the initial page as shown in the upper figure of Figure 7. The user object can right-click the mouse at the editing position to switch the page from the upper figure of Figure 7 to the lower figure of Figure 7 and select the code source for building the knowledge base. When the user object triggers the selection control of 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 the user object triggers the selection control of the endogenous project, the terminal obtains the project code in the endogenous project library as the original code and the supporting documents of the endogenous project library as the build information. When the user object triggers the selection control of the 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. In Figure 7, two concentric circles are used as selection controls. The user object can choose to trigger one or more controls based on programming requirements and click the OK button after triggering. The terminal thus obtains the original code and build information. FIG7 also includes a cancel control, which is used to cancel the selection of the code source and exit the selection page.
[0083] In one possible implementation, the processing device can also access a function code library, which includes implementation code for various functions and components. For example, implementation code for image processing functions such as image filters, cropping, and rotation. The implementation code in this function code library can be reused during project development. When a project involves related functions and components, the implementation code in the function code library can be directly called, avoiding duplication of code. In one possible scenario, the function code library can be called a third-party library. The third-party library provides the implementation code in a computer file format (JAR), an Android library project binary archive (Android archive, AAR), 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 from the function code library, and use the obtained implementation code as the original code for building the code knowledge base. The processing device also obtains code information from the function code library as project build information for the code, which describes how to call the code in the function code library.
[0084] Similar to the above-mentioned project code selection process, the processing device can choose to obtain the original code and the construction 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 original code and the construction 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 construction information as descriptive features of the original code, and obtain code features including descriptive features and structural features.
[0085] In one possible case, the processing device will also obtain 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, construct a knowledge graph of each original code based on 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. For example, the processing device can construct a structure such as the control flow graph (CFG) of the original code based on the code features of the original code, and then establish edges based on the usage impact relationship to obtain the knowledge graph of the original code.
[0086] After obtaining a knowledge graph that can represent the correspondence between the original codes, the processing device can construct a code knowledge base based on the knowledge graph. For example, the CFG is connected to the control flow graph within 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 global graph information. Then, the knowledge graph algorithm is used to train based on the global graph information and the connected control flow graph to obtain node and edge representations. 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, and multiple original codes are stored according to the corresponding relationship.
[0087] Regardless of the method by which the processing device obtains 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, 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 referred to as the similar code retrieved from the code knowledge base as shown in Figure 6.
[0088] Since the reference code is similar in structure to the candidate code to be repaired and can provide functions similar to those of 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 a search page, and the function of the reference code is to call website A to search for keyword B and display a search page. Therefore, the candidate code to be repaired can be repaired by the reference code as shown in Figure 6 to automatically repair the error code. The repair process is, for example, to match the reference code and the candidate code to be repaired, and select parameters from the reference code according to the matching results to replace the erroneous parameters included in the candidate code to be repaired, so as to obtain the repaired candidate code. Exemplarily, the processing device matches the structure and variables of the reference code and the candidate code to be repaired, thereby determining the corresponding parameters in the reference code of the parameters that need to be repaired included in the candidate code to be repaired, and replaces the parameters that need 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.
[0089] Among them, replacement can refer to 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, replacement can refer to many-to-one replacement. In this case, replacement can be referred to as adding the corresponding parameter in the reference code to the candidate code to be repaired. For example, as shown in Figure 3, in (3) in Figure 3, the variable type of the candidate code to be repaired is wrong. The processing device repairs the variable type by supplementing the parameter in the candidate code to be repaired. The supplemented parameter is also the parameter marked with a rectangular box in the recommended repaired code. Alternatively, replacement can refer to one-to-many replacement, that is, the wrong parameter in the candidate code to be repaired does not have a corresponding parameter in the reference code, but since the reference code can also run normally without the wrong parameter, the processing device determines that the wrong parameter can be deleted. For example, based on the matching result between the reference code and the candidate code to be repaired, it is determined that there is duplicate code in the reference code. The processing device deletes the duplicate code to repair the candidate code.
[0090] After the processing device repairs the candidate code and obtains 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 as an example, the processing device can return the code to the user, for example, by displaying the repaired candidate code and other unrepaired candidate codes on the user's terminal, thereby recommending the code generation result to the user. Since the terminal recommends the code process is similar whether the processing device returns the code to the user through a communication connection control terminal or the processing device returns the code as the user's terminal, the interaction process between the processing device and the user is temporarily explained using the example of the processing device as the user's terminal.
[0091] Optionally, when the terminal displays the code generation result including multiple candidate codes, it will sort the multiple candidate codes. For example, as shown in Figure 5, the terminal determines whether the candidate code after repair has errors that need to be automatically repaired. If there are errors, the repair process of the candidate code is repeated. If not, the repaired candidate code and other candidate codes in the given inference code result are displayed as the code generation result. 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 based on the code features, obtains the similarity between each code and the original code in the code knowledge base, and sorts each code based on 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 has achieved preliminary sorting based on accuracy through similarity, it will further determine whether the code has errors and further adjust the sorting based on the number of errors in each code. For example, the code with fewer errors will be displayed at the front of the terminal. The code generation results are returned through sorting, thereby achieving the effect of recommending codes with fewer errors after inferring candidate codes through the code large model as shown in Figure 6.
[0092] 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 parameters replaced in the above embodiment, or the parameters added, or the parameters reduced. 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.
[0093] 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, "×" in (2) of Figure 3. Based on the click of the error control, the terminal expands the modification page shown in (3) of Figure 3. In the process of displaying the modification page, the code repair position is highlighted. The color selected for highlighting can be green, yellow, or any bright color that is different from the page. By identifying the code repair position, the user can quickly understand the repair status of the repaired candidate code. (2) in Figure 3 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 is, for example, "√" in (2) of Figure 3.
[0094] After the terminal determines that the code that needs to be repaired for the object 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 based on the correspondence between the error type and the error repair method of the candidate code before repair, as the at least one error repair method corresponding to the candidate code after repair. Taking the error type as an undefined parameter as an example, the error repair method can 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 adopt 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.
[0095] After the terminal displays the error repair method, the user can repair the error based on the error repair method displayed by the terminal, or repair the displayed code based on experience. Referring to (3) of Figure 3, the modification page displayed by the terminal includes the error code that needs 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 candidate code after repair in the above embodiment, the terminal can also mark the repair position in the repaired code entered 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.
[0096] In one possible implementation, after the user inputs the modified modification code, the user object can send the modification code to the terminal. For example, the user object triggers the update control in (3) of Figure 3 to upload the modification code to the terminal, and the terminal thereby obtains the modification code returned by the user 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.
[0097] The above-mentioned process of updating the reference code can be performed after the recommended candidate code after repair. For example, as shown in Figure 5, after the user, as the user, checks the repaired candidate code, he or she corrects the candidate code by supplementing the data. The terminal updates the code knowledge base based on the modified code feedback from the user, and updates the error repair method corresponding to the error type based on the error repair method feedback from the user. Optionally, the above-mentioned process of updating the code based on the modified code can also be performed before repairing the candidate code to be repaired. For the case in the above embodiment where the parameters of the error included in the candidate code to be repaired are repaired based on the reference code, the terminal can obtain the modified code obtained by modifying the recommended first code, where the first code was repaired based on the second code before the recommendation; extract the modification features of the modified code, and update the second code based on the extracted modification features to obtain the reference code. The first code is the code displayed by the terminal to the user, the modified code is the code after the user modifies the first code, and the second code is the original code stored in the code knowledge base that is similar to the first code before the modification. After obtaining the modified code of the user, the terminal updates the second code stored in the code knowledge base based on the modified code to obtain the reference code.
[0098] In addition to returning the updated modification code to the terminal, the object can also trigger a 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 to switch from the modification page in (3) of Figure 3 to the display page in (2) of Figure 3. The page exit control can be the Cancel button and the OK button in (3) of Figure 3. Among them, the OK button means saving the modification of the displayed code and closing the page, and the Cancel button means abandoning the modification of the displayed code and closing the page.
[0099] In summary, the code recommendation method provided by the embodiment of the present application is such that after generating the candidate code, the processing device 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. Moreover, 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 that includes 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.
[0100] 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 is a structural diagram of a code recommendation device provided by the embodiment of the present application. Based on the following multiple modules shown in Figure 8, the code recommendation device shown in Figure 8 can perform all or part of the operations shown in Figure 2 above. It should be understood that the device may include more additional modules than the modules shown or omit some of the modules shown therein, and the embodiment of the present application is not limited to this. As shown in Figure 8, the device includes:
[0101] 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;
[0102] A generating module 802 is configured to generate at least one candidate code according to the code generation information, where the at least one candidate code satisfies the programming task described by the code generation information;
[0103] A determination module 803 is configured to determine a candidate code to be repaired from at least one candidate code, where the candidate code to be repaired includes an incorrect parameter, and the incorrect parameter does not satisfy at least one of a grammatical constraint or a semantic constraint of a programming language corresponding to the programming task;
[0104] 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 a 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.
[0105] In one possible implementation, the determination module 803 is used to detect each candidate code in at least one candidate code to obtain a detection result 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 based on the matching result of each candidate code, and the reference type indicates the error type that supports repair.
[0106] In one possible implementation, the determination module 803 is used to perform at least one of the following: for any candidate code, perform syntax parsing on any candidate code, and determine whether any candidate code has a syntax error based on the parsing 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 running result.
[0107] 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 successfully matches the reference type; 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.
[0108] 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.
[0109] In one possible implementation, the recommendation module 804 is used to obtain a reference code corresponding to the candidate code to be repaired, where 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 the erroneous parameters included in the candidate code to be repaired, so as to obtain the repaired candidate code.
[0110] 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.
[0111] 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.
[0112] In a possible implementation, the recommendation module 804 is configured to determine a code repair location corresponding to the repaired candidate code, identify the code repair location, and recommend the identified repaired candidate code and unrepaired candidate code.
[0113] In one possible implementation, the acquisition module 801 is further used to obtain at least one error repair method corresponding to the repaired candidate code; the recommendation module 804 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.
[0114] In one possible implementation, the erroneous parameters are repaired based on the reference code, and the acquisition module 801 is further used to obtain a 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 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.
[0115] 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 accurate code, the higher the accuracy of the code, the more likely it is to be used 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.
[0116] The acquisition module 801, generation module 802, determination module 803, and recommendation module 804 can all be implemented via software or hardware. For example, the implementation of generation module 802 will be described below using generation module 802 as an example. Similarly, the implementation of acquisition module 801, determination module 803, and recommendation module 804 can refer to the implementation of generation module 802.
[0117] As an example of a software functional unit, the generation module 802 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the 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 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 geographically close data centers. Typically, a region may include multiple AZs.
[0118] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.
[0119] As an example of a hardware functional unit, the generation module 802 may include at least one computing device, such as a server. Alternatively, the generation module 802 may be 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.
[0120] 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.
[0121] 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. 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.
[0122] This application also provides a computing device 900. As shown in Figure 9, computing device 900 includes a bus 902, a processor 904, a memory 906, and a communication interface 908. Processor 904, memory 906, and communication interface 908 communicate with each other via bus 902. Computing device 900 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 900.
[0123] Bus 902 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG9 illustrates a single bus line, but this does not imply a single bus or type of bus. Bus 902 may include a path for transmitting information between various components of computing device 900 (e.g., memory 906, processor 904, and communication interface 908).
[0124] The processor 904 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0125] The memory 906 may include volatile memory, such as random access memory (RAM). The processor 904 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0126] The memory 906 stores executable program code, and the processor 904 executes the executable program code to implement the functions of the acquisition module, generation module, determination module, or recommendation module, respectively, thereby implementing the code recommendation method. In other words, the memory 906 stores instructions for executing the code recommendation method.
[0127] 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 a communication network.
[0128] Embodiments of the present application also provide 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 smartphone.
[0129] Optionally, the structure of at least one computing device included in the computing device cluster may refer to the computing device 900 shown in Figure 9. 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.
[0130] 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 can jointly execute the instructions for executing the code recommendation method.
[0131] It should be noted that the memory 906 in different computing devices 900 in the computing device cluster can store different instructions, each for executing a portion of the functions of the code recommendation apparatus. In other words, the instructions stored in the memory 906 in different computing devices 900 can implement the functions of one or more of the acquisition module, generation module, determination module, or recommendation module.
[0132] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network. The network may be a wide area network or a local area network, etc. FIG10 shows a possible implementation. As shown in FIG10 , 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.
[0133] The connection method between the computing device clusters shown in Figure 10 can be based on the interactive intention that the code recommendation method provided in this application requires feedback on the code generation results, so it is considered to entrust the functions implemented by the determination module and the recommendation module to the computing device 1000A for execution.
[0134] It should be understood that the functions of the computing device 1000A shown in FIG10 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.
[0135] An embodiment of the present application further provides a communication device comprising: a transceiver, a memory, and a processor. The transceiver, the memory, and the processor communicate with each other via an internal connection path. The memory is configured to store instructions, and the processor is configured to execute the instructions stored in the memory to control the transceiver to receive signals and to control the transceiver to transmit signals. When the processor executes the instructions stored in the memory, the processor executes a code recommendation method.
[0136] It should be understood that the 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. It is worth noting that the processor may be a processor that supports the Advanced RISC Machine (ARM) architecture.
[0137] Furthermore, 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 device type information.
[0138] The memory may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM), which is used as an external cache memory. By way of example and not limitation, many forms of RAM are available. For example, static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0139] The present application also provides a computer program (product) comprising instructions. The computer program (product) may be software or a program (product) comprising 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.
[0140] 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 that contains 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 drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the code recommendation method.
[0141] 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.
[0142] 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.
[0143] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented 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, all or part of the processes or functions described herein are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may 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 integrated therein. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive).
[0144] To clearly illustrate the interchangeability of hardware and software, the above description has generally described the steps and components of each embodiment according to their functions. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled 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.
[0145] The computer program code for realizing the method for the embodiment of the application can be written in one or more programming languages.These computer program codes can be provided to the processor of general-purpose computer, special-purpose computer or other programmable rule-finding device, so that program code, when being executed by computer or other programmable rule-finding device, causes the function / operation specified in flow chart and / or block diagram to be implemented.Program code can be executed completely on computer, partly on computer, as an independent software package, partly on computer and partly on remote computer or completely on remote computer or server.
[0146] In the context of the embodiments of the present application, computer program code or related data may be carried by any suitable 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, and the like. Examples of signals may include electrical, optical, radio, acoustic, or other forms of propagated signals, such as carrier waves, infrared signals, and the like.
[0147] Those skilled in the art will clearly understand that, for the sake of convenience and brevity of description, the specific working processes of the above-described systems, devices, and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0148] In the several embodiments provided in this 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 merely schematic. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, 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 can be electrical, mechanical or other forms of connection.
[0149] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across 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.
[0150] In addition, the functional modules in the various embodiments of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into a single module. The above-mentioned integrated modules may be implemented in the form of hardware or software functional modules.
[0151] 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, storage, display, 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 the relevant countries and regions. For example, the code generation information involved in this application is obtained with full authorization.
[0152] 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 there a limit on the quantity and execution order. 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 can be referred to as a second link, and similarly, a second link can be referred to as a first link.
[0153] 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.
[0154] In this application, the term "at least one" means one or more, and the term "plurality" means two or more. For example, "plurality of second messages" means two or more second messages. The terms "system" and "network" are often used interchangeably herein.
[0155] It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing particular examples only and is 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.
[0156] It will 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.
[0157] 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…” or “in response to determining…” or “upon detecting [stated condition or event]” or “in response to detecting [stated condition or event]”.
[0158] It should be understood that determining B based on A does not mean determining B based solely on A. B can also be determined based on A and / or other information.
[0159] It should also be understood that references throughout this specification to "one embodiment," "an embodiment," or "one possible implementation" mean that specific features, structures, or characteristics associated with that embodiment or implementation are included in at least one embodiment of the present application. Therefore, the appearance of "in one embodiment," "in an embodiment," or "one possible implementation" throughout this specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0160] 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 them. 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 deviate the essence of the corresponding technical solutions 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
Patent Citations
Code recommendation method, device and equipment and computer readable storage medium
CN119806625A
Code review method and device based on artificial intelligence, storage medium and server
CN114185548A
Code generation method and device, equipment and storage medium
CN115048102A
Code generation method and device
CN116719520A
Method and a tool for automatically generating program code for a computer program
US20140109042A1
Cited By
Construction method and system for producing available code interpretation large model
CN120872408A
A construction method and system of a production available code interpretation large model
CN120872408B
Code generation method and computing device
CN121166525A
Robot task execution code automatic generation method and related equipment
CN121879737A