Grammar repairing method and device, computer equipment and storage medium
By constructing a sample database and training a target repair model, a deep learning model is used to identify and repair SQL syntax errors across databases, solving the problem of low efficiency in syntax error repair in existing technologies and achieving efficient automatic syntax error repair.
Patent Information
- Application Number
- CN202511731039.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-24
- Publication Date
- 2026-02-27
AI Technical Summary
Existing database tools and frameworks cannot automatically identify and parse SQL syntax differences across databases, making it difficult for developers to quickly locate problems and propose solutions when syntax is incompatible, resulting in low efficiency in syntax error repair.
By constructing a sample database, training a target repair model, obtaining error information from cross-database business query requests, and using deep learning models such as CodeT5 to identify and repair syntax errors, the error causes and repair solutions are output.
It improves the efficiency of syntax error correction, reduces the time developers spend manually fixing errors, ensures smooth cross-database migration and adaptation, and enables the system to adapt to constantly changing database environments.
Smart Images

Figure CN121579503A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a grammar repair method and device, computer equipment and storage medium. BACKGROUND
[0002] A database management system (DBMS) is the core component of data storage, processing and management. With the continuous expansion of data size and the diversification of application scenarios, various types of relational and non-relational database systems have emerged. However, different database systems have significant differences in structure, data model and query language. For example, when developers write and execute structured query language (SQL) queries, they often need to be compatible with different syntaxes among multiple database systems.
[0003] In this process, syntax errors are one of the common challenges for developers.
[0004] Most existing database tools and frameworks cannot automatically identify and parse SQL syntax differences across databases, making it difficult for developers to quickly locate problems and propose solutions when syntax is not compatible, resulting in low efficiency in repairing syntax errors. SUMMARY
[0005] Therefore, it is necessary to provide a grammar repair method, device, computer equipment and storage medium to improve the efficiency of repairing syntax errors.
[0006] In a first aspect, the present application provides a grammar repair method, comprising:
[0007] Obtaining a business query request initiated by a client across databases;
[0008] In the case where it is identified that the business query request has a syntax error, obtaining error information of the business query request; wherein the error information at least includes error type, error location and error statement;
[0009] Inputting the error information into a target repair model to output a repair result for the business query request; wherein the repair result at least includes error cause and repair scheme.
[0010] In one of the embodiments, the target repair model is trained by the following way:
[0011] Constructing a sample database; wherein the sample database includes a plurality of data knowledge bases, and the plurality of data knowledge bases are used to record error information and corresponding solutions in different dimensions;
[0012] The sample database is sampled to train an initial repair model to obtain a target repair model.
[0013] In one of the embodiments, the plurality of data knowledge bases comprises at least two of the following:
[0014] a syntax compatibility knowledge base for recording compatible error information and corresponding solutions;
[0015] a syntax difference knowledge base for recording syntax differences between different databases and corresponding solutions;
[0016] a syntax conflict knowledge base for recording conflict types, conflict positions, error information and corresponding solutions.
[0017] In one of the embodiments, the number of repair results is a plurality, and the method further comprises:
[0018] obtaining historical evaluations corresponding to each repair result;
[0019] sorting each repair result according to the historical evaluation corresponding to each repair result;
[0020] displaying each repair result in the order of arrangement.
[0021] In one of the embodiments, the sorting each repair result according to the historical evaluation corresponding to each repair result comprises:
[0022] for each repair result, if the historical evaluation corresponding to the repair result is not empty, determining a score of the repair result according to the level of the historical evaluation corresponding to the repair result;
[0023] if the historical evaluation corresponding to the repair result is empty, determining the score of the repair result according to an initial value of the historical evaluation;
[0024] sorting each repair result according to the score of each repair result.
[0025] In one of the embodiments, the method further comprises:
[0026] obtaining a current evaluation for the repair result;
[0027] in a case where it is identified that the current evaluation represents that the repair result is unqualified, outputting a display box; wherein the display box is used to prompt a user end to input a new repair result;
[0028] updating the target repair model based on the new repair result input by the user end in the display box.
[0029] In a second aspect, the application further provides a syntax repair device, comprising:
[0030] The first obtaining module is configured to obtain a cross-database service query request initiated by a client.
[0031] The second obtaining module is configured to, in a case where it is identified that the service query request has a syntax error, obtain error information of the service query request; wherein the error information at least includes an error type, an error position and an error statement.
[0032] The output module is configured to input the error information into a target repair model, and output a repair result for the service query request; wherein the repair result at least includes an error cause and a repair scheme.
[0033] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0034] The first obtaining module is configured to obtain a cross-database service query request initiated by a client.
[0035] The second obtaining module is configured to, in a case where it is identified that the service query request has a syntax error, obtain error information of the service query request; wherein the error information at least includes an error type, an error position and an error statement.
[0036] The output module is configured to input the error information into a target repair model, and output a repair result for the service query request; wherein the repair result at least includes an error cause and a repair scheme.
[0037] In a fourth aspect, the present application further provides a computer readable storage medium, which stores a computer program, and the computer program implements the following steps when executed by a processor:
[0038] The first obtaining module is configured to obtain a cross-database service query request initiated by a client.
[0039] The second obtaining module is configured to, in a case where it is identified that the service query request has a syntax error, obtain error information of the service query request; wherein the error information at least includes an error type, an error position and an error statement.
[0040] The output module is configured to input the error information into a target repair model, and output a repair result for the service query request; wherein the repair result at least includes an error cause and a repair scheme.
[0041] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, and the computer program implements the following steps when executed by a processor:
[0042] The first obtaining module is configured to obtain a cross-database service query request initiated by a client.
[0043] In a case where it is identified that the business query request has a syntax error, error information of the business query request is acquired; wherein the error information at least includes an error type, an error position and an error statement;
[0044] The error information is input into a target repair model, and a repair result for the business query request is output; wherein the repair result at least includes an error cause and a repair scheme.
[0045] The above syntax repair method, device, computer device and storage medium acquire a cross-database business query request initiated by a client; in a case where it is identified that the business query request has a syntax error, error information of the business query request is acquired; wherein the error information at least includes an error type, an error position and an error statement; the error information is input into a target repair model, and a repair result for the business query request is output; wherein the repair result at least includes an error cause and a repair scheme. By inputting the error information into the target repair model, the syntax error is repaired without manual repair by a developer, thereby improving the efficiency of syntax error repair. BRIEF DESCRIPTION OF DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0047] Figure 1 A flowchart of a syntax repair method in an embodiment;
[0048] Figure 2 A flowchart of training a target repair model in an embodiment;
[0049] Figure 3 A flowchart of displaying a repair result in an embodiment;
[0050] Figure 4 A flowchart of sorting repair results in an embodiment;
[0051] Figure 5 A flowchart of updating the target repair model in an embodiment;
[0052] Figure 6 A flowchart of a syntax repair method in another embodiment;
[0053] Figure 7A structural block diagram of a syntax repair device in an embodiment;
[0054] Figure 8 An internal structural diagram of a computer device in an embodiment. DETAILED DESCRIPTION
[0055] For the purpose, technical solutions and advantages of the present application to be clearer, the present application is further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0056] The syntax repair method provided by the embodiment of the present application can be applied to an application scenario of cross-database business query, and is specifically applied to quickly repairing syntax errors when a syntax error occurs in a business query request in the process of cross-database business query, so as to solve the syntax error problem.
[0057] The method can be executed by a server or a terminal. The server can be a stand-alone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle-mounted device, a projection device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc.
[0058] In an exemplary embodiment, as shown in Figure 1 A syntax repair method is provided, which is described by applying the method to a server and includes the following steps:
[0059] S101, obtaining a cross-database business query request initiated by a client.
[0060] Exemplarily, the cross-database business query request refers to an SQL query request initiated by a client and to be executed between at least two different databases (such as Oracle and PostgreSQL), which contains information such as a target database type (such as Oracle19c and PostgreSQL14), an SQL statement text (such as SELECT*FROM table CONNECT BY parent_id=id), and a business identifier (such as user order query).
[0061] The client can send a request to the server through a HyperText Transfer Protocol / HyperText Transfer Protocol Secure (HTTP / HTTPS) protocol, and a request receiving component of the server parses the request header and request body, and extracts a business query request.
[0062] S102, in the case where it is identified that the business query request has a syntax error, error information of the business query request is obtained.
[0063] The error information at least includes an error type, an error position, and an error statement.
[0064] For example, the syntax error refers to a problem that an SQL statement does not conform to a target database syntax rule, including syntax incompatibility (such as using Oracle proprietary syntax in PostgreSQL) and syntax conflict (such as a custom function name being duplicated with a database keyword).
[0065] The error information is used for positioning and analyzing core data of an error, wherein the error type can be labeled by a syntax parsing tool (such as cross-database syntax incompatibility), the error position can be accurately located to a line number and a column number of an SQL statement (such as line 3, column 15), and the error statement can be a complete SQL segment containing an error (such as CONNECT BY parent_id = id).
[0066] In the case where it is identified that the business query request has a syntax error, a syntax parsing tool can be called to perform a compilation-level detection on the SQL statement, and the syntax parsing tool can be a Bison syntax analyzer integrated; if an error is detected, a database log (such as a pg_log of PostgreSQL) is automatically read, an error type, an error position, and an error statement are extracted through a regular expression, and the extracted error type, error position, and error statement can be formatted and stored in a JSON structure.
[0067] S103, the error information is input into a target repair model, and a repair result for the business query request is output.
[0068] The repair result at least includes an error cause and a repair scheme.
[0069] For example, the target repair model can be a deep learning model based on a CodeT5 (Code-to-Text Transfer Transformer) model fine-tuned, which is specially used for processing SQL syntax error identification and repair, and has the ability to understand cross-database syntax differences.
[0070] Exemplarily, the error information in JSON format can be converted into a text sequence recognizable by the model, for example, the error type is cross-database syntax incompatibility; the error location is line 3, column 15; the error statement is CONNECT BY parent_id=id; and the target database is PostgreSQL 14.
[0071] The text sequence can be input into the target repair model; the model focuses on the error location through the attention mechanism, combines the syntax knowledge in the pre-trained data knowledge base, and outputs a JSON format repair result containing the error cause and repair scheme.
[0072] Exemplarily, the error cause in the repair result is used to explain the nature of the error, for example, PostgreSQL does not support the CONNECT BY syntax of Oracle, which needs to be replaced by WITH RECURSIVE; and the repair scheme in the repair result includes the modified SQL statement and the modification explanation.
[0073] The above syntax repair method obtains a cross-database business query request initiated by a client; in the case where it is identified that the business query request has a syntax error, error information of the business query request is obtained; wherein the error information at least includes error type, error location and error statement; the error information is input into the target repair model, and a repair result for the business query request is output; wherein the repair result at least includes error cause and repair scheme. By inputting the error information into the target repair model, the syntax error is repaired without the need for manual repair by the developer, thereby improving the efficiency of syntax error repair.
[0074] In some optional implementations, referring to Figure 2 , Figure 2 A flowchart for training a target repair model is provided, specifically comprising the following steps:
[0075] S201, constructing a sample database.
[0076] The sample database is a structured data set collection for training the target repair model, and the sample database includes a plurality of data knowledge bases for recording error information and corresponding solutions in different dimensions.
[0077] Exemplarily, sample data can be obtained from public database communities, enterprise internal development logs, database official documents, etc. through a data acquisition component; wherein the public database community can be a SQL error question and answer post of Stack Overflow, so as to extract error description-repair code information therefrom; cross-database syntax error records can be screened from enterprise internal development logs; and the database official document can be an Oracle, PostgreSQL website, etc.
[0078] Further, the collected sample data can be classified according to the error dimension to obtain a plurality of data knowledge bases.
[0079] S202, the sample database trains the initial repair model to obtain a target repair model.
[0080] For example, the sample database can be divided into a training set, a validation set and a test set according to a preset ratio, such as 7:2:1; CodeT5 can be used as an initial model, and a deep learning framework PyTorch can be used for training, and the learning rate, the number of sample data input to the model at one time (batch size), the number of iterations and the like can be set in advance, for example, the learning rate is set to 5e-5, the batch size is set to 16, and the number of iterations is set to 50 rounds, and in each round, the training set is used to update the model parameters, and the validation set is used to calculate the repair accuracy (the number of correctly repaired samples / the total number of samples); when the repair accuracy of the validation set reaches a preset threshold, the training is stopped; the preset threshold can be set according to empirical data or actual conditions, for example, it can be set to 95%; further, the test set is used to verify the generalization ability of the model, and finally the target repair model is obtained.
[0081] In the above embodiment, the model trained based on the multi-dimensional sample database can cover more cross-database syntax error scenarios, has higher repair accuracy, and ensures the reliability of the repair result.
[0082] In some optional implementations, the plurality of data knowledge bases include at least two of the following: a syntax compatibility knowledge base for recording compatible error information and corresponding solutions; a syntax difference knowledge base for recording syntax differences between different databases and corresponding solutions; and a syntax conflict knowledge base for recording conflict types, conflict positions, error information and corresponding solutions.
[0083] The syntax compatibility knowledge base is a structured database for recording cross-database syntax incompatibility errors and repair solutions, for example, using the LIMIT OFFSET syntax of MySQL in openGauss belongs to a compatible error, and the solution is to replace it with the LIMIT OFFSET syntax supported by openGauss.
[0084] Exemplarily, the collected compatibility error data, for example, database A syntax - database B error - repair scheme by source database type - target database type, can be grouped by the data classification component, stored by using a MySQL database, and each record contains an error identifier (Identifier, ID), error description, source database, target database, repair scheme, update time, and the like; when there is new compatibility error data, the format is automatically checked (such as the completeness of the required fields), and the syntax compatibility knowledge base is supplemented through an application programming interface (Application Programming Interface, API) interface.
[0085] The syntax difference knowledge base is used to record the inherent syntax difference and adaptation scheme between different databases, for example, date function difference (such as Oracle uses SYSDATE, and PostgreSQL uses the current log function CURRENT_DATE), and paging syntax difference (such as MySQL uses LIMIT, and Oracle uses ROWNUM).
[0086] Exemplarily, the syntax difference points can be extracted from the official documents of the databases, and the adaptation scheme is supplemented in combination with the development experience of developers to form a record structure of syntax item - database A syntax - database B syntax - adaptation scheme, for example, paging - SELECT * FROM table LIMIT 10 - SELECT * FROM (SELECT t.*, ROWNUM rn FROM table t WHERE ROWNUM≤20) WHERE rn >10 - select the corresponding paging syntax according to the target database; Elasticsearch can be used for storage, and search can be performed according to keywords such as syntax items and database types, so as to facilitate quick calling of the model.
[0087] The syntax conflict knowledge base is used to record the syntax parsing conflict and solution, and the syntax conflict refers to an error reported by a SQL statement during compilation due to a syntax rule conflict, for example, the custom function name SUM is renamed with the database aggregation function SUM, and the conflict type (such as keyword conflict, function name conflict), conflict position (such as the 5th row and the 8th column), and error information (such as ERROR: function sum (integer) is ambiguous).
[0088] Exemplarily, the compiling process of different databases can be simulated by the Bison syntax parsing tool to automatically generate conflict cases (such as executing SELECT SUM (1) after defining the function SUM (int)), and extract conflict information; at the same time, real conflict records in the development log are collected, and are stored according to conflict types including keyword conflict, operator conflict and the like. Each record is attached with conflict reproduction steps and solutions (such as changing the custom function name SUM to SUM_CUSTOM), and supports filtering query according to conflict types.
[0089] In the above embodiments, during model training, by fusing multiple data knowledge bases, it is ensured that the model can simultaneously call multi-dimensional knowledge for repair, so as to improve the reliability of the repair result.
[0090] In some optional implementations, the number of repair results can be multiple, and in the case of multiple repair results, the repair results can be sequentially displayed.
[0091] Referring to Figure 3 , Figure 3 A flowchart for displaying repair results is provided, and specifically includes the following steps:
[0092] S301, obtaining historical evaluations corresponding to each repair result.
[0093] The historical evaluation refers to the use feedback of the repair result by a past user (for example, a developer), which can be divided into four levels of “excellent”, “good”, “qualified” and “unqualified”, which correspond to four scenarios of “the repaired SQL can be directly executed and meets the business requirements”, “can be executed after slight adjustment”, “can be executed after significant adjustment” and “still reports an error after repair”.
[0094] Exemplarily, the server can use the document type database MongoDB to record the historical evaluation of each repair result, and the storage structure is “repair result ID, user ID, evaluation level, evaluation time, remarks”; when sorting is needed, the repair result ID can be used for associated query, and the total number of historical evaluations of the repair result and the proportion of each level (for example, excellent: 80%, good: 20%) can be counted.
[0095] S302, sorting each repair result according to the historical evaluation corresponding to each repair result.
[0096] Exemplarily, the proportion of excellent evaluation can be used as a sorting reference index, for example, the higher the proportion, the higher the sorting; the total number of evaluations can also be used as a sorting reference index, for example, the more the number of evaluations, the higher the sorting.
[0097] S303, displaying each repair result in the order.
[0098] Exemplarily, the repair results and the historical evaluations corresponding to the repair results can be displayed in an arranged order through the visual interface.
[0099] In the above embodiment, the repair results can be sorted according to the historical evaluations, so as to help the user quickly locate the optimal repair scheme and further improve the development efficiency.
[0100] In some optional implementation manners, referring to Figure 4 , Figure 4 A flowchart for sorting the repair results is provided, and specifically includes the following steps:
[0101] S401, for each repair result, if the historical evaluation corresponding to the repair result is not empty, the score of the repair result is determined according to the level of the historical evaluation corresponding to the repair result; if the historical evaluation corresponding to the repair result is empty, the score of the repair result is determined according to the initial value of the historical evaluation.
[0102] Exemplarily, for each repair result, if the historical evaluation corresponding to the repair result is not empty, the score of the repair result is determined according to the level of the historical evaluation corresponding to the repair result. For example, the score rule is set as 10 points / time for “excellent”, 8 points / time for “good”, 6 points / time for “qualified”, and 2 points / time for “unqualified”; the score is the quotient of the sum of the product of the number of each historical evaluation level and the corresponding score and the total number of evaluations. For example: a repair result has 10 historical evaluations (8 times of “excellent” and 2 times of “good”), then the score = (8x10+2x8) / 10 = 9.6 points.
[0103] If the historical evaluation corresponding to the repair result is empty, the score of the repair result is assigned as the initial value, for example, the initial value can be 7 points, and “no evaluation” is marked.
[0104] S402, the repair results are sorted according to the scores of the repair results.
[0105] Exemplarily, the repair results can be sorted according to the scores from high to low; if the scores are the same, the repair results can be sorted again according to the “repair scheme conciseness”, for example, the fewer the number of modified characters, the higher the position.
[0106] In the above embodiment, by quantifying the score rule, the sorting deviation caused by subjective evaluation is avoided; the initial value setting takes into account the exposure of new repair results and user experience, so as to ensure the fairness and rationality of the sorting.
[0107] In some optional implementation manners, in the case that the repair result is unqualified, the user can be prompted to input a new repair result, and the target repair model is updated.
[0108] Exemplarily, referring toFigure 5 , Figure 5 A flowchart illustrating the process of updating the target repair model is provided, specifically including the following steps:
[0109] S501, Obtain the current evaluation of the repair results.
[0110] The current evaluation refers to the feedback submitted by users in real time after using the repair results. Current evaluations of the repair results can be obtained in real time.
[0111] S502, if the current evaluation characterization repair result is found to be unqualified, output a display box.
[0112] For example, if the current evaluation characterization repair result is found to be unqualified, a display box can be output, prompting the user to enter a new repair result. For instance, the display box can be popped up using JavaScript, prompting "This repair solution is unqualified, please enter your repair solution." If the user does not enter anything within a preset time, the display box automatically closes and records "No feedback." The preset time can be set according to actual needs, for example, it can be set to 10 minutes.
[0113] S503, based on the new repair results entered by the user in the display box, update the target repair model.
[0114] For example, the validity of the new repair results can be verified. If the verification passes, the "original repair result - new repair result - current evaluation" data can be added to the corresponding knowledge base. The target repair model can be incrementally trained periodically using the newly added "original repair result - new repair result - current evaluation" data to update the model parameters.
[0115] In the above embodiments, the target repair model is updated based on user feedback, so that the target repair model can continuously adapt to new syntax error scenarios and maintain a high repair accuracy in the long term.
[0116] In some alternative implementations, see [link to relevant documentation]. Figure 6 , Figure 6 A flowchart illustrating another syntax repair method is provided, which includes the following steps:
[0117] S601: Obtain cross-database business query requests initiated by the client.
[0118] S602: If a syntax error is detected in the business query request, obtain the error information of the business query request.
[0119] S603 inputs the error information into the target repair model and outputs the repair results for each business query request.
[0120] S604, obtaining the historical evaluation corresponding to each repair result.
[0121] S605, ranking each repair result according to the historical evaluation corresponding to each repair result.
[0122] S606, displaying each repair result in the order of ranking.
[0123] S607, obtaining the current evaluation for the repair result.
[0124] S608, outputting the display box in the case where it is identified that the current evaluation indicates that the repair result is unqualified.
[0125] S609, updating the target repair model based on the new repair result input by the user in the display box.
[0126] The specific process of S601 to S609 can be referred to the description of the method embodiments, and the implementation principle and technical effects are similar, which will not be described here.
[0127] In addition, the execution order between the steps is only exemplary and does not limit the execution steps, and other step execution orders are within the protection scope of the embodiments of the present application.
[0128] In the above embodiments, the time for the developer to manually troubleshoot errors is reduced, and the efficiency of developing and maintaining database applications is improved. Furthermore, through in-depth analysis of SQL syntax compatibility, the system can help developers more smoothly migrate and adapt SQL statements between different database platforms, reducing problems caused by syntax incompatibility. In addition, by integrating user feedback, the system can continuously adapt to new syntax rules and common errors, ensuring its efficiency and effectiveness in a constantly changing database environment. Furthermore, the embodiments of the present application can promote the development and popularization of database technology, promote compatibility and interoperability between different databases, and provide developers with more extensive tool support.
[0129] It should be understood that, although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0130] Based on the same inventive concept, the embodiments of the present application also provide a syntax repair device for implementing the above-mentioned syntax repair method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more syntax repair device embodiments provided below can refer to the limitations of the syntax repair method described above, which will not be repeated here.
[0131] In one exemplary embodiment, as shown in Figure 7 A syntax repair device is provided, comprising:
[0132] The first acquisition module 10 is configured to acquire a cross-database service query request initiated by a client.
[0133] The second acquisition module 20 is configured to acquire error information of the service query request in a case where it is identified that the service query request has a syntax error; wherein the error information at least includes an error type, an error position, and an error statement.
[0134] The output module 30 is configured to input the error information into a target repair model and output a repair result for the service query request; wherein the repair result at least includes an error cause and a repair scheme.
[0135] The above syntax error repair device acquires a cross-database service query request initiated by a client; acquires error information of the service query request in a case where it is identified that the service query request has a syntax error; wherein the error information at least includes an error type, an error position, and an error statement; inputs the error information into a target repair model and outputs a repair result for the service query request; wherein the repair result at least includes an error cause and a repair scheme. By inputting the error information into the target repair model, the syntax error is repaired without the need for manual repair by the developer, thereby improving the efficiency of syntax error repair.
[0136] In one embodiment, the device further comprises a training module configured to:
[0137] construct a sample database; wherein the sample database comprises a plurality of data knowledge bases, and the plurality of data knowledge bases are configured to record error information and corresponding solutions of different dimensions; and train the initial repair model based on the sample database to obtain the target repair model.
[0138] In one embodiment, the plurality of data knowledge bases include at least two of the following: a syntax compatibility knowledge base configured to record compatible error information and corresponding solutions; a syntax difference knowledge base configured to record syntax differences between different databases and corresponding solutions; and a syntax conflict knowledge base configured to record conflict types, conflict positions, error information, and corresponding solutions.
[0139] In one of the embodiments, the number of repair results is multiple, and the device further comprises a display module, comprising:
[0140] The acquisition unit is configured to acquire the historical evaluation corresponding to each repair result.
[0141] The sorting unit is configured to sort the repair results according to the historical evaluation corresponding to each repair result.
[0142] The display unit is configured to display the repair results in the order.
[0143] In one of the embodiments, the sorting unit is specifically configured to:
[0144] For each repair result, if the historical evaluation corresponding to the repair result is not empty, the score of the repair result is determined according to the level of the historical evaluation corresponding to the repair result; if the historical evaluation corresponding to the repair result is empty, the score of the repair result is determined according to the initial value of the historical evaluation; and the repair results are sorted according to the scores of the repair results.
[0145] In one of the embodiments, the device further comprises an updating module, configured to:
[0146] acquire the current evaluation for the repair result; in a case where it is identified that the current evaluation represents that the repair result is unqualified, output a display box; wherein the display box is used to prompt the user end to input a new repair result; and update the target repair model based on the new repair result input by the user end in the display box.
[0147] Each module in the above syntax repair device can be realized by software, hardware and a combination thereof in whole or in part. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory in the computer device in the form of software, so as to call and execute the operation corresponding to each module by the processor.
[0148] In one exemplary embodiment, a computer device is provided, which can be a server, and the internal structure diagram thereof can be as shown in Figure 8As shown in the figure. The computer device includes a processor, a memory, an Input / Output (I / O) interface and a communication interface. Among them, the processor, the memory and the input / output interface are connected through the system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store syntax knowledge data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through network connection. The computer program is executed by the processor to implement a syntax repair method.
[0149] Those skilled in the art can understand that, Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0150] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the syntax repair method described in any of the above embodiments.
[0151] In one embodiment, a computer readable storage medium is provided, which stores a computer program, and the computer program is executed by the processor to implement the steps of the syntax repair method described in any of the above embodiments.
[0152] In one embodiment, a computer program product is provided, including a computer program, and the computer program is executed by the processor to implement the steps of the syntax repair method described in any of the above embodiments.
[0153] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations.
[0154] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.
[0155] The technical features of the above embodiments can be combined in any manner. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not exist contradictions, they should be considered as the scope of the present application.
[0156] The above-described embodiments are merely illustrative of several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as a limitation on the scope of the patent. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. A syntax repair method, characterized in that, The method includes: Retrieve cross-database business query requests initiated by the client; If a syntax error is detected in the business query request, the error information of the business query request is obtained; wherein, the error information includes at least the error type, error location, and error statement; The error information is input into the target repair model, and the repair result for the business query request is output; wherein the repair result includes at least the cause of the error and the repair solution.
2. The method according to claim 1, characterized in that, The target repair model is trained in the following way: Construct a sample database; wherein, the sample database includes multiple data knowledge bases, which are used to record error information and corresponding solutions in different dimensions; The initial repair model is trained by sampling the sample database to obtain the target repair model.
3. The method according to claim 2, characterized in that, The plurality of data knowledge bases includes at least two of the following: A syntax compatibility knowledge base used to record compatibility error messages and corresponding solutions; A grammar difference knowledge base used to record grammatical differences between different databases and corresponding solutions; A syntax conflict knowledge base used to record conflict types, conflict locations, error messages, and corresponding solutions.
4. The method according to claim 1, characterized in that, The number of repair results is multiple, and the method further includes: Obtain the historical evaluations corresponding to each repair result; Based on the historical evaluations corresponding to each restoration result, the restoration results are ranked. The repair results are displayed in the order listed.
5. The method according to claim 4, characterized in that, The process of sorting the repair results based on their corresponding historical evaluations includes: For each repair result, if the historical evaluation corresponding to the repair result is not empty, the score of the repair result is determined according to the level of the historical evaluation corresponding to the repair result. If the historical evaluation corresponding to the repair result is empty, then the score of the repair result is determined based on the initial value of the historical evaluation. The repair results are ranked according to their scores.
6. The method according to claim 1, characterized in that, The method further includes: Obtain the current evaluation of the repair results; If the current evaluation indicates that the repair result is unqualified, a display box is output; wherein, the display box is used to prompt the user to input a new repair result; The target repair model is updated based on the new repair results entered by the user in the display box.
7. A grammar repair device, characterized in that, The device includes: The first acquisition module is used to acquire cross-database business query requests initiated by the client; The second acquisition module is used to acquire error information of the business query request when a syntax error is detected in the business query request; wherein, the error information includes at least the error type, error location, and error statement; The output module is used to input the error information into the target repair model and output the repair result for the business query request; wherein the repair result includes at least the error cause and the repair solution.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.