Code production method and device based on semantic determination, equipment and medium

By performing abstract syntax tree parsing and multi-dimensional semantic collaborative analysis on the front-end prototype code, the characteristic nodes of the data to be replaced are identified and a data flow subgraph is constructed. This solves the problem in existing technologies that cannot distinguish between code nodes with the same syntax structure but different semantics and overlapping data acquisition logic, and enables lossless conversion of the front-end prototype code into production-grade code and extraction of database seed data.

CN123137635APending Publication Date: 2026-11-20XIAMEN ROAD & BRIDGE INFORMATION ENG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611636054.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-22
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Existing technologies cannot accurately distinguish code nodes with the same syntactic structure but different semantic roles, cannot handle the semantic overlap between data acquisition auxiliary logic and user interface interaction state management, and cannot extract database seed data from front-end prototype code, resulting in front-end prototype code being unable to evolve into production-grade code without loss.

Method used

By performing syntactic structure matching and multi-dimensional semantic collaborative analysis on the abstract syntax tree, the feature nodes of the data to be replaced are identified, a data flow subgraph is constructed to identify semantically overlapping nodes, the statement structure of semantically overlapping nodes is preserved and data dependencies are redirected, and a complete replacement is performed on non-semantically overlapping nodes to generate production-grade code.

Benefits of technology

It enables the accurate and lossless evolution of front-end prototype code into production-grade code, avoiding user interface malfunctions and data source switching issues. At the same time, it extracts seed data from the database in reverse, ensuring the reliability and auditability of code transformation decisions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123137635A_ABST
    Figure CN123137635A_ABST
Patent Text Reader

Abstract

The application provides a code production method and device based on semantic determination, equipment and medium. The method comprises the following steps: obtaining an abstract syntax tree of source code containing to-be-replaced data characteristics and state control logic, performing syntax structure matching on nodes of the abstract syntax tree to obtain a syntax matching result; performing multi-dimensional semantic collaborative analysis on the nodes indicated by the syntax matching result to obtain semantic roles; determining the to-be-replaced data characteristic nodes based on the syntax matching result and the semantic roles; constructing a data flow subgraph for the to-be-replaced data characteristic nodes, identifying semantic overlap nodes based on the reachability of data flow targets and state control logic of nodes in the data flow subgraph; retaining the statement structure of the semantic overlap nodes and redirecting data dependencies, and performing complete replacement on non-semantic overlap to-be-replaced data characteristic nodes to obtain front-end code. The application enables the front-end prototype code to evolve into production-level code accurately and losslessly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus, device and medium for code production based on semantic determination. Background Technology

[0002] With the rapid development of AI-assisted software engineering, large language models combined with intelligent agent skills can now automatically generate front-end prototype code based on business requirements described in natural language. This front-end prototype code contains simulated data, and through a simulated data interception layer, it can run independently without back-end service support, enabling product managers and front-end developers to perform interface interaction verification and functional demonstrations in the early stages of a project. However, evolving from front-end prototype code to production-grade code ready for direct deployment still requires replacing the simulated data used in the prototyping stage with real back-end API calls.

[0003] Currently, code transformation tools based on abstract syntax trees (ASTs) are widely used in batch refactoring and migration of front-end code. These tools allow developers to write code modification scripts that locate the code to be modified by matching the syntax structure of AST nodes and then perform the corresponding replacement operations. However, existing technologies still have the following technical problems: First, it cannot distinguish between code nodes with the same syntactic structure but different semantic roles. The front-end prototype code contains many code nodes with identical syntactic structures but different semantic roles. For example, two commit operations for the state management repository may have identical structures at the abstract syntax tree level, but one operation's data comes from simulated data, while the other's data comes from real data from business logic. Tools based on syntax node type matching cannot distinguish between these two types of nodes, and methods based on regular expression string detection or code structure pattern matching also cannot handle such semantic differences. Developers must manually identify and write exclusion rules one by one, which is not scalable.

[0004] Second, it cannot handle the semantic overlap between data acquisition auxiliary logic and user interface interaction state management. In the front-end prototype code, there are statements that simultaneously serve both simulated data acquisition and user interface state management. For example, modifying or not modifying a loading state control statement will cause functional abnormalities at different levels: deleting it will cause the user interface loading indicator to malfunction, while retaining it completely will prevent the switching of data sources. Existing tools cannot identify such semantically overlapping nodes and make reasonable processing decisions.

[0005] Third, it is impossible to extract database seed data from the front-end prototype code. The demo data constructed during the front-end prototyping stage is a concrete representation of real business scenarios, containing key information such as field names, data types, and business meanings. However, this demo data is usually discarded when integrating with the back-end, and back-end initialization requires manual rewriting of the seed data file. Existing tools only support forward generation from database schema definitions to data files, lacking a corresponding processing mechanism for demo data already constructed in the front-end prototype code.

[0006] In summary, existing technologies lack a solution that can accurately and seamlessly evolve front-end prototype code into production-grade code. Summary of the Invention

[0007] To address the aforementioned problems in the prior art, this application provides a method, apparatus, device, and medium for code production based on semantic determination, enabling front-end prototype code to evolve into production-grade code accurately and without loss.

