Method and device for generating code capability description

Through code scanning and recognition of large prediction models, automatic real-time, non-invasive code capability description generation is achieved, solving the problems of large labor costs and increased development workload in the existing technology, improving generation efficiency and saving costs.

CN119883267APending Publication Date: 2025-04-25BEIJING JINGDONG TUOXIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311378289.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-23
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

In the prior art, the manual drawing method generates code capability descriptions for a lot of manpower, making it difficult to ensure accuracy, and the annotation reporting method increases the development workload, the code is highly invasive and cannot meet the actual application needs.

Method used

Through code scanning and recognition of large prediction models, automatic real-time, non-invasive code capability generation method is realized, which improves generation efficiency and saves labor costs.

Benefits of technology

It realizes automated, real-time and non-invasive code capability description generation, improves generation efficiency, reduces labor costs, and meets practical application needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883267A_ABST
    Figure CN119883267A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for generating code capability description, and relates to the technical field of computers. A specific embodiment of the method comprises the following steps: in response to a received generation request for code capability description, performing static code scanning on an obtained code file, and obtaining a list of target classes and a list of target methods in each target class; for each target method in the list of the target methods, performing method capability identification on a code of each target method by using a pre-constructed large language model to obtain a capability description of each target method; according to the capability description of each target method, the capability description of the corresponding target class is obtained, and then the capability description of the code file is obtained. According to the implementation mode, an automatic real-time non-intrusive code capability description generation method is realized, the generation efficiency of the capability description is improved, and the labor cost is saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating a code capability description. Background Art

[0002] With the rapid development of computer technology, the scale and complexity of software system development are also increasing. As the most core and complex part of the code, the good readability of the business logic code is of great significance to system development and maintenance. The capability description is a text or graphic description of the business logic capability of the code, aiming to improve the readability of the code. Its specific form can be a flowchart of the code, text or other specified format of the description document. The commonly used methods for generating capability descriptions are: manual drawing method and annotation reporting method.

