A method and device for code and requirement alignment review based on a large model

By converting rich text requirement documents into structured text and leveraging the semantic understanding of large models, the problem of alignment and consistency review between requirements and code in large-scale software projects is solved. This enables fast and accurate automated review, improves efficiency and accuracy, and supports the traceability of code issues.

CN122364073APending Publication Date: 2026-07-10SHANGHAI AEROSPACE COMP TECH INST

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI AEROSPACE COMP TECH INST
Filing Date
2026-03-24
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing technologies struggle to quickly and accurately align and review requirements and code in large-scale software projects, especially when dealing with massive amounts of code and complex requirement documents, resulting in information fragmentation and inefficient review processes.

Method used

By converting rich text requirement documents into structured text, leveraging the semantic understanding and chunking techniques of large models, and combining character count thresholds and semantic relevance retrieval, a deep mapping relationship between requirements and code is established for automated code review.

Benefits of technology

It enables rapid alignment and efficient review of requirements and code in large-scale software projects, improves review accuracy and efficiency, fills the blind spots of manual review, and improves the efficiency of fixing problem code by leaving traces in the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122364073A_ABST
    Figure CN122364073A_ABST
Patent Text Reader

Abstract

This invention discloses a review method for aligning code and requirements based on a large model, comprising: obtaining a first document in structured text format from a requirement document in rich text format through format conversion; obtaining a set of requirement function point identifiers and a set of requirement fragments from the first document through cleaning and preprocessing and semantic understanding of the large model; segmenting the project source code according to a preset code syntax structure dimension to obtain a set of code fragments and storing it in a database; parsing the code fragments based on the requirement function point identifiers and the set of requirement function point identifiers using preset prompts from the large model to obtain a functional summary of the project code file; constructing a code fragment group according to a character count threshold set by the context window of the large model, and constructing a requirement-code data tuple by calculating the relevance between requirements and code; obtaining the review result through functional review of the requirement function point identifier set data tuple and storing it in a database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of software testing and large model inference applications, and particularly relates to a review method and apparatus for aligning code with requirements based on large models. Background Technology

[0002] With the rapid development of software engineering, the scale and complexity of software systems are growing exponentially. Software testing, as a key link in ensuring software quality, has a mature process system. However, in the software development process, reviewing the consistency between software design requirements and code implementation still faces significant challenges. Currently, this stage mainly relies on manual reading of design documents, analysis of source code, and establishment of traceability relationships between requirements and code. This traditional manual review method has obvious limitations: on the one hand, facing complex communication protocols, profound mathematical formulas, and highly specialized business logic, manual review requires extremely high professional knowledge and is prone to oversights; on the other hand, as project scale expands, the number of software requirement documents and source code becomes enormous, making manual comparison time-consuming and labor-intensive, resulting in low review efficiency and failing to meet the testing needs of rapid iterative development.

[0003] In recent years, artificial intelligence technology, especially large language models, has made significant progress, providing new technical pathways for intelligent software testing thanks to its powerful semantic understanding and code analysis capabilities. Existing technologies already include applications such as code correctness checking and unit test case generation using large models. However, when applying large models to full-scale code reviews of large-scale projects, existing technologies face significant technical bottlenecks: First, there is a limitation on the length of the context input. Large models generally have an inherent limitation in single-pass throughput. When faced with large-scale projects with hundreds of thousands of lines of code and lengthy requirement documents, it is impossible to input all the information into the model for processing at once.

[0004] Second, information fragmentation leads to misunderstandings. Existing technologies often employ simple truncation or segmented input methods, which disrupt the integrity of code logic and the continuity of the requirement context. This results in "information silos" appearing in large models during analysis, making it difficult to accurately understand complex logical relationships across files and modules, and drastically reducing the accuracy of review.

[0005] Third, there is a lack of systematic review schemes for requirement-code consistency. Current research on large-scale model testing mostly focuses on syntax error checking or test case generation for local code snippets, neglecting the technical challenge of how to quickly and accurately establish the mapping relationship between requirement snippets and code snippets at the project level, and then conduct functional consistency reviews based on this.

[0006] In summary, how to achieve rapid alignment and efficient review of requirements and code in large-scale software projects under the premise of limited computing resources and constraints on single input of large models is a technical problem that urgently needs to be solved. Summary of the Invention

[0007] To address the aforementioned issues, this invention proposes a code and requirement alignment review method and apparatus based on a large model. By automatically converting rich text requirement documents into structured standard text, it solves the problem that unstructured requirements are difficult for machines to parse. Utilizing large model semantic understanding and intelligent block segmentation technology, it overcomes the limitations of the model context window, achieving deep alignment between requirement intent and code logic. Simultaneously, through experimentally verified threshold parameter configuration, it maximizes review accuracy while ensuring retrieval speed, ultimately achieving automated code review.

[0008] A first aspect of the present invention provides a review method for aligning code with requirements based on a large model, comprising: The first document, in structured text format, is obtained by converting the requirement document, which is in rich text format. Based on the first document, a set of required function point identifiers and a set of required fragments are obtained through cleaning and preprocessing and semantic understanding of the large model. Based on the set of required function point identifiers and the set of required fragments, mapping data is obtained through mapping and stored in the database. The project source code is segmented according to the preset code syntax structure to obtain a set of code snippets and stored in the database; Based on the set of code snippets, the function summary of the project code file is obtained by parsing the preset prompt words of the large model; The search is performed based on the set of requirement fragments, the set of code fragments, and the functional summary. A code fragment group is constructed according to the character number threshold set by the large model context window limit. A requirement-code data tuple is constructed by calculating the relevance between requirements and code. Based on the data tuples, the review results are obtained through the large model function review and stored in the database.

[0009] Preferably, the step of obtaining a first document in structured text format from a requirement document in rich text format through format conversion further includes: Obtain the structured data carrier of the requirement document, and parse the structured data carrier into a traversable node tree; Based on the node tree, paragraph nodes and table nodes are obtained by traversing child nodes and filtering out non-core nodes such as styles, bookmarks, and controls. Input the paragraph node, and obtain the paragraph text in standard format through recursive element extraction, formula format conversion and style matching processing; Input the table node, and obtain a standard table by extracting cell attributes and traversing and filling processes; Input the image node in the node tree, and obtain the image tag and relative position data containing the path by extracting the embedding identifier and matching the media resource path; Based on the paragraph text, the standard table, and the image tags, the first document is obtained by cleaning up redundant formatting and merging line breaks.