[0008] To achieve the above objectives, the technical solution adopted in this application is as follows: Firstly, this application provides a code production method based on semantic determination, including: Obtain an abstract syntax tree containing the source code of the data to be replaced and the state control logic, and perform syntax structure matching on the nodes of the abstract syntax tree to obtain the syntax matching result; For the nodes indicated by the syntax matching results, perform multi-dimensional semantic collaborative analysis to obtain semantic roles; Based on the grammar matching results and the semantic roles, a deterministic determination is made to identify the data feature nodes to be replaced; A data flow subgraph is constructed for the data feature nodes to be replaced. Based on the reachability of nodes in the data flow subgraph to the data flow target and state control logic, semantically overlapping nodes are identified. The statement structure is preserved for the semantically overlapping nodes and the data dependencies are redirected. The non-semantically overlapping data feature nodes to be replaced are completely replaced to obtain the front-end code.

[0009] The beneficial effects of this application are as follows: By performing abstract syntax tree parsing and syntax structure matching on the source code containing the data features to be replaced, and combining multi-dimensional semantic collaborative analysis, the semantic role of nodes is comprehensively determined from multiple dimensions such as data flow source, call chain triggering method, and identifier naming semantics, which can effectively avoid misjudgments caused by relying on only a single dimension of information. On this basis, the determination mechanism confirms the data feature nodes to be replaced, making the determination results auditable and traceable, ensuring the reliability of code transformation decisions. At the same time, by constructing a data flow subgraph and identifying semantically overlapping nodes based on the reachability of nodes to data flow targets and state control logic, statements that simultaneously serve data acquisition and user interface state management can be accurately located. For semantically overlapping nodes, a processing method of preserving statement structure and redirecting data dependencies is adopted, so that the same code statement serves the real data flow while maintaining the semantics of user interface state control, thereby avoiding problems such as abnormal user interface function caused by deleting statements or inability to switch data sources due to complete preservation. Thus, the front-end prototype code can be accurately and losslessly evolved into production-grade code.

[0010] Optionally, performing multi-dimensional semantic collaborative analysis to obtain semantic roles includes: Perform data flow source tracing on the data objects operated on by the nodes, and recursively trace the assignment chain to mark the source type; Search for call points to the methods containing the nodes in the project-level call graph, and perform call chain triggering mode analysis to mark the triggering modes; Identifier naming semantic analysis is performed on the identifiers involved in the node, and scores are obtained by comparing them with a preset simulation dictionary and a business dictionary. The corresponding relationship of the backend entities is then checked. The semantic role is determined based on the source type, the triggering method, and the scoring result.

[0011] Optionally, the source type includes state management repository data, simulated data method return values, real interface call return values, user input, or routing parameters; the triggering method includes event handling, lifecycle hooks, listeners, or programmatic calls. Then, determining the semantic role based on the source type, the triggering method, and the scoring result includes: Determine whether the triggering method can be determined; if not, determine that the semantic role indicator is a non-data feature to be replaced. If so, determine whether the source types are all simulated data method return values ​​and do not contain real interface call return values, user input or routing parameters, or whether the simulated naming score in the scoring result is greater than the business naming score. If so, determine that the semantic role indicator is a data feature to be replaced; otherwise, determine that the semantic role indicator is a non-data feature to be replaced. The step of determining the data feature nodes to be replaced based on the syntax matching result and the semantic role includes: When at least one grammatical structure pattern in the grammatical matching result is successfully matched and the semantic role indicates that it is a data feature to be replaced, the node is confirmed as the data feature node to be replaced.

[0012] As described above, by combining multi-dimensional collaboration of data flow source tracing, call chain triggering mode analysis, and identifier naming semantic analysis with a deterministic judgment mechanism to confirm the data feature nodes to be replaced, it is possible to accurately distinguish code nodes with the same syntactic structure but different semantic roles, avoid misjudgment and omission, and make code transformation decisions auditable and traceable.

[0013] Optionally, the step of constructing a data flow subgraph for the data feature nodes to be replaced, and identifying semantically overlapping nodes based on the reachability of nodes within the data flow subgraph to the data flow target and state control logic, includes: The data flow subgraph is constructed with the method in which the data feature node to be replaced is located as the scope. The nodes in the data flow subgraph are labeled with node function types, including replacement type and interface state control type; Starting from the data feature node to be replaced, traverse the data flow subgraph to calculate the first number of reachable nodes of the type to be replaced and the second number of reachable interface state control type nodes. Based on the combination relationship between the first quantity and the second quantity, the semantically overlapping nodes are identified.

[0014] Optionally, identifying the semantically overlapping nodes based on the combination relationship between the first quantity and the second quantity includes: When the first quantity is greater than 0 and the second quantity is equal to 0, it is determined to be a pure data stream node; When the first quantity is greater than 0 and the second quantity is greater than 0, it is determined to be a semantically overlapping node; When the first quantity is equal to 0, the data feature node to be replaced is not modified; The step of preserving the statement structure and redirecting data dependencies for the semantically overlapping nodes includes: The statement structure of the semantically overlapping nodes is preserved to maintain the assignment semantics of the interface state control variables, while the data referenced by the semantically overlapping nodes is redirected from the data source to be replaced to the actual interface call return value.

[0015] As described above, by constructing a data flow subgraph and identifying semantically overlapping nodes based on the reachability of the data flow target and state control logic, and by preserving the statement structure and redirecting data dependencies for semantically overlapping nodes, the same code statement can serve the real data flow while maintaining the semantics of the user interface state control. This avoids problems such as abnormal user interface functions caused by deleting statements or the inability to switch data sources due to complete preservation.