[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems:

[0004] Manual drawing is the method used to implement capability descriptions in most systems. It requires a lot of manpower, especially in systems with fast iteration speeds. It is difficult to ensure that every change is accurately recorded, which can easily lead to logical deviations between capability descriptions and actual code. The method of reporting annotations defined in the code when the code is running will increase the workload of code development, and the code is highly invasive and cannot meet the actual application requirements well. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and device for generating code capability descriptions. Through code scanning and recognition of a large prediction model, an automatic, real-time and non-intrusive method for generating code capability descriptions is implemented, which not only improves the efficiency of generating capability descriptions, but also saves labor costs.

[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for generating a code capability description is provided, comprising:

[0007] In response to receiving a request for generating a code capability description, performing static code scanning on the acquired code file to acquire a list of target classes and a list of target methods in each of the target classes;

[0008] For each target method in the list of target methods, use a pre-built large language model to perform method capability identification on the code of each target method to obtain a capability description of each target method;

[0009] According to the capability description of each target method, the capability description of the corresponding target class is obtained, and then the capability description of the code file is obtained.

[0010] Optionally, static code scanning is performed on the acquired code file to obtain a list of target classes and a list of target methods in each target class, including: using a preset code parsing tool to parse and filter out target classes that meet preset filtering rules from the code file, and obtaining a list of target classes based on the target classes; for each target class in the target class list, parsing and filtering out target methods that meet the preset filtering rules from the code of the target class, and obtaining a list of target methods based on the target methods.

[0011] Optionally, a pre-built large language model is used to identify the method capabilities of the code of each target method to obtain a capability description of each target method, including: using the large language model to perform semantic recognition and logical recognition on the code of each target method according to the execution steps of the code, and outputting a text description document and a script description document of each target method according to preset display rules, so as to generate a corresponding flowchart based on the script description document.

[0012] Optionally, the large language model is used to perform logic recognition according to the execution steps of the code, including: using the large language model to parse the calling relationship of the code according to the execution steps of the code, and identifying the nested methods in the code, and when the nested method is identified, submitting the nested code of the nested method to the large language model, so as to obtain the capability description of the nested method by performing method capability identification on the nested code.

[0013] Optionally, after outputting the text description document and the script description document of each target method, the method further includes: determining whether there is at least one of a class name and a method name in the text description document and the script description document, and if there is at least one of the class name and the method name in the text description document and the script description document, searching the code file for a code segment corresponding to at least one of the class name and the method name; establishing an association relationship between at least one of the class name and the method name and the corresponding code segment; and adding the association relationship to at least one of the corresponding class name and method name in the text description document and the script description document, so as to directly obtain the corresponding code segment through at least one of the class name and the method name in the text description document and the script description document.

[0014] Optionally, after obtaining the capability description of each target method, the method further includes: storing the capability description of each target method in the configuration of each target method, so that the caller of each target method accesses the configuration through the obtained calling path to obtain the corresponding capability description.

[0015] Optionally, the capability description of the code file has a version number, and the method further includes: in response to monitoring an update operation of the code file, issuing an update request for the capability description of the code file to a user; in response to receiving update confirmation information of the capability description, updating the version number of the capability description, using the large language model to perform method capability identification on the code corresponding to the update operation, and obtaining an updated capability description and an updated version number.

[0016] According to a second aspect of an embodiment of the present invention, there is provided an apparatus for generating a code capability description, comprising:

[0017] A code scanning module, configured to perform static code scanning on the acquired code file in response to receiving a request for generating a code capability description, and acquire a list of target classes and a list of target methods in each of the target classes;

[0018] A method capability description acquisition module is used to use a pre-built large language model to perform method capability identification on the code of each target method in the list of target methods, so as to obtain a capability description of each target method;

[0019] The code capability description acquisition module is used to obtain the capability description of the corresponding target class according to the capability description of each target method, and then obtain the capability description of the code file.

[0020] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for generating a code capability description, including:

[0021] one or more processors;

[0022] a storage device for storing one or more programs,

[0023] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.

[0024] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.

[0025] An embodiment of the invention has the following advantages or beneficial effects: by responding to receiving a request to generate a code capability description, a static code scan is performed on the obtained code file to obtain a list of target classes and a list of target methods in each target class; for each target method in the list of target methods, a pre-built large language model is used to identify the method capability of the code of each target method to obtain a capability description of each target method; based on the capability description of each target method, a capability description of the corresponding target class is obtained, and then a technical solution for obtaining the capability description of the code file is obtained, which realizes a method for automatically generating code capability descriptions in real time and non-invasively, which not only improves the efficiency of generating code capability descriptions, but also saves labor costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0027] Figure 1 is a schematic diagram of the main process of a method for generating a code capability description according to an embodiment of the present invention;

[0028] Figure 2 This is a flowchart of the sample code;

[0029] Figure 3 It is a schematic diagram of the generation principle of the code capability description of an embodiment of the present invention;

[0030] Figure 4 is a schematic diagram of main modules of an apparatus for generating a code capability description according to an embodiment of the present invention;

[0031] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0032] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0033] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0034] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0035] The current methods for generating code capability descriptions either require a large amount of manpower and are not very accurate, or they increase the workload of developing code and are highly invasive, and neither method can meet the needs of practical applications.

[0036] In order to solve the above problems existing in the prior art, the present invention proposes a method for generating code capability description, based on the list of target classes obtained by code scanning and the list of target methods in the target class, the pre-built large language model is used to identify the capability of the code of each target method, so as to obtain the capability description of the code through the capability description of the target method. The automatic real-time and non-intrusive generation of code capability description is realized, which not only improves the generation efficiency of capability description, but also saves labor costs.

[0037] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows:

[0038] findBugs: is an Eclipse plug-in tool that can statically analyze source code for possible bugs;

[0039] sonar: is a static code quality analysis tool;

[0040] checkStyle: is a static analysis tool that checks Java program code;

[0041] JS: JavaScript.

[0042] Figure 1 is a schematic diagram of the main process of the method for generating a code capability description according to an embodiment of the present invention, such as Figure 1 As shown, the method for generating a code capability description according to an embodiment of the present invention includes the following steps S101 to S103.

[0043] Step S101 : in response to receiving a request for generating a code capability description, static code scanning is performed on the acquired code file to obtain a list of target classes and a list of target methods in each of the target classes.

