Code automatic generation method based on data model and electronic equipment

Through the automatic code generation method based on data model, the document extraction model and code analysis module are used to generate software program code from software requirements documents without manual participation, which solves the problem that existing programming tools cannot achieve no manual intervention, and realizes an efficient and accurate programming process.

CN120029608AInactive Publication Date: 2025-05-23SHANGHAI LIZHONG CLOUD INTELLIGENT TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510105217.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-05-23
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing auxiliary programming tools cannot implement programming processes without manual intervention, resulting in large programming workloads and low accuracy.

Method used

The automatic code generation method based on the data model is adopted, and the software requirement documents are converted into data models through the document extraction model, and the software program code is generated using the code analysis module. There is no manual participation in the entire process.

Benefits of technology

The software programming process is completely unmanned, the obtained code has unified standards, and the error rate is greatly reduced, which reduces the labor cost in the field of software design.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120029608A_ABST
    Figure CN120029608A_ABST
Patent Text Reader

Abstract

The invention provides an automatic code generation method based on a data model and electronic equipment. The method comprises the steps that a software requirement document is acquired; inputting the software demand document into a document extraction model to obtain a data model; inputting the data model into a code analysis module to obtain a software program code; wherein the document extraction model is obtained by adopting support vector regression (SVR) construction and training. According to the scheme, the software programming process can be completely unmanned, the software program codes obtained through the method have the unified standard, and the error probability is greatly reduced compared with manual programming.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method for automatically generating codes based on a data model and an electronic device. Background Art

[0002] With the continuous development of artificial intelligence technology, all walks of life are using artificial intelligence technology to upgrade the industry and replace human resources. The computer software industry, as the foundation of artificial intelligence technology, is also undergoing tremendous changes. Software programmers have begun to use auxiliary programming tools to reduce programming workload and improve programming accuracy.

[0003] Although many auxiliary programming tools have been widely used, these tools still need human intervention in programming and cannot be completely unmanned. Therefore, a solution that can realize the programming process without human intervention is urgently needed. Summary of the invention

[0004] The embodiments of the present application provide a method and electronic device for automatic code generation based on a data model, which can realize a completely unmanned software programming process. The software program code obtained by this method has a unified standard, and the probability of errors is greatly reduced compared to manual programming.

[0005] An embodiment of the present application provides a method for automatic code generation based on a data model, comprising: obtaining a software requirement document; inputting the software requirement document into a document extraction model to obtain a data model; inputting the data model into a code parsing module to obtain software program code; wherein the document extraction model is constructed and trained using support vector regression (SVR).

[0006] In one embodiment, the step of obtaining the document extraction model includes: searching and obtaining historical software requirement documents in a software requirement document library according to the software requirement document; abstracting historical document data from the historical software requirement documents; constructing an initial document extraction model using the SVR according to the historical document data; performing polynomial fitting on the historical document data to obtain a fitting polynomial and determine a historical fitting result; and training the initial document extraction model according to the historical fitting result to obtain a document extraction model.

[0007] In one embodiment, abstracting the historical document data from the historical software requirement document includes: abstracting static feature data, dynamic behavior data and constraint data from the historical software requirement document; performing weighted summation of the static feature data, dynamic behavior data and constraint data to obtain the historical document data.

[0008] In one embodiment, the initial document extraction model is trained according to the historical matching result to obtain the document extraction model, including: splitting the historical matching result into a training set and a test set; using the training set to train the initial document extraction model to obtain a trained document extraction model; inputting the test set into the trained document extraction model to obtain a historical data model; if the historical data model meets a preset condition, using the trained document extraction model as the document extraction model.

[0009] In one embodiment, the code parsing module includes a template unit, an intermediate code conversion unit, a task management unit, a syntax detection unit and a code generation unit, and the template unit includes a rule template and a syntax template.