[0010] Preferably, the step of obtaining standard-formatted paragraph text further includes: Recursively extract text, formulas, images, and line breaks from a paragraph, convert full-width spaces to standard spaces, and convert line breaks to preset tags; Detect the parity of formula markers to achieve cross-paragraph formula completion, and convert OMML format formulas to LaTeX format adapted to rendering rules; Generate Markdown headings at the corresponding style level based on style-level numbers, or generate indented Markdown lists based on list levels.

[0011] Preferably, the step of obtaining the standard form further includes: The steps of inputting the table node and obtaining a standard table by extracting cell attributes and traversing and filling the table specifically include: Extract the column span and row merging status of table cells to generate a cell attribute matrix; Iterate through the cells to extract text, fill in empty cells spanning columns or rows based on the cell attribute matrix, and output a standard Markdown table or an HTML table with merge attributes.

[0012] Preferably, the steps of obtaining the required function point identifier set and the required fragment set further include: Based on the first document, redundant information about the requirements is removed by performing data cleaning operations to obtain the requirements content; Semantic understanding processing is performed using preset prompt words to obtain a set of requirement function point identifiers and a set of requirement fragments after being broken down by function point dimension; Based on the set of requirement fragments and the set of requirement function point identifiers, a mapping relationship is established through the requirement decomposition of the large model, and the mapping data is stored in the database.

[0013] Preferably, the step of segmenting the project source code according to a preset code syntax structure to obtain a set of code snippets further includes: A set of chunking patterns is constructed based on the syntactic features of the project source code. Based on each chunking pattern in the set of chunking patterns, chunking rules containing semantic feature matching logic and chunk end position determination logic are constructed. Based on the matching priority order, each line of code in the project's source code is processed by block matching rules. Specifically, if a match is successful, the start and end positions of the block are recorded; the code block is obtained based on the start and end positions and marked as identified; if a match is unsuccessful, single-line merging or unclassified marking is performed. Traverse the processing status of the project's source code and update the category identifier. The specific rule is: forcibly mark lines of code that are not covered by matching rules as general single-line blocks. The acquired code blocks are stored in the database to form the code fragment set.

[0014] Preferably, the step of constructing the requirement-code data tuple further includes: Iterate through the set of requirement fragments to obtain the current requirement fragment; Input the current requirement fragment, and retrieve the target code file by calling the large model and searching in the functional summary based on preset prompts; Input the code snippet corresponding to the target code file, and construct a code snippet group based on the character count threshold set by the large model context window limit; Input the code snippet group, and use a large model to perform semantic relevance retrieval to obtain retrieval results including file name, start and end line numbers of the code, and degree of relevance; Based on the search results, the following filtering process is performed: code snippets with a relevance greater than a preset relevance threshold are retained; if no such snippet exists, the code snippet with the highest relevance is retained, and the requirement-code data tuple is obtained and stored in the database.

[0015] Preferably, the character count threshold set according to the large model context window limit is configured as the maximum character limit determined based on the large model retrieval speed verification; the preset relevance threshold is configured as the lower limit of relevance determined based on the alignment accuracy verification.

[0016] Preferably, the step of obtaining the review results through large model functional review further includes: Based on the data tuples, the consistency review results of requirement fragments and code fragments are obtained through a large model; Based on the data tuples, the compliance review results of the algorithm logic, constant values, variable values, and boundary ranges of the reviewed code snippets are obtained through a large model; Based on the data tuples, the risk assessment results of potential risks and vulnerabilities in the code snippets are obtained through large-scale static analysis.

[0017] A second aspect of the present invention provides a review apparatus for aligning code with requirements based on a large model, comprising: The conversion module is used to convert a requirement file in rich text format to a first document in structured text format. The processing module is used to obtain a set of requirement function point identifiers and a set of requirement fragments based on the first document through cleaning and preprocessing and semantic understanding of the large model; and to obtain mapping data and store it in the database based on the set of requirement function point identifiers and the set of requirement fragments. The code segmentation module is used to divide the project source code according to the preset code syntax structure dimensions, obtain a set of code snippets and store them in the database; The summary extraction module is used to parse the code snippets based on the set of code snippets using preset prompts from the large model to obtain a functional summary of the project code files. The alignment module is used to perform retrieval based on the set of requirement fragments, the set of code fragments, and the functional summary. It is used to construct code fragment groups according to the character number threshold set by the large model context window limit, and to construct requirement-code data tuples by calculating the relevance between requirements and code. The review module is used to obtain review results based on the data tuples through the large model function and store them in the database.

[0018] Compared with the prior art, the present invention has the following beneficial effects: By parsing the document's structured structure and filtering non-core nodes, automatic cleaning of rich text requirements is achieved. Cross-paragraph completion solves the problem of complex formulas not being correctly understood by computers in code review scenarios; by generating cell attribute matrices to handle merged cells, the integrity and structure of the required table information are ensured, providing high-quality standard input data for large models.

[0019] By leveraging a large model, requirements are broken down into a set of functional point identifiers and a set of requirement fragments, and the code is transformed into a functional summary. During the retrieval phase, initial screening is performed on the functional summaries, and then semantic relevance retrieval is combined to construct requirement-code data tuples, establishing a deep semantic mapping between requirement intent and code implementation, thereby improving the accuracy of alignment.

[0020] By setting a maximum upper limit for the number of characters based on retrieval speed and a lower limit for relevance based on alignment accuracy, this configuration achieves a balance between processing speed and review accuracy. It avoids slow response times due to excessively long inputs while ensuring the reference value of the selected code snippets.

[0021] By setting matching priorities and fallback logic, the segmented code fragments retain their complete syntactic structure and semantic logic. This provides a foundation for generating accurate "functional summaries" for large models, thereby improving the quality of subsequent retrieval and alignment.

[0022] This solution not only undergoes consistency checks, but also compliance checks on algorithm logic, constant values, variable values, and boundary ranges, and even includes static analysis to identify risks and vulnerabilities. This comprehensive, multi-dimensional review mechanism effectively compensates for the blind spots of manual review.