[0044] Specifically, the structure of the software system is usually divided into three layers: a presentation layer for displaying to the user interface; a business logic layer for processing data business logic; and a data access layer for database operations. For the code of the core business logic layer, it is generally necessary to generate a visual and documented capability description so that other developers or other collaborative teams can quickly understand the business processing logic. The embodiment of the present invention provides a method for automatically generating a code capability description in real time and non-invasively. When a request for generating a code capability description is received, the corresponding code file is obtained from the code repository according to the code information in the generation request. Considering the wide variety of classes and methods contained in the code, it is not necessary to reflect each class and all the methods therein in the capability description. According to the code development requirements, the main class names and method names that may be involved can be used as a target set, and the Java reflection mechanism is used to perform a static scan on the code content in the code file, extract the hit target class, and the target method under the target class, integrate these target classes and the target methods under the target class, and obtain a list of target classes and a list of target methods in each target class.

[0045] According to one embodiment of the present invention, a static code scan is performed on the acquired code file to obtain a list of target classes and a list of target methods in each of the target classes, including: using a preset code parsing tool to parse and filter out target classes that meet preset filtering rules from the code file, and obtaining a list of target classes based on the target classes; for each target class in the target class list, parsing and filtering out target methods that meet the preset filtering rules from the code of the target class, and obtaining a list of target methods based on the target methods.

[0046] Specifically, in order to ensure the scanning efficiency, the classes and methods that need to be presented in the capability description are summarized according to their characteristics, and filtering rules containing class names and method names are obtained. For example, regular expressions of class names and method names are used as filtering rules, and then code scanning and parsing tools, such as findBugs, sonar, checkStyle and other plug-ins, are used to scan and parse the code files according to the filtering rules to obtain the target classes that need to be presented in the capability description, and the list of target methods under the target classes that meet the method name filtering rules, and finally the target classes are summarized into a list of target classes. In the embodiment of the present invention, the interface class that provides services to the outside, such as the microservice interface class of the control layer and the gateway layer, and the methods in the interface class are used as the main presentation content of the capability description. Accordingly, the microservice interface class of the control layer and the gateway layer is used as the filtering rule to obtain a list of target classes composed of the interface classes of the control layer and the gateway layer. Accordingly, the list of target methods corresponding to the target class is composed of the methods included in its interface class. In addition, for the scanning and parsing of the target class and the target method therein, in addition to obtaining the class name and method name, it is also necessary to obtain the input parameters, return value and other information of the method name, so as to facilitate the subsequent ability recognition of the large language model. Finally, the scanning and parsing tool outputs the scanned and parsed information in the form of a table or document. Of course, the specific output format can also be achieved by setting the output rules in advance.

[0047] Step S102: for each target method in the list of target methods, use a pre-built large language model to perform method capability identification on the code of each target method to obtain a capability description of each target method.

[0048] Specifically, based on the list of target classes output by the above-mentioned scanning and parsing tool, and the list of target methods of each target class, the code corresponding to the target method is used as the recognition unit of the large language model, and the code corresponding to each target method is input into the large language model. The large language model's good understanding of the code language is used to identify the capabilities of the code, and the capability description of each target method is output.

[0049] According to one embodiment of the present invention, a pre-built large language model is used to identify the method capabilities of the code of each target method to obtain a capability description of each target method, including: using the large language model to perform semantic recognition and logical recognition on the code of each target method according to the execution steps of the code, and outputting a text description document and a script description document of each target method according to preset display rules, so as to generate a corresponding flowchart according to the script description document.

[0050] Specifically, in order to obtain the output of the large language model with good standard readability, the display rules of the capability description output by the large language model can be predefined, such as the display content of the capability description, the format and typesetting requirements of the capability description, etc. It can be understood that in order to make full use of the recognition results output by the large language model and obtain the capability description in the form of a more readable chart, the embodiment of the present invention selects the output script description document in Mermaid format. Mermaid is a lightweight text descriptive chart language. The syntax of Mermaid is concise and easy to understand. It can be directly embedded in text editors such as Markdown to generate high-quality flowcharts, sequence diagrams, Gantt charts, class diagrams and other types of charts.

[0051] Furthermore, the display rules and the code of the target method are input into the large language model, and the large language model performs semantic recognition and understanding of the code according to the execution steps of the received code, and then constructs logical relationships based on the understanding between the various semantics for logical recognition. According to the results of the semantic and logical recognition, according to the received display rules, the capability description of the text description document of the target method and the capability description of the Mermaid script description document are output, so that the Mermaid script description document can be directly rendered using the Mermaid JS library, and the corresponding flowchart can be automatically generated. The text description document can serve as an auxiliary description of the flowchart to better understand the flowchart. Of course, the capability description here is not limited to the form of flowcharts and text description documents, but can also be only one of the text description documents and script description documents. Any form or combination of any forms can be selected according to the actual application scenario.