[0010] In one embodiment, the inputting of the data model into the code parsing module to obtain the software program code includes: converting the data model into the intermediate code through the intermediate code conversion unit; sending the intermediate code to the grammar detection unit through the task management unit; judging whether the grammar of the intermediate code is accurate through the grammar detection unit, and if accurate, converting the intermediate code into the software program code through the code generation unit; if inaccurate, converting the data model into the intermediate code again through the intermediate code conversion unit until the software program code is obtained.

[0011] In one embodiment, after obtaining the software program code, it includes: judging whether the software program code is accurate through the grammar detection unit, and if accurate, sending the software program code to the user through the task management unit; if inaccurate, re-converting the intermediate code into the software program code through the code generation unit until the software program code is sent to the user.

[0012] In one embodiment, the rule template includes a first rule template and a second rule template, the first rule template stores a conversion rule for converting a data model into an intermediate code, and the second rule template stores a conversion rule for converting an intermediate code into a software program code; the converting of the data model into the intermediate code by the intermediate code conversion unit includes: converting the data model into the intermediate code by the intermediate code conversion unit according to the first rule template; the converting of the intermediate code into the software program code by the code generation unit includes: converting the intermediate code into the software program code by the code generation unit according to the second rule template.

[0013] In one embodiment, the syntax template includes a first syntax template and a second syntax template, the first syntax template stores the syntax of the intermediate code, and the second syntax template stores the syntax of the software program code; the judging whether the syntax of the intermediate code is accurate through the syntax detection unit includes: judging whether the syntax of the intermediate code is accurate according to the first syntax template through the syntax detection unit; the judging whether the software program code is accurate through the syntax detection unit includes: judging whether the software program code is accurate according to the second syntax template through the syntax detection unit.

[0014] An embodiment of the present application also provides an electronic device, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to execute the above-mentioned data model-based automatic code generation method.

[0015] The embodiments of the present application can realize the process of converting software requirement documents into software program codes without human intervention. First, the software requirement document obtains a data model through a document extraction model, and then the data model obtains the software program code through a code parsing model. Both of these steps require no human intervention, which can greatly reduce the labor cost in the field of software design, and the error rate of the obtained code is low. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solution of the embodiments of the present application, the drawings required for use in the embodiments of the present application are briefly introduced below.

[0017] Figure 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0018] Figure 2 It is a flowchart of a method for automatic code generation based on a data model provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0020] Similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0021] In the related technologies, programmers in the software industry have begun to use a large number of auxiliary programming tools to reduce the workload of programming and improve the accuracy of programming. Although these auxiliary programming tools have become more intelligent with the rapid development of artificial technology, there is currently no tool that can achieve the software development process without human intervention. Only through the software requirements document can the software development process without human intervention be realized.

[0022] In view of this, the embodiment of the present application provides a method for automatic code generation based on a data model, including: obtaining a software requirement document; inputting the software requirement document into a document extraction model to obtain a data model; inputting the data model into a code parsing module to obtain a software program code; wherein the document extraction model is constructed and trained using support vector regression SVR. This method can realize a completely unmanned software programming process, and the software program code obtained by this method has a unified standard, and the probability of errors is greatly reduced compared to manual programming.

[0023] Figure 1 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 100 can be used to execute the automatic code generation method based on the data model, and the electronic device can be, for example, a PC computer. Figure 1 As shown, the electronic device 100 includes: one or more processors 102, and one or more memories 104 storing processor executable instructions. The processor 102 is configured to execute the data model-based automatic code generation method provided in the following embodiment of the present application.

[0024] The processor 102 can be a gateway, a smart terminal, or a device including a central processing unit (CPU), a graphics processing unit (GPU), or other forms of processing units with data processing capabilities and / or instruction execution capabilities. It can process data of other components in the electronic device 100 and control other components in the electronic device 100 to perform desired functions.

[0025] The memory 104 may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 102 may run the program instructions to implement the automatic code generation method based on the data model described below. Various applications and various data, such as various data used and / or generated by the application, may also be stored in the computer-readable storage medium.

[0026] In one embodiment, Figure 1 The electronic device 100 shown may also include an input device 106, an output device 108, and a data acquisition device 110, which are interconnected via a bus system 112 and / or other forms of connection mechanisms (not shown). Figure 1 The components and structures of the electronic device 100 shown are merely exemplary and non-limiting. The electronic device 100 may also have other components and structures as required.

