A cloud computing-based code generation system and method

By quantifying the independence and functionality of code snippets, constructing necessary code group libraries, and filtering and combining efficient and high-quality code snippets, the problem of insufficient code generation quality and efficiency in existing technologies is solved, achieving efficient, fast, and functionally accurate code generation.

CN120353454BActive Publication Date: 2025-11-14XIAN HENGGE DIGITAL TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410486469.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-22
Publication Date
2025-11-14
Estimated Expiration
2044-04-22

AI Technical Summary

Technical Problem

Existing cloud-based code generation systems and methods fail to effectively evaluate the quality and efficiency of code snippets before combination, resulting in potentially poor-quality generated code that cannot guarantee resource consumption, execution speed, and functional accuracy.

Method used

By quantifying the independence and function of each extracted code snippet, a necessary code group library is built, high-efficiency and high-quality code snippets are selected and combined, and the generated code is optimized using a pre-set cloud computing platform.

Benefits of technology

Ensure that the generated code consumes minimal resources, executes quickly, has high functional accuracy, and delivers good results that meet expectations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120353454B_ABST
    Figure CN120353454B_ABST
Patent Text Reader

Abstract

This invention relates to the field of code generation technology, and specifically discloses a cloud-based code generation system and method, comprising: a partitioning module for obtaining the independence of each extracted code fragment and all code libraries based on parameter information of each complete code; an acquisition module for obtaining all necessary code libraries based on the overall functionality of the received generated code; a calculation module for obtaining the code efficiency value and code quality value of each extracted code fragment based on all extracted code fragments; a combination module for obtaining the optimal combination of extracted code based on the code efficiency value and code quality value of all extracted code fragments; and a generation module for obtaining generated code based on the optimal combination of extracted code. This invention ensures that the generated code, ultimately composed of extracted code fragments, exhibits good performance in terms of resource consumption, execution speed, code functionality accuracy, and code execution effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of code generation technology, and in particular to a cloud computing-based code generation system and method. Background Technology

[0002] Currently, effectively improving the quality and efficiency of software development is a core concern in the field of software engineering. Many researchers have long sought to enhance the automation level of software development by refining development methodologies and employing technological means. Code generation, in particular, refers to the use of certain technologies to automatically generate software source code, achieving the goal of automated programming based on programmers' needs. Code generation technology is considered an important method for improving the automation and quality of software development and has received widespread attention from both academia and industry.

[0003] However, existing cloud-based code generation systems and methods only generate code through created code generation templates. They simply combine the filler content and common content within the template to obtain the code generation template, without evaluating the code quality and efficiency before combination. Furthermore, they cannot guarantee the effect of the combined code fragments, leading to potentially poor-quality code generated using existing technologies. For example, patent publication number "CN106528165B" and patent title "Code Generation Method and System" includes the following steps: obtaining target sample code and creating a code generation template based on the target sample code, wherein the code generation template contains difference content replacement identifiers and common content; upon receiving an instruction to generate code, determining the filler content corresponding to the difference content replacement identifiers and using the filler content to fill in the difference content replacement identifiers to obtain a processed code generation template; and generating the code based on the processed code generation template, effectively improving code development efficiency and ensuring code standardization and correctness. However, it does not consider the performance of the generated code in terms of resource consumption, execution speed, code functionality accuracy, and code execution effect.

[0004] Therefore, this invention proposes a code generation system and method based on cloud computing. Summary of the Invention

[0005] This invention provides a cloud computing-based code generation system and method. It quantifies the independence of each extracted code segment from the complete code and, combined with the overall functionality of the received generated code, obtains all sub-functions, constructing a necessary code library capable of implementing each sub-function. Furthermore, based on the independence of all extracted code segments in each necessary code library, it determines the code efficiency and quality of each extracted code segment. Specifically, by determining and using code efficiency values ​​to filter extracted code segments in the generated code, it ensures that the extracted code segments ultimately combined into the generated code have relatively low resource consumption and relatively high execution speed. Similarly, by determining and using code quality values ​​to filter extracted code segments in the generated code, it ensures the accuracy of the functionality implemented and the execution effect of the final generated code. Finally, by utilizing a preset cloud computing platform and the code efficiency and quality values ​​of all extracted code segments in all necessary code libraries, it ensures that the final generated code has relatively low resource consumption, relatively high execution speed, and more closely meets the expected functional requirements, resulting in better execution performance.

[0006] This invention provides a cloud computing-based code generation system, comprising:

[0007] The partitioning module is used to extract code from all complete code, obtain all extracted code snippets in each complete code, and obtain the independence and functionality of each extracted code snippet based on the parameter information of each complete code. Based on the independence and functionality of all extracted code snippets, all code group libraries are obtained.

[0008] The acquisition module is used to obtain all sub-functions based on the overall function of the received generated code, and to obtain all necessary code group libraries based on all sub-functions and all code group libraries.