[0052] According to another embodiment of the present invention, using the large language model to perform logic recognition according to the execution steps of the code includes: using the large language model to parse the calling relationship of the code according to the execution steps of the code, and identifying the nested methods in the code, and when the nested method is identified, submitting the nested code of the nested method to the large language model to obtain the capability description of the nested method by performing method capability identification on the nested code.

[0053] Specifically, considering that there may be logical calling relationships in the code of the target method, a large language model is used to identify nested methods in the code. When nested methods are identified, the nested code of the nested methods needs to be recursively submitted to the large language model again to obtain the capability description of the nested methods. According to the calling relationship, the capability descriptions of each nested method are summarized into the capability description of the target method.

[0054] The embodiment of the present invention makes full use of the understanding ability of the large language model, and automatically and non-invasively generates a semantically accurate and logically clear description document in real time according to the display rules of the capability description and the code of the target method.

[0055] Exemplarily, the display rules of the code for the target method are defined as follows: Based on the following source code, the code logic is explained step by step. If it is a method call, the method name needs to be displayed in the step. If it is if, else, switch, while, for or other situations with branches or loops, a secondary number is added to distinguish the description. Finally, all returns are divided into two parts, one is a text description, and the other is a Mermaid format script of the method steps. Please output it completely according to the above requirements. Taking the code of the target method getDoctorDetail (DoctorDetailParamdoctorDetailParam) for querying doctor indicator information in the existing project as an example, the above display rules and the code of the getDoctorDetail target method are input into the large language model. The large language model performs semantic and logical recognition on the code of getDoctorDetail according to the received display rules, and outputs a text description document and a Mermaid format script description document.

[0056] For the sake of explanation, the following uses the structural description language of a certain section of the getDoctorDetail code as an example to show the specific output results of the large language model (in actual applications, specific code programs are used as model input):

[0057] object1 = method1(param1);

[0058] / / Note 1 query doctor indicator information

[0059] if(condition 1)

[0060] {

[0061] object2 = method2(param2);

[0062] }

[0063] The text description document output by the large language model is:

[0064] 1. Encapsulate parameter 1 into object 1 and call method 1 to implement it.

[0065] 2. If condition 1 is met, do the following:

[0066] 2.1 Call method 2, pass parameter 2 as a parameter, and get the returned object 2.

[0067] The corresponding Mermaid script description document is:

[0068] A (start) --> B [encapsulate parameter 1 into object 1 and call method 1];

[0069] B-->C{determine whether condition 1 is true};

[0070] C-->|Yes|D[Query doctor indicator information operation];

[0071] C-->|No|E[Proceed to the next step].

[0072] Furthermore, based on the obtained Mermaid script description document, the corresponding flowchart is directly rendered through JS to obtain Figure 2 The flowchart of the sample code follows the format of the Mermaid script to start, execute steps, and render the judgment block diagram. In addition, it should be noted that the Mermaid script is generated based on the input code. The large language model will recognize and understand the comments in the code. When the matching degree between the meaning of the corresponding code expression and the comments reaches the preset threshold, the comments are selected to replace the meaning of the code to improve the readability of the script description document and be closer to the conventional expression form of the flowchart.

[0073] According to another embodiment of the present invention, after outputting the text description document and the script description document of each target method, the method further includes: determining whether there is at least one of a class name and a method name in the text description document and the script description document, and if there is at least one of the class name and the method name in the text description document and the script description document, searching the code file for a code segment corresponding to at least one of the class name and the method name; establishing an association relationship between at least one of the class name and the method name and the corresponding code segment; and adding the association relationship to at least one of the corresponding class name and method name in the text description document and the script description document, so as to directly obtain the corresponding code segment through at least one of the class name and the method name in the text description document and the script description document.