[0027] The input device 106 may be a device for a user to input instructions, and may include one or more of a keyboard, a mouse, a microphone, and a touch screen. The output device 108 may output various information (e.g., images or sounds) to the outside (e.g., a user), and may include one or more of a display, a speaker, and the like. In an embodiment of the present application, the output device 108 may output software program code. The data acquisition device 110 may collect software requirement documents, and store the collected data in the memory 104 for use by other components. Exemplarily, the data acquisition device 110 may be a camera.

[0028] In one embodiment, the various components in the example electronic device 100 for implementing the data model-based automatic code generation method of the embodiment of the present application can be integrated or dispersed, such as integrating the processor 102, memory 104, input device 106 and output device 108 into one, while separating the data acquisition device 110.

[0029] In one embodiment, the example electronic device 100 for implementing the data model-based automatic code generation method of the embodiment of the present application can be implemented as an intelligent terminal such as a smart phone, a tablet computer, a desktop computer, a server, a vehicle-mounted device, etc.

[0030] Figure 21 is a flow chart of a method for automatically generating code based on a data model provided in an embodiment of the present application. Figure 2 As shown, the method includes the following steps S210-S230.

[0031] Step 210: Obtain software requirement document.

[0032] Regarding the software requirements document, it is a document that describes in detail the expected software system functions, performance, behavior, and design constraints. In the software requirements document, user requirements, system requirements, non-functional requirements, interface requirements, data requirements, and quality requirements can be included. User requirements: include the expectations, needs, and use cases of end users to ensure that the software can meet their expectations. System requirements: define the structure and architecture of the entire system, as well as the relationship between different components. Non-functional requirements: These requirements usually describe the performance, reliability, security and other characteristics of the software. Interface requirements: involve all requirements related to the project interface, such as design, layout, style, and interaction. Data requirements: list the data and information required for the project, covering the type, source, and format of the data. Quality requirements: include code quality, testing requirements, error rate, etc.

[0033] The software requirement document can be written by a software requirement analyst or generated by an intelligent document generation tool, which is not limited in the embodiments of the present application.

[0034] Step 220: Input the software requirement document into the document extraction model to obtain a data model.

[0035] About model data is an abstraction of data features. It describes the static features, dynamic behaviors and constraints of the system from an abstract level, and provides an abstract framework for information representation and operation of the database system. The content described by the data model consists of three parts: data structure, data operation and data constraints. The data model can be a dimensional data model, a document data model, a hierarchical data model, or a network data model. Dimensional data model: emphasizes supporting efficient data queries through the combination of dimensions and fact tables. Document data model: suitable for storing and processing semi-structured or unstructured data, such as MongoDB. Hierarchical data model: a data model that organizes data using a tree-like hierarchy. Network data model: a data structure model that uses a directed graph to represent the connections between entities.

[0036] As mentioned above, the software requirement document may include user requirements, system requirements, non-functional requirements, interface requirements, data requirements, and quality requirements, and these requirements can actually be abstracted into data features to form a data model. However, it is difficult to convert the requirements in the software requirement document into a data model, and the manual conversion workload is extremely large. Therefore, the embodiment of the present application trains a document extraction model, and the trained document extraction model can abstract the software requirement document input into the model into a data model.

[0037] Regarding the document extraction model, it is constructed and trained using support vector regression SVR. The specific steps of obtaining the document extraction model may include:

[0038] Step 2201: Based on the software requirement document, search and obtain historical software requirement documents in a software requirement document library.

[0039] After obtaining the software requirements document, you can use this document as the current software requirements document.

[0040] Regarding the software requirement document library, it refers to a collection of software requirement documents. After the software requirement documents are used up, they can be stored in the software requirement document library so that the documents in the library can be continuously expanded.