[0009] The calculation module is used to obtain the code efficiency value and code quality value of each extracted code fragment of the corresponding necessary code group library based on the independence of all extracted code fragments of each necessary code group library;

[0010] The combination module is used to obtain the best combination of extracted code based on the code efficiency and code quality values ​​of all extracted code snippets in the preset cloud computing platform and all necessary code group libraries.

[0011] The generation module is used to concatenate all extracted code snippets from the optimal extraction code combination to obtain the generated code.

[0012] Preferably, the modules include:

[0013] The system is divided into sub-modules to obtain all complete code from the database and extract code from the corresponding complete code based on the code comments of each complete code, thereby obtaining all extracted code snippets in each complete code.

[0014] The parameter information acquisition module is used to acquire parameter information for each complete code based on a variety of preset tools. The parameter information includes the call frequency and call time of all extracted code segments in the complete code, as well as the data transfer type.

[0015] The independence calculation submodule is used to obtain the independence of each extracted code segment and the code segment function based on the parameter information of each complete code segment;

[0016] The code group library building submodule is used to obtain all code group libraries based on the independence and functionality of all extracted code snippets in all complete code.

[0017] Preferably, the sub-modules include:

[0018] The retrieval unit is used to retrieve all complete code and code comments for each complete code in the database.

[0019] The segmentation unit is used to filter out all comments with preset characteristics from the code comments of each complete code as all functional comments, and to take the complete code block covered by each functional comment of the corresponding complete code as the extracted code fragment in the corresponding complete code, so as to obtain all the extracted code fragments in each complete code.

[0020] Preferably, the independence calculation submodule includes:

[0021] The parameter acquisition unit is used to obtain the call frequency and call time, and data transfer type of all extracted code segments in each complete code from the parameter information of each complete code;

[0022] The assignment unit is used to assign values ​​to the corresponding extracted code segments based on the data transfer type of each extracted code segment in each complete code, so as to obtain the data transfer assignment results of each extracted code segment in each complete code;

[0023] The computational unit is used to calculate the degree of independence of each extracted code segment in each complete code based on the call frequency and call time of all extracted code segments in each complete code, which is:

[0024]

[0025] Where δ is the independence of a single extracted code segment in the currently computed complete code, T is the runtime of the currently computed complete code, t is the call time of the currently computed extracted code segment in the currently computed complete code, ε is the call frequency of the currently computed extracted code segment in the currently computed complete code, ε0 is the mean call frequency of all extracted code segments in the currently computed complete code, σ is the data transfer assignment result of the currently computed extracted code segment in the currently computed complete code, ln is the natural logarithm function, and the natural constant e has a value of 2.718;

[0026] The code snippet function acquisition unit is used to treat the function annotation of each extracted code snippet as the corresponding code snippet function, and obtain the code snippet function of each extracted code snippet.

[0027] Preferably, the code group library building submodule includes:

[0028] The first building unit is used to select all extracted code fragments with an independence greater than a preset independence threshold from all extracted code fragments in all complete code, and to use them as independent code fragments.

[0029] The second building unit is used to obtain the code snippet functions of all independent code snippets, and to aggregate all independent code snippets with the same code snippet functions as a separate code group library, thereby obtaining all code group libraries.

[0030] Preferably, the acquisition module includes:

[0031] The receiving submodule is used to receive the overall code generation function uploaded by the user to the code generation system, and obtain all sub-functions based on the received overall code generation function and the preset function decomposition model.

[0032] The Necessary Code Group Library submodule is used to filter out code group libraries whose functional annotations are the same as each sub-function from all code group libraries and summarize them to obtain all necessary code group libraries.

[0033] Preferably, the computing module includes:

[0034] The parameter acquisition submodule is used to obtain the memory usage, total number of lines of code, and runtime of all extracted code snippets in each necessary code group library.

[0035] The first calculation submodule is used to calculate the code efficiency and code quality values ​​of each extracted code fragment in each necessary code group library based on the memory usage, total number of lines of code, runtime, and independence of all extracted code fragments in each necessary code group library.

[0036]

[0037]

[0038] Where ρ is the code efficiency value of the currently calculated extracted code segment, τ is the code quality value of the currently calculated extracted code segment, r is the running time of the currently calculated extracted code segment, max(r) is the maximum running time among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, q is the memory usage value of the currently calculated extracted code segment, max(q) is the maximum memory usage value among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, w is the number of lines of code of the currently calculated extracted code segment, max(w) is the maximum number of lines of code among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, and δ is the degree of independence of the currently calculated extracted code segment.

[0039] Preferably, the combined module includes:

[0040] The Combination submodule is used to combine one extracted code snippet from each necessary code group library to obtain all extracted code combinations, where each extracted code combination contains one extracted code snippet from each necessary code group library.

