Method, device and equipment for generating software code based on design document of large model, medium and product

Through the method of generating software code based on large-model design documents, the problems of low efficiency and long cycle of traditional software project development are solved, and project code is directly generated from detailed design documents, reducing communication costs and dependencies, and improving development efficiency and shorten the development cycle.

CN119396374APending Publication Date: 2025-02-07SHANGHAI OUYE FINANCIAL INFORMATION SERVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411479569.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

Traditional waterfall software projects are inefficient in development, have long cycles and high costs, and have high communication costs between designers and developers and their dependence on developers.

Method used

Using the method of generating software code based on large-model design documents, reading front-end, back-end and database design documents, using open-source python package for segmentation and traversal processing, generating prompt words and calling the big model to generate code blocks, and finally using regular expressions Process the determination code information.

Benefits of technology

This method can directly generate project code from detailed design documents, reduce the communication costs between design and developers, reduce dependence on developers, improve development efficiency and reduce development cycle.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396374A_ABST
    Figure CN119396374A_ABST
Patent Text Reader

Abstract

The invention discloses a method, device and equipment for generating a software code based on a design document of a large model, a medium and a product, and relates to the technical field of project software development. The method comprises the following steps: reading a design document; the design document comprises a front-end detailed design document, a rear-end detailed design document and a database design document; performing segmentation traversal processing on the design document by using an open source python packet to obtain a text file, and transmitting the text file to a specified directory; reading text file contents in a specified directory by adopting python, combining the text file contents with predefined cue word template contents to generate cue words, and calling a large model to input the cue words to return a text containing code blocks; performing regular expression processing on the text by using python, and determining code information; the code information comprises a code file path name, a code package name, a file name and code content. The development efficiency can be improved, and the development period can be shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of project software development, and in particular to a method, apparatus, device, medium and product for generating software code from a design document based on a large model. Background Art

[0002] Traditional waterfall software projects are usually implemented in multiple stages, including requirements analysis, basic design, detailed design, code development, system testing, and system launch. In the detailed design stage, designers break down system modules into more fine-grained page functions, write detailed front-end and back-end design documents and database design documents for the functions, and in the development stage, developers write software code based on the design documents and development specifications. However, there are problems such as low development efficiency, long software project development cycle, and high cost. Summary of the invention

[0003] The purpose of this application is to provide a method, device, equipment, medium and product for generating software code from design documents based on a large model, which can improve development efficiency and shorten the development cycle.

[0004] To achieve the above objectives, this application provides the following solutions:

[0005] In a first aspect, the present application provides a method for generating software code from a design document based on a large model, comprising:

[0006] Read the design documents; the design documents include: front-end detailed design documents, back-end detailed design documents and database design documents;

[0007] Use an open source Python package to segment and traverse the design document to obtain a text file, and transfer the text file to a specified directory;

[0008] Using Python to read the text files in the specified directory, and combining them with predefined prompt word templates in sequence to generate prompt words;

[0009] Use python to call the large model to input prompt words and determine the text containing the code block;

[0010] Use Python to perform regular expression processing on the text containing the code block to determine the code information; the code information includes: code file path name, code package name, file name and code content.

[0011] Optionally, the design document is segmented and traversed using an open source python package to obtain a text file, and the text file is transferred to a specified directory, specifically including:

[0012] An open source python package is used to segment the design document into paragraphs to obtain a paragraph element list;

[0013] Traverse the paragraph element list to find the second-level title; the second-level title is an element with a directory depth of 1;

[0014] Merge the contents between every two second-level headings into one chapter;

[0015] Save the content corresponding to each chapter as a text file and transfer it to the specified directory.

[0016] Optionally, the content of the front-end detailed design document includes: a front-end page directory, a front-end page name, a defined layout of different areas of the front-end page, defined form fields, and a defined page interaction logic.

[0017] Optionally, the content of the back-end detailed design document includes: design information of the control layer, design information of the service logic layer, and design information of the data operation layer; the design information includes: directory, file name, input parameter data, processing logic and output parameter data.

[0018] Optionally, the content of the database design document includes: table name and defined table field information.

[0019] Optionally, the front-end detailed design document and the back-end detailed design document are organized and laid out with one chapter per page.

[0020] In a second aspect, the present application provides a device for generating software code based on a design document of a large model, comprising:

[0021] A reading module is used to read design documents; the design documents include: front-end detailed design documents, back-end detailed design documents and database design documents;

[0022] A processing module, used to use an open source Python package to segment and traverse the design document to obtain a text file, and transfer the text file to a specified directory;

[0023] A prompt word generation module is used to use Python to read the text files in the specified directory and sequentially combine them with predefined prompt word templates to generate prompt words;

[0024] The large model calling module is used to use Python to call the large model input prompt word and determine the text containing the code block;

[0025] The code information determination module is used to use Python to perform regular expression processing on the text containing the code block to determine the code information; the code information includes: code file path name, code package name, file name and code content.

[0026] In a third aspect, the present application provides a computer device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-mentioned method of generating software code from design documents based on a large model.