[0041] Regarding the historical software requirement document, it can be a requirement document in the software requirement document library that matches the current software requirement document. Matching can mean that at least one of the user requirements, system requirements, non-functional requirements, interface requirements, data requirements, and quality requirements of the two software requirement documents is exactly the same. Matching can also mean that the user requirements, system requirements, non-functional requirements, interface requirements, data requirements, and quality requirements of the two software requirement documents are all the same.

[0042] According to the software requirement document, the historical software requirement document is searched and obtained in the software requirement document library, specifically: the software requirement document library is searched for a document matching the current software requirement document, and if the matching conditions are met, the document is used as the historical software requirement document.

[0043] Step 2202: Abstracting historical document data from the historical software requirement document.

[0044] Regarding historical document data, it is the result of weighted summation of static feature data, dynamic behavior data and constraint condition data, wherein static feature data, dynamic behavior data and constraint condition data are the elements constituting the data model.

[0045] For the acquisition of static feature data, dynamic behavior data and constraint data, firstly, the user requirements, system requirements, non-functional requirements, interface requirements, data requirements and quality requirements in the historical software requirement documents are extracted respectively, and then the user requirements, system requirements, non-functional requirements, interface requirements, data requirements and quality requirements are abstracted into static feature data, dynamic behavior data and constraint data respectively according to the characteristics of the data.

[0046] Step 2203: Based on the historical document data, the SVR is used to construct an initial document extraction model.

[0047] Support Vector Regression (SVR) is a machine learning algorithm for regression analysis that attempts to find an "optimal hyperplane" among data points. However, in regression problems, this hyperplane is a regression function that is as close to the data points as possible and makes predictions within the allowable error range.

[0048] The basis of the initial document extraction model can be a convolutional neural network (CNN). By inputting historical document data into the convolutional neural network and cooperating with SVR, an initial document extraction model can be constructed.

[0049] Step 2204: Perform polynomial fitting on the historical document data to obtain a fitting polynomial and determine a historical fitting result.

[0050] As mentioned above, historical document data is abstracted from historical software requirement documents. Therefore, data points (X i ,Y i ) represents (i=0,1,…,m), where X i Indicates the number of the i-th historical document data, Y i Represents the specific value of the i-th historical document data. The serial number of the historical document data may be the code of the historical software requirement document in the software requirement document library. An n-order polynomial may be constructed for fitting the historical document data. Specifically, the historical document data is fitted with a polynomial using the least squares method to obtain an n-order fitting polynomial.

[0051] The n-order fitting polynomial is specifically: Among them, a k are polynomial coefficients. The least squares method makes the data point (X i ,Y i ) and the n-order fitting polynomial The error between them is the smallest, as shown in the following formula (1):

[0052]

[0053] The formula (1) can be used to adjust a k After obtaining a suitable fitting polynomial, the number can be substituted into the fitting polynomial to obtain the result of the fitting polynomial, that is, the historical fitting result.

[0054] Although a large number of documents are stored in the software requirement document library, it is difficult to guarantee the number of historical software requirement documents that can meet the requirements, especially when the requirements for matching two software requirement documents are very high, the number of historical requirement documents that can meet the requirements will be even smaller. In order to solve the above problems, the embodiment of the present application adopts a polynomial fitting method, which only requires a small amount of historical document data to obtain a fitting polynomial, and then a large number of historical fitting results can be obtained by substituting the number into the fitting polynomial. Therefore, the historical fitting results can be regarded as a substitute for the historical document data. Although it is not equal to the historical document data, it is infinitely close to the historical document data through polynomial fitting. In this way, the problem of insufficient historical document data can be solved, and at the same time, the deviation between the historical fitting results and the historical document data is relatively small.

[0055] Step 2205: According to the historical matching results, the initial document extraction model is trained to obtain a document extraction model.

[0056] After obtaining the historical matching results, the historical matching results can be split into a training set and a test set. The training set is used to train the initial document extraction model, and the test set is used to test the trained document extraction model. Through training and testing, the model parameters of the initial document extraction model are continuously adjusted to finally obtain the document extraction model.