[0074] Specifically, in order for the user to conveniently and quickly obtain at least one corresponding code of the calling class and calling method involved in the capability description when consulting the capability description of the target method, the embodiment of the present invention queries and judges at least one of the calling classes and calling methods involved in the text description document and the script description document output by the large language model. When at least one of the calling classes and calling methods exists in the text description document and the script description document, the code segment of the calling class and / or the calling method is found from the code file, and an association relationship between the calling class and the corresponding code is established, and / or an association relationship between the calling method and the corresponding code is established. These association relationships are then added to at least one of the corresponding class names and method names in the text description document and the script description document, so that a code jump mark similar to a hyperlink function is established at the position of at least one of the class names and method names in the text description document and the script description document, so that the user can directly obtain the corresponding code segment through the class name and method name in the capability description, and directly obtain the corresponding code segment through the class name and method name in the flow chart rendered by the Mermaid script description document.

[0075] According to another embodiment of the present invention, after obtaining the capability description of each target method, the method further includes: storing the capability description of each target method in the configuration of each target method, so that the caller of each target method can access the configuration through the obtained calling path to obtain the corresponding capability description.

[0076] Specifically, after obtaining the capability description of each target method, the capability description of each target method can also be stored in the configuration of the corresponding target method, or in a dedicated configuration file, so that when the code of other systems builds the capability description, if there is a cross-system call to the target method, such as an RPC service call, the configuration of the target method can be accessed through the call path obtained by its code, and the capability description of the generated target method can be directly obtained.

[0077] Step S103: According to the capability description of each target method, obtain the capability description of the corresponding target class, and then obtain the capability description of the code file.

[0078] Specifically, according to the capability description of each target method obtained above, the capability descriptions of each target method are combined to obtain the capability description of the corresponding target class, and each target class in the target class list is traversed. According to the above method, the capability description corresponding to the target class list can be obtained, that is, the capability description of the code file.

[0079] According to one embodiment of the present invention, the capability description of the code file has a version number, and the method further includes: in response to monitoring an update operation of the code file, issuing an update request for the capability description of the code file to a user; in response to receiving update confirmation information of the capability description, updating the version number of the capability description, using the large language model to perform method capability identification on the code corresponding to the update operation, and obtaining an updated capability description and an updated version number.

[0080] Specifically, in the iterative development scenario of the existing system, the system code files will be updated as planned to enrich the system functions or optimize the functions. In order to ensure the accuracy of the above-mentioned capability description, a version number is established for each generated capability description, and a version number can be shared with the code file. When the update operation of the code file is monitored, an update request for the capability description is sent to the code updater. Considering that iterative development usually updates the code file, and the update of the code file is not necessarily iterative development, and there may also be temporary modifications in the testing phase, the code updater determines whether to update the capability description based on the actual business situation. After receiving the update confirmation information, the version number of the capability description is updated, the code corresponding to the update operation is input into the large language model, and the capability description corresponding to the update operation is generated. The capability description corresponding to the update operation and the original capability description are replaced, merged, etc. to obtain the updated capability description and the corresponding updated capability description version number.

[0081] The monitoring and updating method of the capability description can effectively ensure the accuracy of the capability description, especially in iterative development scenarios, so that each iterative update can be accurately recorded to achieve the effect of "diagram is code, code is diagram".

[0082] Figure 3 It is a schematic diagram of the generation principle of the code capability description of the embodiment of the present invention. According to the received generation request for the code capability description, the code file is obtained from the code library, and the class information and method information of the code file are scanned and parsed by the scanning and parsing tool to obtain a list of target classes and a list of target methods in each target class; for each target method in the list of target methods, the code of each target method is semantically recognized and logically called according to the execution steps of the code using a pre-built large language model to obtain the capability description of each target method, and the capability description of each target method is merged to obtain the capability description of the target class, and then the capability description of the code file is obtained. In addition, in order to ensure the accuracy and beauty of the final capability description, the capability description can be reviewed and fine-tuned to obtain a standard and beautiful capability description.

[0083] The method for generating a capability description in an embodiment of the present invention can not only improve the readability of the system code, especially for outdated system code, and solve the problem that the business logic can only be understood through the code; it also improves the maintainability of the capability description, facilitates timely updating of the capability description during the system iteration process, ensures the accuracy of the code capability description, and achieves the effect of "picture is code, code is picture".

[0084] Figure 4 Schematic diagram of the main modules of the device for generating code capability description according to an embodiment of the present invention. Figure 4 As shown, the device 400 for generating a code capability description mainly includes a code scanning module 401 , a method capability description acquisition module 402 and a code capability description acquisition module 403 .

