Script verification method and computer readable storage medium
By dynamically extracting and filling data into script templates and verifying consistency and logical integrity, the problem of low script verification efficiency and difficult to detect logical errors in game development is solved, and script management is efficient and accurate.
Patent Information
- Application Number
- CN202510136497.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-06-06
Smart Images

Figure CN120104459A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a script verification method and a computer-readable storage medium. Background Art
[0002] In the process of game development, the store system is an important component, and it is usually necessary to frequently update product information. This product information involves multiple parameters such as product ID, name, price, inventory, etc., and is stored in the database (SQL script) and Lua script. In order to ensure the consistency and accuracy of product information, it is necessary to check the product information in the script. However, the existing checking method has the following disadvantages: 1. Manual verification is inefficient. Manual verification of parameters in SQL scripts and Lua scripts is time-consuming and laborious, especially when processing a large amount of product information, which is prone to errors, leading to missed detections and logical conflicts.
[0003] 2. Logical errors are difficult to detect. There are complex logical relationships between parameters, such as the rationality of price, inventory, and discounts. Traditional manual inspections are difficult to detect potential errors in a timely manner.
[0004] 3. Lack of automated verification and repair mechanisms. Most existing tools cannot automatically verify the generated scripts and lack intelligent error location and repair suggestion functions.
[0005] Therefore, an automated verification method is urgently needed to improve overall efficiency and accuracy. Summary of the invention
[0006] The technical problem to be solved by the present invention is to provide a script verification method and a computer-readable storage medium, which can improve the efficiency and accuracy of script verification.
[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is: a script verification method, comprising: Dynamically extract target data from a preset data source, and fill the target data into a preset first script template and a second script template, respectively, to generate a first script and a second script; Performing consistency verification on the target data in the first script and the second script; The first script and the second script are subjected to logic integrity verification, wherein the logic integrity verification includes field value legitimacy verification, necessary field integrity verification, and script logic execution order verification.
[0008] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described above is implemented.
[0009] The beneficial effects of the present invention are: through data extraction, template filling, script consistency verification and logic integrity verification, data parsing automation, script generation consistency and logic verification intelligence are realized, and the consistency of script content and the correctness of business logic can be ensured, thereby improving the efficiency and accuracy of script management in a complex business environment. The present invention can solve the problems of low manual efficiency, incomplete verification and difficulty in error repair in the prior art, and greatly improve the efficiency and accuracy of script verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 A flowchart of a script verification method of the present invention; Figure 2 This is a flow chart of a method according to Embodiment 1 of the present invention; Figure 3 This is a schematic diagram of a consistency verification report according to Embodiment 1 of the present invention; Figure 4 This is a schematic diagram of a repair suggestion report according to Embodiment 1 of the present invention. DETAILED DESCRIPTION
[0011] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0012] Please refer to Figure 1 , a script verification method, comprising: Dynamically extract target data from a preset data source, and fill the target data into a preset first script template and a second script template, respectively, to generate a first script and a second script; Performing consistency verification on the target data in the first script and the second script; The first script and the second script are subjected to logic integrity verification, wherein the logic integrity verification includes field value legitimacy verification, necessary field integrity verification, and script logic execution order verification.
[0013] From the above description, it can be seen that the beneficial effects of the present invention are: it can solve the problems of low manual efficiency, incomplete verification and difficulty in error repair in the prior art, and greatly improve the efficiency and accuracy of script verification.
[0014] Furthermore, the first script is a SQL script, and the second script is a Lua script.
[0015] Further, the data sources include Excel files, JOSN files and databases; The dynamically extracting target data from a preset data source includes: Parse the data table in the preset Excel file through Python's pandas library to obtain the header information, and dynamically extract the target data based on the header information; Dynamically parse the nested JOSN structure in the preset JOSN file through a recursive algorithm to extract the target data; Through the query instructions corresponding to the target data, the target data is queried and extracted in the preset database.
[0016] From the above description, it can be seen that the target data can be dynamically extracted from Excel, JSON and databases, so as to be subsequently filled into the script template to realize the automatic generation of the script.
[0017] Furthermore, the step of filling the target data into a preset first script template and a preset second script template respectively to generate a first script and a second script includes: The target data is filled into the preset first script template and the second script template respectively through the template engine.
[0018] From the above description, it can be seen that filling through the template engine can improve the efficiency and accuracy of filling.
[0019] Furthermore, the step of filling the target data into a preset first script template and a preset second script template respectively to generate a first script and a second script further includes: If the data field is inconsistent with the template field, the corresponding relationship between the data field and the template field is determined through a preset field mapping rule table, where the data field is the field of the target data and the template field is the field in the script template.
[0020] From the above description, it can be seen that the incomplete filling caused by the inconsistency between the data field and the template field is avoided.
[0021] Furthermore, the consistency verification of the target data in the first script and the second script includes: Parse and obtain the fields of target data in the first script and the second script respectively; Through text parsing or structured data comparison, the field values of the same field in the first script and the second script are compared one by one, and a consistency verification report is generated based on the comparison results.
[0022] From the above description, it can be seen that the automation of script consistency verification can be achieved.
[0023] Furthermore, the consistency verification of the target data in the first script and the second script further includes: If it is detected that the fields of the target data in the first script and the second script are inconsistent, the inconsistent fields and the script line numbers where they are located are marked.
[0024] From the above description, it can be seen that automatic error location can be supported to facilitate subsequent repair.
[0025] Further, the field value legal value verification includes: verifying the legality of the field values of the target data in the first script and the second script respectively according to the value range and type corresponding to each field of the target data; The necessary field integrity verification includes: performing integrity verification on the fields of the target data in the first script and the second script respectively according to the preset necessary fields; The script logic execution order verification includes: verifying the execution order of target data in the first script and the second script and the logical relationship between fields according to preset business logic and field rules.
[0026] From the above description, it can be seen that by intelligently verifying the script logic, that is, intelligently verifying the parameter relevance, execution logic and functional validity in the script, it is possible to detect whether the script complies with the preset business rules and prevent system failures caused by parameter configuration errors, logical errors or inconsistencies.
[0027] Furthermore, logical integrity verification is performed through a preset artificial intelligence model, and the artificial intelligence model is trained based on verified historical scripts.
[0028] From the above description, it can be seen that implementing logic verification through AI models can improve the efficiency and accuracy of script verification.
[0029] Furthermore, after the logical integrity verification of the first script and the second script is performed, the method further includes: If the logical integrity verification fails, the error location is located and corresponding repair suggestions are provided based on the error type.
[0030] From the above description, it can be seen that the error location can be automatically identified and repair suggestions can be provided.
[0031] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described above is implemented.
[0032] Embodiment 1 Please refer to Figure 2-4 , Embodiment 1 of the present invention is: a script verification method, which is applicable to game development, product information management, automated testing and other scenarios. In this embodiment, the application to product information management is used as an example for explanation, that is, the target data is product data, which may include product ID, name, price, inventory and other fields.
[0033] like Figure 2As shown, the following steps are included: S1: Dynamically extract target data from the preset data source.
[0034] In this embodiment, the data source includes Excel files, JOSN files and databases, and the file format of the data source can be automatically identified by extension or content features. For Excel files, Python's pandas library can be used to parse Excel data tables and dynamically extract target data based on header information; for JOSN files, a recursive algorithm can be used to dynamically parse nested JSON structures and extract target data; for databases, SQL queries can be used to extract target data, such as "SELECT product ID, name, price, inventory FROM product table".
[0035] Among them, pandas is the abbreviation of python+data+analysis. It is a third-party data analysis library in Python based on numpy and matplotlib. Together with the latter two, it constitutes the basic toolkit for Python data analysis.
[0036] Furthermore, after extracting the target data, the target data is subjected to abnormal data detection, such as checking for missing fields, illegal values (such as negative numbers, null values), and data format inconsistencies, and based on the detection results, an error report is generated to indicate the problem fields and locations.
[0037] S2: Fill the target data into the preset first script template and the second script template respectively to generate the first script and the second script.
[0038] In this embodiment, the first script is a SQL script, and the second script is a Lua script.
[0039] In actual application scenarios, the target data can be filled into SQL script templates and Lua script templates through the Jinja2 template engine. The example is as follows: SQL template example: "UPDATE product table SET name='{{name}}', price={{price}}, inventory={{inventory}} WHERE product ID={{product ID}}"; Lua template example: "Product table [{{Product ID}}] = { Name = "{{Name}}", Price = {{Price}}, Inventory = {{Inventory}}}".
[0040] Furthermore, if there is a problem that the data field (ie, the field of the target data) is inconsistent with the template field (ie, the field in the script template), the field mapping rule table can be used to determine the corresponding data field and template field, and generate a log record problem field.
[0041] S3: Verify the consistency of the target data in the first script and the second script.
[0042] Specifically, the SQL script and Lua script are automatically parsed to extract the fields of the target data, such as product ID, price, inventory and other key fields, and then the field values of the same field in the SQL script and Lua script are compared one by one through text parsing or structured data comparison, and a consistency verification report is generated based on the comparison results, such as Figure 3 shown.
[0043] In actual application scenarios, when field inconsistencies are detected, the system can automatically mark the error field and the script line number where it is located. The consistency verification report can include the error type and location.
[0044] Furthermore, it can also support verification of newly added or changed fields to improve verification efficiency.
[0045] S4: Perform logical integrity verification on the first script and the second script, including field value legitimacy verification, necessary field integrity verification, and script logic execution order verification.
[0046] For field value validity verification, predefine the expected value range and type of each field. For example, the value of the "price" field must be a positive number and within the specified range (such as 10~9999), and the value of the "inventory" field must be a non-negative integer. Then, implement field value verification through regular expressions and conditional judgments, for example: def validate_price(value): return isinstance(value,(int,float)) and 10 <=value<=9999 def validate_stock(value): return isinstance(value,int) and value>=0 For the required field integrity verification, it means ensuring that the generated script contains all the required fields. For example, the SQL script must contain the product ID, and the Lua script must contain the product name and price fields.
[0047] Furthermore, when the system detects that certain fields are missing or misconfigured, it will automatically complete the missing fields or generate new script paragraphs to ensure the consistency of the script in format and logic.
[0048] Verify the execution order of script logic, that is, verify the execution order of the script. By pre-defining field rules and business logic in the template, the system automatically identifies each field in the script and determines whether the fields are logically related according to the preset rules. For example, check whether there is a logical contradiction between the price and inventory of the product, or whether the discount of the order complies with the relevant policy.
[0049] In an optional embodiment, insert the basic product information first, then update the price or inventory; ensure that the limited-time discount is consistent with the original price logic to prevent conflicts. Example verification: def check_discount_logic(original_price,discount_price): return discount_price<original_price This embodiment not only compares the script content, but also performs intelligent verification on the script logic, that is, when comparing scripts, in addition to comparing whether the content of the text fields is consistent, the parameter relevance, execution logic and functional validity in the script are also intelligently verified. This verification mechanism can detect whether the script complies with the preset business rules and prevent system failures caused by parameter configuration errors, logical errors or inconsistencies. This embodiment can handle complex logical relationships. For example, when comparing multiple fields such as price, inventory, discount, etc., we not only perform direct text comparison on the fields, but also judge the rationality and consistency between these fields through the set business rules. In this way, even if the contents of two scripts are similar, if they conflict or do not meet the specifications in business logic, warnings can be actively issued and repair suggestions can be provided. Through business logic verification, the accuracy and execution effectiveness of the script can be guaranteed from a higher level.
[0050] Furthermore, the preset artificial intelligence model (AI model) can be used to assist in logic verification. The system uses historical script data sets (SQL scripts and Lua scripts that have been verified in historical projects) to train the AI model. The training process compares the input and target scripts, automatically optimizes the weights, and improves the verification accuracy. The AI model can identify common logical errors and conflicts. For example, the AI model may include decision trees and deep learning models. Decision trees are used to verify simple logic, and deep learning models (such as BERT) are used to detect complex logic and semantic errors. The AI model can continuously improve the logic verification effect by learning new rules or abnormal patterns and adapting to new business logic verification requirements.
[0051] Furthermore, the system parses SQL scripts and Lua scripts to accurately locate the field and line number where the error is located. The AI model analyzes the error type, such as missing fields, abnormal values, or logical errors. Then, based on the AI model and preset business rules, it automatically gives repair suggestions.
[0052] For example, if a parameter setting in a script is found to be inconsistent with business rules, the system will prompt possible modification methods and provide relevant reference materials. For example, when a negative value is detected in a price field, it is recommended to set a default value or a reasonable range. When a limited-time discount is below the minimum threshold, the system prompts to correct the discount price. The repair suggestion report can be as follows: Figure 4 shown.
[0053] In actual application scenarios, the system can use a multi-threaded mechanism to perform consistency verification and logical integrity verification in parallel, that is, steps S3 and S4 can be performed simultaneously to improve verification efficiency. It is also possible to verify only newly added or modified fields to reduce redundant calculations and improve large-scale verification performance.
[0054] In an actual test scenario involving 10,000 pieces of product data, the full verification time was 8.5 seconds, the incremental verification time was 3.2 seconds, the field consistency accuracy was 99.8%, and the logical integrity detection accuracy was 98.5%.
[0055] Furthermore, the system can be further expanded, for example, including: Data format expansion: The system supports the access of new formats (such as XML, YAML) through modular design, and users can customize parsing rules.
[0056] Script template adaptation: Users can import new SQL and Lua script templates, and the system automatically adapts the field filling logic.
[0057] CI / CD tool integration: The system supports integration with automation tools such as Jenkins and GitLab CI to achieve continuous script verification and testing.
[0058] Dynamic rule expansion: AI models can be trained and updated through new rules input by users, automatically adapting to new logic verification requirements.
[0059] Compared with existing tools that can only perform simple text comparison but cannot implement complex logic verification and intelligent error repair, this embodiment integrates AI models to implement field consistency verification and logic error detection, supports automatic error location and repair suggestions, dynamically adapts to business logic, has good scalability, and improves large-scale script verification performance through incremental verification and parallel optimization.
[0060] In a large-scale game project, the system automatically verified 15,000 product data items, and the results were as follows: manual verification time: 8 hours, system verification time: 10 minutes; manual error rate: 3.5%, system error rate: 0.2%. The repair suggestions automatically generated by the system helped developers quickly resolve more than 80% of the verification errors.
[0061] Furthermore, in addition to static syntax checking, the system can also dynamically execute scripts to verify whether the scripts can work properly during actual operation, and provide timely feedback on the operation results to ensure that the scripts can be executed as expected in all situations.
[0062] Embodiment 2 This embodiment is a computer-readable storage medium corresponding to the above embodiment, on which a computer program is stored. When the program is executed by the processor, the various steps of a script verification method in the above embodiment are implemented, and the same technical effect can be achieved, which will not be repeated here.
[0063] In summary, the script verification method and computer-readable storage medium provided by the present invention break through the limitations of existing verification tools, and greatly improve the efficiency and accuracy of script verification through innovative functions such as AI intelligent verification, error location and repair suggestions. The system has strong scalability and performance optimization capabilities, and can be widely used in game development, product management, automated testing and other fields.
[0064] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A script verification method, characterized in that: include: Dynamically extract target data from a preset data source, and fill the target data into a preset first script template and a second script template, respectively, to generate a first script and a second script; Performing consistency verification on the target data in the first script and the second script; The first script and the second script are subjected to logic integrity verification, wherein the logic integrity verification includes field value legitimacy verification, necessary field integrity verification, and script logic execution order verification.
2. The script verification method according to claim 1, characterized in that: Data sources include Excel files, JOSN files and databases; The dynamically extracting target data from a preset data source includes: Parse the data table in the preset Excel file through Python's pandas library to obtain the header information, and dynamically extract the target data based on the header information; Dynamically parse the nested JOSN structure in the preset JOSN file through a recursive algorithm to extract the target data; Through the query instructions corresponding to the target data, the target data is queried and extracted in the preset database.
3. The script verification method according to claim 1, characterized in that: The step of filling the target data into a preset first script template and a second script template respectively to generate a first script and a second script comprises: The target data is filled into the preset first script template and the second script template respectively through the template engine.
4. The script verification method according to claim 3, characterized in that: The step of filling the target data into the preset first script template and the second script template respectively to generate the first script and the second script further includes: If the data field is inconsistent with the template field, the corresponding relationship between the data field and the template field is determined through a preset field mapping rule table, where the data field is the field of the target data and the template field is the field in the script template.
5. The script verification method according to claim 1, characterized in that: The consistency verification of the target data in the first script and the second script includes: Parse and obtain the fields of target data in the first script and the second script respectively; Through text parsing or structured data comparison, the field values of the same field in the first script and the second script are compared one by one, and a consistency verification report is generated based on the comparison results.
6. The script verification method according to claim 5, characterized in that: The consistency verification of the target data in the first script and the second script further includes: If it is detected that the fields of the target data in the first script and the second script are inconsistent, the inconsistent fields and the script line numbers where they are located are marked.
7. The script verification method according to claim 1, characterized in that: The field value legality verification includes: verifying the legality of the field values of the target data in the first script and the second script respectively according to the value range and type corresponding to each field of the target data; The necessary field integrity verification includes: performing integrity verification on the fields of the target data in the first script and the second script respectively according to the preset necessary fields; The script logic execution order verification includes: verifying the execution order of target data in the first script and the second script and the logical relationship between fields according to preset business logic and field rules.
8. The script verification method according to claim 1, characterized in that: Logical integrity verification is performed using a preset artificial intelligence model, which is trained based on verified historical scripts.
9. The script verification method according to claim 1, characterized in that: After the logic integrity verification of the first script and the second script is performed, the method further includes: If the logical integrity verification fails, the error location is located and corresponding repair suggestions are provided based on the error type.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.