[0041] The second calculation submodule is used to calculate the comprehensive quality value of each extracted code combination based on the code efficiency and code quality values ​​of all extracted code snippets from the preset cloud computing platform and all necessary code group libraries.

[0042]

[0043] in, ρ represents the overall quality value of a single extracted code combination, where i is the i-th extracted code fragment within the corresponding extracted code combination, n is the total number of extracted code fragments within the corresponding extracted code combination, and ρ i τ is the code efficiency value of the i-th extracted code segment within the corresponding extracted code combination. i Let ln be the code quality value of the i-th extracted code segment within the code combination, where ln is the natural logarithm function and the natural constant e is 2.718.

[0044] The judgment submodule is used to select the extraction code combination with the highest overall quality value among all extraction code combinations as the best extraction code combination.

[0045] Preferably, the combined module includes:

[0046] Build submodules to construct code splicing models;

[0047] The combination submodule is used to input the best extracted code combination into the code concatenation model for code concatenation to obtain the generated code.

[0048] This invention provides a cloud computing-based code generation method, applicable to any one of embodiments 1 to 9, including:

[0049] S1: Extract code from all complete code, obtain all extracted code snippets in each complete code, and obtain the independence and functionality of each extracted code snippet based on the parameter information of each complete code. Obtain all code group libraries based on the independence and functionality of all extracted code snippets.

[0050] S2: Obtain all sub-functions based on the overall function of the received generated code, and obtain all necessary code libraries based on all sub-functions and all code libraries;

[0051] S3: Based on the independence of all extracted code snippets in each necessary code group library, obtain the code efficiency value and code quality value of each extracted code snippet in the corresponding necessary code group library;

[0052] S4: Based on the code efficiency and code quality values ​​of all extracted code snippets in the preset cloud computing platform and all necessary code group libraries, obtain the best combination of extracted code;

[0053] S5: Concatenate all extracted code snippets from the optimal code extraction combination to obtain the generated code.

[0054] The beneficial effects of this invention compared to existing technologies are as follows: By quantifying the independence of each extracted code segment in the complete code and combining it with the overall function of the received generated code to obtain all sub-functions, a necessary code library capable of implementing each sub-function is constructed. Furthermore, based on the independence of all extracted code segments in each necessary code library, the code efficiency and code quality of each extracted code segment in the necessary code library are determined. That is, by determining the code efficiency value and using the code efficiency value to filter the extracted code segments in the generated code, it is ensured that the resource consumption of the extracted code segments finally combined into the generated code is relatively small and the execution speed is relatively high. By determining the code quality value and using the code quality value to filter the extracted code segments in the generated code, the accuracy of the code implementation function and the code execution effect of the code finally combined into the generated code are ensured. In addition, by utilizing the preset cloud computing platform and the code efficiency and code quality values ​​of all extracted code segments in all necessary code libraries, it is ensured that the resource consumption of the finally combined generated code is relatively small, the execution speed is relatively high, and the implemented function is more in line with the expected requirements, resulting in better execution effect.

[0055] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written documents of this application.

[0056] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0057] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0058] Figure 1 This is a schematic diagram of a cloud computing-based code generation system according to an embodiment of the present invention;

[0059] Figure 2 This is a flowchart of a cloud computing-based code generation method in an embodiment of the present invention. Detailed Implementation

[0060] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0061] Example 1:

[0062] This invention provides a reference Figure 1 ,include:

[0063] The partitioning module is used to extract code from all complete code, obtain all extracted code snippets in each complete code, and obtain the independence and functionality of each extracted code snippet based on the parameter information of each complete code. Based on the independence and functionality of all extracted code snippets, all code group libraries are obtained.

[0064] The acquisition module is used to obtain all sub-functions based on the overall function of the received generated code, and to obtain all necessary code group libraries based on all sub-functions and all code group libraries.

[0065] The calculation module is used to obtain the code efficiency value and code quality value of each extracted code fragment of the corresponding necessary code group library based on the independence of all extracted code fragments of each necessary code group library;

[0066] The combination module is used to obtain the best combination of extracted code based on the code efficiency and code quality values ​​of all extracted code snippets in the preset cloud computing platform and all necessary code group libraries.

[0067] The generation module is used to concatenate all extracted code snippets from the optimal extraction code combination to obtain the generated code.

[0068] In this embodiment, the complete code refers to all fully executable code extracted from a pre-set database (containing code samples that have been used).

[0069] In this embodiment, code extraction is the process of obtaining all extracted code fragments from each complete code.

[0070] In this embodiment, the extracted code snippet is a code snippet obtained by extracting code from each complete code, which can at least achieve a simple function, and the code snippet contains multiple code statements.

[0071] In this embodiment, the parameter information of the complete code is a parameter that reflects the running status of all extracted code segments within the execution of the complete code.