[0016] Optionally, performing a complete replacement on non-semantically overlapping data feature nodes to be replaced includes: Under the management of function configuration documents, a refactoring sequence is generated based on the readiness status of the backend interface corresponding to each data feature node to be replaced, and the replacement is performed in batches according to the preset dependency constraints. Before each replacement is performed, the allowed and prohibited boundaries of the set to be modified are verified. The reconstruction progress is quantified by the ratio of the number of replaced data feature nodes to the total number of data feature nodes to be replaced.

[0017] Optionally, it also includes: Based on the data feature nodes to be replaced, a list of data features to be replaced is obtained, which includes data source type and data definition. Extract data definitions from the list of data features to be replaced according to the data source type; Conflict detection is performed on the data definitions of the same business entity in different data sources, and multi-source conflicts are resolved according to the preset data source priority chain to obtain unified data; Perform cross-layer format conversion on the unified data. The cross-layer format conversion includes conversion from a first naming style to a second naming style, and conversion of the display value to the encoded value based on a preset mapping dictionary. When the value to be converted is not in the mapping dictionary, an exception flag is returned and an alarm is triggered. Based on the unified data, database table creation statements and data insertion statements are generated.

[0018] As described above, starting from the confirmed data feature nodes to be replaced, through multi-source extraction, priority chain conflict resolution, and cross-layer format conversion, database table creation statements and data insertion statements are generated. This realizes the reverse extraction of database seed data from the front-end prototype code, which is the opposite of the existing tools that generate seed data from the database schema definition in the forward direction. This avoids the problem of discarding demonstration data and having to manually rewrite the seed file.

[0019] Secondly, this application provides a code production apparatus based on semantic determination, comprising: The syntax matching module is used to obtain an abstract syntax tree containing the source code of the data to be replaced and the state control logic, and to perform syntax structure matching on the nodes of the abstract syntax tree to obtain the syntax matching result. The semantic analysis module is used to perform multi-dimensional semantic collaborative analysis on the nodes indicated by the syntax matching results to obtain semantic roles; The deterministic determination module is used to make a deterministic determination based on the syntax matching result and the semantic role to confirm the data feature node to be replaced; The overlap determination module is used to construct a data flow subgraph for the data feature nodes to be replaced, and to identify semantically overlapping nodes based on the reachability of nodes in the data flow subgraph to the data flow target and state control logic. The code production module is used to preserve the statement structure of the semantically overlapping nodes and redirect data dependencies, and to perform a complete replacement on the non-semantically overlapping data feature nodes to be replaced, thereby obtaining the front-end code.

[0020] Thirdly, this application provides a computer device, including: one or more processors, and a memory; the memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the method described in the first aspect.

[0021] Fourthly, this application provides a storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the method described in the first aspect.

[0022] The technical effects of the code production apparatus based on semantic determination provided in the second aspect, the computer device provided in the third aspect, and the storage medium provided in the fourth aspect are described in the relevant description of the code production method based on semantic determination provided in the first aspect. Attached Figure Description

[0023] Figure 1 This is a schematic diagram of the main process of the semantic determination-based code production method in this application embodiment; Figure 2 This is a schematic diagram of the structure of a semantically determined code production device according to an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a computer device according to an embodiment of this application. Detailed Implementation

[0024] To better understand the above technical solutions, exemplary embodiments of this application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of this application are shown in the drawings, it should be understood that this application can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application can be understood more clearly and thoroughly, and that the scope of this application can be fully conveyed to those skilled in the art.

[0025] The embodiments of this application are applied to front-end engineering and AI-assisted software development scenarios, and are particularly suitable for code production-oriented transformation scenarios after front-end prototype code is automatically generated by combining large language models with intelligent agent skills. Existing technologies lack a mechanism for automatically identifying and accurately replacing simulated data features in prototype code.

[0026] To this end, in various embodiments of this application, an abstract syntax tree containing the source code of the data features to be replaced and the state control logic is obtained; the nodes of the abstract syntax tree are matched with syntax structure to obtain syntax matching results; for the nodes indicated by the syntax matching results, multi-dimensional semantic collaborative analysis is performed to obtain semantic roles; based on the syntax matching results and semantic roles, a deterministic determination is made to confirm the data feature nodes to be replaced; a data flow subgraph is constructed for the data feature nodes to be replaced; based on the reachability of nodes in the data flow subgraph to the data flow target and state control logic, semantically overlapping nodes are identified; the statement structure of semantically overlapping nodes is preserved and data dependencies are redirected; and a complete replacement is performed on the non-semantically overlapping data feature nodes to be replaced to obtain the front-end code. Thus, the front-end prototype code can be accurately and losslessly evolved into production-grade code.

[0027] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.

[0028] This application provides a code production method based on semantic determination, such as... Figure 1 As shown, the method includes: Step S1: Obtain the abstract syntax tree containing the source code of the data to be replaced and the state control logic, and perform syntax structure matching on the nodes of the abstract syntax tree to obtain the syntax matching result.

[0029] The source code is the front-end prototype code, which is automatically generated from natural language business requirements by combining a large language model with intelligent agent skills. It contains simulated data features and achieves independent operation without a backend through a simulated data interception layer. It is also equipped with functional specification documents and backend interface definitions.