[0057] Specifically, the historical matching results are split into a training set and a test set; the initial document extraction model is trained using the training set to obtain a trained document extraction model; the test set is input into the trained document extraction model to obtain a historical data model; if the historical data model meets preset conditions, the trained document extraction model is used as the document extraction model.

[0058] Whether the historical data model meets the preset conditions can be determined through the following steps: first, determine the static feature data, dynamic behavior data and constraint data of the historical data model; second, perform weighted summation on the static feature data, dynamic behavior data and constraint data to obtain the model data of the historical data model; finally, determine the similarity between the model data and the historical document data. If the similarity is higher than a preset threshold, it is judged that the historical data model meets the preset conditions. If the similarity is not higher than the preset threshold, it is judged that the historical data model does not meet the preset conditions.

[0059] Step 230: Input the data model into a code parsing module to obtain software program code.

[0060] Regarding software program code, it refers to a collection of computer data and instructions organized in a specific order to complete specific functions or solve specific problems. Software program codes are usually written by programmers using the language supported by development tools. These codes are a set of ordered numbers or letters, representing symbols of objective entities and their attributes. For example, codes written in programming languages ​​such as C++ and Java are common software program codes.

[0061] Regarding the code parsing module, it includes a template unit, an intermediate code conversion unit, a task management unit, a grammar detection unit and a code generation unit. Among them, the template unit includes a rule template and a grammar template. The intermediate code conversion unit is mainly used to convert the data model into an intermediate code, and the intermediate code refers to a code written in an interpretive language for various programming languages, such as a code written in Python, JavaScript, and Ruby. The grammar detection unit is mainly used to determine whether the grammar of the intermediate code is accurate, and to determine whether the software program code is accurate. The code generation unit is mainly used to convert the intermediate code into the software program code. The task management unit is mainly used to send the intermediate code to the grammar detection unit. The task management unit is also used to call the rule template to help the intermediate code conversion unit complete the work of converting the data model into the intermediate code, and to help the code generation unit complete the work of converting the intermediate code into the software program code. The task management unit is also used to call the grammar template to help the grammar detection unit detect whether the grammar of the intermediate code is accurate, and to detect whether the grammar of the software program code is accurate.

[0062] The data model is input into the code parsing module to obtain the software program code, which specifically includes: converting the data model into the intermediate code through the intermediate code conversion unit; sending the intermediate code to the grammar detection unit through the task management unit; judging whether the grammar of the intermediate code is accurate through the grammar detection unit, if accurate, converting the intermediate code into the software program code through the code generation unit; if inaccurate, re-converting the data model into the intermediate code through the intermediate code conversion unit until the software program code is obtained. Judging whether the software program code is accurate through the grammar detection unit, if accurate, sending the software program code to the user through the task management unit; if inaccurate, re-converting the intermediate code into the software program code through the code generation unit until the software program code is sent to the user. The rule template includes a first rule template and a second rule template, the first rule template stores a conversion rule for converting a data model into an intermediate code, and the second rule template stores a conversion rule for converting an intermediate code into a software program code; the conversion of the data model into the intermediate code by the intermediate code conversion unit includes: the data model is converted into the intermediate code by the intermediate code conversion unit according to the first rule template; the conversion of the intermediate code into the software program code by the code generation unit includes: the intermediate code is converted into the software program code by the code generation unit according to the second rule template. The syntax template includes a first syntax template and a second syntax template, the first syntax template stores the syntax of the intermediate code, and the second syntax template stores the syntax of the software program code; the determination of whether the syntax of the intermediate code is accurate by the syntax detection unit includes: the syntax of the intermediate code is accurate by the syntax detection unit according to the first syntax template; the determination of whether the software program code is accurate by the syntax detection unit includes: the software program code is accurate by the syntax detection unit according to the second syntax template.

[0063] The above method of the embodiment of the present application can achieve no human intervention in the process of converting the software requirement document into software program code. First, the software requirement document obtains the data model through the document extraction model, and then the data model obtains the software program code through the code parsing model. There is no human intervention in these two steps, which can greatly reduce the labor cost in the field of software design, and the error rate of the obtained code is low.