[0072] In this embodiment, the degree of independence is a numerical value obtained based on the parameter information of each complete code, which characterizes the degree of independence between each extracted code segment and the rest of the corresponding complete code. The greater the degree of independence, the smaller the difference between the code function when the code segment is implemented independently and the corresponding part of the code function implemented in the complete code. That is, the smaller the deviation between its independent function and its function implemented in the complete code.

[0073] In this embodiment, the code snippet function is used to extract functional comments from the code snippet.

[0074] In this embodiment, the code group library is a library of code snippets containing all extracted code snippets that can implement a certain sub-function, extracted from all the complete code.

[0075] In this embodiment, the overall function of the generated code is the function that the user inputs into the cloud-based code generation system and wants the final generated code to achieve, such as filtering out all user information that meets condition A1 in database A.

[0076] In this embodiment, the sub-function is a partial sub-function of the overall function of the generated code obtained based on the received overall function of the generated code and the preset function decomposition model.

[0077] In this embodiment, the necessary code library is the code library selected from all code libraries whose function annotations are the same as each sub-function.

[0078] In this embodiment, the code efficiency value is obtained based on the memory usage, total number of lines of code, and running time of all extracted code fragments in each necessary code group library. It represents the performance value of each extracted code fragment in the corresponding necessary code group library in two dimensions: resource consumption and execution speed. That is, the larger the code efficiency value, the smaller its resource consumption and the faster its execution speed, and vice versa.

[0079] In this embodiment, the code quality value is a performance value calculated based on the memory usage, total number of lines of code, running time, and independence of all extracted code fragments in each necessary code group library. It represents the performance of each extracted code fragment in each necessary code group library in terms of code functionality accuracy and code execution effect (e.g., resource consumption, code execution speed, etc.). That is, the higher the code quality value, the higher its performance in terms of functionality accuracy and execution effect, and vice versa.

[0080] In this embodiment, the preset cloud computing platform is a pre-configured platform used to decompose computing tasks and accelerate the calculation of the overall quality value of each extracted code combination, such as Microsoft Azure.

[0081] In this embodiment, the optimal code extraction combination is the best combination of multiple extracted code fragments required to achieve the overall function of the generated code.

[0082] In this embodiment, code concatenation refers to the process of inputting the best extracted code combination into a code concatenation model to obtain new code.

[0083] The beneficial effects of the above technology are as follows: By quantifying the independence of each extracted code segment in the complete code and combining it with the overall function of the received generated code to obtain all sub-functions, a necessary code library capable of implementing each sub-function is built. Furthermore, based on the independence of all extracted code segments in each necessary code library, the code efficiency and code quality of each extracted code segment in the necessary code library are determined. That is, by determining the code efficiency value and using the code efficiency value to filter the extracted code segments in the generated code, it is ensured that the extracted code segments that are finally combined into the generated code have relatively low resource consumption and relatively high execution speed. By determining the code quality value and using the code quality value to filter the extracted code segments in the generated code, the accuracy of the code implementation function and the code execution effect of the code implemented in the final combined generated code are ensured. In addition, by using the preset cloud computing platform and the code efficiency value and code quality value of all extracted code segments in all necessary code libraries, it is ensured that the final combined generated code has relatively low resource consumption, relatively high execution speed, and the implemented function is more in line with the expected requirements, resulting in better execution effect.

[0084] Example 2:

[0085] Based on Example 1, the modules are divided, including:

[0086] The system is divided into sub-modules to obtain all complete code from the database and extract code from the corresponding complete code based on the code comments of each complete code, thereby obtaining all extracted code snippets in each complete code.

[0087] The parameter information acquisition module is used to acquire parameter information for each complete code based on a variety of preset tools. The parameter information includes the call frequency and call time of all extracted code segments in the complete code, as well as the data transfer type.

[0088] The independence calculation submodule is used to obtain the independence of each extracted code segment and the code segment function based on the parameter information of each complete code segment;

[0089] The code group library building submodule is used to obtain all code group libraries based on the independence and functionality of all extracted code snippets in all complete code.

[0090] In this embodiment, code comments are explanatory texts added by the programmer to the code, used to describe the code's function, logic, parameters, return value, and other matters that need attention.

[0091] In this embodiment, the preset tool is a pre-set tool used to obtain parameter information for each complete code, such as IDE tools, logging, performance analysis tools, etc.

[0092] In this embodiment, the call frequency of the extracted code segment is the number of times the extracted code segment is called by the other code segments in the complete code during the entire program's execution (from program startup to program termination).

[0093] In this embodiment, the invocation time is the sum of the durations during which the extracted code segment is called multiple times by other code segments during the entire program's execution (from program startup to program termination).

[0094] In this embodiment, the data transfer type is the type of information, variable, or value transfer between different code segments, such as pass-by-value, pass-by-reference, pass-by-pointer, etc.