[0030] In this embodiment, the simulated data is fictitious data used in the front-end prototyping stage to replace the actual back-end return value. Syntax structure matching is used to perform simulated feature pattern matching on Abstract Syntax Tree (AST) nodes; a successful match indicates that the node possesses the structural features of the data to be replaced at the syntactic level. Using P... k (n) represents the matching result of the k-th syntax structure pattern. When the match is successful, P k (n)=1.

[0031] Specifically, the simulation feature patterns include seven patterns based on abstract syntax tree structure conditions: state management repository operation pattern, where the evaluation result of the called object is a state management repository instance and the attribute is a commit or dispatch method; computed property simulation mapping pattern; local array method chaining call pattern; timer simulation asynchronous pattern where the delay time does not exceed a preset threshold; method pattern where the method name contains simulation keywords; event emission pattern carrying form data payload; and local identifier generation pattern in identifier context.

[0032] Step S2: Perform multi-dimensional semantic collaborative analysis on the nodes that are matched by the syntax matching results to obtain semantic roles.

[0033] In this embodiment, semantic role S ctx (n) indicates whether the node belongs to the data feature to be replaced or not. Data features to be replaced refer to code features originating from simulated data that should be replaced by real Application Programming Interface (API) calls; non-data features refer to code features belonging to business logic that should not be modified. Multi-dimensional semantic collaborative analysis includes three dimensions: data flow source tracing, call chain triggering method analysis, and identifier naming semantic analysis.

[0034] This three-step analysis has a synergistic effect; no single step or combination of two steps can achieve complete differentiation: data flow tracing alone cannot distinguish between simulated asynchronous operations and real timers; naming analysis alone cannot handle nodes containing ambiguous terms; and data flow and naming analysis alone cannot distinguish between data operations triggered by event handling and data operations triggered by lifecycles. In this embodiment, in step S2, multi-dimensional semantic collaborative analysis is performed to obtain semantic roles, including: Step S21: Perform data flow source tracing on the data object of the node operation, and recursively trace the assignment chain to mark the source type.

[0035] Specifically, for the data objects operated on by candidate nodes, their assignment chain is recursively traced, with a maximum depth of five levels, i.e., d. max=5. Source types include state management repository data, simulated data method return values, real interface call return values, user input, or routing parameters. During recursive tracing, the generation position of the data object is traced backward along the assignment expression in the abstract syntax tree until the preset depth limit is reached or the initial definition position of the data object is traced. The source type finally traced is taken as the data source type of that node.

[0036] Step S22: Search for the call point of the method where the node is located in the project-level call graph, and perform call chain triggering mode analysis to mark the triggering mode.

[0037] In this embodiment, the project-level call graph is constructed based on static scanning of the abstract syntax tree. The specific construction process is as follows: Abstract syntax tree parsing is performed on single-file components and module files in the project, extracting all method definition nodes, including methods, computed properties, and module-level exported functions in the component's method objects. The name, file, and abstract syntax tree position of each method are recorded. Then, the call expression nodes in the abstract syntax tree are traversed, and the target method for each call is determined through callee analysis, recording the call point position and the method of the caller. The project-level call graph also includes cross-file call tracing: through abstract syntax tree analysis of module import / export statements, method references between different files are associated.

[0038] The triggering methods include event handling (EVENT_HANDLER), lifecycle hooks (LIFECYCLE), watchers (WATCH), or programmatic calls (PROGRAMMATIC). Dynamic calls that cannot be resolved by static analysis are classified as programmatic calls, which are the weakest in semantic signal among the four triggering methods. A dual confirmation mechanism of three-step collaboration and deterministic product is used to ensure that the overall judgment result is not affected.

[0039] Step S23: Perform identifier naming semantic analysis on the identifiers involved in the node, score them against the preset simulation dictionary and business dictionary, obtain the score results, and check the correspondence of backend entities.

[0040] Specifically, identifiers include string literals, variable names, and method type names. The pre-defined mock keyword dictionary includes keywords such as mock, fake, test, demo, sample, dummy, and stub; the pre-defined business keyword dictionary includes keywords such as permission, authentication, role, audit, log, configuration, and system. For each identifier involved in a node, the number of keywords matching the mock and business dictionaries is counted, resulting in a mock naming score and a business naming score. Simultaneously, the backend interface definition is queried to determine whether the identifier corresponds to a real backend entity, i.e., an EntityExistsInBackend check is performed.

[0041] Step S24: Determine the semantic role based on the source type, triggering method, and scoring results.

[0042] In this embodiment, step S24 includes: Step S241: Determine whether the triggering method can be determined. If not, determine that the semantic role indicator is a non-data feature to be replaced.

[0043] Specifically, if the triggering method cannot be determined, the semantic role indicator is determined to be a non-data feature to be replaced, that is, a conservative strategy is adopted, and the default business logic is used when the semantics are unclear to avoid accidental deletion.

[0044] Step S242: If yes, determine whether the source type is a simulated data method return value and there is no real interface call return value, user input or routing parameter, or whether the simulated naming score in the scoring result is greater than the business naming score. If yes, determine that the semantic role indicator is a data feature to be replaced; otherwise, determine that the semantic role indicator is a non-data feature to be replaced.

[0045] If the triggering method can be determined, further determine whether the source type is always a simulated data method return value and there are no real interface call return values, user inputs, or routing parameters, or whether the simulated naming score in the scoring result is greater than the business naming score. If the above conditions are met, the semantic role indicator is determined to be a data feature to be replaced; otherwise, the semantic role indicator is determined to be a non-data feature to be replaced.