[0027] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned method of generating software code from a design document based on a large model.

[0028] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above-mentioned method of generating software code from design documents based on a large model.

[0029] According to the specific embodiments provided in this application, this application has the following technical effects:

[0030] The present application provides a method, device, equipment, medium and product for generating software code from design documents based on large models, which can realize the direct generation of project code from detailed design documents of the project, reduce the communication cost between designers and developers, reduce the dependence on developers, and greatly improve the efficiency of project development. And by dividing the design documents into functional page chapters and generating codes in batches by page, the problem of missing codes caused by the length limit of large model output text is reduced. Therefore, the present application can improve development efficiency and shorten the development cycle. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0032] Figure 1 A flowchart of a method for generating software code based on a design document of a large model for the present application;

[0033] Figure 2 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0035] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0036] Using big models to write code can greatly improve its capabilities. During the development phase, detailed design documents can be input into the big model, and the big model generates code, which can then be redeveloped by developers. This will greatly improve development efficiency and reduce the software project development cycle and cost. However, at this stage, big model code writing is mainly used for auxiliary programming applications. The big model generates code blocks based on a small amount of code context information or annotation predictions. The efficiency and quality of code development are still highly dependent on the subjective initiative and personal ability of developers.

[0037] like Figure 1 As shown, the present application provides a method for generating software code based on a design document of a large model, the method comprising:

[0038] Step 100: Read the design document, which includes: front-end detailed design document, back-end detailed design document and database design document.

[0039] Step 200: Use an open source Python package to segment and traverse the design document to obtain a text file, and transfer the text file to a specified directory.

[0040] Step 300: Use Python to read text files in a specified directory, and combine them with predefined prompt word templates in sequence to generate prompt words.

[0041] Step 400: using Python to call the large model to input the prompt word and determine the text containing the code block;

[0042] Step 500: Use Python to perform regular expression processing on the text containing the code block to determine the code information. The code information includes: code file path name, code package name, file name and code content.

[0043] In one embodiment, an open source python package is used to segment and traverse the design document to obtain a text file, and the text file is transferred to a specified directory, specifically including:

[0044] Use an open source Python package to split the design document into paragraphs to get a list of paragraph elements; traverse the list of paragraph elements to find the second-level title; the second-level title is an element with a directory depth of 1.

[0045] Merge the contents between every two second-level headings into one chapter; save the contents corresponding to each chapter as a text file and transfer it to the specified directory.

[0046] Among them, the content of the front-end detailed design document includes: front-end page directory, front-end page name, defined layout of different areas of the front-end page, defined form fields, and defined page interaction logic.

[0047] The content of the back-end detailed design document includes: design information of the control layer, design information of the service logic layer, and design information of the data operation layer; the design information includes: directory, file name, input parameter data, processing logic and output parameter data. The content of the database design document includes: table name and defined table field information.

[0048] The front-end detailed design document and the back-end detailed design document are organized and laid out with one chapter per page.

[0049] In practical applications, the actual operation steps of the method mentioned in this application can be as follows:

[0050] Step 1: Define the project front-end detailed design document, back-end detailed design document and database design document. The front-end detailed design document includes the front-end page directory and page name, as well as the layout definition of different areas of the page, form field definition, button definition and page interaction logic definition; the back-end detailed design document includes the directory and file name of the control layer, service logic layer, and data operation layer, as well as the definition of input parameters, processing logic and output parameters; the database design document includes the table name and table field information definition; the front-end and back-end design documents are organized as one chapter per page.

[0051] Step 2: Define the prompt word template text content for front-end and back-end code generation. The prompt word template content includes: code development specifications and code generation instructions.

[0052] Take front-end and back-end code generation as an example:

[0053] Step 3: Generate front-end Vue code:

[0054] Step 3.1: The automatic code generation system reads the front-end design document, uses the open source python package langchain.document_loaders to divide the design document into paragraphs and output a list of paragraph elements. It traverses the list of paragraph elements and finds the element with a directory depth of 1, which is the second-level title. It continues to search from the current second-level title until the next second-level title. It merges the content between every two second-level titles into a chapter, and saves the content of each chapter independently as a text file and outputs it to the specified directory.

[0055] Step 3.2: Use Python to read all text files in the specified directory output by step 3.1, traverse the text file list, read the content of the text file and append the file content to the end of the front-end code generation prompt word template text defined in step 2, generate a complete prompt word, call the big model to input the prompt word, and return the json string from the big model to get the text with the key content. The text content includes the package name, file name and code content of the page front-end code, such as:

[0056] src / views / EWHB01 / index.vue

[0057] ```

[0058] vue

[0059] Code content

[0060] ```

[0061] Step 3.3: Use Python to execute the regular expression ((\S+)\n\s*```[^\n]*\n(.+?)```) on the text output in Step 3.2 to get the page front-end code file path name and code content. Use Python to create a file according to the file path name and write the code content into the file to complete the page front-end code generation.

[0062] Step 4: Generate page backend java code:

[0063] Step 4.1: Use the same method as step 3.1 to split the contents of the backend design document chapters and output them to the specified directory.

[0064] Step 4.2: Use Python to read all text files in the specified directory output by step 4.1, traverse the text file list, read the content of the text file and append the file content to the end of the backend code generation prompt word template text defined in step 2, generate a complete prompt word, call the big model to input the prompt word, and return the json string from the big model to get the text with the key content. The text content contains the package name, file name and code content of the page backend code, including controller, service and mapper, such as:

[0065] src / main / java / com / ouyeelf / rm / user / controller / UserMaintController.java

[0066] ```java

[0067] Code content

[0068] ```

[0069] Step 4.3: Use Python to execute the regular expression ((\S+)\n\s*```[^\n]*\n(.+?)```) on the text output in Step 4.2 to obtain multiple groups of page backend code file path names and code contents (i.e., the file path names and code contents of controller, service, and mapper). For each group, use Python to create a file according to the file path name and write the code content into the file to complete the page backend code generation.

[0070] Based on the same inventive concept, the embodiment of the present application also provides a device for generating software code from a design document based on a large model for implementing the method for generating software code from a design document based on a large model involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of one or more devices for generating software code from a design document based on a large model provided below can be referred to the limitations of the method for generating software code from a design document based on a large model above, and will not be repeated here.

[0071] In an exemplary embodiment, a device for generating software code based on a design document of a large model is provided, comprising:

[0072] The reading module is used to read the design documents; the design documents include: front-end detailed design documents, back-end detailed design documents and database design documents.

[0073] The processing module is used to use the open source Python package to segment and traverse the design documents, obtain text files, and transfer the text files to the specified directory.

[0074] The prompt word generation module is used to use Python to read text files in a specified directory and combine them with pre-defined prompt word templates to generate prompt words.

[0075] The large model calling module is used to use Python to call the large model input prompt words and determine the text including the code block;

[0076] The code information determination module is used to use Python to perform regular expression processing on the text containing the code block to determine the code information; the code information includes: code file path name, code package name, file name and code content.

[0077] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 2 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store software code data generated based on design documents. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for generating software code based on a design document of a large model is implemented.

[0078] Those skilled in the art will understand that Figure 2 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components. In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0079] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0080] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0081] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0082] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0083] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.

[0084] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0085] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.

Claims

1. A method for generating software code from a design document based on a large model, characterized in that: The method for generating software code based on design documents comprises: Read the design documents; the design documents include: front-end detailed design documents, back-end detailed design documents and database design documents; Use an open source Python package to segment and traverse the design document to obtain a text file, and transfer the text file to a specified directory; Using Python to read the text files in the specified directory, and combining them with predefined prompt word templates in sequence to generate prompt words; Use python to call the large model to input prompt words and determine the text containing the code block; Use Python to perform regular expression processing on the text containing the code block to determine the code information; the code information includes: code file path name, code package name, file name and code content.

2. The method for generating software code from design documents based on a large model according to claim 1, characterized in that: Use an open source Python package to segment and traverse the design document to obtain a text file, and transfer the text file to a specified directory, specifically including: An open source python package is used to segment the design document into paragraphs to obtain a paragraph element list; Traverse the paragraph element list to find the second-level title; the second-level title is an element with a directory depth of 1; Merge the contents between every two second-level headings into one chapter; Save the content corresponding to each chapter as a text file and transfer it to the specified directory.

3. The method for generating software code from design documents based on a large model according to claim 1, characterized in that: The content of the front-end detailed design document includes: front-end page directory, front-end page name, defined layout of different areas of the front-end page, defined form fields, and defined page interaction logic.

4. The method for generating software code from design documents based on a large model according to claim 1, characterized in that: The content of the back-end detailed design document includes: design information of the control layer, design information of the service logic layer, and design information of the data operation layer; the design information includes: directory, file name, input parameter data, processing logic and output parameter data.

5. The method for generating software code from design documents based on a large model according to claim 1, characterized in that: The content of the database design document includes: table name and defined table field information.

6. The method for generating software code from design documents based on a large model according to claim 1, characterized in that: The front-end detailed design document and the back-end detailed design document are organized and laid out with one chapter per page.

7. A device for generating software code based on a design document of a large model, characterized in that: The device for generating software code based on the design document includes: A reading module is used to read design documents; the design documents include: front-end detailed design documents, back-end detailed design documents and database design documents; A processing module, used to use an open source Python package to segment and traverse the design document to obtain a text file, and transfer the text file to a specified directory; A prompt word generation module is used to use Python to read the text files in the specified directory and sequentially combine them with predefined prompt word templates to generate prompt words; The large model calling module is used to use Python to call the large model input prompt word and determine the text containing the code block; The code information determination module is used to use Python to perform regular expression processing on the text containing the code block to determine the code information; the code information includes: code file path name, code package name, file name and code content.

8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method for generating software code from design documents based on a large model as described in any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for generating software code from design documents based on a large model described in any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for generating software code from design documents based on a large model described in any one of claims 1 to 6 is implemented.