[0095] The beneficial effects of the above technology are as follows: all complete code is extracted to obtain all extracted code fragments in each complete code; code in the complete code that does not directly implement specific functions is removed; and the independence and function of each extracted code fragment are obtained based on the parameter information of each complete code. The independence of each extracted code fragment in the complete code is quantified, which facilitates the constraint of the independence of the extracted code fragments in the subsequent code group library construction process.

[0096] Example 3:

[0097] Based on Example 2, the system is divided into sub-modules, including:

[0098] The retrieval unit is used to retrieve all complete code and code comments for each complete code in the database.

[0099] The segmentation unit is used to filter out all comments with preset characteristics from the code comments of each complete code as all functional comments, and to take the complete code block covered by each functional comment of the corresponding complete code as the extracted code fragment in the corresponding complete code, so as to obtain all the extracted code fragments in each complete code.

[0100] In this embodiment, the preset feature is a feature that includes a comment describing the function of the code.

[0101] In this embodiment, a complete code block covered by a function annotation is a code snippet that can implement the function of the code in the function annotation, and it contains multiple code statements.

[0102] The beneficial effects of the above technology are: based on functional annotations, code extraction can be achieved for all complete code, obtaining all extracted code snippets in each complete code, thereby eliminating code in the complete code that does not directly implement specific functions.

[0103] Example 4:

[0104] Based on Example 2, the independence calculation submodule includes:

[0105] The parameter acquisition unit is used to obtain the call frequency and call time, and data transfer type of all extracted code segments in each complete code from the parameter information of each complete code;

[0106] The assignment unit is used to assign values ​​to the corresponding extracted code segments based on the data transfer type of each extracted code segment in each complete code, so as to obtain the data transfer assignment results of each extracted code segment in each complete code;

[0107] The computational unit is used to calculate the degree of independence of each extracted code segment in each complete code based on the call frequency and call time of all extracted code segments in each complete code, which is:

[0108]

[0109] Where δ is the independence of a single extracted code segment in the currently computed complete code, T is the runtime of the currently computed complete code, t is the call time of the currently computed extracted code segment in the currently computed complete code, ε is the call frequency of the currently computed extracted code segment in the currently computed complete code, ε0 is the mean call frequency of all extracted code segments in the currently computed complete code, σ is the data transfer assignment result of the currently computed extracted code segment in the currently computed complete code, ln is the natural logarithm function, and the natural constant e has a value of 2.718;

[0110] The code snippet function acquisition unit is used to treat the function annotation of each extracted code snippet as the corresponding code snippet function, and obtain the code snippet function of each extracted code snippet.

[0111] In this embodiment, assigning a value to the corresponding extracted code segment based on the data transfer type of each extracted code segment in each complete code is as follows:

[0112] When the data transfer type of each extracted code snippet in each complete code is pass-by-value, the data transfer assignment result of the corresponding extracted code snippet is set to 1;

[0113] When the data transfer type for each extracted code snippet in each complete code is pass-by-reference, the data transfer assignment result for the corresponding extracted code snippet will be set to 2;

[0114] When the data transfer type for each extracted code snippet in each complete code is pointer transfer, the data transfer assignment result for the corresponding extracted code snippet is set to 3;

[0115] When the data transfer type of each extracted code snippet in each complete code is message passing, the data transfer assignment result of the corresponding extracted code snippet is set to 4;

[0116] When the data transfer type of each extracted code snippet in each complete code is a callback function, the data transfer assignment result of the corresponding extracted code snippet is set to 5;

[0117] When there are multiple data transfer types for each extracted code segment in each complete code, the one with the largest data transfer assignment result is taken as the data transfer assignment result for the corresponding extracted code segment.

[0118] In this embodiment, the data transfer assignment result is the result of assigning a value to the data transfer type of each extracted code segment in each complete code.

[0119] The beneficial effects of the above technology are: based on the parameter information of each complete code, the independence and functionality of each extracted code segment can be obtained, that is, the independence of the extracted code segment can be accurately calculated from the perspective of its association with other code segments, which facilitates the construction of subsequent code group libraries.

[0120] Example 5:

[0121] Based on Example 2, the code group library constructs a sub-module, including:

[0122] The first building unit is used to select all extracted code fragments with an independence greater than a preset independence threshold from all extracted code fragments in all complete code, and to use them as independent code fragments.

[0123] The second building unit is used to obtain the code snippet functions of all independent code snippets, and to aggregate all independent code snippets with the same code snippet functions as a separate code group library, thereby obtaining all code group libraries.

[0124] In this embodiment, the preset independence threshold is a pre-set independence threshold used to filter out independent code segments from all extracted code segments in all complete code.

[0125] In this embodiment, an independent code snippet is a code snippet that can be extracted individually from all extracted code snippets in the entire complete code.