[0046] That is, according to the comprehensive judgment rule, S is determined when all data sources are analog and there is no business source. ctx (n)=1, indicating data characteristics to be replaced; when the simulated naming score is greater than the business naming score, S is determined. ctx (n)=1; otherwise, a conservative strategy is used to determine S. ctx (n)=0, meaning that the default business logic is used when the semantics are unclear in order to avoid accidental deletion.

[0047] Step S3: Based on the syntax matching results and semantic roles, make a deterministic determination to confirm the data feature nodes to be replaced.

[0048] In this embodiment, step S3 includes: When at least one grammatical structure pattern in the grammatical matching result is successfully matched and the semantic role indicates that it is a data feature to be replaced, the node is confirmed as a data feature node to be replaced.

[0049] In this embodiment, the deterministic decision is a deterministic product decision, not a probabilistic classification. This can be expressed by the formula: ; In the formula, P k (n) represents the matching result of the k-th grammatical structure pattern, S ct x(n) represents the semantic role determination result.

[0050] A node is only identified as a data feature to be replaced when the grammatical pattern matching passes at least one pattern and the semantic context determines it to be a simulated data operation. Therefore, the deterministic determination result is auditable and traceable, unlike existing technologies that use machine learning probabilistic classification.

[0051] Step S4: Construct a data flow subgraph for the data feature nodes to be replaced, and identify semantically overlapping nodes based on the reachability of nodes within the data flow subgraph to the data flow target and state control logic.

[0052] In this embodiment, the data flow subgraph is a directed graph G. n State control logic refers to the user interface state management logic, including the control of user interface states such as loading state, visible state, disabled state, showDialog state, and activeTab state.

[0053] In this embodiment, step S4 includes: Step S41: Construct a data flow subgraph with the method where the data feature node to be replaced is located as the scope.

[0054] Specifically, the abstract syntax tree of the method is extracted, and all data flow edges within the method are identified, including data dependencies such as variable assignment, function call parameter passing, and return value passing. Using the statements within the method as nodes and the data dependencies as edges, a directed data flow subgraph G is constructed. n .

[0055] Step S42: Label the nodes in the data flow subgraph with node function types, including the type to be replaced and the interface state control type.

[0056] Specifically, for each node in the data flow subgraph, if the node has been identified as a data feature node to be replaced, it is marked as MOCK (to be replaced); if the variable name operated on by the node matches the user interface state pattern, it is marked as UI_STATE (interface state control type); and the remaining nodes are marked as OTHER (other types).

[0057] Step S43: Starting from the data feature node to be replaced, traverse the data flow subgraph and calculate the first number of reachable nodes of the type to be replaced and the second number of reachable interface state control type nodes.

[0058] Specifically, starting from the feature node of the data to be replaced, a breadth-first search traversal is performed in the data flow subgraph, visiting all reachable nodes along the data dependency edges. The number of nodes of the type to be replaced visited during the traversal is counted as the first quantity V. mock (n), the number of accessed interface state control type nodes is used as the second quantity V. ui (n).

[0059] Step S44: Identify semantically overlapping nodes based on the combination relationship between the first quantity and the second quantity.

[0060] Specifically, step S44 includes: When the first quantity is greater than 0 and the second quantity is equal to 0, it is determined to be a pure data flow node; When both the first and second counts are greater than 0, they are determined to be semantically overlapping nodes. When the first quantity is equal to 0, the data feature node to be replaced is not modified.

[0061] Specifically, the mathematical expression for step S44 above is: ; When the node is a pure data stream node, it corresponds to the BR (Boundary Rule)-1 rule and performs a complete replacement; when the node is a semantically overlapping node, it corresponds to the BR-3 rule and performs a data source reconnection; and when the first quantity is equal to 0, protective measures are taken for the data feature node to be replaced and it is not modified.

[0062] Step S5: Preserve the statement structure for semantically overlapping nodes and redirect data dependencies, and perform a complete replacement on non-semantically overlapping data feature nodes to be replaced to obtain the front-end code.

[0063] In this embodiment, step S5, which preserves the statement structure and redirects data dependencies for semantically overlapping nodes, includes: Step S51: Preserve the statement structure of semantically overlapping nodes to maintain the assignment semantics of interface state control variables, and redirect the data referenced by semantically overlapping nodes from the source of the data to be replaced to the return value of the actual interface call.

[0064] Specifically, for semantically overlapping nodes, the statement structure of the node is preserved to maintain the assignment semantics of the interface state control variables. This includes retaining variable names, assignment operators, and statement locations. Simultaneously, the data object referenced by the node is redirected from the simulated data source to the replaced real interface call return value. Unlike Bieman and Ott's gluetokens, which only retain metric tokens without driving transformations, this application preserves the statement structure while redirecting data dependencies, allowing the same code statement to serve both the user interface state control semantics and the real data flow. Therefore, this node serves the real data flow while maintaining the user interface state control semantics, achieving the technical effect of modifying the data source without disrupting user interface interaction.

[0065] In this embodiment, step S5 involves performing a complete replacement on non-semantically overlapping data feature nodes to be replaced, including: Step S52: Under the function configuration document management, generate a reconstruction sequence based on the readiness status of the backend interface corresponding to each data feature node to be replaced, and perform the replacement in batches according to the preset dependency constraints.

