Script generation method and device, equipment, storage medium and product
By automatically generating template configuration files and abstract syntax trees, executable scripts are automatically generated, solving the problems of low efficiency in batch script generation and error-prone manual programming, thus achieving efficient and accurate script development.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies have low efficiency in generating batch scripts, and manual programming is prone to errors, making it difficult to adapt to rapidly changing business needs. In particular, large projects require synchronous updates to mapping documents, resulting in long development times and high error rates.
By acquiring business requirements information, template configuration files are automatically generated, abstract syntax trees are parsed based on logical rules, and executable scripts are automatically generated, reducing manual intervention and improving generation efficiency and accuracy.
No manual coding is required; scripts are automatically generated, reducing development costs and error risks, improving generation efficiency and accuracy, and simplifying the maintenance process.
Smart Images

Figure CN121638199A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of computers, and particularly relates to a script generation method and device, equipment, a storage medium and a product. BACKGROUND
[0002] At present, in order to improve the processing efficiency of data, a batch processing script is usually used to execute a batch processing task.
[0003] In the related art, a batch processing script is usually manually programmed and developed by a human being, which reduces the generation efficiency of the script. SUMMARY
[0004] The embodiments of the present application provide a script generation method and device, equipment, a storage medium and a product, which do not require manual code writing or template configuration, and can improve the generation efficiency of the script.
[0005] In a first aspect, the embodiments of the present application provide a script generation method, which includes: obtaining business requirement information corresponding to a target business function; performing semantic analysis on the business requirement information to generate a template configuration file, the template configuration file including at least business parameters required for implementing the target business function, attribute information of the business parameters, and logic rules corresponding to the business parameters; performing analysis on the logic rules to generate an abstract syntax tree corresponding to the target business function; and performing data integration on the business parameters, the attribute information of the business parameters, and the abstract syntax tree to generate an executable script for implementing the target business function.
[0006] In some possible implementation manners, the semantic analysis on the business requirement information to generate the template configuration file includes: performing multi-dimensional context analysis on the business requirement information to obtain business concepts corresponding to the business requirement information; constructing a business concept graph expressing semantic relationships between the business concepts; determining the business parameters required for implementing the target business function and attribute information corresponding to the business parameters based on the business concept graph and a constraint propagation network; performing semantic role labeling on the business requirement information based on the business concept graph to identify business actions corresponding to the target business function and action attribute information associated with the business actions; and performing semantic extension and association on the business actions and the action attribute information based on the semantic relationships between the business concepts in the business concept graph to generate the logic rules corresponding to the business parameters.
[0007] In some possible implementation manners, the method of generating the script further includes: before the semantic analysis on the service requirement information and the generation of the template configuration file, obtaining other service requirement information corresponding to other service functions, where the other service requirement information has a corresponding other template configuration file; performing similarity matching on the other service requirement information and the service requirement information to obtain a matching result; and in a case where the matching result indicates that a similarity between the other service requirement information and the service requirement information satisfies a preset condition, taking the other template configuration file as the template configuration file corresponding to the target service function.
[0008] In some possible implementation manners, the data integration on the service parameter, the attribute information of the service parameter, and the abstract syntax tree to generate the executable script for implementing the target service function includes: mapping the attribute information of the service parameter to a node corresponding to the service parameter in the abstract syntax tree; and generating the executable script corresponding to the target service function according to a node type of the node in the abstract syntax tree and the attribute information of the service parameter corresponding to the node.
[0009] In some possible implementation manners, the generation of the executable script corresponding to the target service function according to the node type of the node in the abstract syntax tree and the attribute information of the service parameter corresponding to the node includes: predicting a logical complexity of the executable script based on the node type of the node in the abstract syntax tree and an association relationship between the nodes in the abstract syntax tree; in a case where the logical complexity is higher than a preset complexity threshold, splitting the abstract syntax tree into a plurality of sub syntax trees according to the association relationship between the nodes in the abstract syntax tree; generating a plurality of code segments according to the node type of the node in the plurality of sub syntax trees and the attribute information of the service parameter corresponding to the node; and combining the plurality of code segments according to an association relationship between the plurality of sub syntax trees in a logical rule to generate the executable script corresponding to the target service function.
[0010] In some possible implementation manners, the method of generating the script further includes: after the generation of the plurality of code segments according to the node type of the node in the plurality of sub syntax trees and the attribute information of the service parameter corresponding to the node, performing static analysis on the plurality of code segments to identify a target operation point in each code segment, where a service influence degree of the target operation point is greater than a service influence degree threshold; and injecting an exception capture code and a log recording code into the target operation point.
[0011] In some possible implementation manners, the method of generating a script further includes: after the data integration of the business parameter, the attribute information of the business parameter, and the abstract syntax tree, and the generation of the executable script for implementing the target business function, the method further includes: obtaining a system configuration file corresponding to the business system, the system configuration file at least including running logic between a plurality of business functions; and performing combination processing on the executable script corresponding to the target business function and the executable script corresponding to other business functions in the business system based on the running logic, to obtain a target executable script corresponding to the business system.
[0012] In a second aspect, an embodiment of the present application provides a device for generating a script, which includes: a requirement obtaining module configured to obtain business requirement information corresponding to a target business function; a template generating module configured to perform semantic analysis on the business requirement information, and generate a template configuration file, the template configuration file at least including a business parameter required for implementing the target business function, attribute information of the business parameter, and a logic rule corresponding to the business parameter; a rule analyzing module configured to analyze the logic rule, and generate an abstract syntax tree corresponding to the target business function; and a script generating module configured to perform data integration on the business parameter, the attribute information of the business parameter, and the abstract syntax tree, and generate an executable script for implementing the target business function.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory storing computer program instructions; and the processor implements the method of generating a script according to any one of the above aspects when executing the computer program instructions.
[0014] In a fourth aspect, an embodiment of the present application provides a computer storage medium, and the computer storage medium stores computer program instructions, and the computer program instructions are executed by a processor to implement the method of generating a script according to any one of the above aspects.
[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, and instructions in the computer program product are executed by a processor of an electronic device, so that the electronic device can execute the method of generating a script according to any one of the above aspects.
[0016] As known from the above, in the embodiment of the present application, the executable script is obtained by analyzing and integrating the configuration information in the template configuration file, and this process does not require manual code writing, thereby improving the script generation efficiency. In addition, in the embodiment of the present application, the template configuration file is automatically configured and generated based on the business requirement information, that is, in the embodiment of the present application, the user only needs to input the business requirement information corresponding to the target business function, and does not need to configure the template configuration file. Compared with the semi-automatic script generation method in the related art in which the template file is manually configured, the script generation efficiency can be further improved. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments of the present application. Those skilled in the art can further obtain other drawings according to these drawings without any creative effort.
[0018] Figure 1 is a flow diagram of a method for generating a script according to an embodiment of the present application; Figure 2 is a structural diagram of a device for generating a script according to another embodiment of the present application; Figure 3 is a structural diagram of an electronic device according to yet another embodiment of the present application. DETAILED DESCRIPTION
[0019] The features and exemplary embodiments of various aspects of the present application will be described in detail below with reference to the drawings. To make the purposes, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, but not to limit the present application. The present application can be implemented without some of the specific details by those skilled in the art. The following description of the embodiments is only intended to provide a better understanding of the present application by showing examples of the present application.
[0020] It should be noted that, in this document, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the elements defined by the statement "include" do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0021] It should be noted that the acquisition, storage, use and processing of data in the embodiments of the present application all comply with the relevant provisions of national laws and regulations.
[0022] In addition, it should be noted that in the embodiments of the present application, some industry existing solutions, components, models, etc. may be mentioned, which should be considered as exemplary, and the purpose is only to illustrate the feasibility of the implementation of the technical solutions of the present application, but does not mean that the applicant has or will necessarily use the solution.
[0023] Batch processing scripts can realize batch processing of data, especially in the fields of finance, telecommunications and other fields that need to process a large amount of data, and the batch processing scripts can improve the processing efficiency of data.
[0024] In the related art, a data line batch processing script is usually developed in a manual programming manner, which is time-consuming, has a high error rate, and is difficult to adapt to rapidly changing requirements. Especially in some large projects, a mapping document (for example, a data dictionary) needs to be developed and maintained at the same time as the data line batch processing script is developed, in order to improve the readability of the data processing caliber, but in this manner, when the script is updated, the mapping document needs to be updated synchronously, additional effort is required to maintain the mapping document, and the problem of disconnection between the mapping document and the script code is prone to occur.
[0025] To solve the problems in the prior art, an embodiment of the present application provides a method, device, equipment, storage medium and product for generating a script.
[0026] In the embodiment of the present application, a template configuration file is automatically generated based on the business requirement information of the user, the template configuration file contains business parameters, business attributes and logical rules of the business parameters, therefore, only one document of the template configuration file needs to be maintained, which reduces the risk of disconnection between the mapping document and the script code. Moreover, the template configuration file is automatically generated based on the business requirement information of the user, without manual configuration of the template, thereby simplifying the development process, reducing the maintenance cost of the script, and improving the generation efficiency of the script to a certain extent. In addition, in the embodiment of the present application, the logical rules corresponding to the business function are obtained by parsing the template configuration file, an abstract syntax tree is generated based on the logical rules, and then the business parameters, attribute information of the business parameters and the abstract syntax tree are integrated, so as to automatically generate an executable script. This process does not require human intervention, reduces the error risk of manual programming, and improves the generation efficiency and accuracy of the script.
[0027] Firstly, the method for generating a script provided by the embodiment of the present application will be introduced. It should be noted that the script development tool can be the execution subject of the method provided by the embodiment of the present application, and the script development tool can run on a terminal device (for example, a computer).
[0028] Figure 1 A flowchart of the method for generating a script provided by an embodiment of the present application is shown. As shown in Figure 1 The method can include the following steps S101 to S104: Step S101, obtaining business requirement information corresponding to a target business function.
[0029] In step S101, the target business functions vary for different industries. For example, for the financial industry, the target business functions may include, but are not limited to, loan business functions, deposit business functions, and withdrawal business functions; for the telecommunications industry, the target business functions may include, but are not limited to, call business functions, SMS business functions, and broadband business functions.
[0030] In step S101, the business requirements information corresponding to different business functions are also different. For example, for loan business, the business requirement information may be "query the user permissions of each customer".
[0031] It should be noted that the business requirement information can be input by the user in the form of a rule expression or in natural language. To improve script generation efficiency and user experience, in this embodiment, the user can directly input the business requirement information expressed in natural language into the script development tool.
[0032] Step S102: Perform semantic analysis on the business requirement information and generate a template configuration file.
[0033] In step S102, the template configuration file includes at least the business parameters required to implement the target business function, the attribute information of the business parameters, and the logical rules corresponding to the business parameters. For example, for data query business, the business parameters may include the field name to be queried, such as name, identifier, and loan amount; the attribute information of the business parameters is used to characterize the attributes of the corresponding field. For example, the attribute information of the "name" field may include the data type and field length of the field; the logical rules corresponding to the business parameters are used to characterize the constraints on the field, such as age must be greater than 18 years old and the name field length must be between 5 and 20 characters.
[0034] For example, the template configuration file can be an Excel file with multiple columns, each corresponding to business parameters, attribute information of the business parameters, and logical rules of the business parameters. The script development tool can install Perl modules via tools such as CPAN or CPANM. These Perl modules include Spreadsheet::ParseExcel and Spreadsheet::WriteExcel. The script development tool uses the Spreadsheet::WriteExcel module to write business requirement information into the template configuration file. The script development tool uses the Spreadsheet::ParseExcel module to read at least one of the business parameters, attribute information of the business parameters, and corresponding logical rules from the template configuration file to generate an executable script corresponding to the target business function.
[0035] It should be noted that in the embodiments of the present application, the service parameters in the template configuration file cover the necessary fields required for project development, so as to reduce the maintenance cost of the template configuration file and improve the accuracy of the template configuration file.
[0036] In addition, it should be further noted that in the embodiments of the present application, the service parameters, the attribute information of the service parameters, and the logical rules corresponding to the service parameters are integrated in the template configuration file. As can be seen, the template configuration file contains the fields and field attributes required for generating scripts, and also contains the business logic rules for describing business information. Therefore, when the executable script needs to be updated, the corresponding service parameters in the template configuration file can be updated, without the need to maintain multiple documents, thereby improving the update efficiency and accuracy of the executable script.
[0037] In step S103, the logical rules are parsed to generate an abstract syntax tree corresponding to the target business function.
[0038] For example, in the embodiments of the present application, the script development tool uses the preadsheet::ParseExcel module to parse the template configuration file to obtain the logical rules, and maps the logical rules, so as to obtain the abstract syntax tree.
[0039] In step S103, the abstract syntax tree can reflect the execution logic corresponding to the target business function. The abstract syntax tree can include multiple nodes, and each node can represent a data conversion operation. The edges connecting the nodes can represent data flow and control dependencies. The execution logic of the target business function can be clearly represented by the abstract syntax tree, and then the corresponding service parameters and attribute information of the service parameters can be injected into the nodes of the abstract syntax tree, so as to generate an executable script corresponding to the target business function.
[0040] In step S104, the service parameters, the attribute information of the service parameters, and the abstract syntax tree are integrated to generate an executable script for implementing the target business function.
[0041] In step S104, after the abstract syntax tree is created, the script development tool can map the service parameters, the attribute information of the service parameters, and other data to the nodes corresponding to the abstract syntax tree, so as to obtain an executable script for implementing the target business function.
[0042] Exemplarily, after the abstract syntax tree is created, the script development tool sequentially traverses all fields corresponding to the business parameter in the template configuration file, and creates a script statement according to a logical rule corresponding to the field, for example, the logical rule is a data table query rule, the script development tool determines a data source corresponding to the data to be queried from the attribute information corresponding to the business parameter, and generates a SQL (Structured Query Language) query statement based on this, to realize the query of the data; for another example, the logical rule is to create a data table, the script development tool determines a data source corresponding to the data to be queried from the attribute information corresponding to the business parameter, and generates a CREATE TABLE statement based on this, to realize the creation of the data table.
[0043] Based on the scheme defined in the steps S101 to S104, it can be known that in the embodiment of the present application, the executable script is obtained by parsing and integrating the configuration information in the template configuration file, and the process does not need manual code writing, thereby improving the generation efficiency of the script. In addition, in the embodiment of the present application, the template configuration file is automatically configured and generated based on the business requirement information, that is, in the embodiment of the present application, the user only needs to input the business requirement information corresponding to the target business function, and does not need to configure the template configuration file. Compared with the semi-automatic script generation method in the related art in which the template file is manually configured, the generation efficiency of the script can be further improved.
[0044] The specific implementation process of the method provided in the embodiment of the present application is described below.
[0045] In some embodiments, after the business requirement information of the target business function is obtained, the script development tool performs semantic analysis on the business requirement information to generate a template configuration file.
[0046] Specifically, the script development tool performs multi-dimensional context analysis on the business requirement information to obtain business concepts corresponding to the business requirement information, and constructs a business concept graph expressing the semantic relationship between the business concepts; then, based on the business concept graph, the business parameters required to realize the target business function and the attribute information corresponding to the business parameters are determined through a constraint propagation network; based on the business concept graph, the semantic role labeling is performed on the business requirement information, and the business action corresponding to the target business function and the action attribute information associated with the business action are identified; finally, based on the semantic relationship between the business concepts in the business concept graph, the semantic extension and association of the business action and the action attribute information are performed, and the logical rule corresponding to the business parameter is generated.
[0047] Exemplarily, the script development tool first constructs a business context and extracts concepts. After receiving the business requirement information, the script development tool performs multi-dimensional context analysis on the business requirement information, such as context analysis from dimensions of domain identification, scope definition, role analysis, target extraction, and the like. Through context analysis from the dimension of domain identification, the business domain to which the requirement belongs (for example, e-commerce, finance, medical treatment, and the like) can be determined. Through context analysis from the dimension of scope definition, the boundary and influence scope of the business function can be identified. Through context analysis from the dimension of role analysis, the involved business roles and their mutual relationship can be extracted. Through context analysis from the dimension of target extraction, the core business target and the secondary target can be extracted from the description.
[0048] After multi-dimensional context analysis on the business requirement information, the script development tool dynamically constructs a semantic network between business concepts, thereby obtaining a business concept graph. Specifically, the script development tool maps the requirement text obtained from multi-dimensional context analysis and the business concept graph, identifies business concept instances appearing in the requirement text, such as users, orders, products, and the like, then extracts the relationship types between the business concept instances, such as the relationship types of containing, dependency, constraint, triggering, and the like, and then establishes the hierarchical structure and attribute inheritance relationship of the concepts and labels the business semantic weight and importance level of the concepts, thereby obtaining the business concept graph.
[0049] After obtaining the business concept graph, the script development tool performs deep analysis on the business intent, such as deep semantic role labeling on the requirement description to identify the business action and its execution subject and action object, and extract the condition part and result part of the business rule, analyze the preconditions and post-effects of the business scenario, and mine the implicit business constraints and boundary conditions. Then, the script development tool converts the fuzzy business target into an operable target system according to the analysis result, such as decomposing the high-level target into verifiable sub-targets, establishing the support relationship and conflict detection between the targets, defining the quantifiable success standard for each sub-target, and sorting the targets based on the business value and technical feasibility.
[0050] Next, the script development tool performs parameter ecosystem discovery and attribute derivation. First, it identifies explicit parameters, such as explicitly mentioned business parameters directly extracted from business requirement information, including numerical parameters like price, data, and ratio; categorical parameters like status, type, and level; time-related parameters like duration, frequency, and timeliness; and textual parameters like name, description, and remarks. Simultaneously, the script development tool further derives implicit parameters from the business requirement information. In this embodiment, the tool discovers necessary parameters not explicitly mentioned through constraint propagation and logical reasoning. For example, it discovers indirect parameters based on functional dependencies between parameters, ensures the complete set of parameters required for business scenario coverage through integrity checks, derives parameter value ranges and constraints through boundary condition analysis, and derives reasonable default values for parameters based on business common sense. The script development tool also establishes a complete attribute description for each parameter. For example, for data type, it specifies the data type and precision requirements of the parameter; for value range, it defines the range of values and valid boundaries of the parameter; for business semantic annotation, it describes the specific meaning of the parameter in the business context; and for constraints, it records the business rules and technical restrictions related to the parameter and defines the method of obtaining the parameter and access permissions.
[0051] After completing parameter ecosystem discovery and attribute derivation, the script development tool continues to extract and structure logical rules. First, the script development tool extracts complete business rules from business requirement information. For example, by parsing the condition part, it identifies the preconditions and judgment criteria for rule triggering; by extracting the action part, it extracts the business operations to be executed when the conditions are met; by determining priorities, it can determine the execution order of rules based on business importance; in addition, it can also identify possible abnormal situations during rule execution.
[0052] Next, the script development tool constructs a dynamic relationship model between business parameters. First, based on the state transition diagram corresponding to the business parameters, the transition conditions between different states of the business parameters are determined, and the transmission and transformation of parameter values in the business process are tracked to achieve data flow analysis. Then, the control flow is modeled to establish the logical flow and control structure of business decisions, and the time dependency and sequence constraints of business operations are analyzed to obtain the dynamic relationship model.
[0053] To ensure the rationality of business logic rules, the script development tool also performs consistency verification on these rules to ensure the inherent consistency of the extracted rule set. For example, conflict detection of logical rules identifies contradictory or overlapping business rules; integrity checks verify whether the rule set covers all business scenarios; reachability analysis ensures that each business state has a legitimate path to reach it; and termination verification confirms that the business process will not fall into an infinite loop.
[0054] After completing the above operations, the script development tool organizes the analysis results into a standard template configuration file. Specifically, it first defines all business parameters and their attributes according to a standard format, and describes the business logic rules in a structured way. Then, it records the relationships between parameters and rules, and generates metadata based on information such as the configuration version, author, and update time, thus obtaining the template configuration file.
[0055] To ensure the rationality of the template configuration file, the script development tool optimizes the generated template configuration file after it is generated. For example, it merges duplicate or equivalent parameters and rules to eliminate redundancy; it finds a balance between expressiveness and conciseness to optimize the complexity of the logic; and it optimizes the execution efficiency and resource consumption of the configuration to improve the execution performance of the script.
[0056] To ensure that the template configuration file accurately reflects the user's true intent, after the template configuration file is generated, the script development tool performs backtracking verification to check that each configuration item can be traced back to the original requirement; scenario coverage testing is used to verify that the configuration supports all identified business scenarios; constraint satisfaction checks are used to confirm that the configuration meets all business and technical constraints; and consistency audits are used to ensure that the configuration content is semantically consistent.
[0057] As described above, unlike traditional pattern matching methods, this embodiment constructs a complete business cognition system, achieving a deep semantic understanding of business requirements and enabling the handling of ambiguous, incomplete, or even implicit business needs. Employing a constraint propagation-based parameter discovery mechanism, a complete parameter ecosystem can be derived from limited explicit requirements, solving the problem of excessive reliance on requirement completeness in traditional methods. Furthermore, a semantic mapping relationship from original requirements to final configuration is established and maintained throughout the analysis process, ensuring that the technical solution accurately reflects business intent. Finally, based on multi-objective optimization theory, the optimal balance is automatically sought among dimensions such as functional completeness, technical feasibility, and maintenance convenience, generating a high-quality configuration scheme.
[0058] Through the above solution, the script development tool can automatically convert unstructured business requirements into accurate, complete, and consistent structured template configurations, greatly improving the efficiency and quality of the conversion from business requirements to technical implementation.
[0059] In some embodiments, to improve the efficiency of generating template configuration files, before performing semantic analysis on business requirement information and generating template configuration files, the script development tool can search for historical template configuration files that meet the conditions, and use the historical template configuration file or adjust the historical template configuration file to obtain a template configuration file that can be applied to the target business function.
[0060] Specifically, the script development tool obtains other business requirement information corresponding to other business functions, where other business requirement information has corresponding other template configuration files; then, it performs similarity matching between other business requirement information and business requirement information to obtain matching results; if the matching results indicate that the similarity between other business requirement information and business requirement information meets preset conditions, the other template configuration files are used as the template configuration files corresponding to the target business function.
[0061] For example, the script development tool can communicate with a server that stores template configuration files corresponding to different business requirement information. After obtaining the business requirement information corresponding to the target business function, the script development tool first queries the server for other business requirement information whose similarity to the business requirement information corresponding to the target business function meets certain conditions, such as the similarity being greater than a preset similarity threshold; then, it uses the template configuration file corresponding to the other business requirement information as the template configuration file for the business requirement information corresponding to the target business function.
[0062] To improve the accuracy of template configuration file generation, the script development tool can calculate the difference data between the business requirement information corresponding to the target business function and other business requirement information, and adjust the template configuration files corresponding to other business requirement information based on the difference data, thereby obtaining the template configuration file corresponding to the target business function.
[0063] It should be noted that if the above similarity scores are all less than or equal to the preset similarity threshold, the script development tool will automatically generate the template configuration file using the above template configuration file generation method to improve the accuracy of the template configuration file.
[0064] After generating the template configuration file, the script development tool parses the logical rules in the template configuration file to obtain an abstract syntax tree. Then, it integrates the business parameters, the attribute information of the business parameters, and the abstract syntax tree to generate an executable script for implementing the target business function.
[0065] Specifically, the script development tool maps the attribute information of the business parameters to the nodes in the abstract syntax tree that correspond to the business parameters; then, it generates an executable script corresponding to the target business function based on the node type in the abstract syntax tree and the attribute information of the business parameters corresponding to the nodes.
[0066] For example, the business requirements information may also include the language corresponding to the executable script, such as Perl, C, C++, Python, etc. The script development tool first establishes a parameter type environment, mapping the data type, value range, and other attributes of each business parameter to the corresponding node in the abstract syntax tree. Then, it traverses the syntax tree structure and generates an executable script in the target language based on the node type and parameter attributes, such as converting conditional statements into if-else structures and business operations into function calls.
[0067] Through the above process, the script development tool can automatically generate executable scripts without human intervention, reducing the cost of script generation and improving the efficiency of script generation.
[0068] In some embodiments, after generating multiple code snippets based on the node types of nodes in multiple sub-syntax trees and the attribute information of the business parameters corresponding to the nodes, the script development tool also performs static analysis on the multiple code snippets to identify the target operation points in each code snippet whose business impact is greater than the business impact threshold; and injects exception handling code and logging code into the target operation points.
[0069] For example, in the embodiments of this application, the script development tool also embeds parameter validation logic and exception handling mechanism into the code, and adds necessary dependency declarations, boundary checks and production-grade features (such as logging and performance monitoring) through context-aware code optimization, outputting type-safe, directly deployable executable scripts to ensure the accurate implementation of business logic and technical feasibility.
[0070] In some embodiments, the script development tool predicts the logical complexity of the executable script based on the node types of nodes in the abstract syntax tree and the relationships between nodes in the abstract syntax tree. If the logical complexity is higher than a preset complexity threshold, the abstract syntax tree is split into multiple sub-syntax trees according to the relationships between nodes in the abstract syntax tree. Then, multiple code snippets are generated according to the node types of nodes in the multiple sub-syntax trees and the attribute information of the business parameters corresponding to the nodes. Finally, the multiple code snippets are combined according to the logical rules of the multiple sub-syntax trees to generate the executable script corresponding to the target business function.
[0071] For example, in a loan approval scenario, the business requirement information is: "The system needs to automatically approve corporate loan applications. First, verify the company's qualifications: it must have been established for at least 3 years and have no adverse credit records. If it meets these requirements, proceed to financial assessment: calculate its debt-to-asset ratio to be less than 50% and its annual revenue growth rate to be greater than 10%. If the financial assessment also passes, calculate the final credit limit and interest rate using different models based on the company's size and industry. If any step fails, reject the application and record the reason."
[0072] The script development tool constructs an abstract syntax tree based on the above business requirements information. This abstract syntax tree contains a large number of nodes, such as multiple condition judgment nodes for checking "years of establishment", "credit records", "asset-liability ratio", "revenue growth rate" and other conditions; logical nodes such as "AND" and "OR" that connect these conditions; and multiple action execution nodes such as "calculate credit limit", "set interest rate" and "reject application".
[0073] By analyzing the variety of node types (conditions, calculations, branches, actions) and the intricate relationships between nodes (multi-layered nested conditional judgments and tightly interdependent evaluation stages), the script development tool predicts that the approval script has high logical complexity. Therefore, based on the natural breakpoints of the business process, the tool splits the abstract syntax tree into three logically independent sub-syntax trees: sub-syntax tree A for initial qualification review, sub-syntax tree B for assessing financial health, and sub-syntax tree C for determining quotas and pricing. Based on these three sub-syntax trees, the tool generates three code snippets and, according to the relationships between sub-processes in the original business logic, combines these three code snippets into an executable script.
[0074] It should be noted that in this embodiment, the large and complex script is broken down into independent modules with single responsibilities that are easy to manage and test. This not only fully implements the business functions, but also has a clean structure and high readability. When the business functions need to be adjusted, only the corresponding code snippets need to be adjusted, which improves the maintainability of the executable script.
[0075] In some embodiments, after integrating business parameters, attribute information of business parameters, and abstract syntax trees to generate an executable script for implementing the target business function, the script development tool can also obtain the system configuration file corresponding to the business system, and combine the executable script corresponding to the target business function and the executable scripts corresponding to other business functions in the business system based on the running logic to obtain the target executable script corresponding to the business system.
[0076] For example, the system configuration file includes at least the running logic between multiple business functions. The system configuration file defines the execution order between the executable scripts corresponding to each business function. The script development tool can combine the executable scripts corresponding to multiple business functions based on the execution order to obtain the target executable script of the business system.
[0077] The above solution combines executable scripts corresponding to multiple business functions, intelligently assembling originally independently developed executable scripts for a single business function (such as risk assessment, portfolio recommendation, and transaction execution) into a complete system target script that is seamlessly collaborative, data-connected, and business-resilient. This solves the integration problem between modules, ensures the synergy of functional modules, data consistency, and process correctness in complex business systems, and greatly improves the automation level and overall reliability of system development.
[0078] This concludes the introduction of the methods provided in the embodiments of this application.
[0079] As can be seen from the above, the solution provided in this application automatically generates a template configuration file and generates an executable script based on the template configuration file. While realizing low-code development scripts, it also simplifies the development process and reduces maintenance costs.
[0080] Based on the script generation method provided in the above embodiments, this application also provides specific implementations of the script generation apparatus. Please refer to the following embodiments.
[0081] First see Figure 2 The script generation device 200 provided in this application embodiment includes: a requirement acquisition module 201, a template generation module 202, a rule parsing module 203, and a script generation module 204.
[0082] The requirement acquisition module 201 is used to acquire business requirement information corresponding to the target business function; The template generation module 202 is used to perform semantic analysis on business requirement information and generate a template configuration file. The template configuration file includes at least the business parameters required to implement the target business function, the attribute information of the business parameters, and the logical rules corresponding to the business parameters. The rule parsing module 203 is used to parse logical rules and generate an abstract syntax tree corresponding to the target business function; The script generation module 204 is used to integrate business parameters, attribute information of business parameters and abstract syntax tree to generate an executable script for implementing the target business function.
[0083] In some embodiments, the template generation module is specifically used to perform multi-dimensional contextual analysis on business requirement information to obtain business concepts corresponding to the business requirement information; construct a business concept graph expressing the semantic relationships between business concepts; based on the business concept graph, determine the business parameters required to achieve the target business function and the attribute information corresponding to the business parameters through a constraint propagation network; perform semantic role labeling on the business requirement information based on the business concept graph to identify the business actions corresponding to the target business function and the action attribute information associated with the business actions; and perform semantic expansion and association on the business actions and action attribute information based on the semantic relationships between business concepts in the business concept graph to generate logical rules corresponding to the business parameters.
[0084] In some embodiments, the script generation apparatus further includes: a template configuration module, configured to, before performing semantic analysis on the business requirement information and generating a template configuration file, obtain other business requirement information corresponding to other business functions, wherein the other business requirement information has corresponding other template configuration files; perform similarity matching between the other business requirement information and the business requirement information to obtain a matching result; and, if the matching result indicates that the similarity between the other business requirement information and the business requirement information meets a preset condition, use the other template configuration file as the template configuration file corresponding to the target business function.
[0085] In some embodiments, the script generation module includes a mapping module and a first generation module. The mapping module is used to map the attribute information of business parameters to nodes in the abstract syntax tree corresponding to the business parameters. The first generation module is used to generate an executable script corresponding to the target business function based on the node type of the nodes in the abstract syntax tree and the attribute information of the business parameters corresponding to the nodes.
[0086] In some embodiments, the first generation module is specifically used to predict the logical complexity of the executable script based on the node type of the nodes in the abstract syntax tree and the association between the nodes in the abstract syntax tree; if the logical complexity is higher than a preset complexity threshold, the abstract syntax tree is split into multiple sub-syntax trees according to the association between the nodes in the abstract syntax tree; multiple code snippets are generated according to the node type of the nodes in the multiple sub-syntax trees and the attribute information of the business parameters corresponding to the nodes; and the multiple code snippets are combined according to the association between the multiple sub-syntax trees in logical rules to generate an executable script corresponding to the target business function.
[0087] In some embodiments, the script generation apparatus further includes: a recording module, configured to generate multiple code snippets based on the node types of nodes in multiple sub-syntax trees and the attribute information of the business parameters corresponding to the nodes, perform static analysis on the multiple code snippets, identify target operation points in each code snippet whose business impact is greater than a business impact threshold, and inject exception capture code and logging code into the target operation points.
[0088] In some embodiments, the script generation apparatus further includes: a script combination module, configured to, after integrating business parameters, attribute information of business parameters and abstract syntax tree to generate an executable script for implementing the target business function, obtain a system configuration file corresponding to the business system, the system configuration file including at least the running logic between multiple business functions; and combine the executable script corresponding to the target business function and the executable scripts corresponding to other business functions in the business system based on the running logic to obtain the target executable script corresponding to the business system.
[0089] The various modules of the script generation device provided in this application embodiment can achieve... Figure 1 The method provides functionality for each step of generating scripts and achieves the corresponding technical effects. For the sake of brevity, these details will not be elaborated here.
[0090] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0091] The electronic device 300 may include a processor 301 and a memory 302 storing computer program instructions.
[0092] Specifically, the processor 301 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0093] Memory 302 may include mass storage for data or instructions. For example, and not limitingly, memory 302 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 302 may include removable or non-removable (or fixed) media. Where appropriate, memory 302 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 302 is non-volatile solid-state memory.
[0094] In certain embodiments, the memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Thus, generally, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this application.
[0095] The processor 301 implements any of the script generation methods described in the above embodiments by reading and executing computer program instructions stored in the memory 302.
[0096] In some examples, the electronic device 300 may also include a communication interface 303 and a bus 304. For example, Figure 3 As shown, the processor 301, memory 302, and communication interface 303 are connected through bus 304 and complete communication with each other.
[0097] The communication interface 303 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0098] Bus 304 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not as a limitation, bus 304 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 304 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.
[0099] For example, the electronic device 300 can be a mobile phone, tablet computer, laptop computer, handheld computer, in-vehicle electronic device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc.
[0100] The electronic device 300 can execute the script generation method in the embodiments of this application, thereby achieving the combination Figure 1 The method described for generating the script.
[0101] In addition, in conjunction with the script generation methods in the above embodiments, this application also provides a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the script generation methods in the above embodiments. Examples of computer-readable storage media include non-transitory computer-readable storage media, such as portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, etc.
[0102] This application also provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a processor, they implement any of the script generation methods described in the above embodiments.
[0103] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0104] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0105] This application also provides a computer program product, including a computer program, which, when executed, implements any of the script generation methods described in the above embodiments.
[0106] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0107] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0108] The above are merely specific embodiments of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A method of generating a script, characterized by, The method comprises the following steps: obtaining business requirement information corresponding to a target business function; performing semantic analysis on the business requirement information to generate a template configuration file, wherein the template configuration file at least includes business parameters required for implementing the target business function, attribute information of the business parameters, and logical rules corresponding to the business parameters; parsing the logical rules to generate an abstract syntax tree corresponding to the target business function; integrating the business parameters, the attribute information of the business parameters, and the abstract syntax tree to generate an executable script for implementing the target business function.
2. The method of claim 1, wherein, The method of performing semantic analysis on the business requirement information to generate a template configuration file comprises the following steps: performing multi-dimensional context analysis on the business requirement information to obtain business concepts corresponding to the business requirement information; constructing a business concept graph expressing semantic relationships between the business concepts; determining business parameters required for implementing the target business function and attribute information corresponding to the business parameters based on the business concept graph through a constraint propagation network; performing semantic role labeling on the business requirement information based on the business concept graph to identify business actions corresponding to the target business function and action attribute information associated with the business actions; performing semantic extension and association on the business actions and the action attribute information based on the semantic relationships between the business concepts in the business concept graph to generate logical rules corresponding to the business parameters.
3. The method of claim 2, wherein, Before the step of performing semantic analysis on the business requirement information to generate a template configuration file, the method further comprises the following steps: obtaining other business requirement information corresponding to other business functions, wherein the other business requirement information has a corresponding other template configuration file; performing similarity matching on the other business requirement information and the business requirement information to obtain a matching result; in a case where the matching result indicates that the similarity between the other business requirement information and the business requirement information satisfies a preset condition, taking the other template configuration file as the template configuration file corresponding to the target business function.
4. The method of claim 1, wherein, The method of integrating the business parameters, the attribute information of the business parameters, and the abstract syntax tree to generate an executable script for implementing the target business function comprises the following steps: mapping the attribute information of the business parameters to nodes in the abstract syntax tree corresponding to the business parameters; generating an executable script corresponding to the target business function according to the node types of the nodes in the abstract syntax tree and the attribute information of the business parameters corresponding to the nodes.
5. The method of claim 4, wherein, The method of generating an executable script corresponding to the target business function according to the node types of the nodes in the abstract syntax tree and the attribute information of the business parameters corresponding to the nodes comprises the following steps: predicting the logical complexity of the executable script based on the node types of the nodes in the abstract syntax tree and the association relationships between the nodes in the abstract syntax tree; in a case where the logical complexity is higher than a preset complexity threshold, splitting the abstract syntax tree into multiple sub-syntax trees according to the association relationships between the nodes in the abstract syntax tree. generating a plurality of code segments according to node types of nodes in the plurality of sub syntax trees and attribute information of service parameters corresponding to the nodes; combining the plurality of code segments according to association relationships of the plurality of sub syntax trees on logical rules, to generate an executable script corresponding to the target service function.
6. The method of claim 5, wherein, After the plurality of code segments are generated according to the node types of the nodes in the plurality of sub syntax trees and the attribute information of the service parameters corresponding to the nodes, the method further includes: performing static analysis on the plurality of code segments, to identify a target operation point in each code segment with a service impact degree greater than a service impact degree threshold; injecting exception capture code and log recording code into the target operation point.
7. The method according to any one of claims 1 to 6, characterized in that, After the data integration of the service parameters, the attribute information of the service parameters, and the abstract syntax tree is performed to generate the executable script for implementing the target service function, the method further includes: obtaining a system configuration file corresponding to a business system, the system configuration file including at least running logic between a plurality of service functions; performing combination processing on the executable script corresponding to the target service function and executable scripts corresponding to other service functions in the business system based on the running logic, to obtain a target executable script corresponding to the business system.
8. An apparatus for generating a script, characterized by comprise: a requirement obtaining module configured to obtain business requirement information corresponding to a target service function; a template generating module configured to perform semantic analysis on the business requirement information, to generate a template configuration file including at least a service parameter required for implementing the target service function, attribute information of the service parameter, and a logical rule corresponding to the service parameter; a rule analyzing module configured to analyze the logical rule, to generate an abstract syntax tree corresponding to the target service function; a script generating module configured to perform data integration on the service parameter, the attribute information of the service parameter, and the abstract syntax tree, to generate an executable script for implementing the target service function.
9. An electronic device, comprising: The device comprises a processor and a memory storing computer program instructions; the processor implements the method of generating a script as claimed in any one of claims 1-7 when executing the computer program instructions.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer program instructions; the computer program instructions are executed by a processor to implement the method of generating a script as claimed in any one of claims 1-7.
11. A computer program product, characterised in that, The instructions in the computer program product are executed by a processor of an electronic device, so that the electronic device can execute the method of generating a script as claimed in any one of claims 1-7.
Citation Information
Cited By
Hierarchical text-driven three-dimensional modeling method, device and medium
CN122021065A