[0064] In several embodiments provided in the present application, the disclosed devices and methods can also be implemented in other ways. The device and method embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and a part of a module, a program segment or a code contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes 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 and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0065] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0066] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.

Claims

1. A method for automatic code generation based on a data model, characterized in that: include: Obtain software requirements documents; Inputting the software requirement document into a document extraction model to obtain a data model; Inputting the data model into a code parsing module to obtain software program code; The document extraction model is constructed and trained using support vector regression (SVR).

2. The method for automatic code generation based on a data model according to claim 1, characterized in that: The steps of obtaining the document extraction model include: According to the software requirement document, searching and obtaining historical software requirement documents in a software requirement document library; Abstracting historical document data from the historical software requirement document; According to the historical document data, an initial document extraction model is constructed using the SVR; Performing polynomial fitting on the historical document data to obtain a fitting polynomial and determine a historical fitting result; The initial document extraction model is trained according to the history matching result to obtain a document extraction model.

3. The method for automatic code generation based on a data model according to claim 2, characterized in that: The step of abstracting the historical document data from the historical software requirement document comprises: Abstracting static feature data, dynamic behavior data and constraint condition data from the historical software requirement document; The static feature data, dynamic behavior data and constraint condition data are weightedly summed to obtain the historical document data.

4. The method for automatic code generation based on a data model according to claim 2, characterized in that: The step of training the initial document extraction model according to the historical matching result to obtain the document extraction model comprises: Splitting the history matching results into a training set and a test set; Using the training set to train the initial document extraction model to obtain a trained document extraction model; Inputting the test set into the trained document extraction model to obtain a historical data model; If the historical data model meets the preset conditions, the trained document extraction model is used as the document extraction model.

5. The method for automatic code generation based on a data model according to claim 1, characterized in that: The code parsing module includes a template unit, an intermediate code conversion unit, a task management unit, a grammar detection unit and a code generation unit, and the template unit includes a rule template and a grammar template.

6. The method for automatic code generation based on a data model according to claim 5, characterized in that: The step of inputting the data model into a code parsing module to obtain software program code comprises: The data model is converted into an intermediate code by the intermediate code conversion unit; Sending the intermediate code to the grammar detection unit through the task management unit; The grammar detection unit is used to determine whether the grammar of the intermediate code is accurate. If it is accurate, the code generation unit is used to convert the intermediate code into the software program code. If it is inaccurate, the data model is converted into the intermediate code again through the intermediate code conversion unit until the software program code is obtained.

7. The method for automatic code generation based on a data model according to claim 6, characterized in that: After obtaining the software program code, the method further comprises: The grammar detection unit is used to determine whether the software program code is accurate. If it is accurate, the software program code is sent to the user through the task management unit. If it is inaccurate, the intermediate code is converted into the software program code again through the code generation unit until the software program code is sent to the user.

8. The method for automatic code generation based on a data model according to claim 6, characterized in that: The rule template includes a first rule template and a second rule template, the first rule template stores a conversion rule for converting a data model into an intermediate code, and the second rule template stores a conversion rule for converting an intermediate code into a software program code; The step of converting the data model into an intermediate code by the intermediate code conversion unit includes: The data model is converted into an intermediate code according to the first rule template by the intermediate code conversion unit; The converting the intermediate code into the software program code by the code generating unit includes: The code generation unit converts the intermediate code into the software program code according to the second rule template.

9. The method for automatic code generation based on a data model according to claim 7, characterized in that: The grammar template includes a first grammar template and a second grammar template, the first grammar template stores the grammar of the intermediate code, and the second grammar template stores the grammar of the software program code; The step of judging whether the syntax of the intermediate code is accurate by the syntax detection unit includes: Determining, by the grammar detection unit, whether the grammar of the intermediate code is accurate according to the first grammar template; The step of determining whether the software program code is accurate by the grammar detection unit includes: The grammar detection unit determines whether the software program code is accurate according to the second grammar template.

10. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; The processor is configured to execute the data model-based automatic code generation method according to any one of claims 1 to 9.