[0085] A code scanning module 401 is used for, in response to receiving a request for generating a code capability description, performing static code scanning on the acquired code file to acquire a list of target classes and a list of target methods in each of the target classes;

[0086] A method capability description acquisition module 402 is used to identify the method capability of each target method in the list of target methods by using a pre-built large language model to the code of each target method, so as to obtain the capability description of each target method;

[0087] The code capability description acquisition module 403 is used to obtain the capability description of the corresponding target class according to the capability description of each target method, and then obtain the capability description of the code file.

[0088] According to one embodiment of the present invention, the code scanning module 401 is also used to: use a preset code parsing tool to parse and filter out target classes that meet preset filtering rules from the code file, and obtain a list of target classes based on the target classes; for each target class in the target class list, parse and filter out target methods that meet the preset filtering rules from the code of the target class, and obtain a list of target methods based on the target methods.

[0089] According to another embodiment of the present invention, the method capability description acquisition module 402 is also used to: use the large language model to perform semantic recognition and logical recognition on the code of each target method according to the execution steps of the code, and output a text description document and a script description document of each target method according to preset display rules, so as to generate a corresponding flowchart according to the script description document.

[0090] According to another embodiment of the present invention, the method capability description acquisition module 402 is further used to: use the large language model to parse the calling relationship of the code according to the execution steps of the code, and identify the nested methods in the code, and when the nested method is identified, submit the nested code of the nested method to the large language model to obtain the capability description of the nested method by performing method capability identification on the nested code.

[0091] According to another embodiment of the present invention, the device 400 for generating code capability description also includes a code mapping association module (not shown in the figure), which is used to: after outputting the text description document and the script description document of each target method, determine whether there is at least one of the class name and the method name in the text description document and the script description document, and when there is at least one of the class name and the method name in the text description document and the script description document, search for a code segment corresponding to at least one of the class name and the method name from the code file; establish an association relationship between at least one of the class name and the method name and the corresponding code segment; add the association relationship to at least one of the corresponding class name and method name in the text description document and the script description document, so as to directly obtain the corresponding code segment through at least one of the class name and method name in the text description document and the script description document.

[0092] According to another embodiment of the present invention, the device 400 for generating code capability description also includes a storage module (not shown in the figure), which is used to: after obtaining the capability description of each target method, store the capability description of each target method in the configuration of each target method, so that the caller of each target method can access the configuration through the obtained calling path to obtain the corresponding capability description.

[0093] According to another embodiment of the present invention, the capability description of the code file has a version number, and the device 400 for generating the code capability description also includes an update module (not shown in the figure), which is used to: in response to monitoring the update operation of the code file, issue an update request for the capability description of the code file to the user; in response to receiving the update confirmation information of the capability description, update the version number of the capability description, use the large language model to identify the method capability of the code corresponding to the update operation, and obtain the updated capability description and the updated version number.

[0094] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.

[0095] like Figure 5As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0096] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as applications that generate code capability descriptions, etc. (only as an example).

[0097] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0098] Server 505 may be a server that provides various services, such as a background management server that provides support for the capability description performed by users using terminal devices 501, 502, and 503 (for example only). In response to receiving a request to generate a code capability description, the background management server may perform static code scanning on the acquired code file to obtain a list of target classes and a list of target methods in each of the target classes; for each target method in the list of target methods, use a pre-built large language model to perform method capability identification on the code of each target method to obtain a capability description of each target method; obtain the capability description of the corresponding target class based on the capability description of each target method, and then obtain the capability description of the code file, etc., and feed back the processing result (such as code capability description, etc. - for example only) to the terminal device.

[0099] It should be noted that the method for generating a code capability description provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the device for generating a code capability description is generally set in the server 505 .

[0100] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0101] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 6 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0102] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0103] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0104] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.

[0105] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination thereof.

[0106] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0107] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes: a code scanning module, a method capability description acquisition module and a code capability description acquisition module.

[0108] Among them, the names of these modules do not constitute a limitation of the module itself in some cases. For example, the code scanning module can also be described as "a module for performing static code scanning on the acquired code file in response to receiving a request to generate a code capability description, and obtaining a list of target classes and a list of target methods in each of the target classes."