[0066] In this embodiment, each operation defined in the module composition section of the functional configuration document corresponds to a simulated feature cluster. When the backend interface corresponding to an operation is ready, the replacement readiness of that feature cluster flips to true, triggering the hardening execution of that cluster. The hardening sequence follows dependency constraints, that is, first the replacement of the data retrieval GET operation is executed, then the replacement of the data submission POST, PUT, or DELETE operation is executed, and finally the replacement of the cleanup dependency operation is executed.

[0067] Step S53: Before each replacement is performed, the allowed and prohibited boundaries of the set to be modified are verified.

[0068] Specifically, boundary B is allowed. allow This includes operations such as data acquisition and replacement, data submission and replacement, and simulation method deletion; boundary B is prohibited. deny This includes operations such as page template structure, interaction logic, business rule judgment, styling, and access control. Replacement will only be performed if the entire set of modifications to be executed falls within the allowed boundaries and does not touch the prohibited boundaries.

[0069] Step S54: Quantify the reconstruction progress by the ratio of the number of replaced data feature nodes to the total number of data feature nodes to be replaced.

[0070] Specifically, the hardening degree H is equal to the number of replaced features F.replaced divided by the total number of features F total , that is H=|F replaced | / |F total |. When H=0, the code is in a prototype state; when 0<H<1, the code is in a progressive state; when H=1, the code is in a production state, such that the same front-end source code file runs through the three states without being rewritten.

[0071] In one embodiment, the semantic judgment-based code productionization method further comprises: Step S6: Acquire a to-be-replaced data feature list based on the to-be-replaced data feature nodes, wherein the to-be-replaced data feature list includes data source types and data definitions.

[0072] In this embodiment, the to-be-replaced data feature list is a shared intermediate product output by the core semantic analysis layer, and is consumed in parallel by the progressive hardening execution engine and the database seed reverse extraction engine. The data source types include a state management repository simulation state, a mock data method return value, and a Functional Specification Document (FSD) example. The data definitions include field names, data types, and constraint rules.

[0073] Step S7: Extract data definitions from the to-be-replaced data feature list according to the data source types.

[0074] Specifically, the mock data definitions of the same business entity are extracted from the to-be-replaced data feature list by classification according to the data source types. For example, the definition of the simulation state is extracted from the state management repository, the definition of the return value is extracted from the mock data method, and the definition of the example data is extracted from the functional specification document.

[0075] Step S8: Perform conflict detection on the data definitions of the same business entity in different data sources, and resolve multi-source conflicts according to a preset data source priority chain to obtain unified data.

[0076] In this embodiment, the preset data source priority chain π source is: the priority of the state management repository is higher than that of the mock data method, the priority of the mock data method is higher than that of the document example, and the priority of the document example is higher than that of artificial intelligence inference. The conflict types include: field name conflict, which refers to that the same field adopts different naming styles in different data sources, such as camel case and underscore case; field value conflict, which refers to that the same field adopts different value forms in different data sources, such as Chinese display values and coded values; field quantity conflict, which refers to that the number of fields contained in the same business entity in different data sources is inconsistent; type conflict, which refers to that the data type of the same field in different data sources is inconsistent. When resolving multi-source conflicts, the data source with a higher priority overrides the data source with a lower priority.

[0077] Step S9: Perform cross-level format conversion on the unified data. The cross-level format conversion includes the conversion from the first naming style to the second naming style, and the conversion of the display value to the encoded value based on the preset mapping dictionary. When the value to be converted is not in the mapping dictionary, an exception flag is returned and an alarm is triggered.

[0078] In this embodiment, the first naming style is front-end camelCase, and the second naming style is database underscore naming. For example, the front-end field name `userName` is converted to the database field name `user_name`. Status value mapping is used to convert front-end displayed values ​​to database encoded values; for example, the gender display value `male` is converted to the encoded value 0, and `female` is converted to the encoded value 1. When the displayed value to be converted is not in the mapping dictionary, the system returns an exception flag and triggers an alarm, prompting developers to manually intervene.

[0079] Step S10: Based on unified data, generate database table creation statements and data insertion statements.

[0080] In this embodiment, the table creation statement is the Structured Query Language (SCL) statement `CREATE TABLE`, and the data insertion statement is the SCL statement `INSERT INTO`. Therefore, it can be seen that this achieves the reverse extraction of database seed data from simulated data in the front-end prototype code, which is the opposite of existing tools that generate seed data from the database schema definition in the forward direction.

[0081] Therefore, the technical solution provided in this application includes two parallel processing branches: front-end code production and reverse extraction of database seed data. Steps S1 to S5 complete the semantic analysis and production-oriented transformation of the front-end source code, outputting production-grade front-end code that can be directly deployed. Steps S6 to S10, based on the same list of data features to be replaced, reverse extract database seed data from existing simulated data in the source code. The two processing branches share the list of data features to be replaced output by the core semantic analysis layer, together forming a complete production-grade link from prototype code to production-grade code.

[0082] In summary, the various embodiments of this application have the following technical effects: By performing abstract syntax tree parsing and syntax structure matching on the source code containing the data features to be replaced, and combining multi-dimensional collaboration of data flow source tracing, call chain triggering mode analysis, and identifier naming semantic analysis, the semantic role of the node can be comprehensively determined from multiple dimensions, which can effectively avoid misjudgment caused by relying on only a single dimension of information.

