Error detection method and apparatus for database query text, and device
By decomposing query text into text fragments and applying semantic parsing and error correction rules, the problem of inaccurate semantic error correction of database query text is solved, achieving more efficient semantic evaluation and error correction.
Patent Information
- Application Number
- PCT/CN2026/090173
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-05-15
- Filing Date
- 2026-04-13
- Publication Date
- 2026-11-19
Smart Images

Figure CN2026090173_19112026_PF_FP_ABST
Abstract
Description
Error detection methods, devices and equipment for database query text
[0001] This application claims priority to Chinese Patent Application No. 202510629793.1, filed on May 15, 2025, entitled "Error Detection Method, Apparatus and Device for Database Query Text", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of computer technology, and in particular to a method, apparatus, and device for error detection in database query text. Background Technology
[0003] With the development of computer technology, users can query databases by editing input text. For example, the database management system converts the user's input text into query text for the database, such as SQL (Structured Query Language) statements, to query the target data in the database. In this process, the database management system needs to detect whether there are any errors in the query text and correct them.
[0004] In related technologies, database management systems typically use LLM (Large Language Model) to perform semantic error correction on query text. For example, by using the rubber duck debugging method, the semantic deviation between the query text and the input text is detected line by line to find semantic errors in the query text. Then, SQL tools (such as those with a finely tuned LLM) are used to perform semantic error correction on the query text to generate corrected query text. The corrected query text is then used to retrieve the corresponding data in the database.
[0005] However, the relevant technologies have a weak ability to understand and analyze long texts, which can easily lead to inaccurate semantic correction of query texts. Summary of the Invention
[0006] This application provides a method, apparatus, and device for error detection in database query text. The technical solutions provided in this application may include the following.
[0007] According to one aspect of the embodiments of this application, a method for error detection of database query text is provided, the method being executed by a computer device, the method comprising:
[0008] Obtain query text for a database, the query text including at least one text fragment, the query text being used to query data in the database;
[0009] Perform semantic parsing on the query text to obtain at least one suspicious text fragment in the query text, wherein the suspicious text fragment is a text fragment that is suspected of having a semantic error;
[0010] Obtain the semantic error correction rules corresponding to the at least one suspicious text fragment, and the semantic error correction rules are used to indicate the correction strategy for semantic errors;
[0011] Based on the semantic error correction rules corresponding to the query text, the at least one suspicious text fragment, and the at least one suspicious text fragment, a semantic evaluation result of the query text is obtained, and the semantic evaluation result is used to indicate whether there is a semantic error in the query text.
[0012] According to one aspect of the embodiments of this application, an error detection device for database query text is provided, the device comprising:
[0013] The text acquisition module is used to acquire query text for a database, the query text including at least one text fragment, the query text being used to query data in the database;
[0014] The semantic parsing module is used to perform semantic parsing on the query text to obtain at least one suspicious text fragment in the query text, wherein the suspicious text fragment is a text fragment that is suspected of having semantic errors;
[0015] The rule extraction module is used to obtain the semantic error correction rules corresponding to the at least one suspicious text fragment, and the semantic error correction rules are used to indicate the correction strategy for semantic errors;
[0016] The semantic evaluation module is used to obtain the semantic evaluation result of the query text based on the semantic error correction rules corresponding to the query text, the at least one suspicious text fragment, and the at least one suspicious text fragment, respectively. The semantic evaluation result is used to indicate whether there is a semantic error in the query text.
[0017] According to one aspect of the embodiments of this application, a computer device is provided, the computer device including a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above-described error detection method for database query text.
[0018] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, the computer program being loaded and executed by a processor to implement the above-described error detection method for database query text.
[0019] According to one aspect of the embodiments of this application, a computer program product is provided, the computer program product including a computer program, the computer program being loaded and executed by a processor to implement the above-described error detection method for database query text.
[0020] The technical solutions provided in this application can bring the following beneficial effects.
[0021] By decomposing the query text into at least one text segment, each segment can be semantically evaluated independently, achieving localized semantic evaluation of the query text. Compared to related technologies that directly evaluate the complete query text, the technical solution provided in this application reduces the difficulty of understanding the query text. This improves the ability to understand and analyze the query text, thereby enhancing the accuracy of the semantic evaluation results and consequently improving the accuracy of subsequent semantic error correction based on the evaluation results. Furthermore, by additionally using at least one suspicious text segment in the query text, along with the corresponding semantic error correction rules, as the basis for determining the semantic evaluation results, this not only enriches the criteria for semantic evaluation but also allows for targeted detection of semantic errors within the at least one suspicious text segment. This leads to a better understanding of each text segment in the query text, further improving the accuracy of the semantic evaluation results. Attached Figure Description
[0022] Figure 1 is a schematic diagram of a computer system provided in an embodiment of this application;
[0023] Figure 2 is a flowchart of an error detection method for database query text provided in an embodiment of this application;
[0024] Figure 3 is a schematic diagram of a first configuration template provided in an embodiment of this application;
[0025] Figure 4 is a schematic diagram of the text error detection interface of a data management program provided in an embodiment of this application;
[0026] Figure 5 is a flowchart of a knowledge base update method provided in one embodiment of this application;
[0027] Figure 6 is a schematic diagram of the error correction process of query text provided in an embodiment of this application;
[0028] Figure 7 is a flowchart of a semantic error correction method for query text provided in an embodiment of this application;
[0029] Figure 8 is a schematic diagram of a second configuration template provided in one embodiment of this application;
[0030] Figure 9 is a schematic diagram of a semantic error correction process provided in an embodiment of this application;
[0031] Figure 10 is a flowchart of a syntax correction method for query text provided in an embodiment of this application;
[0032] Figure 11 is a schematic diagram of a syntax correction process provided in an embodiment of this application;
[0033] Figure 12 is a flowchart of an error detection method for database query text applied in the field of logistics and transportation provided in an embodiment of this application;
[0034] Figure 13 is a flowchart of an error detection method for database query text applied in the financial field according to an embodiment of this application;
[0035] Figure 14 is a block diagram of an error detection device for database query text provided in an embodiment of this application;
[0036] Figure 15 is a structural block diagram of a computer device provided in one embodiment of this application. Detailed Implementation
[0037] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0038] Please refer to Figure 1, which shows a schematic diagram of a computer system provided in one embodiment of this application. The computer system may include: a terminal device 10 and a server 20.
[0039] The number of terminal devices 10 can be one or more. Terminal devices 10 can be electronic devices such as mobile phones, tablets, laptops, desktop computers, game consoles, e-book readers, multimedia playback devices, wearable devices, smart voice interaction devices, smart home appliances, in-vehicle terminals, and aircraft. Terminal devices 10 can have a client running a target application installed, such as a data management program, a database management system (DBMS), a data retrieval application, a smart question-and-answer application, or any application that supports database management. The data management program has a database-based query function; for example, a user can input query text through the client of the data management program to obtain the target data corresponding to the query text from the database corresponding to the data management program. Optionally, the data management program can be an application that requires downloading and installation, or it can be an application that can be used immediately upon clicking; this application does not limit this.
[0040] Server 20 provides background services to clients of target applications (such as data management programs) installed and running on terminal device 10. For example, server 20 can be a background server for the aforementioned target application. Server 20 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This application does not limit this. Optionally, server 20 can simultaneously provide background services to target applications (such as data management programs) on multiple terminal devices 10. Terminal devices 10 and server 20 can communicate with each other via a network.
[0041] Optionally, for the computation work of the technical solution provided in the embodiments of this application, server 20 undertakes the main computation work and terminal device 10 undertakes the secondary computation work; or, server 20 undertakes the secondary computation work and terminal device 10 undertakes the main computation work; or, server 20 and terminal device 10 adopt a distributed computing architecture for collaborative computation. The embodiments of this application do not limit this approach. The embodiments of this application use server 20 undertaking the main computation work as an example for illustration.
[0042] For example, a user edits query text through a data management program client. The client sends the edited query text to the server. The server receives the query text, which includes at least one text segment used to query data in the database. The server performs semantic parsing on the query text through the data management program, analyzing text segments suspected of containing semantic errors to identify at least one suspicious text segment. The server then retrieves semantic correction rules corresponding to each suspicious text segment from the data management program's knowledge base. These rules indicate the correction strategy for semantic errors in the suspicious text segments. The server performs semantic evaluation on the query text based on the query text, the at least one suspicious text segment, and the corresponding semantic correction rules, obtaining a semantic evaluation result indicating whether the query text contains semantic errors. If the query text does not contain semantic errors, data is queried from the database. If the query text contains semantic errors, it is corrected to obtain a corrected query text, and data is then queried from the database based on the corrected query text. The retrieved data is then returned to the client.
[0043] The following will use method embodiments to illustrate the technical solutions provided in the embodiments of this application. For content not described in the method embodiments, please refer to the above embodiments, which will not be repeated here.
[0044] Please refer to Figure 2, which shows a flowchart of a database query text error detection method according to an embodiment of this application. The execution entity for each step of this method can be a computer device, such as the terminal device 20 or server 20 in the computer system shown in Figure 1. The method may include at least one of the following steps 210 to 240.
[0045] Step 210: Obtain the query text for the database. The query text includes at least one text fragment and is used to query data in the database.
[0046] The query text can be directly edited by the user. For example, the query text is text entered by the user in a data management program, used to query data stored in the database. The query text may include at least one text fragment, each of which can be independent of each other. For example, each text fragment may indicate a part of the text content of the query text, or it may be used to indicate a different location in the database. Different text fragments may also be used to indicate different query intentions, which is not limited in this application. Exemplarily, the query text can be edited using assembly language for the database. For example, if the query text is an SQL query statement, then at least one text fragment included in the query text may refer to at least one SQL query clause included in the SQL query statement. The SQL query clause includes at least one of the following: SELECT clause, FROM clause, WHERE clause, GROUP BY clause, HAVING clause, ORDER BY clause, each SQL query clause indicating a part of the query intention in the SQL query statement.
[0047] The query text mentioned above can also be text converted from user-edited input text, such as an SQL query statement converted from user-edited natural language text. An SQL query statement can also be simply referred to as an SQL statement, and this application does not limit this. Optionally, the query text can also be used to manage data stored in a database; for example, the query text can also be used to update, manipulate (such as move, delete, etc.), and process data in the database. After obtaining the query text, the server splits the query text into at least one independent text segment.
[0048] Database query text refers to the query text targeting a database. A database is used to store data; for example, the database mentioned above is the database of a data management program, which can be used to store business data related to the data management program. Optionally, the data management program mentioned above is a comprehensive data management program that can manage multiple databases. For example, the data management program supports data queries against multiple databases, each database can be used to indicate a vertical domain and store data within that vertical domain. A vertical domain can include at least one of the following: logistics and transportation, finance, e-commerce, healthcare, social media, gaming, education, business operations, and website management. When a user initiates a data query, the data management program can select the database to query from the multiple databases and then query the target data in the selected database.
[0049] Optionally, the data management program is a targeted data management program that can be used to manage a single database. For example, the data management program supports data queries for a single database. When a user initiates a data query, the data management program can directly query the target data in the database corresponding to the data management program. The type of data in the database is related to the type of data management program. For example, if the data management program is for managing logistics and transportation data, then the database is a database that stores logistics and transportation data, such as cargo status, transportation routes, vehicle locations, delivery history, etc. For example, if the data management program is for managing financial data, then the database is a database that stores financial data, such as account balances, transaction records, risk assessments, customer credit scores, etc. For example, if the data management program is for managing medical data, then the database is a database that stores medical data, such as patient information, medical records, drug prescriptions, examination results, etc. This application does not limit this.
[0050] Because query text may contain semantic or syntactic errors, computer devices (such as servers) can first input the query text into the text detection system of the data management program after receiving it. The text detection system checks for semantic or syntactic errors. Semantic errors can refer to discrepancies between the query text and the input text, while syntactic errors can refer to violations of database syntax rules. If semantic or syntactic errors are found, the query text is then input into the text correction system of the data management program. This system corrects the semantic or syntactic errors, resulting in a corrected query text. Semantic correction ensures the semantic correctness of the query text, while syntactic correction ensures that the query text can be compiled and executed. The corrected query text is then input into the database system of the data management program, which uses the corrected query text to search for the corresponding target data. Conversely, if the query text does not contain any syntactic or semantic errors, it can be directly input into the database system, which then searches for the corresponding target data.
[0051] In some embodiments, the computer device performs a syntax evaluation on the query text using a compiler to obtain a syntax evaluation result for the query text. This result indicates whether the query text contains syntax errors. For example, the compiler can be a compiler for a DBMS (Database Management System).
[0052] Syntax evaluation is the process of assessing whether there are syntax errors in the query text. Syntax errors refer to errors in the text structure of the query text. If the query text contains syntax errors, the database system cannot find the target data based on the textual logic of the query text, which will cause the database system to malfunction.
[0053] Optionally, the syntax evaluation includes two stages: lexical analysis and syntax analysis. For example, taking an SQL query statement, in the lexical analysis stage, after the query text is input into the compiler, the compiler scans the SQL query statement character by character, identifying lexical units (tokens) according to predefined lexical rules (such as regular expressions). Lexical units include, but are not limited to, keywords, identifiers, operators, delimiters, etc., and then pass the obtained lexical units to the syntax analysis stage. If unrecognized characters (such as Chinese symbols or special characters), or unclosed strings or comments are encountered, the compiler will immediately report an error, indicating a syntax error.
[0054] During the syntax analysis phase, the compiler uses parsing algorithms to convert lexical units into an abstract syntax tree (AST). Then, it uses the AST to check whether the structure of the SQL query statement conforms to predefined syntax rules (such as the clause order and bracket matching in a SELECT statement). Specifically, if it detects keyword errors (such as spelling errors or using reserved keywords as identifiers), incorrect clause order (such as a WHERE clause preceding a FROM clause), or mismatched brackets (such as unclosed brackets in nested queries or function calls), the compiler will immediately report an error, indicating a syntax error. During this syntax evaluation process, the compiler obtains the location of the syntax error in the query text and the syntax error type. The syntax error location is the position in the query text where the syntax error occurs, and the syntax error type is the type of syntax error.
[0055] For example, in the case of syntax errors in the query text, the syntax evaluation result is also used to indicate at least one syntax error location in the query text and the syntax error type corresponding to each syntax error location. The syntax error location in the query text is used to indicate a syntax error segment in the query text where a syntax error occurs. A syntax error location includes the start position and end position of the character where the syntax error occurs. A syntax error segment refers to a local text segment between the start and end positions of the character where the syntax error occurs. Optionally, a local text segment can be a text segment within the query text (such as an SQL query clause), a portion of the text content within a text segment (such as a portion of the clause content within an SQL query clause), or a portion of the text content within the query text (such as a clause content including one SQL query clause and a portion of another SQL query clause).
[0056] The syntax error type corresponding to the syntax error location indicates the cause of the syntax error segment at that location. For example, the syntax error type can include at least one of the following: unrecognized characters in the syntax error segment, an unclosed string in the syntax error segment, a spelling error in the syntax error segment, an incorrect order of text segments in the syntax error segment, or an incorrect nesting of parentheses in the syntax error segment.
[0057] Each syntax error location corresponds to at least one syntax error type. The syntax error types corresponding to different syntax error locations can be the same or different. That is, a syntax error type in the syntax evaluation result can correspond to one syntax error location or multiple syntax error locations.
[0058] In some embodiments, when the syntax evaluation result indicates that the query text contains a syntax error, the computer device does not perform semantic evaluation on the query text, but directly performs syntax correction on the query text. When the syntax evaluation result indicates that the query text does not contain a syntax error, semantic evaluation is performed on the query text to obtain a semantic evaluation result. When the semantic evaluation result indicates that the query text contains a semantic error, semantic correction is performed on the query text. The specific processes of syntax correction and semantic correction can be referred to the following embodiments, and will not be repeated here.
[0059] Steps 220 to 240 below correspond to the semantic evaluation process of the query text, that is, performing semantic evaluation on the query text to detect whether there are semantic errors in the query text.
[0060] Semantic evaluation is the process of assessing whether there are semantic errors in the query text. A semantic error refers to an error where the meaning of the query text does not achieve the expected function and cannot obtain the expected result; that is, there is a discrepancy between the meaning of the query text and the meaning of the input text. If the query text contains semantic errors, the database system will search for the target data based on the meaning of the query text, resulting in the retrieved target data not being the data the user expected to find.
[0061] Step 220: Perform semantic parsing on the query text to obtain at least one suspicious text fragment in the query text. The suspicious text fragment is a text fragment that is suspected of having semantic errors.
[0062] Semantic parsing is the process of parsing the semantics of query text. For example, a semantic parsing algorithm can be used to perform semantic parsing on the query text to analyze the execution path it intends to achieve and capture suspicious text fragments. For instance, a suspicious text fragment can be a text fragment with an algorithmic logic error, such as a text fragment where an incorrect factorial result is caused by an incorrect loop condition when calculating a factorial. A suspicious text fragment can also be a text fragment with an incorrect data type, such as a text fragment with mismatched operand types, such as a text fragment containing the addition of a string and a number. A suspicious text fragment can also be a text fragment with an incorrect variable scope, such as a text fragment accessing an undefined or out-of-scope variable, such as a text fragment accessing a local variable inside a function from outside the function. A suspicious text fragment can also be a text fragment with incorrect boundary conditions, such as a text fragment that does not correctly handle boundary cases of input, such as an array out-of-bounds access or a text fragment that does not handle negative number inputs; this application does not limit this.
[0063] Optionally, a suspicious text fragment may contain semantic errors or it may not. Further semantic evaluation is needed to determine whether a suspicious text fragment contains semantic errors. Suspicious text fragments can serve as the primary target for semantic evaluation, thereby reducing the workload of the semantic evaluation process.
[0064] Step 230: Obtain the semantic error correction rules corresponding to at least one suspicious text segment. The semantic error correction rules are used to indicate the correction strategy for semantic errors.
[0065] The aforementioned semantic error correction rules are obtained from a knowledge base, which includes at least one semantic error correction rule. For example, a computer device obtains at least one semantic error correction rule corresponding to each suspicious text fragment from the knowledge base. The knowledge base is a systematic and structured collection of knowledge. In this embodiment, the knowledge base may include: semantic error correction rules for correcting semantic errors and grammatical error correction rules for correcting grammatical errors. The semantic error correction strategy is a strategy for correcting semantic errors.
[0066] The knowledge base also includes tag information corresponding to at least one semantic error correction rule. Each semantic error correction rule corresponds to one tag, which uniquely identifies the rule. For example, the semantic error correction strategy explains how semantic errors should be corrected, and the tag information corresponding to a semantic error correction rule can be a keyword phrase or a regular expression. For instance, a semantic error correction rule could be "Before sorting a particular field in ascending order, ensure that all values in that field are not NULL." and the tag information corresponding to this rule could be "SORT_IN_ASC_ORDER".
[0067] The semantic error correction rules corresponding to suspicious text fragments are used to indicate the correction strategy for the semantic errors corresponding to suspicious text fragments.
[0068] In some embodiments, step 230 includes at least one of sub-steps 231 to 232.
[0069] Sub-step 231: For each suspicious text segment, based on the label information corresponding to the suspicious text segment and at least one semantic error correction rule, obtain the label information matching the suspicious text segment. The label information matching the suspicious text segment is the label information with the highest matching degree among the label information corresponding to at least one semantic error correction rule.
[0070] Optionally, regular expressions are used to perform character matching on the label information corresponding to the suspicious text fragment and at least one semantic error correction rule, respectively, to obtain the label information corresponding to the semantic error correction rule that matches the suspicious text fragment, that is, to obtain the label information matching the suspicious text fragment.
[0071] Alternatively, the similarity between the suspicious text fragment and the label information corresponding to at least one semantic error correction rule can be calculated to obtain at least one similarity (i.e., matching degree). The label information of the semantic error correction rule corresponding to the maximum value of at least one similarity is determined as the label information matching the suspicious text fragment.
[0072] Sub-step 232: Determine the semantic error correction rule corresponding to the tag information matching the suspicious text fragment in the knowledge base as the semantic error correction rule corresponding to the suspicious text fragment.
[0073] Since there is a one-to-one correspondence between tag information and semantic error correction rules, the semantic error correction rules corresponding to the tag information matching the suspicious text fragments can be obtained from the knowledge base.
[0074] By storing the tag information corresponding to semantic error correction rules in the knowledge base, computer devices can match the corresponding semantic error correction rules from the knowledge base based on the tag information. Compared with matching directly based on semantic error correction rules, matching based on tag information saves the computing resources required for semantic error correction rule matching and improves the matching speed of semantic error correction rules.
[0075] Step 240: Based on the semantic error correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment respectively, obtain the semantic evaluation result of the query text. The semantic evaluation result is used to indicate whether there are semantic errors in the query text.
[0076] Based on the semantic error correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment respectively, the semantic evaluation of at least one suspicious text fragment is performed again to obtain the semantic evaluation results corresponding to at least one suspicious text fragment respectively. The semantic evaluation results of the suspicious text fragment are used to indicate whether there is a semantic error in the suspicious text fragment. The semantic evaluation results of the query text include the semantic evaluation results corresponding to at least one suspicious text fragment respectively.
[0077] Optionally, a holistic semantic evaluation can be performed on the query text to determine whether, besides at least one suspicious text segment, there are other text segments with semantic errors. Semantic evaluation results for each of these other text segments are obtained, indicating whether they contain semantic errors. Based on the semantic evaluation results corresponding to at least one suspicious text segment and at least one other text segment, a semantic evaluation result for the query text is obtained. This result indicates whether the query text contains semantically erroneous segments, or in other words, whether there are semantically erroneous segments within the query text. Semantically erroneous segments are text segments containing semantic errors.
[0078] In some embodiments, step 240 may include at least one of sub-steps 241 to 242.
[0079] Sub-step 241: Generate a first prompt message based on the semantic correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment, and the first configuration template; wherein, the first configuration template is used to indicate the arrangement rules of the semantic correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment.
[0080] The first configuration template is a template set up for semantic evaluation. It can be used as the judgment criteria required for structured semantic evaluation, serving as prompt information for semantic evaluation. For example, the semantic error correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment are respectively filled into the first configuration template to obtain the first prompt information. The first prompt information is in text form.
[0081] For example, referring to Figure 3, the first configuration template includes a first template content 301, a second template content 302, and a third template content 303. The first template content 301 indicates the evaluation steps of the semantic evaluation, the second template content 302 indicates the task requirements of the semantic evaluation, and the third template content 303 indicates the arrangement rules for the semantic correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment, respectively. The third template content 303 can be filled with the semantic correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment, respectively.
[0082] The first template content 301 supports the rubber duck debugging method for checking, which can be used to guide the first AI (Artificial Intelligence) model to simulate the dialogue process and perform semantic evaluation through self-questioning and self-answering.
[0083] Sub-step 242: The first AI model obtains the semantic evaluation result of the query text based on the first prompt information.
[0084] The first AI model is an AI model used to achieve semantic evaluation. It can be any publicly available large language model. For example, the first AI model is a natural language model based on a transformer structure that is trained with a large amount of data. The large amount of data can reach the level of hundreds of millions of samples. This application does not limit this.
[0085] The first prompt information is input into the first AI model. Guided by the prompt information, the first AI model performs a comprehensive semantic evaluation of the query text, obtaining the semantic evaluation result. The first AI model can perform targeted semantic evaluation on suspicious text fragments, or it can perform a holistic semantic evaluation of the query text. For example, if the query text contains semantic errors, the semantic evaluation result can be a semantic evaluation report in JSON format, that is, an evaluation report on the semantic error, including information such as the cause and conclusion.
[0086] In some embodiments, when there are semantic errors in the query text, the semantic evaluation results are also used to indicate at least one semantically erroneous segment in the query text, the semantic error type corresponding to the at least one semantically erroneous segment, and a semantic correction suggestion for the query text.
[0087] A semantically erroneous fragment refers to a text fragment in the query text that contains semantic errors. For example, if at least one other text fragment does not contain semantic errors, and at least one suspicious text fragment contains semantic errors, then at least one semantically erroneous fragment includes at least one suspicious text fragment. If at least one other text fragment does not contain semantic errors, and a suspicious text fragment is evaluated as not containing semantic errors, then at least one semantically erroneous fragment includes a portion of the suspicious text fragments. If at least one other text fragment contains semantic errors, and at least one suspicious text fragment does not contain semantic errors, then at least one semantically erroneous fragment includes at least one other text fragment. If other text fragments are evaluated as containing semantic errors, and at least one suspicious text fragment does not contain semantic errors, then at least one semantically erroneous fragment includes a portion of the other text fragments. For example, if the query text includes text fragment 1, text fragment 2, and text fragment 3, and text fragment 1 and text fragment 2 are suspicious text fragments, then at least one semantically erroneous fragment may include text fragment 1 and text fragment 2, or it may only include text fragment 1, or it may include text fragment 1, text fragment 2, and text fragment 3 simultaneously, or it may only include text fragment 3; this application does not limit this.
[0088] The semantic error type corresponding to a semantic error fragment indicates the cause of the error. For example, a semantic error type can include at least one of the following: an algorithmic logic error in the semantic error fragment, a data type error in the semantic error fragment, a variable scope error in the semantic error fragment, or a boundary condition error in the semantic error fragment. Each semantic error fragment corresponds to at least one semantic error type. Different semantic error fragments may correspond to the same or different semantic error types; that is, one semantic error type in the semantic evaluation result may correspond to one semantic error fragment or multiple semantic error fragments.
[0089] Semantic correction suggestions for query text are suggestions for correcting semantic errors in at least one semantically erroneous segment, which can be used to indicate how semantic errors in query text should be corrected.
[0090] By using the first configuration template to generate the first prompt information, the computer device can easily identify the various data in the first prompt information to generate the semantic evaluation result of the query text. This helps to improve the standardization and convenience of error detection, and makes the semantic evaluation result conform to the text format required in the first configuration template. This makes it easier for the computer device to identify the information contained in the semantic evaluation result to perform semantic error correction on the query text, thereby improving the standardization and convenience of error correction.
[0091] In summary, the technical solution provided in this application decomposes the query text into at least one text segment, allowing each text segment to be semantically evaluated independently. This achieves localized semantic evaluation of the query text. Compared to related technologies that directly perform semantic evaluation on the complete query text, the technical solution provided in this application reduces the difficulty of understanding the query text. This improves the ability to understand and analyze the query text, thereby enhancing the accuracy of the semantic evaluation results and consequently improving the accuracy of subsequent semantic error correction based on the evaluation results. Furthermore, by additionally using at least one suspicious text segment in the query text, along with the corresponding semantic error correction rules, as the basis for determining the semantic evaluation results, the criteria for semantic evaluation are enriched. This also allows for targeted detection of semantic errors within the at least one suspicious text segment, leading to a better understanding of each text segment in the query text and further improving the accuracy of the semantic evaluation results.
[0092] For example, Figure 4 shows a schematic diagram of the text error detection interface of a data management program. The data management program is a comprehensive system. The client of the data management program displays a database selection box 401 in the text error detection interface 400, where the user can select the database to query. The text error detection interface 400 also displays a text input box and a data management control 403. The user can enter query text 402 in the text input box. In response to the user clicking the error correction control in the data management control 403, the client can call the server to complete error detection and correction of the query text 402, obtaining the corrected query text. In response to the user continuing to click the query control in the data management control 403, the client can call the server to query the target data in the selected database based on the corrected query text.
[0093] In some embodiments, the knowledge base mentioned above includes a grammar rule base and a semantic rule base.
[0094] The semantic rule base includes at least one semantic error correction rule and corresponding tag information for each semantic error correction rule. For details, please refer to the above embodiment; further elaboration is not provided here. The syntax rule base includes at least one syntax error correction rule and corresponding tag information for each syntax error correction rule. The syntax error correction rule is used to indicate the correction strategy for syntax errors. The syntax error correction rule includes at least one of the following: database indication information, local text fragment indication information, and the correction strategy of the syntax error correction rule. The database indication information indicates whether to use database table metadata to perform syntax correction, and the local text fragment indication information indicates whether to extract syntax error fragments from the query text to perform syntax correction. Syntax correction is the process of correcting syntax errors. The syntax error correction rule is stored in a syntax rule base, and the semantic error correction rule is stored in a semantic rule base. Compared to storing syntax error correction rules and semantic error correction rules in the same database, this improves the efficiency and convenience of determining the syntax error correction rules and semantic error correction rules.
[0095] Each syntax correction rule corresponds to a tag, which can be a keyword phrase or a regular expression. For example, a syntax correction rule is a three-element group of information, including database indication information, local text fragment indication information, and the syntax correction rule's correction strategy. The database indication information indicates whether the syntax error corresponding to the syntax correction rule requires syntax correction using database table metadata. Database table metadata indicates the database's structural information, such as the structure and attributes of tables. It only provides information about the tables themselves and does not contain the actual data. Database table metadata may include at least one of the following: basic table information (e.g., table name, table creation time), column information (e.g., column name), index information (e.g., index name), constraint information (e.g., relationships between tables), trigger information (execution process when a trigger is activated), storage information (e.g., tablespace), and other metadata (e.g., descriptive information about tables or columns). The indication information for local text fragments indicates whether, for a grammatical error corresponding to a grammatical error rule, the fragment containing the grammatical error needs to be extracted for grammatical correction. The correction strategy of the grammatical error correction rule explains how the grammatical error should be corrected.
[0096] Please refer to Figure 5, which shows a flowchart of a knowledge base update method according to an embodiment of this application. The execution entity for each step of this method can be a computer device. The method may include at least one of the following steps A1 to A5.
[0097] Step A1: Obtain the log data of query failures. The log data of query failures includes the query failure text and the process information of the query failure text. The query failure text is the query text that failed to retrieve data from the database. The process information is used to indicate the query steps of the query failure text.
[0098] A query failure refers to the process where a query text fails to retrieve data. Log data is used to record the data generated by query failures. When a user uses query text to query data in the database, if the target data is found in the database, the query text is considered successful, and a successful query log is generated. If the target data is not found in the database, the query text is considered a failed query, and a failed query log is generated. In this case, the query text can be called a query failure text.
[0099] The process information for querying failed texts includes the expected query steps and the actual query steps. Based on this process information, the reason for the failure can be determined. The expected query steps are the predicted query steps for the failed text.
[0100] Step A2: The fourth AI model generates error correction rules corresponding to the failed query text based on the failed query text and the process information of the failed query text.
[0101] The fourth AI model is an AI model used to generate error correction rules. This fourth AI model can be any publicly available large language model, such as a natural language model trained with a large amount of data and based on a transformer structure; this application does not limit this. Optionally, the fourth AI model and the first AI model can be the same AI model or different AI models. Error correction rules are rules used to correct errors in the query text, which can include semantic error correction rules or grammatical error correction rules. For example, if the failed query text contains semantic errors, the fourth AI model generates semantic error correction rules; if the failed query text contains grammatical errors, the fourth AI model generates grammatical error correction rules.
[0102] Optionally, the process information of the failed query text is summarized and analyzed using a fourth AI model to generate error correction rules corresponding to the failed query text. These error correction rules are then converted into JSON structured data and stored in a knowledge base. The error correction rules corresponding to the failed query text are used to indicate the correction strategy for text errors in the failed query text.
[0103] Optionally, the generated error correction rules can also be temporarily stored in an external buffer of the knowledge base for verification. To ensure the compliance of the error correction rules, a threshold trigger mechanism can be used to initiate a manual expert review process. For example, if the number of new rules added to the buffer exceeds a preset threshold t1 or the interval since the last rule update exceeds a threshold t2, experts will perform compliance verification on the error correction rules in the buffer according to predefined conditions, and store the error correction rules that pass the compliance verification into the knowledge base.
[0104] Optionally, if the error correction rule corresponding to the failed query text passes the compliance verification, the knowledge base corresponding to the semantic error correction rule is updated according to the error correction rule corresponding to the failed query text to obtain the updated knowledge base. For example, the error correction rule that passes the compliance verification is added to the knowledge base to obtain the updated knowledge base; alternatively, the error correction rule that passes the compliance verification can be merged with the error correction rules in the knowledge base to obtain the updated knowledge base. This embodiment does not limit this approach.
[0105] By analyzing log data, text cases of failed queries are automatically captured, and the fourth AI model is driven to generate new error correction rules. Based on the error correction rules reviewed by experts, the knowledge base is updated to obtain an updated knowledge base. This realizes a self-iterative update system for the knowledge base, which helps to ensure the accuracy of each error correction rule in the knowledge base, as well as the effectiveness and richness of the knowledge base.
[0106] Step A3: If the error correction rule corresponding to the failed query text passes the compliance verification, calculate the similarity between the error correction rule corresponding to the failed query text and at least two error correction rules to obtain at least two similarity scores.
[0107] To avoid redundancy of similar rules, when adding error correction rules corresponding to failed query texts to the knowledge base, clustering can be performed on the error correction rules corresponding to failed query texts and existing error correction rules in the knowledge base. Semantic deduplication can also be performed on the error correction rules in the knowledge base to ensure the uniqueness of each type of error correction rule in the knowledge base. Semantic deduplication is the process of eliminating redundancy for error correction rules with semantic overlap. For example, for multiple error correction rules with semantic overlap, only one error correction rule is retained, or multiple error correction rules are merged into one.
[0108] The similarity between the error correction rule corresponding to the failed query text and at least two error correction rules in the knowledge base is calculated to obtain at least two similarity scores. This application does not limit the calculation method of the similarity score, such as cosine similarity, Euclidean distance, etc. The similarity score can be used to indicate the semantic similarity between error correction rules.
[0109] Step A4: Semantically merge the error correction rule corresponding to the maximum value of at least two similarities with the error correction rule corresponding to the failed query text to obtain the updated error correction rule.
[0110] A centroid synthesis deduplication mechanism is employed. For the error correction rule corresponding to the maximum similarity among at least two similarity values, semantic merging is performed with the error correction rule corresponding to the failed query text to obtain the updated error correction rule. Semantic merging refers to the process of integrating error correction rules, such as merging and filtering operations.
[0111] Step A5: Replace the error correction rule corresponding to the maximum value in the knowledge base with the updated error correction rule to obtain the updated knowledge base.
[0112] Optionally, if the maximum value of at least two similarities is less than the similarity threshold, it can be determined that the error correction rule corresponding to the failed query text does not belong to any existing error correction rule in the knowledge base. In this case, the error correction rule corresponding to the failed query text is determined as a new type of error correction rule, and the error correction rule corresponding to the failed query text can be directly added to the knowledge base to obtain the updated knowledge base.
[0113] If the maximum value of at least two similarities is greater than or equal to the similarity threshold, it can be determined that the error correction rule corresponding to the failed query text belongs to a certain type of error correction rule already existing in the knowledge base. Then, the error correction rule corresponding to the failed query text is semantically merged with the error correction rule of that type to obtain the updated error correction rule. Then, the knowledge base is updated according to the updated error correction rule to obtain the updated knowledge base.
[0114] By semantically removing error correction rules belonging to the same category in the knowledge base, redundancy of similar error correction rules is avoided, thereby ensuring the uniqueness of error correction rules of each type in the knowledge base.
[0115] In some embodiments, query text with semantic errors may retrieve data in the database that does not match expectations, but it will not result in a failure to retrieve data, i.e., the query will fail. However, query text with grammatical errors cannot be used to query data in the database. Therefore, the above-mentioned knowledge base update method can be an update method for the grammar rule base in the knowledge base.
[0116] For example, log data of failed queries is obtained. A fourth AI model generates syntax correction rules corresponding to the failed query text based on the text itself and its processing information. If the correction rules for the failed query text pass compliance verification, the similarity between these rules and at least one other syntax correction rule is calculated to obtain at least one similarity score. Semantic merging is performed on the syntax correction rule corresponding to the maximum similarity score and the syntax correction rule corresponding to the failed query text to obtain updated syntax correction rules. The syntax correction rule corresponding to the maximum similarity score in the syntax rule base is replaced with the updated syntax correction rule to obtain an updated syntax rule base, which in turn yields an updated knowledge base. Updates to the semantic rule base within the knowledge base can be achieved by experts manually formulating and correcting at least one semantic correction rule.
[0117] In some embodiments, step 240 is followed by step 250, which is a process for correcting the query text. Step 250 may include at least one of the following: a semantic error correction process and a syntax error correction process. Exemplarily, step 250 may include at least one of sub-steps 251 to 252.
[0118] Sub-step 251: Based on at least one of the semantic evaluation results and the syntactic evaluation results of the query text, obtain the error correction rules corresponding to the query text from the knowledge base.
[0119] Specifically, the grammatical evaluation result is used to indicate whether there are grammatical errors in the query text; when the grammatical evaluation result indicates that there are grammatical errors in the query text, the error correction rules corresponding to the query text include the grammatical error correction rules corresponding to the query text; when the semantic evaluation result indicates that there are semantic errors in the query text, the error correction rules corresponding to the query text include the semantic error correction rules corresponding to the query text.
[0120] For example, the error correction rules for the query text may include semantic error correction rules for at least one semantically erroneous segment, and at least one syntactic error correction rule. Semantic and syntactic error correction rules are collectively referred to as error correction rules.
[0121] Sub-step 252: Based on the error correction rules corresponding to the query text, correct the query text to obtain the corrected query text.
[0122] The corrected query text can refer to the query text that has undergone semantic correction, the query text that has undergone grammatical correction, or the query text that has undergone both semantic and grammatical correction.
[0123] For example, perform a grammatical evaluation on the query text to obtain the grammatical evaluation result. If the grammatical evaluation result indicates that there is a grammatical error in the query text, retrieve the corresponding grammatical correction rule from the knowledge base based on the grammatical error, and perform grammatical correction on the query text based on the corresponding grammatical correction rule to obtain the grammatically corrected query text.
[0124] For example, a semantic evaluation is performed on the query text to obtain the semantic evaluation result. If the semantic evaluation result indicates that there is a semantic error in the query text, the semantic error correction rule corresponding to the query text is obtained from the knowledge base according to the semantic error. Based on the semantic error correction rule corresponding to the query text, the semantic error is corrected on the query text to obtain the semantically corrected query text.
[0125] For example, performing a syntactic evaluation on the query text yields a syntactic evaluation result. If the result indicates a syntactic error, no semantic evaluation is performed; instead, syntactic correction is applied directly. The syntactic correction rules for the query text are retrieved from the knowledge base. Based on these rules, syntactic correction is applied to the query text, resulting in the syntactically corrected query text. Alternatively, if the syntactic evaluation result indicates no syntactic errors, a semantic evaluation is performed on the query text, yielding a semantic evaluation result. If the result indicates a semantic error, semantic correction is applied. The syntactic correction rules for the query text are retrieved from the knowledge base. Based on these rules, semantic correction is applied to the query text, resulting in the semantically corrected query text.
[0126] By combining semantic and syntactic evaluation results to correct query text, semantic and syntactic error correction for query text is achieved. This helps improve the comprehensiveness of text correction and the accuracy of the corrected query text. Therefore, querying the database based on the corrected query text can increase the probability of successful query and improve the accuracy of query results.
[0127] Referring to Figure 6, which illustrates a schematic diagram of the query text correction process provided in an embodiment of this application, the data management program mainly includes three modules: a text detection system, a text correction system, and a database system. After the user inputs the query text, the data management program first inputs the query text to the correctness evaluator 601 in the text detection system. The correctness evaluator 601 detects whether the query text has semantic or syntactic errors. If the query text has semantic or syntactic errors, the data management program inputs the query text to the error corrector 602 in the text correction system. The error corrector 602 corrects the semantic or syntactic errors in the query text. The corrected query text is then resent to the correctness evaluator 601 for a new round of correctness evaluation until the correctness evaluator 601 does not detect any semantic or syntactic errors, resulting in the corrected query text. During the text detection and text correction process, the data management program can extract task-related error correction rules from the knowledge base to implement correctness evaluation and error correction. The corrected query text is then input into the database system, which searches for the corresponding target data in database 603 based on the corrected query text. During the query process in the database system, the data management program can also collect log data of failed queries to extract and generate new syntax correction rules, which are then updated in the knowledge base.
[0128] The semantic error correction process for the query text will be described below. For content not described in this embodiment, please refer to the above embodiments, which will not be repeated here.
[0129] Please refer to Figure 7, which shows a flowchart of a semantic error correction method for query text provided in an embodiment of this application. The execution entity for each step of this method can be a computer device. The method may include at least one of the following steps 710 to 770:
[0130] Step 710: For each semantic error segment, determine the matching label information of the semantic error segment based on the semantic error type corresponding to the semantic error segment and the label information corresponding to at least one semantic error correction rule. The matching label information of the semantic error segment is the label information with the highest matching degree among the label information corresponding to at least one semantic error correction rule.
[0131] In the case of semantic errors in the query text, the semantic evaluation results are also used to indicate at least one semantically erroneous segment in the query text and the semantic error type corresponding to each of the at least one semantically erroneous segment.
[0132] Optionally, regular expressions are used to perform character matching on the semantic error type corresponding to the semantic error fragment and the tag information corresponding to at least one semantic error correction rule, respectively, to obtain the tag information corresponding to the semantic error correction rule that matches the semantic error type corresponding to the semantic error fragment, which is then used as the tag information for semantic error fragment matching.
[0133] Optionally, the similarity between the semantic error type corresponding to the semantic error segment and the label information corresponding to at least one semantic error correction rule is calculated to obtain at least one similarity. The label information of the semantic error correction rule corresponding to the maximum value of the at least one similarity is determined as the label information for matching the semantic error segment.
[0134] Step 720: Determine the semantic error correction rule corresponding to the tag information matching the semantic error fragment in the knowledge base as the semantic error correction rule corresponding to the semantic error fragment.
[0135] Since there is a one-to-one correspondence between label information and semantic error correction rules, the semantic error correction rules corresponding to the label information matching the semantic error fragment are obtained from the semantic rule base, thus obtaining the semantic error correction rules corresponding to the semantic error fragment.
[0136] Step 730: Obtain the semantic correction rules corresponding to the query text based on the semantic correction rules corresponding to at least one semantically erroneous segment.
[0137] The semantic correction rules corresponding to the query text include semantic correction rules corresponding to at least one semantically erroneous segment. Optionally, the semantic correction rules corresponding to the at least one semantically erroneous segment may contain duplicate semantic correction rules, or they may all be different semantic correction rules.
[0138] By extracting semantic error correction rules corresponding to semantic error segments from the knowledge base, subsequent semantic correction of semantic error segments in the query text can be carried out in a targeted manner based on the semantic error correction rules corresponding to the semantic error segments, which helps to improve the accuracy of semantic correction.
[0139] Step 740: Obtain partial table cell information corresponding to the query text. The partial table cell information is used to indicate the structural information in the database that matches the query text.
[0140] Retrieve partial table metadata corresponding to the query text from the database's table metadata. This partial table metadata is related to the query text within the database's table metadata and can be used to indicate partial structural information in the database that matches the query text. For example, based on the table metadata indicated by the query text, retrieve partial table metadata corresponding to the query text from the database's table metadata. For instance, partial table metadata includes at least one of the following: basic table information related to the query text (e.g., partial table name), column information related to the query text (e.g., partial column name), index information related to the query text (e.g., partial index name), constraint information related to the query text (e.g., partial relationships between tables), trigger information related to the query text (partial execution process when the trigger is activated), storage information related to the query text (e.g., partial tablespace), and other metadata related to the query text (e.g., partial descriptive information about the table or column).
[0141] Step 750: Based on partial table element information, semantic error correction rules corresponding to the query text, at least one semantic error fragment, and semantic correction suggestions, obtain the first preparation data corresponding to the query text. The first preparation data is the data used to perform semantic error correction on the query text.
[0142] The first set of preparation data corresponding to the query text includes some table metadata, semantic error correction rules corresponding to the query text, at least one semantic error fragment, and semantic correction suggestions for the query text.
[0143] Step 760: Generate a second prompt message based on the first prepared data and the second configuration template. The second configuration template is used to indicate the arrangement rules of the first prepared data.
[0144] The first set of prepared data is entered into the second configuration template to obtain the second prompt information. For example, the second prompt information is in text format. The second configuration template is a template set for semantic correction, which can be used to structure the judgment criteria required for semantic correction, serving as prompt information for semantic correction. The second prompt information is used to guide the second AI model to perform semantic correction on the query text.
[0145] For example, referring to Figure 8, the second configuration template includes a third template content 801, a fourth template content 802, and a fifth template content 803. The third template content 801 indicates the error correction steps for semantic correction, the fourth template content 802 indicates the task requirements for semantic correction, and the fifth template content 803 indicates the arrangement rules for the first prepared data.
[0146] Step 770: The second AI model generates the semantically corrected query text based on the second prompt information.
[0147] The second AI model is an AI model used to achieve semantic error correction. The second AI model can be any publicly available large language model, such as a natural language model based on a transformer structure trained with a large amount of data. This application does not limit this. Optionally, the second AI model can be the same as the first AI model or the fourth AI model mentioned above, or it can be an AI model that is different from both the first AI model and the fourth AI model mentioned above.
[0148] The second AI model uses the second prompt information to perform semantic correction on at least one semantically erroneous segment in the query text, resulting in the semantically corrected query text. The semantically corrected query text can refer to the query text after the semantic errors have been corrected.
[0149] By using a second configuration template to generate the second prompt information, the computer device can easily identify the various data in the second prompt information to generate semantically corrected query text. This improves the standardization and convenience of semantic correction, thereby increasing its speed. Furthermore, using semantically erroneous fragments as input to the second AI model, instead of the complete query text, reduces the contextual load on the second AI model, thus improving the efficiency of query text correction.
[0150] Referring to Figure 9, which illustrates a schematic diagram of a semantic error correction process provided in an embodiment of this application, the semantic error correction process includes a data preparation stage and a semantic error correction stage. In the data preparation stage, the data management program obtains at least one semantically erroneous segment in the query text, the semantic error type corresponding to each of the at least one semantically erroneous segment, and semantic correction suggestions for the query text based on the semantic evaluation results of the query text. Semantic error correction rules corresponding to each of the at least one semantically erroneous segment are obtained based on the semantic error type corresponding to each of the at least one semantically erroneous segment. Partial table metadata corresponding to the query text is obtained based on the query text. A second prompt message 901 is constructed based on the at least one semantically erroneous segment, the semantic error correction rules corresponding to each of the at least one semantically erroneous segment, the partial table metadata, and the semantic correction suggestions. In the semantic error correction stage, the data management program generates the semantically corrected query text based on the second prompt message 901 using a second AI model 902.
[0151] The following will explain the syntax correction process for the query text. For any content not explained in this embodiment, please refer to the above embodiments, which will not be repeated here.
[0152] Please refer to Figure 10, which shows a flowchart of a syntax correction method for query text provided in an embodiment of this application. The execution entity for each step of this method can be a computer device. The method may include at least one of the following steps 1010 to 1060:
[0153] Step 1010: For each syntax error location, determine the matching tag information of the syntax error location based on the syntax error type corresponding to the syntax error location and the tag information corresponding to at least one syntax correction rule. The matching tag information of the syntax error location is the tag information with the highest matching degree between the tag information corresponding to at least one syntax correction rule and the syntax error type corresponding to the syntax error location.
[0154] In the event that there are grammatical errors in the query text, the grammatical evaluation result is also used to indicate at least one grammatical error location in the query text and the grammatical error type corresponding to each of the at least one grammatical error locations.
[0155] The syntax error type corresponding to a syntax error location refers to the syntax error type of the syntax error segment corresponding to that location. Each syntax error location corresponds to one syntax error segment. A syntax error segment is a text segment containing syntax errors. The syntax error location indicates the position of the corresponding syntax error segment within the query text.
[0156] Optionally, regular expressions are used to perform character matching on the syntax error type corresponding to the syntax error location and the tag information corresponding to at least one syntax correction rule, respectively, to obtain the tag information corresponding to the syntax correction rule that matches the syntax error type corresponding to the syntax error location, which is then used as the tag information for syntax error location matching.
[0157] Optionally, the similarity between the syntax error type corresponding to the syntax error location and the label information corresponding to at least one syntax correction rule is calculated to obtain at least one similarity. The label information of the syntax correction rule corresponding to the maximum value of the at least one similarity is determined as the label information matching the syntax error location.
[0158] Step 1020: Determine the syntax correction rules corresponding to the tag information matching the syntax error location in the knowledge base as the syntax correction rules corresponding to the syntax error location.
[0159] Since there is a one-to-one correspondence between tag information and syntax correction rules, the syntax correction rules corresponding to the tag information matching the syntax error position are obtained from the syntax rule base, thus obtaining the syntax correction rules corresponding to the syntax error position.
[0160] Step 1030: Obtain the syntax correction rules corresponding to the query text based on the syntax correction rules corresponding to at least one syntax error location.
[0161] The syntax correction rules corresponding to the query text include syntax correction rules corresponding to at least one syntax error location. Optionally, the syntax correction rules corresponding to at least one syntax error location may contain duplicate syntax correction rules, or they may all be different syntax correction rules.
[0162] By extracting semantic error correction rules corresponding to the locations of grammatical errors from the knowledge base, subsequent grammatical correction of grammatically incorrect segments in the query text can be performed based on these rules, which helps improve the accuracy of grammatical correction.
[0163] Step 1040: Based on the query text and the corresponding syntax correction rules, obtain the second preparation data corresponding to the query text. The second preparation data is the data used to perform syntax correction on the query text.
[0164] In some embodiments, step 1040 includes at least one of sub-steps 1041 to 1043.
[0165] Sub-step 1041: If the database instruction information indicates that the database table meta information is used to perform syntax correction, obtain the partial table meta information corresponding to the query text.
[0166] The interpretation of some table element information can be found in the above-described semantic error correction process implementation examples, and will not be repeated here.
[0167] When the database's instruction information is used to indicate that the database's table metadata is not used to perform syntax correction, it is not necessary to obtain partial table metadata corresponding to the query text.
[0168] Sub-step 1042: In the case where the indication information of the local text fragment is used to indicate the extraction of local text fragments in the query text to perform syntax correction, at least one local text fragment at the location of a syntax error is extracted from the query text to obtain at least one syntax error fragment in the query text.
[0169] A syntax error location can include the starting and ending positions of the characters where the syntax error occurs. Therefore, the local text segment at the syntax error location can refer to the local text segment between the starting and ending positions of the characters where the syntax error occurs. Based on at least one syntax error location, at least one syntax error segment in the query text is obtained.
[0170] In cases where the indication information for a local text fragment is used to indicate that a local text fragment in the query text should not be extracted for syntax correction, it is not necessary to extract at least one grammatically incorrect fragment.
[0171] Sub-step 1043: Based on the partial table information, the correction strategy of the syntax error correction rule corresponding to at least one syntax error segment and at least one syntax error position, the second preparation data is obtained.
[0172] For example, when the database instruction information is used to instruct the use of the database table meta information to perform syntax correction, and the local text fragment instruction information is used to instruct the extraction of local text fragments from the query text to perform syntax correction, the second preparation data corresponding to the query text includes partial table meta information, at least one syntax error fragment, and syntax correction rules corresponding to at least one syntax error location.
[0173] In cases where the database instruction information is used to indicate that the database table meta information is not used to perform syntax correction, and the local text fragment instruction information is used to indicate that local text fragments in the query text are extracted to perform syntax correction, the second preparation data corresponding to the query text includes at least one syntax error fragment and at least one syntax error location corresponding to a syntax correction rule.
[0174] In cases where the database instruction information is used to indicate the use of database table metadata to perform syntax correction, and the local text fragment instruction information is used to indicate that local text fragments in the query text are not extracted to perform syntax correction, the second preparation data corresponding to the query text includes partial table metadata and syntax correction rules corresponding to at least one syntax error location.
[0175] In cases where the database instruction information is used to indicate that the database table meta information is not used to perform syntax correction, and the local text fragment instruction information is used to indicate that local text fragments in the query text are not extracted to perform syntax correction, the second preparation data corresponding to the query text includes at least one syntax correction rule corresponding to each syntax error location.
[0176] By using the triplet information in the syntax correction rules, it is determined whether to use the table meta-information from the database and the syntax error fragments in the query text for syntax correction. This ensures that the second preparation data is specifically used for syntax correction of the query text, avoiding redundancy and improving the efficiency of syntax correction. Furthermore, using syntax error fragments as input to the third AI model, instead of the complete query text, reduces the context load on the third AI model, thereby improving the efficiency of query text correction.
[0177] Step 1050: Generate a third prompt message based on the second prepared data and the third configuration template. The third configuration template is used to indicate the arrangement rules of the second prepared data.
[0178] The second set of prepared data is entered into the third configuration template to obtain the third prompt information. For example, the third prompt information is in text format. The third configuration template is a template for syntax correction settings, which can be used as the judgment criteria required for structured syntax correction, serving as prompt information for syntax correction. The third prompt information is used to guide the third AI model to perform syntax correction on the query text.
[0179] Step 1060: The third AI model obtains the grammatically corrected query text based on the third prompt information.
[0180] The third AI model is an AI model for implementing grammatical error correction. This third AI model can be any publicly available large language model, such as a natural language model trained with a large amount of data and based on a transformer structure; this application does not limit its scope. Optionally, the third AI model can be the same as the first, fourth, or second AI model mentioned above, or it can be an AI model that is different from all three of the aforementioned AI models.
[0181] A third AI model uses third-party prompts to correct at least one grammatically incorrect segment in the query text, resulting in a grammatically corrected query text. The grammatically corrected query text can refer to the query text after the grammatical errors have been corrected.
[0182] By using a third configuration template to generate third prompt information, computer devices can easily identify the various data in the third prompt information to generate the query text after syntax correction. This helps to improve the standardization and convenience of syntax correction, thereby improving the speed of syntax correction.
[0183] In some embodiments, a third AI model generates at least one corrected syntax error fragment based on third prompt information; at least one syntax error fragment in the query text is replaced with at least one corrected syntax error fragment to obtain the syntax-corrected query text.
[0184] The third prompt information is input into the third AI model, which outputs at least one corrected syntax error segment corresponding to at least one syntax error segment. The at least one corrected syntax error segment is then replaced with at least one syntax error segment in the query text to obtain the syntax-corrected query text.
[0185] By performing syntax correction on at least one syntax error segment and generating at least one corrected syntax error segment, targeted syntax correction can be achieved for each syntax error segment. Compared with directly generating the syntax-corrected query text, this avoids missing syntax errors that have not been corrected, which helps improve the accuracy of syntax correction.
[0186] Referring to Figure 11, which illustrates a schematic diagram of a syntax correction process provided in an embodiment of this application, the syntax correction process includes a rule retrieval stage, a data preparation stage, and a semantic correction stage. In the rule retrieval stage, the data management program obtains at least one syntax error location and the syntax error type corresponding to each of the at least one syntax error locations in the query text based on the syntax evaluation results of the query text. Based on the syntax error types corresponding to each of the at least one syntax error locations, syntax correction rules corresponding to each of the at least one syntax error locations are obtained from the knowledge base. In the data preparation stage, the data management program determines whether to use the table meta information of the database to perform syntax correction based on the database indication information in the syntax correction rules, and determines whether to extract syntax error segments from the query text to perform syntax correction based on the local text segment indication information in the syntax correction rules. Then, based on the correction strategy in the syntax correction rules and the information recalled in the data preparation stage, a third prompt message 1101 is constructed. In the syntax correction stage, the data management program generates at least one corrected syntax error segment using a third AI model 1102 based on the third prompt message 1101, and then replaces the at least one corrected syntax error segment in the query text to obtain the syntax-corrected query text.
[0187] In some embodiments, this application tested error detection and error correction capabilities on the BIRD (Big Impulse Response Dataset) public dataset. For error detection, this application used the result set of the CodeS-7B model on the BIRD dataset (i.e., the identified erroneous SQL query statements) as the detection object to determine whether an SQL query statement contains errors at the syntactic and semantic levels. Since this is a binary classification problem, this application used accuracy and F1 score as evaluation metrics. The test results are shown in Table 1 below.
[0188] Table 1
[0189] Regarding error correction capabilities, this application uses erroneous SQL query statements identified by the CodeS-7B and CodeS-15B models on the BIRD dataset as the correction targets, attempting to correct SQL query statements with syntax or semantic errors. This application uses correction accuracy as the evaluation metric, and the results are shown in Table 2 below.
[0190] Table 2
[0191] The experimental results above show that the technical solution provided in this application significantly outperforms the SQL error correction tool SQLFixAgent in both error detection and correction. This superiority is particularly evident in the challenging data, demonstrating that the technical solution provided in this application offers a significant improvement over existing technologies in handling long and complex SQL queries. The amount of erroneous data refers to the number of erroneous SQL queries.
[0192] Application scenario examples:
[0193] The error detection method for database query text provided in this application embodiment can be applied to at least one of the following fields: logistics and transportation, finance, e-commerce, medical, social, gaming, education, enterprise operation, and website management. The following will use the application to the e-commerce and finance fields as examples for illustration.
[0194] Applications in the logistics and transportation sector:
[0195] In one application scenario, the error detection method for database query text can be applied to the logistics and transportation field. Figure 12 shows a flowchart of an error detection method for database query text applied to the logistics and transportation field according to an embodiment of this application. The execution entity of each step of the method can be a computer device. The method may include at least one of the following steps 1210 to 1240.
[0196] Step 1210: Obtain the query text for the logistics database. The query text includes at least one text fragment and is used to query logistics data in the logistics database.
[0197] Step 1220: Perform semantic parsing on the query text to obtain at least one suspicious text fragment in the query text. The suspicious text fragment is a text fragment that is suspected of having semantic errors.
[0198] Step 1230: Obtain at least one semantic error correction rule corresponding to each suspicious text fragment from the knowledge base. The knowledge base includes at least one semantic error correction rule, which is used to indicate the correction strategy for semantic errors.
[0199] Step 1240: Based on the semantic error correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment respectively, obtain the semantic evaluation result of the query text. The semantic evaluation result is used to indicate whether there are semantic errors in the query text.
[0200] In some embodiments, the knowledge base also includes tag information corresponding to at least one semantic correction rule. For each suspicious text fragment, based on the suspicious text fragment and the tag information corresponding to at least one semantic correction rule, tag information matching the suspicious text fragment is obtained. The tag information matching the suspicious text fragment is the tag information with the highest matching degree among the tag information corresponding to at least one semantic correction rule. The semantic correction rule corresponding to the tag information matching the suspicious text fragment in the knowledge base is determined as the semantic correction rule corresponding to the suspicious text fragment.
[0201] In some embodiments, a first prompt message is generated based on the query text, at least one suspicious text fragment, semantic correction rules corresponding to at least one suspicious text fragment, and a first configuration template; wherein, the first configuration template is used to indicate the arrangement rules of the semantic correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment. The semantic evaluation result of the query text is obtained by a first AI model based on the first prompt message.
[0202] In some embodiments, the knowledge base further includes at least one syntax correction rule, which indicates a strategy for correcting syntax errors. Based on at least one of the semantic evaluation result and the syntax evaluation result of the query text, a correction rule corresponding to the query text is obtained from the knowledge base; wherein, the syntax evaluation result indicates whether the query text contains syntax errors; if the syntax evaluation result indicates that the query text contains syntax errors, the correction rule corresponding to the query text includes the syntax correction rule corresponding to the query text; if the semantic evaluation result indicates that the query text contains semantic errors, the correction rule corresponding to the query text includes the semantic correction rule corresponding to the query text. Based on the correction rule corresponding to the query text, the query text is corrected to obtain the corrected query text.
[0203] In some embodiments, when semantic errors exist in the query text, the semantic evaluation result is further used to indicate at least one semantically erroneous segment in the query text and the semantic error type corresponding to each semantically erroneous segment. For each semantically erroneous segment, based on the semantic error type corresponding to the semantically erroneous segment and the tag information corresponding to at least one semantic correction rule, the tag information matching the semantically erroneous segment is determined. The tag information matching the semantically erroneous segment is the tag information with the highest matching degree among the tag information corresponding to at least one semantic correction rule. The semantic correction rule corresponding to the tag information matching the semantically erroneous segment in the knowledge base is determined as the semantic correction rule corresponding to the semantically erroneous segment. Based on the semantic correction rules corresponding to at least one semantically erroneous segment, the semantic correction rule corresponding to the query text is obtained.
[0204] In some embodiments, when semantic errors exist in the query text, the semantic evaluation result is also used to indicate semantic correction suggestions for the query text. Partial table metadata corresponding to the query text is obtained; this partial table metadata indicates the structural information in the logistics database that matches the query text. Based on the partial table metadata, the semantic correction rules corresponding to the query text, at least one semantically erroneous segment, and the semantic correction suggestions, first preparation data corresponding to the query text is obtained. This first preparation data is the data used to perform semantic correction on the query text. Based on the first preparation data and a second configuration template, a second prompt message is generated; the second configuration template indicates the arrangement rules of the first preparation data. A second AI model generates the semantically corrected query text based on the second prompt message.
[0205] In some embodiments, when the query text contains grammatical errors, the grammatical evaluation result is further used to indicate at least one grammatical error location and the corresponding grammatical error type of each grammatical error location in the query text; the knowledge base also includes tag information corresponding to at least one grammatical correction rule. For each grammatical error location, based on the grammatical error type corresponding to the grammatical error location and the tag information corresponding to at least one grammatical correction rule, the tag information matching the grammatical error location is determined. The tag information matching the grammatical error location is the tag information with the highest matching degree between the tag information corresponding to at least one grammatical correction rule and the grammatical error type corresponding to the grammatical error location. The grammatical correction rule corresponding to the tag information matching the grammatical error location in the knowledge base is determined as the grammatical correction rule corresponding to the grammatical error location. Based on the grammatical correction rules corresponding to at least one grammatical error location, the grammatical correction rule corresponding to the query text is obtained.
[0206] In some embodiments, second preparation data corresponding to the query text is obtained based on the query text and the corresponding syntax correction rules. This second preparation data is the data used to perform syntax correction on the query text. A third prompt message is generated based on the second preparation data and a third configuration template, whereby the third configuration template indicates the arrangement rules of the second preparation data. The syntax-corrected query text is then obtained through a third AI model based on the third prompt message.
[0207] In some embodiments, the syntax correction rules corresponding to the syntax error locations include: database indication information, local text fragment indication information, and correction strategies for the syntax correction rules corresponding to the syntax error locations. The database indication information indicates whether to use the database's table metadata to perform syntax correction, and the local text fragment indication information indicates whether to extract syntax error fragments from the query text to perform syntax correction. When the logistics database indication information indicates that the logistics database's table metadata is used to perform syntax correction, partial table metadata corresponding to the query text is obtained. When the local text fragment indication information indicates that local text fragments are extracted from the query text to perform syntax correction, at least one syntax error fragment is extracted from the query text. Second preparation data is obtained based on the correction strategies for the syntax correction rules corresponding to the partial table metadata, at least one syntax error fragment, and at least one syntax error location.
[0208] In some embodiments, a third AI model generates at least one corrected syntax error fragment based on third prompt information. The at least one syntax error fragment in the query text is then replaced with at least one corrected syntax error fragment to obtain the syntax-corrected query text.
[0209] In some embodiments, the knowledge base includes a grammar rule base and a semantic rule base. The grammar rule base includes at least one grammar correction rule, which is used to indicate a strategy for correcting grammatical errors. The semantic rule base includes at least one semantic correction rule.
[0210] In some embodiments, log data of failed queries is obtained. This log data includes the query failure text and process information related to the failed query text. The query failure text indicates that data was not successfully retrieved from the logistics database, and the process information indicates the query steps involved. A fourth AI model generates correction rules corresponding to the failed query text based on the text and its process information. If the correction rules for the failed query text pass compliance verification, the knowledge base is updated according to these rules to obtain the updated knowledge base.
[0211] In some embodiments, the similarity between the error correction rule corresponding to the failed query text and at least two other error correction rules is calculated to obtain at least two similarity scores. The error correction rule corresponding to the maximum similarity score among the at least two similarity scores is semantically merged with the error correction rule corresponding to the failed query text to obtain an updated error correction rule. The error correction rule corresponding to the maximum similarity score in the knowledge base is replaced with the updated error correction rule to obtain an updated knowledge base.
[0212] By decomposing the query text into at least one text segment, each segment can be semantically evaluated independently, achieving localized semantic evaluation of the query text. Compared to related technologies that directly evaluate the complete query text, the technical solution provided in this application reduces the difficulty of understanding the query text. This improves the ability to understand and analyze the query text, thereby enhancing the accuracy of the semantic evaluation results and consequently improving the accuracy of subsequent semantic error correction based on the evaluation results. Furthermore, by additionally using at least one suspicious text segment in the query text, along with the corresponding semantic error correction rules, as the basis for determining the semantic evaluation results, this not only enriches the criteria for semantic evaluation but also allows for targeted detection of semantic errors within the at least one suspicious text segment. This leads to a better understanding of each text segment in the query text, further improving the accuracy of the semantic evaluation results.
[0213] Furthermore, by combining semantic and syntactic evaluation results to correct query text, semantic and syntactic error correction for query text is achieved, improving the comprehensiveness of text correction and the accuracy of the corrected query text. Thus, querying the logistics database based on the corrected query text can increase the probability of successful query and improve the accuracy of query results.
[0214] Applications in the financial sector:
[0215] In one application scenario, the error detection method for database query text can be applied to the financial field. Figure 13 shows a flowchart of an error detection method for database query text applied to the financial field according to an embodiment of this application. The execution entity of each step of the method can be a computer device. The method may include at least one of the following steps 1310 to 1340.
[0216] Step 1310: Obtain the query text for the financial database. The query text includes at least one text fragment and is used to query financial data in the financial database.
[0217] Step 1320: Perform semantic parsing on the query text to obtain at least one suspicious text fragment in the query text. The suspicious text fragment is a text fragment that is suspected of having a semantic error.
[0218] Step 1330: Obtain at least one semantic error correction rule corresponding to each suspicious text fragment from the knowledge base. The knowledge base includes at least one semantic error correction rule, which is used to indicate the correction strategy for semantic errors.
[0219] Step 1340: Based on the semantic error correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment respectively, obtain the semantic evaluation result of the query text. The semantic evaluation result is used to indicate whether there are semantic errors in the query text.
[0220] In some embodiments, the knowledge base also includes tag information corresponding to at least one semantic correction rule. For each suspicious text fragment, based on the suspicious text fragment and the tag information corresponding to at least one semantic correction rule, tag information matching the suspicious text fragment is obtained. The tag information matching the suspicious text fragment is the tag information with the highest matching degree among the tag information corresponding to at least one semantic correction rule. The semantic correction rule corresponding to the tag information matching the suspicious text fragment in the knowledge base is determined as the semantic correction rule corresponding to the suspicious text fragment.
[0221] In some embodiments, a first prompt message is generated based on the query text, at least one suspicious text fragment, semantic correction rules corresponding to at least one suspicious text fragment, and a first configuration template; wherein, the first configuration template is used to indicate the arrangement rules of the semantic correction rules corresponding to the query text, at least one suspicious text fragment, and at least one suspicious text fragment. The semantic evaluation result of the query text is obtained by a first AI model based on the first prompt message.
[0222] In some embodiments, the knowledge base further includes at least one syntax correction rule, which indicates a strategy for correcting syntax errors. Based on at least one of the semantic evaluation result and the syntax evaluation result of the query text, a correction rule corresponding to the query text is obtained from the knowledge base; wherein, the syntax evaluation result indicates whether the query text contains syntax errors; if the syntax evaluation result indicates that the query text contains syntax errors, the correction rule corresponding to the query text includes the syntax correction rule corresponding to the query text; if the semantic evaluation result indicates that the query text contains semantic errors, the correction rule corresponding to the query text includes the semantic correction rule corresponding to the query text. Based on the correction rule corresponding to the query text, the query text is corrected to obtain the corrected query text.
[0223] In some embodiments, when semantic errors exist in the query text, the semantic evaluation result is further used to indicate at least one semantically erroneous segment in the query text and the semantic error type corresponding to each semantically erroneous segment. For each semantically erroneous segment, based on the semantic error type corresponding to the semantically erroneous segment and the tag information corresponding to at least one semantic correction rule, the tag information matching the semantically erroneous segment is determined. The tag information matching the semantically erroneous segment is the tag information with the highest matching degree among the tag information corresponding to at least one semantic correction rule. The semantic correction rule corresponding to the tag information matching the semantically erroneous segment in the knowledge base is determined as the semantic correction rule corresponding to the semantically erroneous segment. Based on the semantic correction rules corresponding to at least one semantically erroneous segment, the semantic correction rule corresponding to the query text is obtained.
[0224] In some embodiments, when semantic errors exist in the query text, the semantic evaluation result is also used to indicate semantic correction suggestions for the query text. Partial table metadata corresponding to the query text is obtained; this partial table metadata indicates the structural information in the financial database that matches the query text. Based on the partial table metadata, the semantic correction rules corresponding to the query text, at least one semantically erroneous segment, and the semantic correction suggestions, first preparation data corresponding to the query text is obtained. This first preparation data is the data used to perform semantic correction on the query text. Based on the first preparation data and a second configuration template, a second prompt message is generated; the second configuration template indicates the arrangement rules of the first preparation data. A second AI model generates the semantically corrected query text based on the second prompt message.
[0225] In some embodiments, when the query text contains grammatical errors, the grammatical evaluation result is further used to indicate at least one grammatical error location and the corresponding grammatical error type of each grammatical error location in the query text; the knowledge base also includes tag information corresponding to at least one grammatical correction rule. For each grammatical error location, based on the grammatical error type corresponding to the grammatical error location and the tag information corresponding to at least one grammatical correction rule, the tag information matching the grammatical error location is determined. The tag information matching the grammatical error location is the tag information with the highest matching degree between the tag information corresponding to at least one grammatical correction rule and the grammatical error type corresponding to the grammatical error location. The grammatical correction rule corresponding to the tag information matching the grammatical error location in the knowledge base is determined as the grammatical correction rule corresponding to the grammatical error location. Based on the grammatical correction rules corresponding to at least one grammatical error location, the grammatical correction rule corresponding to the query text is obtained.
[0226] In some embodiments, second preparation data corresponding to the query text is obtained based on the query text and the corresponding syntax correction rules. This second preparation data is the data used to perform syntax correction on the query text. A third prompt message is generated based on the second preparation data and a third configuration template, whereby the third configuration template indicates the arrangement rules of the second preparation data. The syntax-corrected query text is then obtained through a third AI model based on the third prompt message.
[0227] In some embodiments, the syntax correction rules corresponding to the syntax error locations include: database indication information, local text fragment indication information, and correction strategies for the syntax correction rules corresponding to the syntax error locations. The database indication information indicates whether to use the database's table metadata to perform syntax correction, and the local text fragment indication information indicates whether to extract syntax error fragments from the query text to perform syntax correction. When the financial database indication information indicates that the financial database's table metadata is used to perform syntax correction, partial table metadata corresponding to the query text is obtained. When the local text fragment indication information indicates that local text fragments are extracted from the query text to perform syntax correction, at least one syntax error fragment is extracted from the query text. Second preparation data is obtained based on the correction strategies for the syntax correction rules corresponding to the partial table metadata, at least one syntax error fragment, and at least one syntax error location.
[0228] In some embodiments, a third AI model generates at least one corrected syntax error fragment based on third prompt information. The at least one syntax error fragment in the query text is then replaced with at least one corrected syntax error fragment to obtain the syntax-corrected query text.
[0229] In some embodiments, the knowledge base includes a grammar rule base and a semantic rule base. The grammar rule base includes at least one grammar correction rule, which is used to indicate a strategy for correcting grammatical errors. The semantic rule base includes at least one semantic correction rule.
[0230] In some embodiments, log data of failed queries is obtained. This log data includes the query failure text and process information related to the failed query text. The query failure text indicates a query that failed to retrieve data from the financial database, and the process information indicates the query steps involved. A fourth AI model generates correction rules corresponding to the failed query text based on the text and its process information. If the correction rules for the failed query text pass compliance verification, the knowledge base is updated according to these rules to obtain the updated knowledge base.
[0231] In some embodiments, the similarity between the error correction rule corresponding to the failed query text and at least two other error correction rules is calculated to obtain at least two similarity scores. The error correction rule corresponding to the maximum similarity score among the at least two similarity scores is semantically merged with the error correction rule corresponding to the failed query text to obtain an updated error correction rule. The error correction rule corresponding to the maximum similarity score in the knowledge base is replaced with the updated error correction rule to obtain an updated knowledge base.
[0232] By decomposing the query text into at least one text segment, each segment can be semantically evaluated independently, achieving localized semantic evaluation of the query text. Compared to related technologies that directly evaluate the complete query text, the technical solution provided in this application reduces the difficulty of understanding the query text. This improves the ability to understand and analyze the query text, thereby enhancing the accuracy of the semantic evaluation results and consequently improving the accuracy of subsequent semantic error correction based on the evaluation results. Furthermore, by additionally using at least one suspicious text segment in the query text, along with the corresponding semantic error correction rules, as the basis for determining the semantic evaluation results, this not only enriches the criteria for semantic evaluation but also allows for targeted detection of semantic errors within the at least one suspicious text segment. This leads to a better understanding of each text segment in the query text, further improving the accuracy of the semantic evaluation results.
[0233] Furthermore, by combining semantic and syntactic evaluation results to correct query text, semantic and syntactic error correction for query text is achieved, improving the comprehensiveness of text correction and the accuracy of the corrected query text. Thus, querying financial databases based on the corrected query text can increase the probability of successful query and improve the accuracy of query results.
[0234] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0235] Please refer to Figure 14, which shows a block diagram of a database query text error detection device according to an embodiment of this application. This device has the function of implementing the above-described database query text error detection method; the function can be implemented in hardware or by hardware executing corresponding software. The device can be the computer device described above, or it can be installed within a computer device. As shown in Figure 14, the device 1400 may include: a text acquisition module 1410, a semantic parsing module 1420, a rule extraction module 1430, and a semantic evaluation module 1440.
[0236] The text acquisition module 1410 is used to acquire query text for a database, the query text including at least one text fragment, the query text being used to query data in the database.
[0237] The semantic parsing module 1420 is used to perform semantic parsing on the query text to obtain at least one suspicious text fragment in the query text, wherein the suspicious text fragment is a text fragment that is suspected of having semantic errors.
[0238] The rule extraction module 1430 is used to obtain the semantic error correction rules corresponding to the at least one suspicious text fragment, and the semantic error correction rules are used to indicate the correction strategy for semantic errors.
[0239] The semantic evaluation module 1440 is used to obtain the semantic evaluation result of the query text based on the semantic error correction rules corresponding to the query text, the at least one suspicious text fragment, and the at least one suspicious text fragment, respectively. The semantic evaluation result is used to indicate whether there is a semantic error in the query text.
[0240] In some embodiments, the semantic error correction rule is obtained from a knowledge base, which includes at least one semantic error correction rule and tag information corresponding to each of the at least one semantic error correction rule; the rule extraction module 1430 is used for:
[0241] For each suspicious text segment, according to the tag information corresponding to the suspicious text segment and the at least one semantic error correction rule respectively, the tag information matching the suspicious text segment is obtained. The tag information matching the suspicious text segment is the tag information with the highest matching degree among the tag information corresponding to the at least one semantic error correction rule respectively.
[0242] The semantic error correction rules corresponding to the tag information matched by the suspicious text fragment in the knowledge base are determined as the semantic error correction rules corresponding to the suspicious text fragment.
[0243] In some embodiments, the semantic evaluation module 1440 is configured to:
[0244] A first prompt message is generated based on the query text, the at least one suspicious text fragment, the semantic correction rules corresponding to the at least one suspicious text fragment, and the first configuration template; wherein, the first configuration template is used to indicate the arrangement rules of the semantic correction rules corresponding to the query text, the at least one suspicious text fragment, and the at least one suspicious text fragment.
[0245] The first AI model obtains the semantic evaluation result of the query text based on the first prompt information.
[0246] In some embodiments, the knowledge base corresponding to the semantic error correction rule further includes at least one syntax error correction rule, which is used to indicate a strategy for correcting syntax errors; the device 1400 further includes: a text error correction module (not shown in the figure), which is used to:
[0247] Based on at least one of the semantic evaluation result and the grammatical evaluation result of the query text, the error correction rule corresponding to the query text is obtained from the knowledge base; wherein, the grammatical evaluation result is used to indicate whether the query text has a grammatical error; when the grammatical evaluation result indicates that the query text has a grammatical error, the error correction rule corresponding to the query text includes the grammatical error correction rule corresponding to the query text; when the semantic evaluation result indicates that the query text has a semantic error, the error correction rule corresponding to the query text includes the semantic error correction rule corresponding to the query text.
[0248] Based on the error correction rules corresponding to the query text, the query text is corrected to obtain the corrected query text.
[0249] In some embodiments, when the query text contains semantic errors, the semantic evaluation result is further used to indicate at least one semantically erroneous segment in the query text and the semantic error type corresponding to the at least one semantically erroneous segment; the text correction module is used to:
[0250] For each semantic error segment, the label information matching the semantic error segment is determined according to the semantic error type corresponding to the semantic error segment and the label information corresponding to the at least one semantic error correction rule respectively. The label information matching the semantic error segment is the label information with the highest matching degree between the at least one semantic error correction rule and the semantic error segment.
[0251] The semantic error correction rule corresponding to the tag information matched by the semantic error fragment in the knowledge base is determined as the semantic error correction rule corresponding to the semantic error fragment;
[0252] Based on the semantic correction rules corresponding to the at least one semantically erroneous segment, the semantic correction rules corresponding to the query text are obtained.
[0253] In some embodiments, if the query text contains semantic errors, the semantic evaluation result is further used to indicate semantic correction suggestions for the query text; the text correction module is used to:
[0254] Obtain partial table element information corresponding to the query text, wherein the partial table element information is used to indicate the structural information in the database that matches the query text;
[0255] Based on the partial table metadata, the semantic error correction rules corresponding to the query text, the at least one semantic error fragment, and the semantic correction suggestion, the first preparation data corresponding to the query text is obtained. The first preparation data is the data used to perform semantic error correction on the query text.
[0256] Based on the first prepared data and the second configuration template, a second prompt message is generated, wherein the second configuration template is used to indicate the arrangement rules of the first prepared data.
[0257] The second AI model generates semantically corrected query text based on the second prompt information.
[0258] In some embodiments, when the query text contains grammatical errors, the grammatical evaluation result is further used to indicate at least one grammatical error location in the query text and the grammatical error type corresponding to each of the at least one grammatical error locations; the knowledge base also includes tag information corresponding to at least one grammatical correction rule; the text correction module is used to:
[0259] For each of the syntax error locations, based on the syntax error type corresponding to the syntax error location and the tag information corresponding to the at least one syntax correction rule, the tag information matching the syntax error location is determined. The tag information matching the syntax error location is the tag information with the highest matching degree between the tag information corresponding to the at least one syntax correction rule and the syntax error type corresponding to the syntax error location.
[0260] The syntax correction rule corresponding to the tag information matching the syntax error location in the knowledge base is determined as the syntax correction rule corresponding to the syntax error location.
[0261] Based on the syntax correction rules corresponding to the at least one syntax error location, the syntax correction rules corresponding to the query text are obtained.
[0262] In some embodiments, the text correction module is used for:
[0263] Based on the query text and the corresponding syntax correction rules, the second preparation data corresponding to the query text is obtained. The second preparation data is the data used to perform syntax correction on the query text.
[0264] Based on the second prepared data and the third configuration template, a third prompt message is generated, wherein the third configuration template is used to indicate the arrangement rules of the second prepared data;
[0265] The third AI model obtains the grammatically corrected query text based on the third prompt information.
[0266] In some embodiments, the syntax correction rules corresponding to the syntax error locations include: indication information from the database, indication information from local text fragments, and a correction strategy for the syntax correction rules corresponding to the syntax error locations. The indication information from the database is used to indicate whether to use the table metadata of the database to perform syntax correction, and the indication information from the local text fragments is used to indicate whether to extract syntax error fragments from the query text to perform syntax correction. The text correction module is used to:
[0267] When the database's instruction information is used to indicate that the database's table metadata is used to perform syntax correction, partial table metadata corresponding to the query text is obtained;
[0268] When the indication information of the local text fragment is used to indicate the extraction of local text fragments in the query text to perform syntax correction, the local text fragments at the positions of the at least one syntax error are extracted from the query text to obtain at least one syntax error fragment in the query text;
[0269] The second preparation data is obtained based on the partial table information, the correction strategies of the at least one syntax error segment and the syntax error location corresponding to the syntax correction rules.
[0270] In some embodiments, the text correction module is used for:
[0271] The third AI model generates at least one corrected grammatical error fragment based on the third prompt information.
[0272] The query text is modified by replacing at least one grammatically incorrect segment with at least one corrected grammatically incorrect segment to obtain the grammatically corrected query text.
[0273] In some embodiments, the knowledge base corresponding to the semantic error correction rule includes a grammar rule base and a semantic rule base. The grammar rule base includes at least one grammar error correction rule, which is used to indicate a strategy for correcting grammatical errors. The semantic rule base includes at least one semantic error correction rule.
[0274] In some embodiments, the apparatus 1400 further includes a knowledge base update module (not shown in the figures), the knowledge base update module being configured to:
[0275] Obtain log data of query failures. The log data of query failures includes query failure text and process information of the query failure text. The query failure text is the query text in which data was not successfully retrieved from the database. The process information is used to indicate the query steps of the query failure text.
[0276] The fourth AI model generates error correction rules corresponding to the query failure text based on the query failure text and the process information of the query failure text;
[0277] If the error correction rule corresponding to the failed query text passes the compliance verification, the knowledge base corresponding to the semantic error correction rule is updated according to the error correction rule corresponding to the failed query text to obtain the updated knowledge base.
[0278] In some embodiments, the knowledge base includes at least two error correction rules; the knowledge base update module is configured to:
[0279] Calculate the similarity between the error correction rule corresponding to the failed query text and the at least two error correction rules respectively to obtain at least two similarities;
[0280] The error correction rule corresponding to the maximum value of the at least two similarities is semantically merged with the error correction rule corresponding to the query failure text to obtain the updated error correction rule;
[0281] The error correction rule corresponding to the maximum value in the knowledge base is replaced with the updated error correction rule to obtain the updated knowledge base.
[0282] In summary, the technical solution provided in this application decomposes the query text into at least one text segment, allowing each text segment to be semantically evaluated independently. This achieves localized semantic evaluation of the query text. Compared to related technologies that directly perform semantic evaluation on the complete query text, the technical solution provided in this application reduces the difficulty of understanding the query text. This improves the ability to understand and analyze the query text, thereby enhancing the accuracy of the semantic evaluation results and consequently improving the accuracy of subsequent semantic error correction based on the evaluation results. Furthermore, by additionally using at least one suspicious text segment in the query text, along with the corresponding semantic error correction rules, as the basis for determining the semantic evaluation results, the criteria for semantic evaluation are enriched. This also allows for targeted detection of semantic errors within the at least one suspicious text segment, leading to a better understanding of each text segment in the query text and further improving the accuracy of the semantic evaluation results.
[0283] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the content structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0284] Please refer to Figure 15, which shows a structural block diagram of a computer device 1500 provided in one embodiment of this application. The computer device 1500 can be any electronic device with data calculation, processing, and storage functions. The computer device 1500 can be used to implement the error detection method for database query text provided in the above embodiments.
[0285] Typically, computer device 1500 includes a processor 1501 and a memory 1502.
[0286] Processor 1501 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1501 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1501 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1501 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 1501 may also include an AI processor for handling computational operations related to machine learning.
[0287] The memory 1502 may include one or more computer-readable storage media, which may be non-transitory. The memory 1502 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1502 is used to store a computer program configured to be executed by one or more processors to implement the above-described error detection method for database query text.
[0288] Those skilled in the art will understand that the structure shown in FIG15 does not constitute a limitation on the computer device 1500, and may include more or fewer components than shown, or combine certain components, or employ different component arrangements.
[0289] In an illustrative embodiment, a computer-readable storage medium is also provided, wherein a computer program is stored in the storage medium, and the computer program, when executed by a processor of a computer device, implements the aforementioned error detection method for database query text. Optionally, the aforementioned computer-readable storage medium may be ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk, and optical data storage device, etc.
[0290] In an exemplary embodiment, a computer program product is also provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the aforementioned error detection method for database query text.
[0291] It should be noted that this application may display prompt interfaces, pop-ups, or output voice prompts before and during the collection of user-related data (such as query text, input text, etc.). These prompt interfaces, pop-ups, or voice prompts are used to inform users that their relevant data is being collected. This ensures that this application only begins the steps of collecting user-related data after obtaining confirmation from the user regarding the prompt interface or pop-up. Otherwise (i.e., without obtaining confirmation from the user regarding the prompt interface or pop-up), the steps of collecting user-related data end, meaning that no user-related data is collected. In other words, all user data collected by this application is processed strictly in accordance with the requirements of relevant national laws and regulations. The informed consent or separate consent of the personal information subject is obtained only with the user's consent and authorization. Subsequent data use and processing are conducted within the scope of laws and regulations and the authorization of the personal information subject. Furthermore, the collection, use, and processing of relevant user data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0292] It should be understood that "multiple" as used herein refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the step numbers described herein are merely illustrative of one possible execution order. In some other embodiments, the steps may not be executed in numerical order, such as two steps with different numbers being executed simultaneously, or two steps with different numbers being executed in the reverse order of the illustration. This application does not limit this.
[0293] The above description is merely an exemplary embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for error detection in database query text, the method being executed by a computer device, the method comprising: Obtain query text for a database, the query text including at least one text fragment, the query text being used to query data in the database; Perform semantic parsing on the query text to obtain at least one suspicious text fragment in the query text, wherein the suspicious text fragment is a text fragment that is suspected of having a semantic error; Obtain the semantic error correction rules corresponding to the at least one suspicious text fragment, and the semantic error correction rules are used to indicate the correction strategy for semantic errors; Based on the semantic error correction rules corresponding to the query text, the at least one suspicious text fragment, and the at least one suspicious text fragment, a semantic evaluation result of the query text is obtained, and the semantic evaluation result is used to indicate whether there is a semantic error in the query text.
2. The method of claim 1, wherein, The semantic error correction rule is obtained from a knowledge base, which includes at least one semantic error correction rule and tag information corresponding to each of the at least one semantic error correction rule. The step of obtaining the semantic error correction rules corresponding to the at least one suspicious text fragment includes: For each suspicious text segment, according to the tag information corresponding to the suspicious text segment and the at least one semantic error correction rule respectively, the tag information matching the suspicious text segment is obtained. The tag information matching the suspicious text segment is the tag information with the highest matching degree among the tag information corresponding to the at least one semantic error correction rule respectively. The semantic error correction rules corresponding to the tag information matched by the suspicious text fragment in the knowledge base are determined as the semantic error correction rules corresponding to the suspicious text fragment.
3. The method of claim 1 or 2, wherein, The step of obtaining the semantic evaluation result of the query text based on the semantic correction rules corresponding to the query text, the at least one suspicious text segment, and the at least one suspicious text segment includes: A first prompt message is generated based on the query text, the at least one suspicious text fragment, the semantic correction rules corresponding to the at least one suspicious text fragment, and the first configuration template; wherein, the first configuration template is used to indicate the arrangement rules of the semantic correction rules corresponding to the query text, the at least one suspicious text fragment, and the at least one suspicious text fragment. The semantic evaluation result of the query text is obtained by the first artificial intelligence (AI) model based on the first prompt information.
4. The method according to any one of claims 1 to 3, wherein, The knowledge base corresponding to the semantic error correction rule also includes at least one syntax error correction rule, which is used to indicate the correction strategy for syntax errors; the method further includes: Based on at least one of the semantic evaluation result and the grammatical evaluation result of the query text, the error correction rule corresponding to the query text is obtained from the knowledge base; wherein, the grammatical evaluation result is used to indicate whether the query text has a grammatical error; when the grammatical evaluation result indicates that the query text has a grammatical error, the error correction rule corresponding to the query text includes the grammatical error correction rule corresponding to the query text; when the semantic evaluation result indicates that the query text has a semantic error, the error correction rule corresponding to the query text includes the semantic error correction rule corresponding to the query text. Based on the error correction rules corresponding to the query text, the query text is corrected to obtain the corrected query text.
5. The method of claim 4, wherein, In the event that the query text contains semantic errors, the semantic evaluation result is also used to indicate at least one semantically erroneous segment in the query text and the semantic error type corresponding to the at least one semantically erroneous segment; The step of obtaining the error correction rule corresponding to the query text from the knowledge base based on at least one of the semantic evaluation result and the syntactic evaluation result of the query text includes: For each semantic error segment, the label information matching the semantic error segment is determined according to the semantic error type corresponding to the semantic error segment and the label information corresponding to the at least one semantic error correction rule respectively. The label information matching the semantic error segment is the label information with the highest matching degree between the at least one semantic error correction rule and the semantic error segment. The semantic error correction rule corresponding to the tag information matched by the semantic error fragment in the knowledge base is determined as the semantic error correction rule corresponding to the semantic error fragment. Based on the semantic error correction rules corresponding to the at least one semantic error segment, the semantic error correction rules corresponding to the query text are obtained.
6. The method of claim 4 or 5, wherein, In the event that the query text contains semantic errors, the semantic evaluation result is also used to indicate semantic correction suggestions for the query text; The step of correcting the query text based on the error correction rules corresponding to the query text to obtain the corrected query text includes: Obtain partial table element information corresponding to the query text, wherein the partial table element information is used to indicate the structural information in the database that matches the query text; Based on the partial table metadata, the semantic error correction rules corresponding to the query text, the at least one semantic error fragment, and the semantic correction suggestion, the first preparation data corresponding to the query text is obtained. The first preparation data is the data used to perform semantic error correction on the query text. Based on the first prepared data and the second configuration template, a second prompt message is generated, wherein the second configuration template is used to indicate the arrangement rules of the first prepared data. The second AI model generates semantically corrected query text based on the second prompt information.
7. The method according to any one of claims 4 to 6, wherein, In the event that the query text contains grammatical errors, the grammatical evaluation result is also used to indicate at least one grammatical error location in the query text and the grammatical error type corresponding to each of the at least one grammatical error locations; the knowledge base also includes tag information corresponding to at least one grammatical correction rule. The step of obtaining the error correction rule corresponding to the query text from the knowledge base based on at least one of the semantic evaluation result and the syntactic evaluation result of the query text includes: For each of the syntax error locations, based on the syntax error type corresponding to the syntax error location and the tag information corresponding to the at least one syntax correction rule, the tag information matching the syntax error location is determined. The tag information matching the syntax error location is the tag information with the highest matching degree between the tag information corresponding to the at least one syntax correction rule and the syntax error type corresponding to the syntax error location. The syntax correction rule corresponding to the tag information matching the syntax error location in the knowledge base is determined as the syntax correction rule corresponding to the syntax error location. Based on the syntax correction rules corresponding to the at least one syntax error location, the syntax correction rules corresponding to the query text are obtained.
8. The method of claim 7, wherein, The step of correcting the query text based on the error correction rules corresponding to the query text to obtain the corrected query text includes: Based on the query text and the corresponding syntax correction rules, the second preparation data corresponding to the query text is obtained. The second preparation data is the data used to perform syntax correction on the query text. Based on the second prepared data and the third configuration template, a third prompt message is generated, wherein the third configuration template is used to indicate the arrangement rules of the second prepared data; The third AI model obtains the grammatically corrected query text based on the third prompt information.
9. The method of claim 8, wherein, The syntax correction rules corresponding to the syntax error locations include: the database's indication information, the local text fragment's indication information, and the correction strategy of the syntax correction rules corresponding to the syntax error locations. The database's indication information is used to indicate whether to use the database's table meta information to perform syntax correction, and the local text fragment's indication information is used to indicate whether to extract the syntax error fragments in the query text to perform syntax correction. The step of obtaining the second preparation data corresponding to the query text based on the query text and the corresponding syntax correction rules includes: When the database's instruction information is used to indicate that the database's table metadata is used to perform syntax correction, partial table metadata corresponding to the query text is obtained; When the indication information of the local text fragment is used to indicate the extraction of local text fragments in the query text to perform syntax correction, the local text fragments at the positions of the at least one syntax error are extracted from the query text to obtain at least one syntax error fragment in the query text; The second preparation data is obtained based on the partial table information, the correction strategies of the at least one syntax error segment and the syntax error location corresponding to the syntax correction rules.
10. The method of claim 9, wherein, The process of obtaining the grammatically corrected query text through a third AI model based on the third prompt information includes: The third AI model generates at least one corrected grammatical error fragment based on the third prompt information. The query text is modified by replacing at least one grammatically incorrect segment with at least one corrected grammatically incorrect segment to obtain the grammatically corrected query text.
11. The method according to any one of claims 1 to 10, wherein, The knowledge base corresponding to the semantic error correction rule includes a syntax rule base and a semantic rule base. The syntax rule base includes at least one syntax error correction rule, which is used to indicate the correction strategy for syntax errors. The semantic rule base includes at least one semantic error correction rule.
12. The method according to any one of claims 1 to 11, wherein, The method further includes: Obtain log data of query failures. The log data of query failures includes query failure text and process information of the query failure text. The query failure text is the query text in which data was not successfully retrieved from the database. The process information is used to indicate the query steps of the query failure text. The fourth AI model generates error correction rules corresponding to the query failure text based on the query failure text and the process information of the query failure text; If the error correction rule corresponding to the failed query text passes the compliance verification, the knowledge base corresponding to the semantic error correction rule is updated according to the error correction rule corresponding to the failed query text to obtain the updated knowledge base.
13. The method of claim 12, wherein, The knowledge base includes at least two error correction rules; The step of updating the knowledge base corresponding to the semantic error correction rule based on the error correction rule corresponding to the failed query text to obtain the updated knowledge base includes: Calculate the similarity between the error correction rule corresponding to the failed query text and the at least two error correction rules respectively to obtain at least two similarities; The error correction rule corresponding to the maximum value of the at least two similarities is semantically merged with the error correction rule corresponding to the query failure text to obtain the updated error correction rule; The error correction rule corresponding to the maximum value in the knowledge base is replaced with the updated error correction rule to obtain the updated knowledge base.
14. An error detection device for database query text, the device comprising: The text acquisition module is used to acquire query text for a database, the query text including at least one text fragment, the query text being used to query data in the database; The semantic parsing module is used to perform semantic parsing on the query text to obtain at least one suspicious text fragment in the query text, wherein the suspicious text fragment is a text fragment that is suspected of having semantic errors; The rule extraction module is used to obtain the semantic error correction rules corresponding to the at least one suspicious text fragment, and the semantic error correction rules are used to indicate the correction strategy for semantic errors; The semantic evaluation module is used to obtain the semantic evaluation result of the query text based on the semantic error correction rules corresponding to the query text, the at least one suspicious text fragment, and the at least one suspicious text fragment, respectively. The semantic evaluation result is used to indicate whether there is a semantic error in the query text.
15. A computer device comprising a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the error detection method for database query text as claimed in any one of claims 1 to 13.
16. A computer-readable storage medium storing a computer program, the computer program being loaded and executed by a processor to implement the error detection method for database query text as described in any one of claims 1 to 13.
17. A computer program product comprising a computer program loaded and executed by a processor to implement the error detection method for database query text as described in any one of claims 1 to 13.
