Code generation method and device, electronic equipment and medium
By identifying component keywords in the system architecture diagram of the software system and generating object code, the problem of long-term code writing is solved, and the effect of improving software development efficiency and shortening development cycle is achieved.
Patent Information
- Application Number
- CN202510220019.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-06-17
AI Technical Summary
In the prior art, code writing takes a long time, resulting in inefficient software development.
By receiving the system architecture diagram of the software system, the component keywords contained in the system architecture diagram are identified, and the target code is automatically generated based on the mapping relationship between the keywords and the code.
It greatly reduces the time of code generation, improves the efficiency of software development, effectively shortens the project development cycle, and enables the software to be launched to the market faster.
Smart Images

Figure CN120162031A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to a code generation method, apparatus, electronic device, and medium. Background Art
[0002] In the current era of rapid development of the Internet, various application software has emerged like mushrooms after a spring rain, greatly changing the lifestyle of users. As the core technology supporting these application software, software development is constantly evolving and innovating. With the increasing complexity and diversification of business requirements, the requirements for software quality and development efficiency are also getting higher and higher. In the field of software development, code, as the basis for implementing various functions, is of great importance. Efficient and accurate code writing is the key to improving the stable operation of software systems and meeting user needs.
[0003] Currently, programmers usually write the code of software systems by manually inputting line by line. Specifically, programmers first design the software system according to business requirements, and then use a specific programming language, such as Java, Python, etc., to write the code of the software system according to the business logic corresponding to the designed software system.
[0004] However, the above code writing method has the disadvantage of taking a long time. Programmers often need to spend a lot of time and energy to complete the code writing work, thus reducing the efficiency of software development. Summary of the Invention
[0005] Embodiments of the present invention aim to provide a code generation method, apparatus, electronic device, and medium, which can greatly reduce the duration of code generation, and thus can improve the efficiency of software development as a whole.
[0006] The specific technical solutions are as follows:
[0007] In the first aspect of the present invention, a code generation method is provided, and the method includes:
[0008] Receiving a system architecture diagram of a software system; the system architecture diagram includes: components of the software system and the connection relationships between the components;
[0009] Identifying the system architecture diagram, and the obtained identification result includes: component keywords included in the system architecture diagram;
[0010] Determining target code corresponding to the component keywords in the system architecture diagram according to the mapping relationship between the keywords and the code;
[0011] Outputting the target code.
[0012] In a second aspect of the implementation of the present invention, a code generation device is provided, and the device includes:
[0013] A diagram receiving module, configured to receive a system architecture diagram of a software system; the system architecture diagram includes: components of the software system;
[0014] A diagram recognition module, configured to recognize the system architecture diagram, and the recognition result obtained includes: component keywords included in the system architecture diagram;
[0015] A code determination module, configured to determine target codes corresponding to the component keywords in the system architecture diagram according to the mapping relationship between keywords and codes;
[0016] A code output module, configured to output the target codes.
[0017] Optionally, the diagram recognition module includes:
[0018] A preprocessing module, configured to preprocess the system architecture diagram to obtain a preprocessed architecture diagram; the preprocessing includes: denoising processing, grayscale processing, binarization processing, skew removal and correction processing, and text area delineation processing;
[0019] A model recognition module, configured to input the preprocessed architecture diagram into a character recognition model, and the character recognition model outputs the recognition result corresponding to the system architecture diagram.
[0020] Optionally, the code determination module includes:
[0021] A first code determination module, configured to search according to the mapping relationship between the component keywords in the system architecture diagram and the keywords and codes recorded in the template code dictionary to obtain the target codes corresponding to the component keywords in the system architecture diagram; or
[0022] A second code determination module, configured to input the component keywords in the system architecture diagram into a large language model, and the large language model outputs the target codes corresponding to the component keywords; the large language model is used to represent the mapping relationship between keywords and codes.
[0023] Optionally, the component is a database - type component, and the target codes include: data source configuration code, database entity code, and database operation code; or
[0024] The component is a cache - type component, and the target codes include: connection configuration code, data operation code, cache policy code, and exception handling code; or
[0025] The component is a search - type component, and the target code includes: connection configuration code, index creation and management code, data writing and query code, paging and sorting code, and exception handling code; or
[0026] The component is a framework - type component, and the target code includes: configuration code, controller code, service layer code, data access object code, entity class code, dependency injection - related code, transaction management code, and exception handling code; or
[0027] The component is a user - interface - type component, and the target code includes: interface layout code, interaction element code, data binding code, form validation code, event handling code, state management code, interface adaptation code, exception handling code, and multi - platform adaptation code; or
[0028] The component is an internal interface class, and the target code includes: interface definition code, interface implementation code, data transfer and conversion code, exception handling code, logging code, performance optimization code, permission control and verification code, unit test code.
[0029] Optionally, the device further includes:
[0030] An object model file determination module, configured to determine the project object model file of the project corresponding to the system architecture diagram;
[0031] A dependency addition module, configured to add dependencies corresponding to the component keywords in the system architecture diagram to the project object model file; the dependencies are used to represent the external software resources required for the operation of the components corresponding to the component keywords; the external software resources refer to the software resources outside the project corresponding to the system architecture diagram.
[0032] Optionally, the device further includes:
[0033] A project configuration file determination module, configured to determine the project configuration file corresponding to the system architecture diagram;
[0034] A configuration item addition module, configured to add configuration items corresponding to the component keywords in the system architecture diagram to the project configuration file; the configuration items are used to configure the data sources of the components corresponding to the component keywords.
[0035] Optionally, the device further includes:
[0036] A line detection module, configured to detect the line information included in the system architecture diagram;
[0037] A connection relationship determination module, configured to determine the connection relationship information between the first component keyword and the second component keyword in the system architecture diagram according to the positional relationship between the line information and the component keywords in the system architecture diagram;
[0038] An annotation information determination module, configured to add corresponding annotation information to the target codes corresponding to the first component keyword and the second component keyword respectively according to the connection relationship information; the annotation information is used to explain and illustrate the target codes.
[0039] In a third aspect of the embodiments of the present invention, an electronic device is further provided, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus;
[0040] The memory is used to store a computer program;
[0041] The processor is configured to implement the foregoing method steps when executing the program stored on the memory.
[0042] In a fourth aspect of the embodiments of the present invention, a computer-readable storage medium is further provided. Instructions are stored in the computer-readable storage medium, and when it runs on a computer, the computer is caused to execute any one of the foregoing methods.
[0043] The code generation method, device, electronic device, and medium provided by the embodiments of the present invention start from the system architecture diagram of the software system, identify the keywords included in the system architecture diagram, and then determine the target codes corresponding to the component keywords in the system architecture diagram in combination with the mapping relationship between the keywords and the codes.
[0044] According to the recognition of the system architecture diagram and the mapping relationship between the keywords and the codes, the embodiments of the present invention automatically generate the target codes corresponding to the component keywords in the system architecture diagram. Since the embodiments of the present invention can save the code writing operations corresponding to the component keywords in the system architecture diagram, the time length of code generation can be greatly reduced, and thus the efficiency of software development can be improved as a whole.
[0045] Moreover, the code generation method of the embodiments of the present invention can effectively shorten the development cycle of the project, enable the software to be launched into the market faster, and thus meet the market's demand for rapid software iteration. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art.
[0047] Figure 1 It is a flowchart of the steps of the code generation method according to an embodiment of the present invention;
[0048] Figure 2 It is a schematic diagram of the system architecture diagram according to an embodiment of the present invention;
[0049] Figure 3 Schematic structural diagram of a code generation device according to an embodiment of the present invention;
[0050] Figure 4 Block diagram of the structure of an electronic device according to an embodiment of the present invention. Specific embodiments
[0051] Next, the technical solutions in the embodiments of the present invention will be described in conjunction with the accompanying drawings in the embodiments of the present invention.
[0052] The code generation method according to the embodiment of the present invention can be used to automatically generate the code of a software system based on the system architecture diagram of the software system, so as to improve the code generation efficiency.
[0053] The embodiment of the present invention does not limit the specific application scenarios corresponding to the software system. For example, the application scenarios of the software system may include: Internet scenarios, Internet of Things scenarios, or financial scenarios, etc.
[0054] In the related art, programmers usually write the code of the software system by manually inputting line by line. However, the above code writing method has the disadvantage of taking a long time. Programmers often need to spend a lot of time and energy to complete the code writing work, thereby reducing the efficiency of software development.
[0055] In view of the technical problem that the code writing method in the related art takes a long time, the embodiment of the present invention provides a code generation method, which specifically includes: receiving the system architecture diagram of the software system; the above system architecture diagram includes: components of the software system; identifying the above system architecture diagram, and the obtained identification result includes: component keywords included in the above system architecture diagram; determining the target code corresponding to the component keywords in the above system architecture diagram according to the mapping relationship between the keywords and the code; outputting the above target code.
[0056] The embodiment of the present invention starts from the system architecture diagram of the software system, identifies the keywords included in the system architecture diagram, and then combines the mapping relationship between the keywords and the code to determine the target code corresponding to the component keywords in the system architecture diagram.
[0057] The embodiment of the present invention automatically generates the target code corresponding to the component keywords in the system architecture diagram according to the identification of the system architecture diagram and the mapping relationship between the keywords and the code. Since the embodiment of the present invention can save the code writing operation corresponding to the component keywords in the system architecture diagram, it can greatly reduce the time required for code generation, and thus can improve the efficiency of software development as a whole.
[0058] Moreover, the code generation method of the embodiment of the present invention can effectively shorten the development cycle of the project, enable the software to be launched on the market faster, and thus meet the market's demand for rapid software iteration.
[0059] The embodiments of the present invention will be described below through specific examples.
[0060] Referring to Figure 1 , a flowchart of the steps of a code generation method according to an embodiment of the present invention is shown. The method may specifically include the following steps:
[0061] Step 101, receive the system architecture diagram of the software system; the above system architecture diagram includes: components of the software system;
[0062] Step 102, identify the above system architecture diagram, and the obtained identification result includes: component keywords included in the above system architecture diagram;
[0063] Step 103, determine the target code corresponding to the component keywords in the above system architecture diagram according to the mapping relationship between the keywords and the code;
[0064] Step 104, output the above target code.
[0065] Figure 1 The method embodiment shown can be used to automatically generate the code of the software system according to the system architecture diagram of the software system, so as to improve the code generation efficiency.
[0066] In the field of computers, software architecture is a description of the overall structure and organization of a software system. It defines the relationships, interaction methods, and behaviors between the various components of the software system. The architecture document is a document that describes and explains the software architecture in detail. As an important part of the architecture document, the system architecture diagram can visually present the structure of the software system and the relationships between the various components in a visual way.
[0067] In step 101, an architecture diagram upload interface can be provided. The above architecture diagram upload interface is used to receive the system architecture diagram uploaded by the user.
[0068] The system architecture diagram usually includes components of the software system. The components of the software system may include: main program components and middleware.
[0069] The main program component is usually the part that implements the core business logic in the software system. It is responsible for processing the main requests and business processes of users, coordinating the operation of each part, and is a key component of the entire software system.
[0070] For example, in an e-commerce platform, the main program component may include: function modules such as user login and registration, product display, shopping cart management, and order processing. These function modules directly face users and process various operations and business requirements of users.
[0071] Middleware is a software layer located between the operating system and applications. It provides various general services and functions for software systems to simplify the development process, improve the maintainability and scalability of the systems.
[0072] Common middleware includes: database management systems (such as MySQL), cache systems (such as Redis), message queues (such as RocketMQ), search engines (such as Elasticsearch), etc. These middleware provide functions such as data storage, cache acceleration, asynchronous communication, and fast search respectively.
[0073] The system architecture diagram can also include: information about the connection relationships between components. The above connection relationship information is used to characterize the call relationship and / or data flow relationship between components.
[0074] Among them, the call relationship refers to the relationship in a software system where one component requests another component to provide services or execute specific functions. It reflects the behavioral dependencies and interaction methods between components, that is, in order to complete its own tasks, one component needs to trigger specific operations or methods of another component.
[0075] For example, in a Web application system, the user interface component may call methods in the business logic component to process form data submitted by users. For example, after the user clicks the "Login" button, the user interface component will call the verification method of the authentication component to check whether the username and password entered by the user are correct.
[0076] The data flow relationship represents the flow direction and path of data between different components. It describes the process of data flowing from the component where it is generated or input, through a series of processing and transmission, and finally reaching the component that uses or outputs the data, showing the propagation trajectory and processing order of data in the system.
[0077] For example, in an e-commerce system, after the user enters order information on the order placement page, this data will flow from the user interface component to the order processing component. After the order processing component verifies and processes the data, it will then pass the data to the inventory management component to update the inventory information, and at the same time pass the data to the payment component for payment operations. Here, it clearly shows the data flow relationship from user input to each relevant component.
[0078] In practical applications, users can use drawing software to draw the system architecture diagram of the software system. It can be understood that the embodiments of the present invention do not limit the specific source of the system architecture diagram.
[0079] In step 102, OCR (Optical Character Recognition) can be used to recognize the above system architecture diagram.
[0080] Optical character recognition refers to the process in which an electronic device (such as a scanner or digital camera) examines the characters printed on paper, determines their shapes by detecting dark and bright patterns, and then translates the shapes into computer text using character recognition methods; that is, for printed characters, an optical method is used to convert the text in a paper document into an image file of black and white dot matrices, and the text in the image is converted into a text format by an identification software for further editing and processing by a word processing software. OCR technology is not limited to recognizing text on paper. With the development of deep learning technology, OCR technology can be applied to various image sources containing text information.
[0081] The process of recognizing the above system architecture diagram in the embodiments of the present invention specifically includes:
[0082] Step A1: Preprocess the above system architecture diagram to obtain a preprocessed architecture diagram; the above preprocessing specifically includes: denoising processing, grayscale processing, binarization processing, skew removal and correction processing, and text area delimitation processing;
[0083] Step A2: Input the preprocessed architecture diagram into a character recognition model, and the character recognition model outputs the recognition result corresponding to the above system architecture diagram.
[0084] The preprocessing in Step A1 can improve the quality of the system architecture diagram and lay a good foundation for the character recognition process in Step A2. Among them, denoising processing removes various interference noises, which can make the image clearer and avoid the adverse effects of noise on character recognition. Grayscale processing simplifies the image information, which can improve the processing efficiency while reducing the computational complexity. Binarization processing further highlights the contrast between characters and the background, making it easier for characters to be separated from the background and greatly reducing the difficulty of subsequent processing. Skew removal and correction processing can make the characters in the correct direction, thus significantly improving the accuracy of character recognition. Text area delimitation processing can focus on key text areas, exclude the interference of irrelevant areas, and improve the pertinence and efficiency of character recognition.
[0085] Among them, the skew removal and correction processing specifically includes: detecting the skew angle of the system architecture diagram, and rotating the system architecture diagram by the corresponding skew angle to restore the characters in the system architecture diagram to the horizontal or vertical direction.
[0086] In short, the preprocessing steps optimize and organize the system architecture diagram through a series of operations, enabling the subsequent character recognition model to more accurately and efficiently recognize the character information in the system architecture diagram and providing reliable input for the entire code generation process.
[0087] In Step A2, the character recognition model can be a machine learning model, which has the ability to recognize characters in images.
[0088] The embodiments of the present invention do not limit the specific structure of the character recognition model. For example, the structure of the character recognition model may include: CRNN (Convolutional Recurrent Neural Network), CTC (Connectionist Temporal Classification), Transformers, etc.
[0089] The embodiments of the present invention can pre-train the character recognition model so that the character recognition model has the ability to recognize characters in images.
[0090] In specific implementation, the training process of the character recognition model specifically includes:
[0091] Step B1, obtain training samples;
[0092] The process of obtaining training samples specifically includes:
[0093] First, collect a large number of image samples containing text. These image samples should cover different fonts, sizes, orientations, backgrounds, etc. to improve the generalization ability of the character recognition model.
[0094] Then, annotate the text in the image samples. The image samples that have been annotated can be used as training samples. Specifically, an annotation tool can be used to annotate the text in the image samples to generate annotation data for training. The annotation data can specifically include: the position of the text (such as the coordinates of the text box) and the specific content of the text.
[0095] Step B2, preprocess the training samples to obtain preprocessed samples; the above preprocessing specifically includes: denoising processing, grayscale processing, binarization processing, deskewing and correction processing, and text region delimitation processing;
[0096] Step B3, use the training samples to train the character recognition model; the character recognition model is used to represent the mapping relationship between the image and the recognition result. In other words, the character recognition model can output the corresponding recognition result according to the input image. The above recognition result specifically includes: the character information contained in the image. The character information specifically includes: the position information of the character and the specific content of the character (such as an English string, or a Chinese string, etc.). When the input image is a system architecture diagram, since the character information in the system architecture diagram includes: component keywords, the corresponding recognition result specifically includes: the component keywords contained in the above system architecture diagram.
[0097] In step B3, the training process of the character recognition model may include: forward propagation and backward propagation.
[0098] Among them, forward propagation can calculate the final output information in sequence according to the parameters of the character recognition model in the order from the input layer to the output layer.
[0099] Backward propagation can calculate and update the parameters of the character recognition model in sequence according to the loss information in the order from the output layer to the input layer. The character recognition model usually adopts the structure of a neural network. The parameters of the character recognition model can include parameters such as the weights of the neural network. Among them, during the backward propagation process, the gradient information of the parameters of the character recognition model can be determined, and this gradient information can be used to update the parameters of the character recognition model. For example, backward propagation can calculate and store the gradient information of the parameters of the character recognition model in sequence according to the chain rule in calculus along the order from the output layer to the input layer.
[0100] During the forward propagation process of the character recognition model, the preprocessed sample can be input into the character recognition model. The character recognition model performs forward operations on the preprocessed sample and outputs the output information. Moreover, the loss information can be determined according to the output information and the labeled data. Among them, the output information can represent the recognition result corresponding to the image sample.
[0101] In a specific implementation, iterative training can be performed according to multiple batches of training samples. The convergence condition of the above iteration can be: the loss information meets the preset condition. The preset condition can be: the absolute value of the difference between the loss information and the target value is less than the difference threshold, or the number of iterations exceeds the number threshold, etc. In other words, when the loss information meets the preset condition, the iteration can be terminated; in this case, the target parameter value of the character recognition model can be obtained. Subsequently, the recognition result corresponding to the system architecture diagram can be determined according to the target parameter value of the character recognition model.
[0102] After completing the training process of the character recognition model, the embodiments of the present invention can also use a test set to evaluate the performance of the character recognition model. The performance of the character recognition model specifically includes: accuracy, recall rate, and the fusion performance of accuracy and recall rate, etc. Among them, the accuracy can be understood as the proportion of the results that are truly the specific character among all the results judged as the specific character by the character recognition model. For example, if the character recognition model judges 100 results as the character "A", and actually 80 of them are truly the character "A", then the accuracy is 80%. The recall rate is the proportion of the specific characters that are correctly recognized by the character recognition model among all the actual specific characters. For example, if there are a total of 120 characters "A" in reality, and the character recognition model recognizes 90 of them as the character "A", then the recall rate is 75%. The fusion performance comprehensively considers the accuracy and recall rate, and it is the harmonic mean of the accuracy and recall rate. The embodiments of the present invention can use manual evaluation methods and automatic evaluation methods to evaluate the performance of the character recognition model.
[0103] Moreover, the evaluation results of the performance of the character recognition model specifically include: evaluation passed or evaluation failed. In the case of evaluation passed, the character recognition model can be deployed. In the case of evaluation failed, the model structure and hyperparameters of the character recognition model can be adjusted, and the adjusted character recognition model can be retrained and re-evaluated until the evaluation result is evaluation passed. In machine learning, hyperparameters are parameters set before the start of the learning process, rather than parameters obtained through training. Hyperparameters specifically include: the number of network layers, learning rate, training batch size, or number of iterations, etc. It can be understood that the embodiments of the present invention do not limit specific hyperparameters.
[0104] The deployment of the character recognition model can deploy the character recognition model with evaluation passed into a preset hardware environment, so that the character recognition model can determine the graphical description language file corresponding to the target code in the preset hardware environment. The preset hardware environment can be a server environment or a client environment. Or, the preset hardware environment can be a server environment or a mobile terminal environment. It can be understood that the embodiments of the present invention do not limit specific preset hardware environments.
[0105] In practical applications, the preprocessed architecture diagram can be input into the character recognition model, and the recognition result output by the character recognition model can be received. The recognition result can include: the component keywords included in the above system architecture diagram.
[0106] Component keywords refer to the character information (such as English strings, Chinese character strings, etc.) that can represent the components of a software system in a system architecture diagram. These character information are usually the names of the components in the software system. Component keywords are used to identify the components in the software system and can reflect relevant characteristics such as the functions or types of the components. For example, "Mysql (relational database)" as a component keyword not only clarifies that the component name is "Mysql" but also reflects its type as "relational database".
[0107] Refer to Figure 2 , which shows a schematic diagram of the system architecture diagram of an embodiment of the present invention. Among them, the system architecture diagram specifically includes the following components: ElasticSearch (elastic search), framework - type components, Mysql (relational database), Redis (remote dictionary service), UserAPI (user interface), and InnerAPI (internal interface).
[0108] Among them, there is an edge from ElasticSearch to the framework - type components, and the data flow label on this edge is "query data", indicating that ElasticSearch provides query data to the framework - type components.
[0109] There is an edge from the framework - type components to the relational database, and the data flow label on this edge is "write data", indicating that the framework - type components write data to the relational database.
[0110] There is an edge from the relational database to ElasticSearch, and the data flow label on this edge is "synchronize", indicating that the relational database synchronizes data to ElasticSearch.
[0111] There is an edge from the relational database to the framework - type components, and the data flow label on this edge is "cache", indicating that the relational database provides cache to the framework - type components.
[0112] There is an edge from the framework - type components to the user interface, and the data flow label on this edge is "display", indicating that the framework - type components provide data for display to the user interface.
[0113] There is an edge from the framework - type components to the internal interface, and the data flow label on this edge is "invoke", indicating that the framework - type components send an invocation request to the internal interface.
[0114] The embodiment of the present invention aims at Figure 2 The recognition results obtained from the shown system architecture diagram specifically include: the component keywords included in the system architecture diagram. For example, Figure 2 The component keywords in the shown system architecture diagram specifically include: "elastic search", "framework - type components", "relational database", "remote dictionary service", "user interface", and "internal interface", etc.
[0115] It can be understood that the recognition result of the embodiment of the present invention may include, in addition to the component keywords included in the system architecture diagram, the data flow labels on the edges included in the system architecture diagram.
[0116] In the system architecture diagram, the data flow label is used to show the flow direction of data between different nodes and the business attributes carried by the data during the flow process. It can help users quickly understand the data interaction method between components in the system and is crucial for analyzing the functions and performance of the system.
[0117] In step 103, according to the mapping relationship between keywords and codes, the target code corresponding to the component keywords in the system architecture diagram is automatically generated, which can save the code writing operation corresponding to the component keywords in the system architecture diagram.
[0118] In a specific implementation, the process of determining the target code corresponding to the component keywords in the above system architecture diagram according to the mapping relationship between keywords and codes may specifically include:
[0119] Step C1: Search according to the mapping relationship between keywords and codes recorded in the template code dictionary based on the component keywords in the system architecture diagram to obtain the target code corresponding to the component keywords in the system architecture diagram; or
[0120] Step C2: Input the component keywords in the system architecture diagram into the large language model, and the large language model outputs the target code corresponding to the component keywords; the large language model is used to represent the mapping relationship between keywords and codes.
[0121] Among them, step C1 uses the template code dictionary to record the mapping relationship between keywords and codes. In this way, the process of searching according to the mapping relationship between keywords and codes recorded in the template code dictionary based on the component keywords in the system architecture diagram specifically includes: matching the component keywords in the system architecture diagram with the keywords recorded in the template code dictionary. If the match is successful, the code recorded in the template code dictionary can be used as the target code corresponding to the component keywords in the system architecture diagram.
[0122] In step C2, the large language model can be used to represent the mapping relationship between keywords and codes. In other words, the large language model can output the code corresponding to the input keyword according to the input keyword.
[0123] The large language model in the embodiments of the present invention can be an artificial intelligence model designed to understand and generate human language. By training on a large amount of text data, the large language model can perform a wide range of tasks, including the task of generating graphical description language files in the embodiments of the present invention and so on. The large language model is generally based on a deep learning architecture, such as the Transformer structure. The embodiments of the present application do not limit the specific type of the large language model. For example, the types of the large language model can include: GPT (Generative Pre-Trained Transformer) model and GLM (General Language Model), etc.
[0124] For example, the GPT model is a large-scale natural language generation model based on the Transformer structure. It uses a vast amount of text data for pre-training and can generate high-quality natural language texts, including articles, dialogues, abstracts, etc. The core of the GPT model is the Transformer structure, which adopts the attention mechanism, enabling the GPT model to consider all positions in the input sequence simultaneously, thereby better capturing long-distance dependencies. After pre-training the GPT model, fine-tuning it can adapt to various downstream text generation tasks.
[0125] The embodiments of the present invention can perform fine-tuning training on the large language model so that the large language model can represent the mapping relationship between keywords and codes. In other words, the fine-tuning training in the embodiments of the present invention enables the large language model to have the ability to output codes according to the input keywords.
[0126] Optionally, the training process of the large language model includes: collecting project training samples of a software system project, where the project training samples specifically include: project component keywords and annotated codes; the annotated codes can be the codes corresponding to the project component keywords; and using the project training samples to train the large language model.
[0127] Since the process of training the large language model using project training samples is similar to the process of training a character recognition model using training samples, it will not be elaborated here and can be referred to each other.
[0128] The embodiments of the present invention do not limit the specific target codes corresponding to the component keywords. The target codes corresponding to the component keywords will be described below according to the specific types of the components.
[0129] Component type 1: The component is a database class component, and the target codes include: data source configuration code, database entity code, and database operation code.
[0130] Examples of database - type components may include: Mysql (relational database), etc.
[0131] Among them, the data source configuration code is used to configure one or more data sources that establish connections with the database - type components, so that these data sources can correctly connect to the database - type components.
[0132] The database entity code is used to define the entity class corresponding to the database - type component. The entity class can be used to describe the basic format of the database table.
[0133] The database operation code can be used to define methods for interacting with the database - type components. The database operation code can contain method declarations for operations such as adding, deleting, modifying, and querying the database, and it can provide a convenient interface for database operations on specific entity classes.
[0134] Component type 2: The component is a cache - type component, and the target code includes: connection configuration code, data operation code, cache policy code, and exception handling code.
[0135] Examples of cache - type components may include: Redis (Remote Dictionary Service), etc.
[0136] The connection configuration code: is used to set the connection parameters of the cache - type component, such as the host name, port number, password, etc.
[0137] The data operation code: includes methods for operating on the data structures (such as strings, lists, hash tables, sets, sorted sets) of the cache - type component.
[0138] The cache policy code: may involve defining cache update policies, expiration time settings, etc.
[0139] The exception handling code: handles possible exception situations during the connection and operation of the cache - type component.
[0140] Component type 3: The component is a search - type component, and the target code includes: connection configuration code, index creation and management code, data writing and querying code, paging and sorting code, and exception handling code.
[0141] Examples of search - type components may include: ElasticSearch (Elastic Search), etc.
[0142] The connection configuration code: is used to configure connection parameters such as the address, port, and authentication information of the search - type component server.
[0143] The index creation and management code: is used to define and create indexes in the search - type component, including setting index mappings, tokenizers, etc.
[0144] Data writing and querying code: Implement writing data into search components and performing various query operations, such as full-text search, conditional filtering, aggregation query, etc.
[0145] Paging and sorting code: Handle the paging and sorting logic of search results.
[0146] Version control code: If version control in search components needs to be handled, it may include relevant code implementations.
[0147] Exception handling code: Cope with possible exceptions that occur when interacting with search components.
[0148] Component type 4. The component is a framework component, and the target code includes: configuration code, controller code, service layer code, data access object code, entity class code, dependency injection related code, transaction management code, and exception handling code.
[0149] Among them, the configuration code is used to define and configure the components and behaviors of the software system corresponding to the application.
[0150] Controller code: Used to handle user requests and return responses.
[0151] Service layer code: Responsible for implementing the business logic of the application.
[0152] Data access object code: Interacts with database components to implement data creation, deletion, update, and query operations.
[0153] Entity class code: Maps the database table structure and defines data objects.
[0154] Dependency injection related code: Manages the dependencies between components through dependency injection.
[0155] Transaction management code: Uses declarative transaction management to ensure the atomicity, consistency, isolation, and durability of database operations.
[0156] Exception handling code: Handles various exceptions that may occur in the application and provides a unified exception handling mechanism.
[0157] Component type 5. The component is a user interface component, and the target code includes: interface layout code, interaction element code, data binding code, form validation code, event handling code, state management code, interface adaptation code, exception handling code, and multi-platform adaptation code.
[0158] Among them, the interface layout code: Used to define the overall structure of the user interface and the arrangement of elements.
[0159] Interactive element code: Used for the definition and configuration of interactive controls such as buttons, input boxes, dropdown menus, etc., including the styles of interactive controls, event handling functions, etc.
[0160] Data binding code: Used to bind the data obtained from the backend to interface elements to achieve dynamic display and update of data.
[0161] Form validation code: Used to verify the legality of user input, such as required fields, format checks, etc.
[0162] Event handling code: Used to respond to user operations, such as clicking buttons, selecting options, etc., and execute corresponding business logic.
[0163] State management code: Used to manage different states of the user interface, such as showing or hiding certain elements, switching different views, etc.
[0164] Interface adaptation code: If integration with different front-end frameworks or libraries is required, adaptation code may need to be written.
[0165] Exception handling code: Used to handle possible exception situations during user interface operations and provide friendly error prompts.
[0166] Multi-platform adaptation code: If the software system's corresponding application needs to support multiple devices or platforms (such as desktops, mobile devices), corresponding adaptation code may be required.
[0167] Component type 6. The component is an internal interface class, and the target code includes: interface definition code, interface implementation code, data transfer and conversion code, exception handling code, logging code, performance optimization code, permission control and verification code, unit test code.
[0168] Among them, the interface definition code clarifies the method signatures, input parameters, and return value types of the internal interface. It provides a contract for interface implementers and users, specifying the functions and behaviors of the interface.
[0169] Interface implementation code: Specifically implements the methods defined by the interface and provides actual functional logic. This is the specific implementation part of the internal interface, which completes specific business tasks according to the interface definition.
[0170] Data transfer and conversion code: When the internal interface transfers data between different modules or components, data format conversion and adaptation may be required. This part of the code is responsible for ensuring that data can be correctly transmitted and understood between different parts.
[0171] Exception handling code: During the execution of internal interfaces, various exceptions may occur, such as incorrect input data, network failures, database connection problems, etc. Exception handling code is used to capture and handle these exceptions to ensure the stability and reliability of the system.
[0172] Logging code: Records the execution process and key events of internal interfaces for system monitoring, troubleshooting, and performance analysis. Logs can provide information about the time of interface calls, input parameters, output results, and possible error messages.
[0173] Performance optimization code: Used to improve the execution efficiency and response speed of internal interfaces.
[0174] Permission control and verification code: Used to ensure that only authorized users or modules can access internal interfaces. Permission control and verification code are used to check the identity and permissions of callers to prevent unauthorized access and operations.
[0175] Unit test code: Conducts unit tests on the functions of internal interfaces to improve the correctness and stability of the interfaces. Unit test code can independently test each method of the interface to verify whether its input and output meet expectations.
[0176] It can be understood that the target codes corresponding to the above 6 types of component categories are only examples. In fact, those skilled in the art can, according to actual application requirements, adopt other target codes corresponding to the above 6 types of component categories. Or, those skilled in the art can also set and adopt corresponding target codes for other component categories other than the 6 types of component categories.
[0177] In a specific implementation, the system architecture diagram may include: N component keywords, where N can be a positive integer. Embodiments of the present invention can obtain the target codes corresponding to all or part of the N component keywords.
[0178] It should be noted that the target code corresponding to a component keyword may include: one or more component code files. Embodiments of the present invention can package multiple component code files corresponding to a component keyword to obtain a single-component packaged file or a single-component compressed file corresponding to this component keyword. Embodiments of the present invention can also package the single-component packaged files corresponding to multiple component keywords in the system architecture diagram to obtain a multi-component packaged file corresponding to this system architecture diagram.
[0179] In step 104, for a system architecture diagram, the packaged files corresponding to all or part of the component keywords included therein can be output.
[0180] For example, the first download link corresponding to the single-component packaged file of all or part of the component keywords in the system architecture diagram can be displayed on the interface, so that the user can download the single-component packaged file according to the first download link. For another example, the second download link corresponding to the multi-component packaged file of the system architecture diagram can be displayed on the interface, so that the user can download the multi-component packaged file according to the second download link.
[0181] In an alternative implementation of the present invention, the above method may further include: determining the POM (Project Object Model) file of the project corresponding to the system architecture diagram; adding dependencies corresponding to the component keywords in the system architecture diagram to the project object model file.
[0182] Dependencies are used to represent the external software resources required for the operation of the components corresponding to the component keywords. The types of these external software resources may include: library files, frameworks, toolkits (such as the log4j toolkit for logging, etc.), services, and other related code modules or files, etc. External software resources refer to the software resources external to the project corresponding to the system architecture diagram.
[0183] In the object model project, the POM file is used to manage the project's dependencies and build configurations. In the embodiments of the present invention, after identifying the component keywords of components such as Mysql introduced into the software system, dependencies related to the component keywords will be newly added to the POM file.
[0184] The POM file plays an important role in building the project. It enables the build tool to automatically obtain and introduce dependencies during the project build process. Specifically, when building the project, the POM file will guide the build tool to automatically download the components corresponding to the dependencies from the corresponding repository and integrate these components into the project. This process enables developers to save time and effort in searching for the components corresponding to these dependencies on the official websites of various libraries or other channels, and they don't need to manually copy the found components to specific directories of the project. In this way, the development efficiency is greatly improved.
[0185] The following is an example of the file content of the POM file:
[0186] 1 <dependencies>
[0187] 2 <!--Spring Boot Starter Data JPA-->
[0188] 3 <dependency>
[0189] 4 <groupid>org.springframework.boot< / groupid>
[0190] 5 <artifactid>spring-boot-starter-data-jpa< / artifactid>
[0191] 6< / dependency>
[0192] 7 <!--MySQL driver-->
[0193] 8 <dependency>
[0194] 9 <groupid>mysql< / groupid>
[0195] 10 <artifactid>mysql-connector-java< / artifactid>
[0196] 11 <scope>runtime< / scope>
[0197] 12< / dependency>
[0198] 13< / dependencies>
[0199] In the above file content, the numbers on the leftmost side of each line represent the line numbers. Among them, the content corresponding to line numbers 1 and 13 is the original content of the POM file.
[0200] In the embodiments of the present invention, the first dependency and the second dependency can be added between the content corresponding to line numbers 1 and 13 according to the component keyword "Mysql".
[0201] Among them, the first dependency is specifically the Spring Boot Starter Data JPA (Java Persistence Application Programming Interface) dependency, and the corresponding line numbers are 2 - 6. The first dependency is used to simplify data persistence operations in applications based on Spring Boot. It integrates the JPA implementation and the data access function of Spring Boot, enabling developers to conveniently perform database operations, including entity class mapping, database query, transaction management, etc.
[0202] The second dependency is specifically the driver dependency of the relational database, and the corresponding line numbers are 7 - 12. The second dependency is the Java driver of the relational database, allowing Java applications to connect and interact with the relational database.
[0203] It can be understood that in the embodiments of the present invention, after identifying the component keywords of other components introduced by the software system in addition to Mysql, dependencies related to the component keywords of other components can also be newly added to the POM file. For example, the dependency corresponding to ElasticSearch can be inserted between lines 12 - 13.
[0204] In an alternative implementation manner of the present invention, the above method may further include: determining the project configuration file corresponding to the system architecture diagram; adding configuration items corresponding to the component keywords in the system architecture diagram to the project configuration file.
[0205] The above project configuration file is used to configure the properties and behaviors of the application corresponding to the software system. In the embodiments of the present invention, after identifying the component keywords of components such as Mysql introduced by the software system, a configuration item for the Mysql data source will be newly added to the project configuration file. The above configuration item is used to configure the data source of the component corresponding to the component keyword. The configuration item of this Mysql data source enables the application to accurately connect to the Mysql database. By configuring multiple Mysql data sources, access to different databases can be achieved to meet the complex data storage requirements in the software system.
[0206] In an alternative implementation of the present invention, the above method may further include: detecting the line information included in the system architecture diagram; determining the connection relationship information between the first component keyword and the second component keyword in the system architecture diagram according to the positional relationship between the line information and the component keyword in the system architecture diagram; and adding corresponding annotation information to the target codes corresponding to the first component keyword and the second component keyword respectively. In the field of software code technology, annotation information is an explanation and description of the target code, aiming to improve the readability and maintainability of the target code.
[0207] In a system architecture diagram, lines are usually used to represent the connection relationships between different components. Embodiments of the present invention can use edge detection technology to detect the line information included in the system architecture diagram. The line information may include: the pixel positions and pixel values corresponding to the lines in the system architecture diagram.
[0208] Embodiments of the present invention can infer the connection relationship according to the positional relationship between the line information and the component keyword in the system architecture diagram. For example, if a line points from component keyword A to component keyword B, then it can be determined that there is a certain connection relationship between component keyword A and component keyword B. This connection relationship may be the data flow direction, call relationship, dependency relationship, etc.
[0209] Once the connection relationship information is determined, embodiments of the present invention can add annotation information to the target codes corresponding to the corresponding component keywords. The annotation information can describe the connection relationship between the components. The annotation information may include: information such as the data flow direction, call relationship, dependency relationship, etc. Or, a large language model can be used to organize the language of the data flow label and the connection relationship information to obtain annotation information in natural language form.
[0210] For example, add a first annotation to the target code of the calling component. The first annotation is used to explain which specific called component the calling component calls, as well as the purpose and method of the call. Another example is to add a second annotation to the target code of the called component. The second annotation is used to explain which calling components the called component may be called by, clarifying its called relationship in the system architecture.
[0211] Those skilled in the art can determine the position of the annotation information according to actual application requirements. For example, the annotation information can be a class-level annotation, which can be located above the class definition. Another example is that the annotation information can be a method-level annotation, which can be located above the method definition.
[0212] In practical applications, embodiments of the present invention can integrate the multi-component package file corresponding to the system architecture diagram with the project object model file and / or the project configuration file to obtain the total package file. In this way, embodiments of the present invention can display the third download link corresponding to the total package file of the system architecture diagram on the interface, so that users can download the total package file according to the third download link.
[0213] It can be understood that those skilled in the art can determine the output manner of the target code according to actual application requirements, and embodiments of the present invention do not limit the specific output manner of the target code.
[0214] In summary, the code generation method of embodiments of the present invention starts from the system architecture diagram of the software system, identifies the keywords included in the system architecture diagram, and then determines the target code corresponding to the component keywords in the system architecture diagram in combination with the mapping relationship between the keywords and the code.
[0215] Embodiments of the present invention automatically generate the target code corresponding to the component keywords in the system architecture diagram according to the optical character recognition technology and the mapping relationship between the keywords and the code. Since embodiments of the present invention can save the code writing operation corresponding to the component keywords in the system architecture diagram, the time for code generation can be greatly reduced, and thus the efficiency of software development can be improved as a whole.
[0216] Moreover, the code generation method of embodiments of the present invention can effectively shorten the development cycle of the project, enable the software to be launched on the market faster, and thus meet the market's demand for rapid software iteration.
[0217] It should be noted that for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that embodiments of the present invention are not limited by the described action sequence, because according to embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential for embodiments of the present invention.
[0218] Refer to Figure 3 , which shows a schematic structural diagram of a code generation device according to an embodiment of the present invention. The code generation device may specifically include the following modules: a diagram receiving module 301, a diagram recognition module 302, a code determination module 303, and a code output module 304.
[0219] The diagram receiving module 301 is configured to receive the system architecture diagram of the software system; the system architecture diagram includes: components of the software system.
[0220] The graph recognition module 302 is used to recognize the system architecture diagram, and the recognition results include: the component keywords included in the system architecture diagram;
[0221] The code determination module 303 is used to determine the target code corresponding to the component keywords in the system architecture diagram according to the mapping relationship between the keywords and the code;
[0222] The code output module 304 is used to output the target code.
[0223] Optionally, the graph recognition module 302 specifically includes:
[0224] The preprocessing module is used to preprocess the system architecture diagram to obtain a preprocessed architecture diagram; the preprocessing includes: denoising processing, grayscale processing, binarization processing, skew removal and correction processing, and text area delimitation processing;
[0225] The model recognition module is used to input the preprocessed architecture diagram into a character recognition model, and the character recognition model outputs the recognition result corresponding to the system architecture diagram.
[0226] Optionally, the code determination module 303 specifically includes:
[0227] The first code determination module is used to search according to the mapping relationship between the component keywords in the system architecture diagram and the keywords and codes recorded in the template code dictionary to obtain the target code corresponding to the component keywords in the system architecture diagram; or
[0228] The second code determination module is used to input the component keywords in the system architecture diagram into a large language model, and the large language model outputs the target code corresponding to the component keywords; the large language model is used to represent the mapping relationship between the keywords and the code.
[0229] Optionally, the component is a database class component, and the target code includes: data source configuration code, database entity code, and database operation code; or
[0230] The component is a cache class component, and the target code includes: connection configuration code, data operation code, cache policy code, and exception handling code; or
[0231] The component is a search class component, and the target code includes: connection configuration code, index creation and management code, data writing and query code, paging and sorting code, and exception handling code; or
[0232] The component is a framework - type component, and the target code includes: configuration code, controller code, service - layer code, data access object code, entity - class code, dependency - injection - related code, transaction - management code, and exception - handling code; or
[0233] The component is a user - interface - type component, and the target code includes: interface - layout code, interactive - element code, data - binding code, form - validation code, event - handling code, state - management code, interface - adaptation code, exception - handling code, and multi - platform - adaptation code; or
[0234] The component is an internal - interface - type component, and the target code includes: interface - definition code, interface - implementation code, data - transfer and conversion code, exception - handling code, logging code, performance - optimization code, permission - control and verification code, and unit - test code.
[0235] Optionally, the device further includes:
[0236] An object - model - file determination module, configured to determine the project object - model file of the project corresponding to the system architecture diagram;
[0237] A dependency - addition module, configured to add dependencies corresponding to the component keywords in the system architecture diagram to the project object - model file; the dependencies are used to represent the external software resources required for the operation of the components corresponding to the component keywords; the external software resources refer to the software resources outside the project corresponding to the system architecture diagram.
[0238] Optionally, the device further includes:
[0239] A project - configuration - file determination module, configured to determine the project configuration file corresponding to the system architecture diagram;
[0240] A configuration - item - addition module, configured to add configuration items corresponding to the component keywords in the system architecture diagram to the project configuration file.
[0241] Optionally, the device further includes:
[0242] A line - detection module, configured to detect the line information included in the system architecture diagram;
[0243] A connection - relationship determination module, configured to determine the connection - relationship information between the first component keyword and the second component keyword in the system architecture diagram according to the positional relationship between the line information and the component keywords in the system architecture diagram;
[0244] A comment - information determination module, configured to add corresponding comment information to the target code corresponding to the first component keyword and the second component keyword respectively according to the connection - relationship information; the comment information is used to explain and illustrate the target code.
[0245] An embodiment of the present invention further provides an electronic device, which can implement the functions of the foregoing storage node, scheduling node, ledger node, or management node.
[0246] As Figure 4 shown, the electronic device may include a processor 1001, a communication interface 1002, a memory 1003, and a communication bus 1004. Among them, the processor 1001, the communication interface 1002, and the memory 1003 communicate with each other through the communication bus 1004.
[0247] The memory 1003 is used to store a computer program.
[0248] When the processor 1001 executes the program stored on the memory 1003, the following steps are implemented:
[0249] Store the storage object.
[0250] Send the storage object to the coupled second storage node, so that the second storage node stores and / or forwards the storage object.
[0251] After successfully storing the storage object, send the object information of the storage object to the ledger node, so that the ledger node saves the ledger information of the first storage node; the ledger information includes: the object information stored in the corresponding storage node.
[0252] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity, only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.
[0253] The communication interface is used for communication between the above electronic device and other devices.
[0254] The memory may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one code generation device located far from the foregoing processor.
[0255] The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it may also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0256] In another embodiment provided by the present invention, a computer-readable storage medium is further provided. Instructions are stored in the computer-readable storage medium. When it runs on a computer, the computer is enabled to execute the code generation method described in any one of the above embodiments.
[0257] In another embodiment provided by the present invention, a computer program product containing instructions is further provided. When it runs on a computer, the computer is enabled to execute the code generation method described in any one of the above embodiments.
[0258] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, a computer, a server, or a data center to another website, a computer, a server, or a data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or a data center that includes one or more integrated available media. Examples of the available medium may be magnetic media (such as floppy disks, hard disks, magnetic tapes), optical media, or semiconductor media (such as solid state disk (SSD)). Examples of optical media may include DVDs (Digital Video Disc).
[0259] It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
[0260] Each embodiment in this specification is described in a related manner. For the same and similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference can be made to the corresponding part of the method embodiment for the relevant content.
[0261] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are included within the protection scope of the present invention.
Claims
1. A code generation method, characterized in that: The method comprises: Receive a system architecture diagram of a software system; the system architecture diagram includes: components of the software system; Identify the system architecture diagram, and obtain identification results including: component keywords included in the system architecture diagram; Determine the target code corresponding to the component keyword in the system architecture diagram according to the mapping relationship between the keyword and the code; The target code is output.
2. The method according to claim 1, characterized in that: The identifying the system architecture diagram includes: Preprocessing the system architecture diagram to obtain a preprocessed architecture diagram; the preprocessing includes: denoising, grayscale, binarization, de-skewing and correction, and text area delineation; The preprocessed architecture diagram is input into a character recognition model, and the character recognition model outputs a recognition result corresponding to the system architecture diagram.
3. The method according to claim 1, characterized in that Determining the target code corresponding to the component keyword in the system architecture diagram according to the mapping relationship between the keyword and the code includes: According to the component keywords in the system architecture diagram, the mapping relationship between the keywords and the codes recorded in the template code dictionary is searched to obtain the target code corresponding to the component keywords in the system architecture diagram; or The component keywords in the system architecture diagram are input into a large language model, and the large language model outputs the target code corresponding to the component keywords; the large language model is used to characterize the mapping relationship between keywords and codes.
4. The method according to claim 1, characterized in that: The component is a database component, and the target code includes: data source configuration code, database entity code, and database operation code; or The component is a cache component, and the target code includes: connection configuration code, data operation code, cache strategy code and exception handling code; or The component is a search component, and the target code includes: connection configuration code, index creation and management code, data writing and query code, paging and sorting code, and exception handling code; or The component is a framework component, and the target code includes: configuration code, controller code, service layer code, data access object code, entity class code, dependency injection related code, transaction management code and exception handling code; or The component is a user interface component, and the target code includes: interface layout code, interactive element code, data binding code, form validation code, event processing code, state management code, interface adaptation code, exception handling code and multi-platform adaptation code; or The component is an internal interface class, and the target code includes: interface definition code, interface implementation code, data transfer and conversion code, exception handling code, logging code, performance optimization code, permission control and verification code, and unit testing code.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Determine a project object model file of the project corresponding to the system architecture diagram; Dependencies corresponding to component keywords in the system architecture diagram are added to the project object model file; dependencies are used to characterize external software resources required for the operation of components corresponding to component keywords; external software resources refer to software resources outside the project corresponding to the system architecture diagram.
6. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Determine the project configuration file corresponding to the system architecture diagram; Add configuration items corresponding to the component keywords in the system architecture diagram in the project configuration file; the configuration items are used to configure the data source of the component corresponding to the component keyword.
7. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Detecting line information contained in the system architecture diagram; Determine connection relationship information between a first component keyword and a second component keyword in the system architecture diagram according to a position relationship between the line information and the component keyword in the system architecture diagram; According to the connection relationship information, corresponding annotation information is added to the target codes corresponding to the first component keyword and the second component keyword respectively; the annotation information is used to explain and illustrate the target code.
8. The method according to any one of claims 1 to 4, characterized in that: The identification result also includes: a data flow label on the edge contained in the system architecture diagram; the data flow label is used to display the flow direction of data between different nodes and the business attributes carried by the data during the flow process.
9. A code generating device, characterized in that: The device comprises: A diagram receiving module is used to receive a system architecture diagram of a software system; the system architecture diagram includes: components of the software system; A diagram recognition module is used to recognize the system architecture diagram, and the obtained recognition results include: component keywords contained in the system architecture diagram; A code determination module, used to determine the target code corresponding to the component keyword in the system architecture diagram according to the mapping relationship between the keyword and the code; A code output module is used to output the target code.
10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
11. A computer-readable storage 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 8 is implemented.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.