[0083] Based on this, a deterministic judgment mechanism is used to identify the data feature nodes to be replaced, making the judgment results auditable and traceable, thus ensuring the reliability of code transformation decisions.

[0084] By constructing a data flow subgraph and identifying semantically overlapping nodes based on the reachability of nodes to data flow targets and state control logic, it is possible to accurately locate statements that simultaneously serve data acquisition and user interface state management. For semantically overlapping nodes, a method of preserving statement structure and redirecting data dependencies is adopted. This ensures that the same code statement serves the real data flow while maintaining the semantics of user interface state control, avoiding user interface malfunctions caused by statement deletion or data source switching issues due to complete preservation.

[0085] Furthermore, by using multi-source extraction, priority chain conflict resolution, and cross-layer format conversion, it is possible to extract seed data from the database from the front-end prototype code in reverse. This is the opposite of existing tools that generate seed data from the database schema definition in the forward direction, thus avoiding the problem of having to manually rewrite the seed file after the demo data is discarded.

[0086] This allows the front-end prototype code to evolve precisely and seamlessly into production-grade code, and the same source code file can be used across prototype, incremental, and production states without rewriting.

[0087] In one embodiment, such as Figure 2 As shown, this application also provides a code production apparatus based on semantic determination, including: The syntax matching module 201 is used to obtain an abstract syntax tree containing the source code of the data to be replaced and the state control logic, and to perform syntax structure matching on the nodes of the abstract syntax tree to obtain the syntax matching result.

[0088] The semantic analysis module 202 is used to perform multi-dimensional semantic collaborative analysis on the nodes matched by the syntax matching result to obtain semantic roles.

[0089] The deterministic determination module 203 is used to make a deterministic determination based on the syntax matching result and the semantic role to confirm the data feature node to be replaced.

[0090] The overlap determination module 204 is used to construct a data flow subgraph for the data feature nodes to be replaced, and to identify semantically overlapping nodes based on the reachability of nodes in the data flow subgraph to the data flow target and state control logic.

[0091] The code production module 205 is used to preserve the statement structure of the semantically overlapping nodes and redirect data dependencies, and to perform a complete replacement on the non-semantically overlapping data feature nodes to be replaced, thereby obtaining the front-end code.

[0092] In one embodiment, such as Figure 3 As shown, this application also provides a computer device 300, comprising: The communication interface 301 allows for information exchange with other devices or network nodes.

[0093] One or more processors 302 are connected to a communication interface 301 to enable information interaction with other devices or network nodes, and to execute the methods provided by one or more technical solutions in the above embodiments when running computer programs.

[0094] Memory 303 is used to store computer-readable instructions that can be executed on processor 302. When the computer-readable instructions are executed by one or more processors 302, the steps of the semantically determined code production method in the above embodiments are performed.

[0095] The computer device 300 in this embodiment only shows a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. A specific computer device may include more or fewer components than shown in the figures, or combine certain components, or have different component arrangements, such as power supplies, input / output interfaces, etc. Furthermore, the computer device 300 of this embodiment can operate on an operating system stored in memory 303, such as Windows Server, Mac OS X, Unix, Linux, Free BSD, or similar.

[0096] In one embodiment, this application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the semantically determined code production method as described in the above embodiments.

[0097] The computer-readable instructions in the aforementioned computer device 300 and storage medium may be application programs.

[0098] Furthermore, the specific descriptions of the technical effects and steps corresponding to the semantically determined code production apparatus, the computer device 300, and the storage medium in the above embodiments are all based on the relevant descriptions of the embodiments in which the semantically determined code production method is located.

[0099] Since the systems / devices described in the above embodiments of this application are systems / devices used to implement the methods of the above embodiments of this application, those skilled in the art can understand the specific structure and modifications of the system / devices based on the methods described in the above embodiments of this application, and therefore will not be repeated here. All systems / devices used in the methods of the above embodiments of this application fall within the scope of protection of this application.

[0100] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0101] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (devices), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions.

[0102] It should be noted that any reference numerals within parentheses in this application should not be construed as limiting the technical solution. The word "comprising" does not exclude the presence of components or steps not listed in the technical solution. The word "a" or "an" preceding a component does not exclude the presence of multiple such components. This application can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In technical solutions that list several devices, several of these devices may be embodied by the same hardware. The use of the terms first, second, third, etc., is merely for convenience and does not indicate any order. These terms can be understood as part of the component names.

[0103] Furthermore, it should be noted that in the description of this specification, the terms "one embodiment," "some embodiments," "embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0104] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the scope of protection of this application should be interpreted to include the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0105] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if these modifications and variations fall within the scope of protection of this application and its equivalents, this application should also include these modifications and variations.

Claims

1. A code production method based on semantic judgment, characterized in that, include: Obtain an abstract syntax tree containing the source code of the data to be replaced and the state control logic, and perform syntax structure matching on the nodes of the abstract syntax tree to obtain the syntax matching result; For the nodes indicated by the syntax matching results, perform multi-dimensional semantic collaborative analysis to obtain semantic roles; Based on the grammar matching results and the semantic roles, a deterministic determination is made to identify the data feature nodes to be replaced; A data flow subgraph is constructed for the data feature nodes to be replaced. Based on the reachability of nodes in the data flow subgraph to the data flow target and state control logic, semantically overlapping nodes are identified. The statement structure is preserved for the semantically overlapping nodes and the data dependencies are redirected. The non-semantically overlapping data feature nodes to be replaced are completely replaced to obtain the front-end code.