[0126] The beneficial effects of the above technology are: all code group libraries are obtained based on the independence and functionality of all extracted code snippets. This embodiment provides a specific method for obtaining all code group libraries based on all extracted code snippets in all complete code.

[0127] Example 6:

[0128] Based on Example 1, the acquisition module includes:

[0129] The receiving submodule is used to receive the overall code generation function uploaded by the user to the code generation system, and obtain all sub-functions based on the received overall code generation function and the preset function decomposition model.

[0130] The Necessary Code Group Library submodule is used to filter out code group libraries whose functional annotations are the same as each sub-function from all code group libraries and summarize them to obtain all necessary code group libraries.

[0131] In this embodiment, the preset functional decomposition model is a model that is pre-trained using a large number of overall functions and all sub-functions corresponding to the overall functions as training samples, and can output all sub-functions when the overall function is input.

[0132] The beneficial effects of the above technologies are: using a preset functional decomposition model to decompose the overall function of the generated code, and selecting code libraries that can implement sub-functions as necessary code combinations.

[0133] Example 7:

[0134] Based on Example 1, the calculation module includes:

[0135] The parameter acquisition submodule is used to obtain the memory usage, total number of lines of code, and runtime of all extracted code snippets in each necessary code group library.

[0136] The first calculation submodule is used to calculate the code efficiency and code quality values ​​of each extracted code fragment in each necessary code group library based on the memory usage, total number of lines of code, runtime, and independence of all extracted code fragments in each necessary code group library.

[0137]

[0138]

[0139] Where ρ is the code efficiency value of the currently calculated extracted code segment, τ is the code quality value of the currently calculated extracted code segment, r is the running time of the currently calculated extracted code segment, max(r) is the maximum running time among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, q is the memory usage value of the currently calculated extracted code segment, max(q) is the maximum memory usage value among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, w is the number of lines of code of the currently calculated extracted code segment, max(w) is the maximum number of lines of code among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, and δ is the degree of independence of the currently calculated extracted code segment.

[0140] In this embodiment, the memory occupied by the code is the runtime memory occupied by each extracted code snippet in the necessary code group library during code execution.

[0141] In this embodiment, the total number of lines of code is the number of lines of code for each extracted code segment in the necessary code group library.

[0142] In this embodiment, the runtime is the runtime of each extracted code snippet in the necessary code group library during code execution.

[0143] The beneficial effects of the above technology are: to comprehensively and quantitatively evaluate each extracted code segment in terms of resource consumption, execution speed, code function accuracy, and code running effect. This embodiment provides a specific method for comprehensively and quantitatively evaluating each extracted code segment in terms of resource consumption, execution speed, code function accuracy, and code running effect.

[0144] Example 8:

[0145] Based on Example 1, the combined module includes:

[0146] The Combination submodule is used to combine one extracted code snippet from each necessary code group library to obtain all extracted code combinations, where each extracted code combination contains one extracted code snippet from each necessary code group library.

[0147] The second calculation submodule is used to calculate the comprehensive quality value of each extracted code combination based on the code efficiency and code quality values ​​of all extracted code snippets from the preset cloud computing platform and all necessary code group libraries.

[0148]

[0149] in, ρ represents the overall quality value of a single extracted code combination, where i is the i-th extracted code fragment within the corresponding extracted code combination, n is the total number of extracted code fragments within the corresponding extracted code combination, and ρ i τ is the code efficiency value of the i-th extracted code segment within the corresponding extracted code combination. i Let ln be the code quality value of the i-th extracted code segment within the code combination, where ln is the natural logarithm function and the natural constant e is 2.718.

[0150] The judgment submodule is used to select the extraction code combination with the highest overall quality value among all extraction code combinations as the best extraction code combination.

[0151] In this embodiment, the comprehensive quality value is calculated based on the code efficiency value and code quality value of all extracted code fragments in all necessary code group libraries. It represents a comprehensive quantitative evaluation of the generated code after splicing each extracted code combination in terms of resource consumption, execution speed, code functionality accuracy, and code running effect.

[0152] The beneficial effects of the above technology are: it efficiently and accurately obtains the best combination of extracted code based on the code efficiency and code quality values ​​of all extracted code fragments in the preset cloud computing platform and all necessary code group libraries, which facilitates subsequent code splicing. This embodiment provides a specific method for obtaining the best combination of extracted code based on the code efficiency and code quality values ​​of all extracted code fragments in all necessary code group libraries.

[0153] Example 9:

[0154] Based on Example 1, the combined module includes:

[0155] Build submodules to construct code splicing models;

[0156] The combination submodule is used to input the best extracted code combination into the code concatenation model for code concatenation to obtain the generated code.

[0157] In this embodiment, the code splicing model is trained using a large number of pre-acquired, manually programmed code samples that have been used and all extracted code fragments extracted from them according to the code extraction process described in embodiments 2 and 3 as training samples. The resulting model can output complete code by inputting multiple code fragments.