[0109] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiment; or it may exist independently without being assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by a device, the device includes: in response to receiving a request for generating a code capability description, static code scanning is performed on the acquired code file to obtain a list of target classes and a list of target methods in each of the target classes; for each target method in the list of target methods, the code of each target method is identified for method capability using a pre-built large language model to obtain a capability description of each target method; according to the capability description of each target method, the capability description of the corresponding target class is obtained, and then the capability description of the code file is obtained.

[0110] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: by responding to receiving a request to generate a code capability description, a static code scan is performed on the obtained code file to obtain a list of target classes and a list of target methods in each target class; for each target method in the list of target methods, a pre-built large language model is used to perform method capability identification on the code of each target method to obtain a capability description of each target method; based on the capability description of each target method, a capability description of the corresponding target class is obtained, and then the technical solution of the capability description of the code file is obtained, which realizes a method for automatically generating code capability descriptions in real time and non-invasively, which not only improves the efficiency of generating code capability descriptions, but also saves labor costs.

[0111] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.

Claims

1. A method for generating a code capability description, characterized in that: include: In response to receiving a request for generating a code capability description, performing static code scanning on the acquired code file to acquire a list of target classes and a list of target methods in each of the target classes; For each target method in the list of target methods, use a pre-built large language model to perform method capability identification on the code of each target method to obtain a capability description of each target method; According to the capability description of each target method, the capability description of the corresponding target class is obtained, and then the capability description of the code file is obtained.

2. The method according to claim 1, characterized in that: Perform static code scanning on the acquired code files to obtain a list of target classes and a list of target methods in each of the target classes, including: Use a preset code parsing tool to parse and filter out target classes that meet preset filtering rules from the code file, and obtain a list of target classes based on the target classes; For each target class in the target class list, target methods that meet preset screening rules are parsed and screened out from the code of the target class, and a list of target methods is obtained based on the target methods.

3. The method according to claim 1, characterized in that Use the pre-built large language model to identify the method capability of the code of each target method, and obtain the capability description of each target method, including: For the code of each target method, the large language model is used to perform semantic recognition and logical recognition according to the execution steps of the code, and according to preset display rules, a text description document and a script description document of each target method are output to generate a corresponding flowchart according to the script description document.

4. The method according to claim 3, characterized in that Using the large language model to perform logic recognition according to the execution steps of the code, including: The large language model is used to parse the calling relationship of the code according to the execution steps of the code, and the nested methods in the code are identified. When the nested method is identified, the nested code of the nested method is submitted to the large language model to obtain the capability description of the nested method by performing method capability identification on the nested code.

5. The method according to claim 3, characterized in that: After outputting the text description document and the script description document of each target method, the method further includes: Determine whether the text description document and the script description document contain at least one of a class name and a method name, and if the text description document and the script description document contain at least one of a class name and a method name, search the code file for a code segment corresponding to at least one of the class name and the method name; Establishing an association relationship between at least one of the class name and the method name and a corresponding code segment; The association relationship is added to at least one of the corresponding class names and method names in the text description document and the script description document, so as to directly obtain the corresponding code segment through at least one of the class names and method names in the text description document and the script description document.

6. The method according to claim 1, characterized in that After obtaining the capability description of each target method, the method further includes: The capability description of each target method is stored in the configuration of each target method, so that the caller of each target method can access the configuration through the acquired calling path to obtain the corresponding capability description.

7. The method according to claim 1, characterized in that The capability description of the code file has a version number. The method further comprises: In response to monitoring the update operation of the code file, sending a request for updating the capability description of the code file to the user; In response to receiving update confirmation information of the capability description, the version number of the capability description is updated, and the method capability is identified on the code corresponding to the update operation using the large language model to obtain an updated capability description and an updated version number.

8. A device for generating a code capability description, characterized in that: include: A code scanning module, configured to perform static code scanning on the acquired code file in response to receiving a request for generating a code capability description, and acquire a list of target classes and a list of target methods in each of the target classes; A method capability description acquisition module is used to use a pre-built large language model to perform method capability identification on the code of each target method in the list of target methods, so as to obtain a capability description of each target method; The code capability description acquisition module is used to obtain the capability description of the corresponding target class according to the capability description of each target method, and then obtain the capability description of the code file.

9. A mobile electronic device terminal, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.