2. The method according to claim 1, characterized in that, The process of performing multi-dimensional semantic collaborative analysis to obtain semantic roles includes: Perform data flow source tracing on the data objects operated on by the nodes, and recursively trace the assignment chain to mark the source type; Search for call points to the methods containing the nodes in the project-level call graph, and perform call chain triggering mode analysis to mark the triggering modes; Identifier naming semantic analysis is performed on the identifiers involved in the node, and scores are obtained by comparing them with a preset simulation dictionary and a business dictionary. The corresponding relationship of the backend entities is then checked. The semantic role is determined based on the source type, the triggering method, and the scoring result.

3. The method according to claim 2, characterized in that, The source types include state management repository data, simulated data method return values, real interface call return values, user input, or routing parameters. The triggering methods include event handling, lifecycle hooks, listeners, or programmatic calls. Therefore, determining the semantic role based on the source type, the triggering method, and the scoring result includes: Determine whether the triggering method can be determined; if not, determine that the semantic role indicator is a non-data feature to be replaced. If so, determine whether the source types are all simulated data method return values ​​and do not contain real interface call return values, user input or routing parameters, or whether the simulated naming score in the scoring result is greater than the business naming score. If so, determine that the semantic role indicator is a data feature to be replaced; otherwise, determine that the semantic role indicator is a non-data feature to be replaced. The step of determining the data feature nodes to be replaced based on the syntax matching result and the semantic role includes: When at least one grammatical structure pattern in the grammatical matching result is successfully matched and the semantic role indicates that it is a data feature to be replaced, the node is confirmed as the data feature node to be replaced.

4. The method according to claim 1, characterized in that, The step of constructing a data flow subgraph for the data feature nodes to be replaced, and identifying semantically overlapping nodes based on the reachability of nodes within the data flow subgraph to the data flow target and state control logic, includes: The data flow subgraph is constructed with the method in which the data feature node to be replaced is located as the scope. The nodes in the data flow subgraph are labeled with node function types, including replacement type and interface state control type; Starting from the data feature node to be replaced, traverse the data flow subgraph to calculate the first number of reachable nodes of the type to be replaced and the second number of reachable interface state control type nodes. Based on the combination relationship between the first quantity and the second quantity, the semantically overlapping nodes are identified.

5. The method according to claim 4, characterized in that, The step of identifying the semantically overlapping nodes based on the combination relationship between the first quantity and the second quantity includes: When the first quantity is greater than 0 and the second quantity is equal to 0, it is determined to be a pure data stream node; When the first quantity is greater than 0 and the second quantity is greater than 0, it is determined to be a semantically overlapping node; When the first quantity is equal to 0, the data feature node to be replaced is not modified; The step of preserving the statement structure and redirecting data dependencies for the semantically overlapping nodes includes: The statement structure of the semantically overlapping nodes is preserved to maintain the assignment semantics of the interface state control variables, while the data referenced by the semantically overlapping nodes is redirected from the data source to be replaced to the actual interface call return value.

6. The method according to claim 1, characterized in that, The complete replacement of non-semantically overlapping data feature nodes to be replaced includes: Under the management of function configuration documents, a refactoring sequence is generated based on the readiness status of the backend interface corresponding to each data feature node to be replaced, and the replacement is performed in batches according to the preset dependency constraints. Before each replacement is performed, the allowed and prohibited boundaries of the set to be modified are verified. The reconstruction progress is quantified by the ratio of the number of replaced data feature nodes to the total number of data feature nodes to be replaced.

7. The method according to claim 1, characterized in that, Also includes: Based on the data feature nodes to be replaced, a list of data features to be replaced is obtained, which includes data source type and data definition. Extract data definitions from the list of data features to be replaced according to the data source type; Conflict detection is performed on the data definitions of the same business entity in different data sources, and multi-source conflicts are resolved according to the preset data source priority chain to obtain unified data; Perform cross-layer format conversion on the unified data. The cross-layer format conversion includes conversion from a first naming style to a second naming style, and conversion of the display value to the encoded value based on a preset mapping dictionary. When the value to be converted is not in the mapping dictionary, an exception flag is returned and an alarm is triggered. Based on the unified data, database table creation statements and data insertion statements are generated.

8. A code production device based on semantic determination, characterized in that, include: The syntax matching module is used to obtain an abstract syntax tree containing the source code of the data to be replaced and the state control logic, and to perform syntax structure matching on the nodes of the abstract syntax tree to obtain the syntax matching result. The semantic analysis module is used to perform multi-dimensional semantic collaborative analysis on the nodes indicated by the syntax matching results to obtain semantic roles; The deterministic determination module is used to make a deterministic determination based on the syntax matching result and the semantic role to confirm the data feature node to be replaced; The overlap determination module is used to construct a data flow subgraph for the data feature nodes to be replaced, and to identify semantically overlapping nodes based on the reachability of nodes in the data flow subgraph to the data flow target and state control logic. The code production module is used to preserve the statement structure of the semantically overlapping nodes and redirect data dependencies, and to perform a complete replacement on the non-semantically overlapping data feature nodes to be replaced, thereby obtaining the front-end code.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

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