[0158] The beneficial effect of the above technology is that it accurately obtains the generated code by concatenating all the extracted code fragments from the optimal extraction code combination.

[0159] Example 10:

[0160] This invention provides a cloud computing-based code generation method, applicable to any one of the cloud computing-based code generation systems described in embodiments 1 to 9, with reference to... Figure 2 include:

[0161] S1: Extract code from all complete code, obtain all extracted code snippets in each complete code, and obtain the independence and functionality of each extracted code snippet based on the parameter information of each complete code. Obtain all code group libraries based on the independence and functionality of all extracted code snippets.

[0162] S2: Obtain all sub-functions based on the overall function of the received generated code, and obtain all necessary code libraries based on all sub-functions and all code libraries;

[0163] S3: Based on the independence of all extracted code snippets in each necessary code group library, obtain the code efficiency value and code quality value of each extracted code snippet in the corresponding necessary code group library;

[0164] S4: Based on the code efficiency and code quality values ​​of all extracted code snippets in the preset cloud computing platform and all necessary code group libraries, obtain the best combination of extracted code;

[0165] S5: Concatenate all extracted code snippets from the optimal code extraction combination to obtain the generated code.

[0166] The beneficial effects of the above technology are as follows: By quantifying the independence of each extracted code segment in the complete code and combining it with the overall function of the received generated code to obtain all sub-functions, a necessary code library capable of implementing each sub-function is built. Furthermore, based on the independence of all extracted code segments in each necessary code library, the code efficiency and code quality of each extracted code segment in the necessary code library are determined. That is, by determining the code efficiency value and using the code efficiency value to filter the extracted code segments in the generated code, it is ensured that the extracted code segments that are finally combined into the generated code have relatively low resource consumption and relatively high execution speed. By determining the code quality value and using the code quality value to filter the extracted code segments in the generated code, the accuracy of the code implementation function and the code execution effect of the code implemented in the final combined generated code are ensured. In addition, by using the preset cloud computing platform and the code efficiency value and code quality value of all extracted code segments in all necessary code libraries, it is ensured that the final combined generated code has relatively low resource consumption, relatively high execution speed, and the implemented function is more in line with the expected requirements, resulting in better execution effect.

[0167] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A cloud computing-based code generation system, characterized in that, include: The segmentation module is used to extract code from all complete code snippets, obtaining all extracted code fragments within each complete code snippet. Based on the parameter information of each complete code snippet, it determines the independence and functionality of each extracted code snippet. Based on the independence and functionality of all extracted code snippets, it obtains all code group libraries, including: The independence calculation submodule includes: The parameter acquisition unit is used to obtain the call frequency and call time, and data transfer type of all extracted code segments in each complete code from the parameter information of each complete code; The assignment unit is used to assign values ​​to the corresponding extracted code segments based on the data transfer type of each extracted code segment in each complete code, so as to obtain the data transfer assignment results of each extracted code segment in each complete code; The computational unit is used to calculate the degree of independence of each extracted code segment in each complete code based on the call frequency and call time of all extracted code segments in each complete code, which is: Where δ is the independence of a single extracted code segment in the currently computed complete code, T is the runtime of the currently computed complete code, t is the call time of the currently computed extracted code segment in the currently computed complete code, ε is the call frequency of the currently computed extracted code segment in the currently computed complete code, ε0 is the mean call frequency of all extracted code segments in the currently computed complete code, σ is the data transfer assignment result of the currently computed extracted code segment in the currently computed complete code, ln is the natural logarithm function, and the natural constant e has a value of 2.718; The code snippet function acquisition unit is used to treat the function annotation of each extracted code snippet as the code snippet function of the corresponding extracted code snippet, and obtain the code snippet function of each extracted code snippet. The acquisition module is used to obtain all sub-functions based on the overall function of the received generated code, and to obtain all necessary code group libraries based on all sub-functions and all code group libraries. The calculation module is used to obtain the code efficiency and code quality values ​​for each extracted code snippet of each necessary code group library based on the independence of all extracted code snippets in each necessary code group library, including: The parameter acquisition submodule is used to obtain the memory usage, total number of lines of code, and runtime of all extracted code snippets in each necessary code group library. The first calculation submodule is used to calculate the code efficiency and code quality values ​​of each extracted code fragment in each necessary code group library based on the memory usage, total number of lines of code, runtime, and independence of all extracted code fragments in each necessary code group library. Where ρ is the code efficiency value of the currently calculated extracted code segment, τ is the code quality value of the currently calculated extracted code segment, r is the running time of the currently calculated extracted code segment, max(r) is the maximum running time among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, q is the memory usage value of the currently calculated extracted code segment, max(q) is the maximum memory usage value among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, w is the number of lines of code of the currently calculated extracted code segment, max(w) is the maximum number of lines of code among all extracted code segments in the necessary code group library to which the currently calculated extracted code segment belongs, and δ is the degree of independence of the currently calculated extracted code segment. The combination module is used to obtain the best combination of extracted code based on the code efficiency and code quality values ​​of all extracted code snippets in the preset cloud computing platform and all necessary code group libraries. The generation module is used to concatenate all extracted code snippets from the optimal extraction code combination to obtain the generated code.