[0023] The device stores mapping data, code snippet sets, data tuples, and review results in the database through various modules, enabling traceability and auditability of the entire review process. This allows developers to quickly locate the filenames and start and end line numbers of problematic code, improving repair efficiency. Attached Figure Description

[0024] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings, wherein: Figure 1 This is the main flowchart of the examination method in this invention; Figure 2 This is a flowchart illustrating one implementation of the examination method in this invention; Figure 3 This is a flowchart illustrating the implementation of requirement decomposition for the large model in this invention. Figure 4 This is a flowchart illustrating an implementation of output information for aligning requirements and code in a large model in this invention. Figure 5 This is a flowchart illustrating the implementation of requirement and code alignment in the large model of this invention. Figure 6 This is a flowchart illustrating an implementation process for code review of the large model in this invention. Detailed Implementation

[0025] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. The advantages and features of the present invention will become clearer from the following description and claims. It should be noted that the drawings are all in a very simplified form and use non-precise ratios, and are only used to facilitate and clarify the illustration of the embodiments of the present invention.

[0026] It should be noted that all directional indicators (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indicator will also change accordingly.

[0027] First Embodiment See Figures 1-6 The first aspect of the present invention provides a review method for aligning code with requirements based on a large model, comprising: The first document, in structured text format, is obtained by converting the requirement document, which is in rich text format. Based on the first document, the required functional point identifier set and the required fragment set are obtained through cleaning and preprocessing and semantic understanding of the large model. Based on the required functional point identifier set and the required fragment set, the mapping data is obtained through mapping and stored in the database. The project source code is segmented according to the preset code syntax structure to obtain a set of code snippets and stored in the database; Based on the code snippet set, the function summary of the project code file is obtained by parsing the preset prompt words of the large model; The search is based on the set of requirement fragments, the set of code fragments, and the functional summary. The code fragment group is constructed according to the character number threshold set by the large model context window limit, and the requirement-code data tuple is constructed by calculating the relevance between requirements and code. Based on data tuples, the review results are obtained through large model function review and stored in the database.

[0028] By converting rich text requirement documents into structured text format first documents, this approach solves the problems of inconsistent requirement document formats and the difficulty of automatically parsing unstructured text by computer programs in traditional review processes. It eliminates redundant formatting interference, provides input for subsequent large-scale model understanding, and reduces manual processing costs. When constructing code snippet groups, an innovative character count threshold based on the large-scale model's context window is introduced. This allows for adaptive and dynamic assembly of code snippets, avoiding information truncation or errors caused by excessively long input exceeding the model's processing limits, and preventing context loss due to insufficient input, thus ensuring the stability and effectiveness of the large-scale model retrieval process. This solution leverages the semantic understanding capabilities of the large-scale model to first generate a set of requirement snippets and code function summaries, and then construct requirement-code data tuples by calculating relevance. Based on semantic-level alignment, it accurately identifies the correspondence between requirement intent and code implementation logic, effectively solving matching errors caused by lexical differences in traditional methods and significantly improving the accuracy of review results. From requirement transformation, slicing, summary extraction, alignment to the storage of final review results, the entire code review process is fully automated. Storing review results in a database ensures process traceability, enabling developers to quickly locate issues and effectively overcoming the shortcomings of manual review, such as low efficiency and incomplete coverage. Its key features include effective preprocessing and regular expression-based code structuring strategies for requirements documents and project code, ensuring the integrity and continuity of knowledge. Furthermore, through code summarization and the construction of code snippet groups, it can more quickly and accurately align requirements with code based on a large model, thereby significantly improving the efficiency and quality of reviewing project code using a large model.

[0029] This application specifically includes the following steps: S100 document format conversion; S200 requirements decomposition; S300 code structuring; S400 code summary; S500 requirements and code alignment; S600 code review.

[0030] See Figures 2-6 An example of an embodiment of the present invention is provided below: See Figure 2 The present invention includes the following steps: document format conversion, requirement decomposition, code structuring, code summarization, requirement and code alignment, and code review, as detailed below: Step a: Document format conversion The original document format of the project under test is Word. Use a Word-Markdown document format conversion tool to convert the Word document into Markdown format.

[0031] Step b: Requirements decomposition Step b1: The converted document needs to be cleaned and preprocessed to remove irrelevant content such as cover pages, approval forms, and referenced documents, and only retain the main text content related to the design requirements.

[0032] Step b2: The preset prompts are as follows: #Task Description As a software testing expert, please strictly adhere to the following requirements when processing input Markdown format requirements documents: 1. Decomposition Rules: Refer to the document's table of contents and subheading hierarchy, and break the entire document down into independent functional points according to the content logic, ensuring that all content is covered and no paragraphs or descriptions are omitted; 2. Output structure: Each function point should include a function point name and a corresponding document fragment. The function point name should be a concise summary of the core function, and the corresponding document fragment should be a direct quote from the original text in the requirements document. 3. Formatting Requirements: Results must be returned strictly according to the following format: [Function Point Name 1][Corresponding Original Fragment 1 in the Requirements Document], [Function Point Name 2][Corresponding Original Fragment 2 in the Requirements Document], ... 4. Additional notes: If the document does not have a clear table of contents or subheadings, break down the functional points according to the content logic, and list the related functional points of different paragraphs together.

[0033] #enter The requirements document contains the following: {req_content}” The large model should understand the content of the requirements document based on prompts and output the decomposed functional points and corresponding requirement fragments in a specified format. (See also...) Figure 3 It has been automatically divided into three functional points: gcd (greatest common divisor), isPrime (prime number determination), and factorial (factorial calculation).

[0034] Step b3: Save the requirements decomposition results output by the large model to the database one by one.

[0035] Step c: Code structuring Step c1: Determine the chunking pattern and sort the chunking patterns according to the priority of multi-line comments, function definitions, class and structure definitions, preprocessor directive blocks (such as multi-line structures like if statements), single-line comments, header files, single-line preprocessor directives, etc.

[0036] Step c2: Design regular expressions for different block patterns.

[0037] Step c3: Traverse all lines of code to try to match known block patterns, and save the code snippets corresponding to the block patterns to the database.

[0038] Repeat step c3 until all lines of code in all files in the project have been matched and saved.

[0039] Step d: Code Summary The code files are input one by one into a large model, with preset prompts. Leveraging the model's analytical and comprehension capabilities, a detailed functional description of each code file is obtained and stored in a database. To reduce the large model's retrieval time, the retrieval scope is not all code, but rather only relevant code files are retrieved based on code summaries. The preset prompts are as follows: #Task Description As a software code review expert, please analyze the input code strictly according to the following requirements: 1. Based on the provided code, understand and analyze the overall functionality of the code and the functions of the different code blocks it contains; 2. Output structure: Note that you should not output the source code, but only output a paragraph that includes an overview of the overall code file's functionality and the core functions of each code block; #enter The code file content is as follows: {code_content} " Step e: Align requirements with code Step e1: Traverse the database and retrieve one required fragment at a time.

[0040] Step e2: For each requirement fragment, preset prompt words are used, and the large model is used to find the most relevant code files in the code summary database of the project according to the prompt words.

[0041] Step e3: Considering the limited amount of data that a large model can read and process at one time, and also taking retrieval speed into account, the code snippets from several of the most relevant code files in Step e2 are extracted sequentially, with a limit of no more than 35,000 characters, to form code snippet groups, ensuring that the code snippets within each group are complete. Ultimately, all code snippets will form several code snippet groups.

[0042] Step e4: For each requirement fragment, iterate through the code fragment group, using preset prompts. Utilize the large model to retrieve the code fragment most relevant to the requirement from the given code fragment group. The large model outputs the filename, start and end line numbers, and relevance level in a specified format, and records this information. The preset prompts are as follows: "You are a seasoned expert in programming."

[0043] #Task Given a Markdown-formatted requirement and a list of code blocks containing several dictionary elements (each dictionary element is formatted as "filename:..., start and end line numbers:..., code content:..."), please retrieve the code content related to the requirement from the **code content** of each element in the list. Return a list where each item is a code block, containing only the **filename** and **line number range**, excluding the code content. The results should strictly adhere to the following JSON format: json [{{"file":filename,"range":[start line number, end line number],"similarity":similarity}},...] ``` #hint 1. Return a list, even if it contains only one element, and try not to return an empty list.

[0044] 2. The list items should only include the filename, line number range, and similarity score. The similarity score refers to the relevance between the requirement and the code snippet, and the value is a two-decimal-place number in the range [0,1]. The similarity score needs to be discriminative.

[0045] 3. Do not provide any other thoughts or explanations.

[0046] 4. "Relevant" refers to code that implements the functionality or logic described in the requirements. Pay attention to finding the most relevant code. If there is no completely corresponding code, you can return an empty list.

[0047] #enter The requirements are as follows: {req_content} The code block list is as follows: {code_content}” See Figure 4 The large model successfully located the input requirement, which is consistent with the code snippet in the code / sorting_algorithms.cpp file with line numbers in the range [3,13], and the similarity is 0.95.

[0048] Step e5: Repeat step e4 until all code snippet groups have been traversed. Filter the code snippets based on their "relevance" information. The specific filtering rule is: retain code snippets with a relevance greater than 0.9; if no such snippet exists, retain the snippet with the highest relevance. Record the filtered code snippets with high relevance as the corresponding code snippets for the required requirement, forming a requirement-code data tuple, and save it to the database.

[0049] Step e6: Repeat steps e2-e5 above until all requirement fragments in the database have been matched.

[0050] See Figure 5 The large model was successfully aligned to the corresponding code snippets based on the three functionalities: gcd (greatest common divisor), isPrime (prime number determination), and factorial (factorial calculation).

[0051] Step f: Code review The system iterates through the requirement-code data tuple. For each element in the requirement-code data tuple, a pre-defined prompt is used. A large model is then used to review the consistency between the requirement fragment and the code fragment, as well as the correctness and standardization of the code implementation. The review results are stored in the database. The pre-defined prompts are as follows: #Task Description As an aerospace software quality review expert, please review the given requirements document snippet and related code snippets, as follows: 1. Generate review and analysis process: (1) Analyze whether the input requirement fragments and code fragments are related, and analyze the consistency between the requirements and the code implementation in detail, as specifically as possible; (2) Please pay attention to the code's functionality, algorithm, parameters, variables, security, and logic, focusing on the following aspects: - Functional consistency: Does the code implement the functions described in the requirements? - Algorithm Consistency: Does the implemented algorithm match the requirements description? Has the formula logic in the requirements been correctly implemented? Pay attention to operators and numerical values. - Parameter consistency: Ensure constant / variable values ​​meet requirements, paying attention to signs, precision, and numerical values. - Variable value consistency: Do the initial values ​​and ranges of variables meet the requirements? - Consistency of boundary range: Ensure the correctness of the domain of the piecewise function, paying attention to open and closed intervals. For example, Q<100 cannot be written as Q<=100. - Potential risks and vulnerabilities (3) The analysis process should be detailed, clear, specific and comprehensive, and should include relevant code and requirements.

[0052] 2. Generate Issue Tickets: If any inconsistencies are found, or if there are issues with the code regarding functionality, algorithms, parameters, variables, security, or logic, please note that **a separate issue ticket will be generated for each issue**, i.e., a list of `issue` entries will be created. If the code fully meets the requirements, the issue ticket section will be null.

[0053] #Output Format Please strictly follow the following JSON format to return the results. Do not add any additional explanations or descriptions. The line numbers must be output with reference to the start and end line numbers of the input code.

[0054] json {{ "review_process": "This is a detailed thought process, broken down into multiple steps, clearly explaining the logic of your analysis and deduction..." "issue":[{{ "level":"high"|"medium"|"low", "summary":"A summary of the issues", "description": "At line number [of line number] of line [function name] in [file name], the program implementation is [specific code implementation], while the requirement in the document [chapter number] is [requirement description]. The implementation and requirement are inconsistent because of [technical analysis]." }},...] }} ``` **Example**: -If there are no problems: json {{ "review_process": "The code functionality is completely consistent with the requirements document, and there are no defects in the code. (Explain your thought process, breaking it down into multiple steps, and clearly articulate the logic of your analysis and derivation.)" "issue":null }} ``` -If there are any problems: json {{ "review_process":"During the review process, it was found that when the input is a negative number, the requirements document requires a return value of 0, but the code implementation returns 1, which does not conform to the requirements. (Explain your thought process, breaking it down into multiple steps, and clearly stating the logic of your analysis and deduction.)" "issue":[{{ "level":"medium", "summary":"The factorial function's handling of negative inputs is inconsistent with the requirements." "description": "In the 'factorial' function of 'algorithms / math_algorithms.cpp', lines 15-23, the program implementation is `if(n<0)return1;`, while Chapter 2 of the math_algorithms.md document requires `return 0 when n is negative`. The implementation is inconsistent with the requirement because the code incorrectly returns 1 for negative input numbers." }},...] }}``` **End of Example** #enter ##Requirement Fragment {requirement} ##Related Code Snippets {related_code}” See Figure 6 The large model successfully reviewed the "gcd" function and found that "the gcd function may enter an infinite loop when processing negative inputs," and gave specific review comments and the severity level of the problem.

[0055] Preferably, the step of obtaining a first document in structured text format from a requirement document in rich text format through format conversion further includes: Obtain the structured data carrier of the requirements document and parse the structured data carrier into a traversable node tree; Paragraph and table nodes are obtained by traversing child nodes and filtering out non-core nodes such as styles, bookmarks, and controls based on the node tree; Input paragraph nodes, and obtain standard formatted paragraph text through recursive element extraction, formula format conversion, and style matching. Input a table node, and obtain a standard table by extracting cell attributes and traversing and filling it. The image nodes in the input node tree are used to extract the embedded identifiers and match the media resource paths to obtain the image tags and relative position data containing the paths. Based on paragraph text, standard tables, and image tags, the first document is obtained by cleaning up redundant formatting and merging line breaks.

[0056] By filtering out non-core nodes such as styles, bookmarks, and controls, and cleaning up redundant formatting, we effectively eliminated distracting information in rich text documents that was only for display but did not contribute to semantic understanding. This not only reduced the waste of invalid data on large model token resources but also avoided format noise from misleading the model's semantic understanding, improving the accuracy of understanding the requirements. By recursively extracting elements and converting formula formats, formulas in the document that were difficult to parse by conventional tools were transformed into standard formats, solving the problem that mathematical logic in the requirements document could not be recognized and reused by machines. By extracting cell attributes and performing traversal filling, we can accurately restore the structural features of tables, such as merged cells and row and column relationships, ensuring the logical integrity of table data and avoiding ambiguity in requirements caused by table structure damage. By extracting embedded identifiers and matching media resource paths, we obtained image tags containing paths, establishing an index relationship between document text and external media resources. This allows subsequent review processes to rely not only on text but also on image resources, ensuring the integrity and traceability of requirements information. This method unifies the heterogeneous data such as complex paragraphs, tables, and images in rich text into a first document, providing a standard and unified data input interface for subsequent data cleaning and semantic understanding steps, thereby reducing the complexity and error probability of subsequent processing.

[0057] Specifically, taking one example from this embodiment as an illustration: In step S100, the document format is the original document format of the project under test. If the software development requires a Word document, it needs to be converted to Markdown format because Word documents contain a large amount of rich text content such as formulas and tables, which cannot all be directly used as input content for a large model. Using a Word-Markdown document format conversion tool to convert the Word document to Markdown format includes the following steps: Step S110: Initialization processing. The Word document to be converted (based on OOXML format) is parsed using an external input method (Python's io.StringIO() method) to obtain the corresponding XML text. This XML text is the structured data carrier of the document content. The XML text is parsed into a traversable node tree. Step S120: Document core node traversal. Locate the nodes in the XML tree (the core content of the Word document), traverse all their child nodes, filter out non-core nodes such as paragraph styles, bookmarks, and content controls, and retain only paragraphs (…). ),sheet( <tbl>The nodes are then processed further. Step S130: Paragraph node transformation; Text extraction: Recursively extract text, formulas, images, line breaks, and other elements within the paragraph, replacing full-width spaces with newlines and converting line breaks to newlines. Page breaks converted to custom< / tbl> Tags; Formula processing: Detect the parity of formula markers $ to complete formulas across paragraphs; Convert OMML format formulas to LaTeX format, adapt to KaTeX rendering rules (adjust array format, spacing, etc.), wrap $ to generate Markdown formulas; Style matching: Heading styles generate corresponding level Markdown headings based on style numbers (1-8), if the number is greater than 8, output plain text; List styles generate indented Markdown unordered lists based on list levels; Normal styles output according to standard Markdown paragraph format. Step S140: Table node conversion; Extract column span, row merging status, and number of merged rows from table cells, generate a cell attribute matrix; If Markdown table is selected: Generate header separators based on column number, traverse cells to extract text, fill in empty cells across columns / row ends, and output a standard Markdown table; If HTML table is selected: Generate a unique ID for the table, traverse cells to add colspan / rowspan attributes, skip merged cells, and output an HTML table compatible with complex merging scenarios. Step S150: Image node conversion; From <drawing> / <object>The node extracts the image embedding ID and matches it with the image path in the media resource dictionary. A unique ID is generated for each image, and the result is output. Tags (including paths) are embedded into the corresponding positions in the Markdown. Step S160: Result optimization; after conversion, clean up consecutive line breaks in the result text (merge them into standard double line breaks), remove leading and trailing whitespace, and output formatted Markdown text.

[0058] Preferably, the step of obtaining standard-formatted paragraph text further includes: Recursively extract text, formulas, images, and line breaks from a paragraph, convert full-width spaces to standard spaces, and convert line breaks to preset tags; Detect the parity of formula markers to achieve cross-paragraph formula completion, and convert OMML format formulas to LaTeX format adapted to rendering rules; Generate Markdown headings at the corresponding style level based on style-level numbers, or generate indented Markdown lists based on list levels.

[0059] By detecting the parity of formula markers to achieve cross-paragraph completion, the problem of long formulas being fragmented was solved, ensuring the integrity and parsability of the mathematical logic in the requirements. Standardizing spaces and line breaks, and converting OMML to LaTeX format, eliminated formatting noise interference, improving the semantic understanding accuracy of large models for complex text. Generating Markdown headings and indented lists at the style level accurately preserved the hierarchical logical structure of the document, enhancing the semantic relevance of the functional modules.

[0060] Preferably, the step of obtaining the standard form further includes: The specific steps for obtaining a standard table by inputting a table node, extracting cell attributes, and iterating through and filling the table include: Extract the column span and row merging status of table cells to generate a cell attribute matrix; Iterate through the cells to extract text, fill in empty cells across columns or at the end of rows based on the cell attribute matrix, and output a standard Markdown table or an HTML table with merge attributes.

[0061] By extracting the cell attribute matrix and restoring the merged structure, the problem of disordered row and column relationships in complex tables was resolved, ensuring the logical integrity of the required table data. Actively filling in empty cells to repair structural gaps avoided parsing errors caused by malformed tables, improving the accuracy and stability of understanding large models. Supporting Markdown or HTML output formats, it flexibly adapts to various scenarios such as semantic analysis of large models and front-end display, enhancing the versatility of the technical solution.

[0062] See Figure 3 Preferably, the steps of obtaining the required function point identifier set and the required fragment set further include: Based on the first document, redundant information about the requirements is removed by performing data cleaning operations to obtain the requirements content. Semantic understanding processing is performed using preset prompt words to obtain a set of requirement function point identifiers and a set of requirement fragments after being broken down by function point dimension; Based on the set of requirement fragments and the set of requirement function point identifiers, a mapping relationship is established through the requirement decomposition of the large model, and the mapping data is stored in the database.

[0063] S200: The first document comes from the requirements document of the project under test. The document is correct and standardized. Based on the content of the document, the software development requirements document is decomposed into several requirement fragments according to functional points using a large model. The specific steps include the following: Step S210: Cleaning and preprocessing, removing content information that may be included in the requirements document, such as cover pages, approval forms, and referenced documents, that is not related to the design requirements, and retaining only the main text content related to the design requirements.

[0064] Step S220: Preset prompts to allow the large model to understand the content of the requirements document according to the prompts, and output the decomposed functional points and corresponding requirement fragments in a specified format.

[0065] Step S230: Save the requirements decomposition results output by the large model to the database one by one.

[0066] Data cleaning removes redundant information, significantly reducing noise interference and improving the accuracy of understanding core requirements. By splitting the large model by functional point dimensions and establishing mappings, structured management of requirement documents is achieved, facilitating precise identification of the review scope for individual functions. Storing the mapping data in a database ensures traceability throughout the requirement processing workflow and provides a standardized data foundation for subsequent automated alignment.

[0067] Preferably, the step of segmenting the project source code according to a preset code syntax structure to obtain a set of code snippets further includes: A set of chunking patterns is constructed based on the syntactic features of the project source code. Based on each chunking pattern in the set of chunking patterns, chunking rules containing semantic feature matching logic and chunk end position determination logic are constructed. Based on the matching priority order, each line of code in the project's source code is processed by block matching rules. The specific rules are as follows: if the match is successful, the start and end positions of the block are recorded; the code block is obtained based on the start and end positions and marked as identified; if the match is unsuccessful, single-line merging or unclassified marking is performed. Traverse the processing status of the project's source code and update the category identifier. The specific rule is: forcibly mark lines of code that are not covered by matching rules as general single-line blocks. The acquired code blocks are stored in the database to form a set of code snippets.

[0068] Further explanation of steps S300: S310: Based on code syntax features, determine the block pattern and design regular expressions for different block patterns. Sort the block patterns according to priority: multi-line comments, function definitions, class and structure definitions, preprocessor directive blocks (e.g., multi-line structures like if statements), single-line comments, header files, single-line preprocessor directives, etc. Define multiple types of block rules according to matching priority (from high to low). Each type of rule includes "semantic feature matching logic" and "block end position determination logic." See Table 1 for the core rules: S320: Line-by-line traversal and block matching traverses the source code text line by line, following the priority order defined in the steps: Verify if the current line conforms to a certain type of multi-line block rule: During traversal, if the current line has already been marked as processed, skip it and process the next line; if a match is successful, record the starting line position of the block, determine the ending line position of the block based on the end position determination logic of the corresponding rule, extract the complete text within the range as a code block, mark all code in the block as processed, and save the code block to the database. If the current line does not match any multi-line rule, verify if it conforms to the general single-line statement rule: If a match is successful, merge consecutive single lines of the same type (e.g., consecutive variable definitions) into a code block, mark it as processed, and store it in the database; if still no match: treat the current line as a general unclassified single line to ensure no lines are missed.

[0069] S330: Last-ditch check and result saving; iterates through the processing status of all lines, finds lines not covered by matching rules, forcibly marks them as general single-line blocks, ensures 100% line coverage, and saves the valid code snippets to the database.

[0070] Segmentation based on syntactic structure ensures the semantic and logical integrity of code fragments, avoiding misunderstandings caused by contextual fragmentation. Priority matching and multi-level rule processing effectively address code structure complexity, improving the accuracy and robustness of the segmentation process. A mandatory tagging mechanism ensures full code traceability, eliminating processing blind spots and guaranteeing the comprehensiveness and completeness of the review scope.

[0071] See Figure 4 and Figure 5 Preferably, the step of constructing the requirement-code data tuple further includes: Iterate through the set of requirement fragments to obtain the current requirement fragment; Input the current requirement fragment, and retrieve the target code file by calling the large model and searching in the function summary based on preset prompts; Input the code snippet corresponding to the target code file, and construct a group of code snippets based on the character count threshold set by the large model context window; Input a group of code snippets, and use a large model to perform semantic relevance retrieval to obtain search results that include filenames, start and end line numbers of the code, and degree of relevance; Based on the search results, the following filtering process is performed: code snippets with a relevance greater than a preset relevance threshold are retained; if no such snippet exists, the code snippet with the highest relevance is retained, and the requirement-code data tuple is obtained and stored in the database.

[0072] A two-stage retrieval strategy, employing initial screening with functional summaries and detailed screening with code snippets, effectively narrowed the search scope and significantly improved the efficiency and accuracy of aligning requirements with code. Dynamically constructing code snippet groups based on the context window constraints of the large model overcomes input length limitations, ensuring the large model can fully process and analyze core code logic. Through a dual mechanism of relevance threshold filtering and retention of the highest relevance score, the accuracy of alignment results is guaranteed while avoiding information omissions due to matching failures, thus improving the reliability of the review results.

[0073] The requirement-to-code alignment step in S600 involves setting predefined prompts for each requirement fragment and using a large model to retrieve the corresponding code fragment that implements the function described by the requirement fragment, thus achieving rapid matching and alignment between requirement fragments and code fragments. Specifically, this includes the following steps: Step S610: Traverse the database and retrieve one required fragment at a time.

[0074] Step S620: For each requirement fragment, preset prompt words are used, and the large model is used to find the most relevant code files in the code summary database of the project according to the prompt words.

[0075] Step S630: Considering the limited amount of data that a large model can process in a single run, and also taking retrieval speed into account, the code fragments from several of the most relevant code files from Step S620 are extracted sequentially. These fragments are grouped by limiting the number of characters to no more than a certain threshold, ensuring that the code fragments within each group are complete. Ultimately, all code fragments will form several code fragment groups.

[0076] Step S640: For each requirement fragment, traverse the code fragment group, preset prompt words, and use the large model to retrieve the code fragment most relevant to the requirement from the given code fragment group. The large model outputs the file name, start and end line numbers, and relevance level according to the specified format, and records this information.

[0077] Step S650: Repeat step S640 above until all code snippet groups have been traversed. Filter according to the recorded "relevance" information. The specific filtering rule is: retain code snippets with a relevance greater than a certain threshold; if no such code snippet exists, retain the code snippet with the highest relevance. The filtered code snippets with higher relevance are then used as the code snippets corresponding to the requirement snippet, forming a requirement-code data tuple, and recorded in the database.

[0078] Step S660: Repeat steps S620-S650 above until all requirement fragments in the database are matched.

[0079] Preferably, the character count threshold set according to the large model context window limit is configured as the maximum character limit determined based on the large model retrieval speed verification; the preset relevance threshold is configured as the lower limit of relevance determined based on the alignment accuracy verification.

[0080] By setting the character count threshold to the maximum limit after retrieval speed verification, an optimal balance between large model processing efficiency and contextual information was achieved. Configuring the relevance threshold to the lower limit based on alignment accuracy verification effectively eliminated low-relevance noise data, ensuring high accuracy in aligning requirements with code. Parameter configurations determined through experimental verification maximized the accuracy and reliability of code review results while ensuring retrieval response speed.

[0081] See Figure 6 Preferably, the step of obtaining the review results through large model functional review further includes: Based on data tuples, the consistency review results between requirement fragments and code fragments are obtained through a large model; Based on data tuples, the compliance review results of the algorithm logic, constant values, variable values, and boundary ranges of the code snippets are obtained through a large model. Based on data tuples, the results of risk assessment of potential risks and vulnerabilities in code snippets are obtained through static analysis of large models.

[0082] Consistency review ensures a strict correspondence between the code implementation and the requirements description, effectively avoiding misunderstandings or omissions during development. In-depth verification of the compliance of details such as algorithm logic, constants, and boundary values ​​accurately identifies deep-seated business logic errors that are difficult to detect with conventional checks. Combined with static analysis to identify potential risks and vulnerabilities, comprehensive quality control is achieved, from business logic correctness to code security. In this step, code review involves traversing the requirements-code data tuple. For each element in the requirements-code data tuple, preset prompts are used, and a large model is used to review the consistency between requirement fragments and code fragments, as well as the correctness and standardization of the code implementation. The review results are stored in the database.

[0083] Second Embodiment A second aspect of the present invention provides a review apparatus for aligning code with requirements based on a large model, comprising: The conversion module is used to convert a requirement file in rich text format to a first document in structured text format. The processing module is used to obtain the set of requirement function point identifiers and the set of requirement fragments based on the first document through cleaning and preprocessing and semantic understanding of the large model. Based on the set of requirement function point identifiers and the set of requirement fragments, it is used to obtain mapping data through mapping and store it in the database. The code segmentation module is used to divide the project source code according to the preset code syntax structure dimensions, obtain a set of code snippets and store them in the database; The summary extraction module is used to parse the code snippets based on the set of code snippets using preset prompts from a large model to obtain a functional summary of the project code files; The alignment module is used for retrieval based on the set of requirement fragments, the set of code fragments, and the functional summary. It is used to construct code fragment groups according to the character number threshold set by the large model context window limit, and to construct requirement-code data tuples by calculating the relevance between requirements and code. The review module is used to obtain review results based on data tuples through large model functions and store them in the database.

[0084] Modular design enables a fully automated closed loop from document parsing and code segmentation to review and analysis, significantly improving code review efficiency. Leveraging large-scale model semantic understanding and multi-dimensional retrieval alignment addresses the pain point of traditional methods struggling to establish deep connections between requirements and code, ensuring the accuracy of review results. Comprehensive handling of functional logic, boundary compliance, and potential risks achieves all-round coverage of code business correctness and security, guaranteeing high-quality review output. It's important to note that neither the database nor the large-scale model is specific; the database is any database that facilitates data storage and manipulation, and the large-scale model is any deployable and usable large-scale model.

[0085] In the description of this application, it should be noted that the terms "inner" and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product is in use. They are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation on this application. In addition, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0086] It should also be noted that, unless otherwise explicitly specified and limited, the terms "setup" and "connection" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.

[0087] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific identification content executed by the system and device described above can be referred to the corresponding process in the foregoing method embodiments.

[0088] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings, but the present invention is not limited to the above embodiments. Even if various changes are made to the present invention, if these changes fall within the scope of the claims of the present invention and their equivalents, they shall still fall within the protection scope of the present invention.< / object> < / drawing>

Claims

1. A review method based on aligning code with requirements using a large model, characterized in that, include: The first document, in structured text format, is obtained by converting the requirement document, which is in rich text format. Based on the first document, a set of required function point identifiers and a set of required fragments are obtained through cleaning and preprocessing and semantic understanding of the large model. Based on the set of required function point identifiers and the set of required fragments, mapping data is obtained through mapping and stored in the database. The project source code is segmented according to the preset code syntax structure to obtain a set of code snippets and stored in the database; Based on the set of code snippets, the function summary of the project code file is obtained by parsing the preset prompt words of the large model; The search is performed based on the set of requirement fragments, the set of code fragments, and the functional summary. A code fragment group is constructed according to the character number threshold set by the large model context window limit. A requirement-code data tuple is constructed by calculating the relevance between requirements and code. Based on the data tuples, the review results are obtained through the large model function review and stored in the database.

2. The review method for aligning code and requirements based on a large model according to claim 1, characterized in that, The steps for obtaining a first document in structured text format from a requirement document in rich text format through format conversion further include: Obtain the structured data carrier of the requirement document, and parse the structured data carrier into a traversable node tree; Based on the node tree, paragraph nodes and table nodes are obtained by traversing child nodes and filtering out non-core nodes such as styles, bookmarks, and controls. Input the paragraph node, and obtain the paragraph text in standard format through recursive element extraction, formula format conversion and style matching processing; Input the table node, and obtain a standard table by extracting cell attributes and traversing and filling processes; Input the image node in the node tree, and obtain the image tag and relative position data containing the path by extracting the embedding identifier and matching the media resource path; Based on the paragraph text, the standard table, and the image tags, the first document is obtained by cleaning up redundant formatting and merging line breaks.

3. The review method for aligning code and requirements based on a large model according to claim 2, characterized in that, The steps to obtain standard-formatted paragraph text further include: Recursively extract text, formulas, images, and line breaks from a paragraph, convert full-width spaces to standard spaces, and convert line breaks to preset tags; Detect the parity of formula markers to achieve cross-paragraph formula completion, and convert OMML format formulas to LaTeX format adapted to rendering rules; Generate Markdown headings at the corresponding style level based on style-level numbers, or generate indented Markdown lists based on list levels.

4. The review method for aligning code and requirements based on a large model according to claim 2, characterized in that, The steps to obtain a standard form further include: The steps of inputting the table node and obtaining a standard table by extracting cell attributes and traversing and filling the table specifically include: Extract the column span and row merging status of table cells to generate a cell attribute matrix; Iterate through the cells to extract text, fill in empty cells spanning columns or rows based on the cell attribute matrix, and output a standard Markdown table or an HTML table with merge attributes.

5. The review method for aligning code and requirements based on a large model according to claim 1, characterized in that, The steps for obtaining the set of required feature point identifiers and the set of required fragments further include: Based on the first document, redundant information about the requirements is removed by performing data cleaning operations to obtain the requirements content; Semantic understanding processing is performed using preset prompt words to obtain a set of requirement function point identifiers and a set of requirement fragments after being broken down by function point dimension; Based on the set of requirement fragments and the set of requirement function point identifiers, a mapping relationship is established through the requirement decomposition of the large model, and the mapping data is stored in the database.

6. The review method for aligning code and requirements based on a large model according to claim 1, characterized in that, The steps of segmenting the project source code according to the preset code syntax structure to obtain a set of code snippets further include: A set of chunking patterns is constructed based on the syntactic features of the project source code. Based on each chunking pattern in the set of chunking patterns, chunking rules containing semantic feature matching logic and chunk end position determination logic are constructed. Based on the matching priority order, each line of code in the project's source code is processed by block matching rules. Specifically, if a match is successful, the start and end positions of the block are recorded; the code block is obtained based on the start and end positions and marked as identified; if a match is unsuccessful, single-line merging or unclassified marking is performed. Traverse the processing status of the project's source code and update the category identifier. The specific rule is: forcibly mark lines of code that are not covered by matching rules as general single-line blocks. The acquired code blocks are stored in the database to form the code fragment set.

7. The review method for aligning code and requirements based on a large model according to claim 1, characterized in that, The steps for constructing the data tuples of requirements-code further include: Iterate through the set of requirement fragments to obtain the current requirement fragment; Input the current requirement fragment, and retrieve the target code file by calling the large model and searching in the functional summary based on preset prompts; Input the code snippet corresponding to the target code file, and construct a code snippet group based on the character count threshold set by the large model context window limit; Input the code snippet group, and use a large model to perform semantic relevance retrieval to obtain retrieval results including file name, start and end line numbers of the code, and degree of relevance; Based on the search results, the following filtering process is performed: code snippets with a relevance greater than a preset relevance threshold are retained; if no such snippet exists, the code snippet with the highest relevance is retained, and the requirement-code data tuple is obtained and stored in the database.

8. The code-requirement alignment review method according to claim 7, characterized in that, The character count threshold set according to the large model context window limit is configured as the maximum character limit determined based on the large model retrieval speed verification; the preset relevance threshold is configured as the lower limit of relevance determined based on the alignment accuracy verification.

9. The code-requirement alignment review method according to claim 1, characterized in that, The steps for obtaining review results through large model functional review further include: Based on the data tuples, the consistency review results of requirement fragments and code fragments are obtained through a large model; Based on the data tuples, the compliance review results of the algorithm logic, constant values, variable values, and boundary ranges of the reviewed code snippets are obtained through a large model; Based on the data tuples, the risk assessment results of potential risks and vulnerabilities in the code snippets are obtained through large-scale static analysis.

10. A review device for aligning code with requirements based on a large model, characterized in that, include: The conversion module is used to convert a requirement file in rich text format to a first document in structured text format. The processing module is used to obtain a set of requirement function point identifiers and a set of requirement fragments based on the first document through cleaning and preprocessing and semantic understanding of the large model; and to obtain mapping data and store it in the database based on the set of requirement function point identifiers and the set of requirement fragments. The code segmentation module is used to divide the project source code according to the preset code syntax structure dimensions, obtain a set of code snippets and store them in the database; The summary extraction module is used to parse the code snippets based on the set of code snippets using preset prompts from the large model to obtain a functional summary of the project code files. The alignment module is used to perform retrieval based on the set of requirement fragments, the set of code fragments, and the functional summary. It is used to construct code fragment groups according to the character number threshold set by the large model context window limit, and to construct requirement-code data tuples by calculating the relevance between requirements and code. The review module is used to obtain review results based on the data tuples through the large model function and store them in the database.