2. The cloud computing-based code generation system according to claim 1, characterized in that, The modules are divided into: The system is divided into sub-modules to obtain all complete code from the database and extract code from the corresponding complete code based on the code comments of each complete code, thereby obtaining all extracted code snippets in each complete code. The parameter information acquisition module is used to acquire parameter information for each complete code based on a variety of preset tools. The parameter information includes the call frequency and call time of all extracted code segments in the complete code, as well as the data transfer type. The independence calculation submodule is used to obtain the independence of each extracted code segment and the code segment function based on the parameter information of each complete code segment; The code group library building submodule is used to obtain all code group libraries based on the independence and functionality of all extracted code snippets in all complete code.

3. The cloud computing-based code generation system according to claim 2, characterized in that, Divide into sub-modules, including: The retrieval unit is used to retrieve all complete code and code comments for each complete code in the database. The segmentation unit is used to filter out all comments with preset characteristics from the code comments of each complete code as all functional comments, and to take the complete code block covered by each functional comment of the corresponding complete code as the extracted code fragment in the corresponding complete code, so as to obtain all the extracted code fragments in each complete code.

4. The cloud computing-based code generation system according to claim 2, characterized in that, The code group library build submodule includes: The first building unit is used to select all extracted code fragments with an independence greater than a preset independence threshold from all extracted code fragments in all complete code, and to use them as independent code fragments. The second building unit is used to obtain the code snippet functions of all independent code snippets, and to aggregate all independent code snippets with the same code snippet functions as a separate code group library, thereby obtaining all code group libraries.

5. The cloud-based code generation system according to claim 1, characterized in that, The acquisition module includes: The receiving submodule is used to receive the overall code generation function uploaded by the user to the code generation system, and obtain all sub-functions based on the received overall code generation function and the preset function decomposition model. The Necessary Code Group Library submodule is used to filter out code group libraries whose functional annotations are the same as each sub-function from all code group libraries and summarize them to obtain all necessary code group libraries.

6. The cloud-based code generation system according to claim 1, characterized in that, The combined module includes: The Combination submodule is used to combine one extracted code snippet from each necessary code group library to obtain all extracted code combinations, where each extracted code combination contains one extracted code snippet from each necessary code group library. The second calculation submodule is used to calculate the comprehensive quality value of each extracted code combination based on the code efficiency and code quality values ​​of all extracted code snippets from the preset cloud computing platform and all necessary code group libraries. in, ρ represents the overall quality value of a single extracted code combination, where i is the i-th extracted code fragment within the corresponding extracted code combination, n is the total number of extracted code fragments within the corresponding extracted code combination, and ρ i τ is the code efficiency value of the i-th extracted code segment within the corresponding extracted code combination. i Let ln be the code quality value of the i-th extracted code segment within the code combination, where ln is the natural logarithm function and the natural constant e is 2.

718. The judgment submodule is used to select the extraction code combination with the highest overall quality value among all extraction code combinations as the best extraction code combination.

7. A cloud computing-based code generation system according to claim 1, characterized in that, The combined module includes: Build submodules to construct code splicing models; The combination submodule is used to input the best extracted code combination into the code concatenation model for code concatenation to obtain the generated code.

8. A code generation method based on cloud computing, characterized in that, An application to a cloud-based code generation system for executing any one of claims 1 to 7, comprising: S1: Extract code from all complete code, obtain all extracted code snippets in each complete code, and obtain the independence and functionality of each extracted code snippet based on the parameter information of each complete code. Obtain all code group libraries based on the independence and functionality of all extracted code snippets. S2: Obtain all sub-functions based on the overall function of the received generated code, and obtain all necessary code libraries based on all sub-functions and all code libraries; S3: Based on the independence of all extracted code snippets in each necessary code group library, obtain the code efficiency value and code quality value of each extracted code snippet in the corresponding necessary code group library; S4: Based on the code efficiency and code quality values ​​of all extracted code snippets in the preset cloud computing platform and all necessary code group libraries, obtain the best combination of extracted code; S5: Concatenate all extracted code snippets from the optimal code extraction combination to obtain the generated code.

Citation Information

Patent Citations

  • Code generation methods and code generation systems

    CN106528165B

  • Code generation method based on image recognition and related equipment

    CN115145568A

  • Intelligent auxiliary method and system for software development based on cloud computing

    CN117032654A