A question and answer correction method based on an sql language, an electronic device, and a storage medium

By splitting user query statements and correcting SQL index conditions, the problem of chaotic response statements in the intelligent question-and-answer system was solved, improving the accuracy of responses and user satisfaction.

CN119271698BActive Publication Date: 2026-04-10MOBILE TECH COMPANY CHINA TRAVELSKY HLDG
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing intelligent question-and-answer systems cannot perform anomaly checks on user-submitted questions, resulting in confusing and inaccurate responses that fail to address user concerns.

Method used

By breaking down user queries into their keywords, converting them into SQL index statements, identifying abnormal index conditions, using a pre-defined list of index identifiers to determine corrective index conditions, integrating non-abnormal index conditions to generate corrective SQL index statements, and finally generating the target response statement.

Benefits of technology

It improved the accuracy and satisfaction of user Q&A, ensuring that the response results matched the user's question intent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271698B_ABST
    Figure CN119271698B_ABST
Patent Text Reader

Abstract

The application provides a question and answer correction method based on an SQL language, an electronic device and a storage medium. The method comprises the following steps: performing SQL language conversion on a user question sentence to obtain an initial SQL index sentence, and determining an initial index result from an information database; if the initial index result indicates that the question and answer index is abnormal, determining an abnormal index condition and a correction index condition corresponding to the abnormal index condition; integrating the correction index condition and the remaining SQL index conditions except the abnormal index condition in a plurality of SQL index conditions to obtain a corrected SQL index sentence; determining a corrected index result from the information database according to the corrected SQL index sentence; and if the corrected index result indicates that the question and answer index is normal, generating a reply sentence to correct a user's incorrect natural language question, so that the obtained reply result is more consistent with the question raised by the user, thereby improving the accuracy of the user's question and answer and the satisfaction of the user.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of sentence question answering, and in particular to a question answering correction method based on an SQL language, an electronic device, and a storage medium. BACKGROUND

[0002] A current user intelligent question answering system analyzes a question raised by a user, finds corresponding information data from a database according to index words obtained through the analysis, and finally generates a reply statement to return to the user. When the semantics of the question raised by the user is insufficient or the question raised by the user is incorrect, the question answering system cannot perform abnormality checking on the question raised by the user because the question answering system only performs direct semantic conversion on the question, so that the analysis of the question raised by the user by the question answering system will be abnormal, which will cause the meaning of the generated reply statement to be confused and the question raised by the user to be unable to be accurately answered. SUMMARY

[0003] In view of the above technical problems, the technical solution adopted by the present application is as follows:

[0004] According to an aspect of the present application, a question answering correction method based on an SQL language is provided, comprising the following steps:

[0005] Step S100, in response to receiving a user question statement, performing splitting processing on the user question statement to obtain a plurality of user question keywords included in the user question statement;

[0006] Step S200, performing SQL language conversion on each user question keyword to obtain an initial SQL index statement corresponding to the user question statement; the initial SQL index statement includes a plurality of SQL index conditions; each SQL index condition corresponds to an index identifier, and the index identifier represents an index type of the corresponding SQL index condition;

[0007] Step S300, determining an initial index result from an information database according to the initial SQL index statement;

[0008] Step S400, if the initial index result represents question answering index abnormality, determining an abnormal index condition from the plurality of SQL index conditions;

[0009] Step S500, determining a correction index condition corresponding to the abnormal index condition from a preset index identifier list according to an index identifier corresponding to the abnormal index condition; the index identifier list stores a mapping relationship between index conditions having similar association relationships among the plurality of index conditions;

[0010] Step S600, integrating the correction index condition and the remaining SQL index conditions except the abnormal index condition from the plurality of SQL index conditions to obtain a corrected SQL index statement;

[0011] Step S700, determining the modified index result from the information database according to the modified sql index statement;

[0012] Step S800, if the modified index result represents that the question and answer index is normal, generating and outputting the target reply statement according to the modified index result and the user query statement.

[0013] In an example embodiment of the present application, step S100 comprises:

[0014] Step S110, performing multi-round rewriting processing on the user query statement to obtain a corresponding target query statement;

[0015] Step S120, performing semantic analysis on the target query statement to obtain a semantic identifier corresponding to each target query word included in the target query statement;

[0016] Step S130, traversing each target query word, and if the semantic identifier corresponding to the target query word is a preset key semantic identifier, determining the target query word as a user query key word.

[0017] In an example embodiment of the present application, step S200 comprises:

[0018] Step S210, determining an index identifier corresponding to each user query key word from a preset semantic identifier mapping table according to the semantic identifier corresponding to each user query key word; the semantic identifier mapping table stores a mapping relationship between a plurality of semantic identifiers and index identifiers corresponding to the semantic identifiers;

[0019] Step S220, performing sql language conversion on the plurality of user query key words to obtain a sql index condition corresponding to each user query key word;

[0020] Step S230, sorting the index identifiers corresponding to the plurality of sql index conditions according to a preset index statement composition rule; the index statement composition rule comprises a composition order of index types in the index statement;

[0021] Step S240, integrating the sql index condition corresponding to each index identifier according to the order of the plurality of index identifiers to obtain an initial sql index statement.

[0022] In an example embodiment of the present application, step S220 comprises:

[0023] Step S221, obtaining a character length of each user query key word to obtain a first character length list B=(B1, B2,..., B g ,...,B h); wherein, g = 1, 2, …, h; h is the number of user query keywords; B g is the character length of the gth user query keyword;

[0024] Step S222, traversing the first character length list B, if B g ≥ B0, the gth user query keyword is determined as the target user query keyword, so as to obtain a plurality of target user query keywords; wherein, B0is a preset character length threshold;

[0025] Step S223, rewriting each target user query keyword according to a preset character abbreviation rule, so as to obtain a rewritten user query keyword corresponding to each target user query keyword; the character length of the rewritten user query keyword is shorter than the character length of the target user query keyword corresponding to the rewritten user query keyword;

[0026] Step S224, obtaining the information entropy of each target user query keyword, so as to obtain a first information entropy list C = (C1, C2, …, C a ,...,C b ); wherein, a = 1, 2, …, b; b is the number of target user query keywords; C a is the information entropy of the ath target user query keyword;

[0027] Step S225, obtaining the information entropy of each rewritten user query keyword, so as to obtain a second information entropy list D = (D1, D2, …, D a ,...,D b ); wherein, D a is the information entropy of the rewritten user query keyword obtained by rewriting the ath target user query keyword;

[0028] Step S226, traversing the first information entropy list C and the second information entropy list D, if |D a -C a |≤ d, the rewritten user query keyword corresponding to the ath target user query keyword is determined as the sql index condition corresponding to the ath target user query keyword; wherein, d is a preset information entropy difference threshold.

[0029] In an exemplary embodiment of the present application, step S222 further comprises:

[0030] Step S2221, if B g <B0, obtaining the information entropy R g of the gth user query keyword;

[0031] Step S2222, if R gIf R0 is greater than or equal to R0, then the keyword of the g-th user's question is determined as the SQL index condition; otherwise, proceed to step S2223; where R0 is the preset information entropy threshold.

[0032] Step S2223: Delete the keywords from the g-th user's question.

[0033] In one exemplary embodiment of this application, step S300 includes:

[0034] Step S310: Obtain the index identifier corresponding to each SQL index condition in the initial SQL index statement, and obtain the index identifier list T = (T1, T2, ..., T...). m ,...,T q ); where m = 1, 2, ..., q; q is the number of SQL index conditions; T m This is the index identifier corresponding to the m-th SQL index condition in the initial SQL index statement;

[0035] Step S320: Traverse the index identifier list T, and use T... m The corresponding index type is used to determine several response data with the same data type as the index type from the information database;

[0036] Step S330, according to T m For each response data point, based on the corresponding SQL index condition, if a response data point exists that corresponds to the SQL index condition, then that response data is identified as the index data corresponding to the m-th SQL index condition, and step S340 is executed; otherwise, a question-and-answer exception flag is generated, and T is set to... m The question-and-answer anomaly identifier was used as the initial index result;

[0037] Step S340: Based on several SQL index conditions in the initial SQL index statement, integrate several index data to obtain the integration result;

[0038] Step S350: If an anomaly occurs in the integration result, a question-and-answer anomaly identifier is generated, and the several index data that have anomaly and the question-and-answer anomaly identifier corresponding to the integration result are determined as the initial index result; otherwise, the integration result is determined as the initial index result.

[0039] In one exemplary embodiment of this application, step S400 includes:

[0040] Step S411: If the initial indexing result includes a question-and-answer anomaly identifier, determine whether the initial indexing result includes index data. If the initial indexing result includes index data, proceed to step S412; otherwise, proceed to step S413.

[0041] Step S412, determine the sql index conditions corresponding to the several index data included in the initial index result as abnormal index conditions.

[0042] Step S413, determine the sql index conditions in the several sql index conditions that do not have a corresponding relationship with any response data as abnormal index conditions.

[0043] In an exemplary embodiment of the present application, step S800 further comprises:

[0044] Step S810, if the revised index result represents the question and answer index abnormality, delete the revised index condition and the abnormal index condition, and integrate the remaining sql index conditions to obtain a target sql index statement;

[0045] Step S820, determine a target index result from the information database according to the target sql index statement;

[0046] Step S830, generate a target reply statement according to the target index result and the user question statement;

[0047] Step S840, perform natural language conversion on the abnormal index condition to obtain an abnormal index statement;

[0048] Step S850, output the target reply statement and the abnormal index statement.

[0049] According to an aspect of the present application, a non-transitory computer readable storage medium is provided, the storage medium stores at least one instruction or at least one program, the at least one instruction or the at least one program is loaded and executed by a processor to implement the foregoing sql language-based question and answer revision method.

[0050] According to an aspect of the present application, an electronic device is provided, comprising a processor and the foregoing non-transitory computer readable storage medium.

[0051] The present application has at least the following beneficial effects:

[0052] The sql language-based question and answer correction method provided by the present application comprises the following steps: BRIEF DESCRIPTION OF DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and all other drawings obtained by those skilled in the art without creative effort are within the scope of the present application.

[0054] Figure 1 The flowchart of the sql language-based question and answer correction method provided by the present application. DETAILED DESCRIPTION

[0055] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of the present application.

[0056] As shown in the drawings, Figure 1 The sql language-based question and answer correction method provided by the present application comprises the following steps:

[0057] Step S100, in response to receiving the user query sentence, splitting the user query sentence to obtain several user query keywords included in the user query sentence;

[0058] The user query sentence is a sentence written in natural language by the user. Since the data stored in the information database is in computer language, if an index is to be created in the information database, the natural language needs to be converted. At present, the data stored in most information databases is written and stored through sql language. Therefore, the user query sentence in natural language needs to be converted into a sql language sentence. Before language conversion, the user query sentence needs to be split to obtain several user query keywords included in the user query sentence. The user query keywords are keywords in the user query sentence that can represent semantic information.

[0059] Further, step S100 includes steps S110-S130:

[0060] Step S110, performing multi-round rewriting processing on the user query sentence to obtain a corresponding target query sentence;

[0061] The multi-round rewriting can be performed by using an existing processing method. The multi-round rewriting is used to supplement the semantics of the user query sentence. If the user query sentence is too simple, such as lacking a subject, if the user query sentence is directly converted into a sql language, the obtained sql sentence will also lack the corresponding keywords, which will cause subsequent indexing to be abnormal. Therefore, the user query sentence is first rewritten in multiple rounds, the semantics of the user query sentence is supplemented by associating the upper and lower sentences of the user query, and then the sql language conversion is performed, which can improve the accuracy of the user's reply.

[0062] Step S120, performing semantic analysis on the target query sentence to obtain a semantic identifier corresponding to each target query word included in the target query sentence;

[0063] After obtaining the target query sentence, the semantic analysis is performed on the target query sentence, that is, the key words in the target query sentence are split to obtain the target query words included in the target query sentence. The semantic analysis and the key word splitting can be performed by using an existing analysis method. The target query words correspond to semantic identifiers. The semantic identifiers represent the semantic types of the corresponding target query words, such as whether the target query word is a subject, a predicate, or an object of the target query sentence. Through the semantic identifier, it can be determined whether the target query word plays a key role in information indexing.

[0064] Step S130, traversing each target query word, if the semantic identifier corresponding to the target query word is a preset key semantic identifier, the target query word is determined as a user query keyword.

[0065] The preset key semantic identifier is a semantic identifier of a semantic type that is indispensable in information indexing. The key semantic identifier can be obtained by keyword splitting statistics on a plurality of historical natural languages.

[0066] In step S200, the key words of each user query are converted into an initial SQL index statement corresponding to the user query statement through SQL language conversion; the initial SQL index statement includes a plurality of SQL index conditions.

[0067] Each SQL index condition corresponds to an index identifier, which represents the index type of the corresponding SQL index condition.

[0068] The initial SQL index statement is parsed to obtain a plurality of SQL index conditions, which are condition statements for information indexing in the information database. Through the SQL index conditions, the type and location of the information data to be found in the information database can be known.

[0069] Further, step S200 includes steps S210-S240:

[0070] In step S210, the index identifier corresponding to each user query keyword is determined from the preset semantic identifier mapping table according to the semantic identifier corresponding to each user query keyword.

[0071] The semantic identifier mapping table stores a mapping relationship between a plurality of semantic identifiers and the index identifiers corresponding to the semantic identifiers. By checking the semantic identifier mapping table, the mapping relationship between the semantic identifiers and the index identifiers can be known.

[0072] For example, the target query statement is "What is the departure time of my flight tomorrow?", and after semantic analysis of the target query statement, one of the target query words obtained is "flight". The semantic identifier corresponding to the target query word represents a predicate, and the index identifier corresponding to the target query word represents a flight information type.

[0073] In step S220, the SQL index conditions corresponding to each user query keyword are obtained through SQL language conversion of the plurality of user query keywords.

[0074] The SQL index condition is a condition statement with an SQL index function obtained through SQL language conversion of the user query keyword.

[0075] In step S220, steps S221-S226 are included:

[0076] In step S221, the character length of each user query keyword is obtained to obtain a first character length list B=(B1, B2,..., Bn). g..., B h ); wherein, g = 1, 2,..., h; h is the number of user query keywords; B g is the character length of the gth user query keyword;

[0077] Step S222, traverse the first character length list B, if B g ≥ B0, determine the gth user query keyword as the target user query keyword, to obtain a plurality of target user query keywords, and execute step S223; otherwise, execute step S2221-Step S2223; wherein, B0is a preset character length threshold;

[0078] Step S2221, if B g < B0, obtain the information entropy R g of the gth user query keyword;

[0079] Step S2222, if R g ≥ R0, determine the gth user query keyword as the sql index condition; otherwise, execute step S2223; wherein, R0is a preset information entropy threshold;

[0080] Step S2223, delete the gth user query keyword.

[0081] The information entropy of the user query keyword represents how much information is contained in the user query keyword, the greater the information entropy, the more information is contained in the corresponding user query keyword, that is, the user query keyword is more important when performing information indexing.

[0082] The character length of the index condition is in a positive proportional relationship with the index time and the computing power occupied by the index, when performing information indexing, the longer the character length of the index condition, the greater the computing power occupied by the index, and the longer the index time, therefore, the character length of the index condition becomes a key factor for reducing the index time.

[0083] If the character length of the user query keyword is less than the character length threshold, and the information entropy of the user query keyword is also less than the information entropy threshold, it indicates that the information amount contained in the user query keyword is too small, and the influence on the understanding of the entire statement is not great, therefore, in order to reduce the data processing amount, the user query keyword is selected to be deleted, and the sql language conversion is not performed.

[0084] Step S223, rewrite each target user query keyword according to a preset character abbreviation rule, to obtain a rewritten user query keyword corresponding to each target user query keyword;

[0085] The character length of the rewritten user question keyword is shorter than the character length of the target user question keyword. If the character length of the user question keyword is too long, it means that the indexing time of the user question keyword is still too long. Therefore, in order to reduce the processing volume of information indexing, it is necessary to rewrite the user question keyword and shorten its character length.

[0086] Step S224: Obtain the information entropy of the keywords asked by each target user, and obtain the first information entropy list C = (C1, C2, ..., C...). a ,...,C b ); where a = 1, 2, ..., b; b is the number of keywords asked by the target user; C a Information entropy of the keywords asked to the a-th target user;

[0087] Step S225: Obtain the information entropy of each modified user query keyword to obtain the second information entropy list D = (D1, D2, ..., D...). a ,...,D b ); where D a This refers to the information entropy of the rewritten user query keywords obtained after rewriting the query keywords of the a-th target user.

[0088] Step S226: Traverse the first information entropy list C and the second information entropy list D. If |D a -C a If |≤d, then the rewritten user question keyword corresponding to the question keyword of the a-th target user will be determined as the SQL index condition corresponding to the question keyword of the a-th target user; where d is the preset information entropy difference threshold.

[0089] After rewriting the keywords in the user's question, it is also necessary to confirm whether the information entropy before and after the rewriting has changed. If the difference in information entropy before and after the rewriting is less than or equal to the information entropy difference threshold, it means that the amount of information has not been lost too much. Therefore, it is determined as an SQL index condition.

[0090] Step S230: Sort the index identifiers corresponding to several SQL index conditions according to the preset index statement composition rules;

[0091] The rules for composing index statements include the order in which the index types are composed in the index statement. These rules can be specific rules determined manually, such as the order of index types being "query time", "flight", and "departure time".

[0092] Step S240: Based on the order of several index identifiers, integrate the SQL index conditions corresponding to each index identifier to obtain the initial SQL index statement.

[0093] The initial SQL index statement is obtained by integrating the several SQL index conditions. Since the data information to be searched by each SQL index condition is different, for example, the SQL index conditions are "flight", "tomorrow", and "departure time", the user's intention cannot be known by looking at a single SQL index condition. Therefore, all the SQL index conditions are integrated to obtain the initial SQL index statement "flight departure time tomorrow" (the statement should be written in SQL language, and natural language is used for easy understanding). The user's intention can be known by the initial SQL index statement.

[0094] The integration method of the SQL index conditions adopts the existing SQL language writing rules.

[0095] Step S300, determining the initial index result from the information database according to the initial SQL index statement;

[0096] The initial index result is the result obtained by indexing the information database by the initial SQL index statement.

[0097] Further, step S300 includes steps S310-S350:

[0098] Step S310, obtaining the index identifier corresponding to each SQL index condition in the initial SQL index statement to obtain the index identifier list T = (T1, T2,..., Tq); where m = 1, 2,..., q; q is the number of SQL index conditions; Tm is the index identifier corresponding to the mth SQL index condition in the initial SQL index statement; m q m

[0099] Step S320, traversing the index identifier list T, and determining several response data of the same data type as the index type corresponding to Tm from the information database; m

[0100] The information data in the information database is stored with the identifier of the corresponding data type to indicate the data type to which the information data belongs. Therefore, when the information data in the information database needs to be traversed, the several information data of the same data type as the index type corresponding to each SQL index condition can be found in the information database directly without traversing each information data in the information database. Therefore, the index processing amount of the information data is reduced, and the index time is shortened.

[0101] Step S330, determining the initial index result from the information database according to the initial SQL index statement; m ​​​​corresponding to the sql index condition, and executing step S340; otherwise, generating a question and answer exception identifier, and determining the T m and the question and answer exception identifier as the initial index result;

[0102] After finding the response data of the same index type as the sql index condition, the index data corresponding to the sql index condition is found from the several response data according to the specific information of the sql index condition. For example, if the index type of the sql index condition is "flight", the data type of all the found response data is "flight" type, and there is a flight of all airlines in the batch of response data. If the sql index condition is "flight of airline A", the response data of "airline A" is found from the response data of all data types "flight", and is determined as the index data.

[0103] If the response data of "airline A" is not found from the response data of all data types "flight", it means that there may be no airline A, that is, airline A may be an error information input by the user, and a question and answer exception identifier is generated, and the index identifier corresponding to the sql index condition and the question and answer exception identifier are determined as the initial index result.

[0104] By verifying the initial index result, it can be checked whether the question raised by the user is wrong. If it is wrong, the question is corrected instead of directly returning an abnormal error information to the user, so as to achieve the purpose of meeting the user's demand to the greatest extent.

[0105] Step S340, integrating the several index data according to the several sql index conditions in the initial sql index statement to obtain an integrated result;

[0106] After obtaining the index data corresponding to each sql index condition, it is integrated to combine the several index data with each other to achieve the purpose of screening. For example, the sql index conditions are "airline A", "tomorrow" and "departure time", but there is no flight information of airline A tomorrow in the integrated result of all the index data, so the integrated result is abnormal and needs to be corrected.

[0107] Step S350, if the integrated result is abnormal, generating a question and answer exception identifier, and determining the several index data corresponding to the integrated result and the question and answer exception identifier as the initial index result; otherwise, determining the integrated result as the initial index result.

[0108] Step S400, if the initial index result represents an abnormal question and answer index, determine the abnormal index condition from the plurality of sql index conditions;

[0109] The abnormal index condition is an sql index condition that has an abnormality or an input error.

[0110] Further, step S400 includes steps S411-S413:

[0111] Step S411, if the initial index result includes an abnormal question and answer identification, determine whether the initial index result includes index data, if the initial index result includes index data, execute step S412; otherwise, execute step S413.

[0112] If the initial index result does not include the abnormal question and answer identification, input the initial index result and the user's question statement into the preset general language model to obtain a target reply statement and output.

[0113] Step S412, determine the sql index condition corresponding to the plurality of index data included in the initial index result as the abnormal index condition.

[0114] Step S413, determine the sql index condition that does not have a corresponding relationship with any response data from the plurality of sql index conditions as the abnormal index condition.

[0115] Step S500, according to the index identification corresponding to the abnormal index condition, determine the correction index condition corresponding to the abnormal index condition from the preset index identification list;

[0116] The index identification list stores a mapping relationship between index conditions having similar association relationships with a plurality of index conditions.

[0117] The correction index condition is an index condition having a similar association relationship with the corresponding abnormal index condition, which is obtained by a developer according to historical index conditions. The developer counts the index conditions that have occurred index errors in a historical period and corrects them to make the index normal. The index condition obtained after correction is the correction index condition. The correction index condition and the index condition before correction are both stored in the index identification list.

[0118] Step S600, integrate the remaining sql index conditions except the abnormal index condition from the plurality of sql index conditions with the correction index condition to obtain a corrected sql index statement.

[0119] Since the abnormal index condition is a keyword with an error, the other sql index conditions except the abnormal index condition are integrated with the corrected index condition to obtain a corrected sql index statement, and the corrected sql index statement is verified again.

[0120] Step S700, determining a corrected index result from the information database according to the corrected sql index statement;

[0121] Step S800, if the corrected index result indicates that the question and answer index is normal, generating and outputting a target reply statement according to the corrected index result and the user question statement; otherwise, performing steps S810-S850.

[0122] If the corrected index result indicates that the question and answer index is normal, it means that the abnormal index condition is indeed an index condition that may cause an index error, and it is deleted.

[0123] The target reply statement is a natural language target reply statement obtained by processing the corrected index result and the user question statement through a preset general language model.

[0124] The general language model can be an existing language model (general language model), which is used to generate a natural language target reply statement from the user question statement and the corrected index result of the sql language, and return the target reply statement to the user for viewing.

[0125] Step S810, if the corrected index result indicates that the question and answer index is abnormal, deleting the corrected index condition and the abnormal index condition, and integrating the remaining sql index conditions to obtain a target sql index statement;

[0126] Step S820, determining a target index result from the information database according to the target sql index statement;

[0127] Step S830, generating a target reply statement according to the target index result and the user question statement;

[0128] Step S840, converting the abnormal index condition into a natural language to obtain an abnormal index statement;

[0129] Step S850, outputting the target reply statement and the abnormal index statement.

[0130] If the modified index result still represents the question and answer index exception, it means that the modified index condition may also have an index error, so it is deleted, and the remaining sql index condition is integrated again to obtain the target sql index statement. In order to shorten the data processing time, the obtained target index result is no longer verified, and the abnormal index statement obtained according to the abnormal index condition is also output to prompt the user to check the user query statement and verify the correctness of the target reply statement.

[0131] The sql language-based question and answer modification method of the application splits the user query statement to obtain a plurality of user query keywords, converts each user query keyword into an sql language to obtain an initial sql index statement, and determines an initial index result from an information database according to the initial sql index statement. If the initial index result represents a question and answer index exception, it means that the initial sql index statement needs to be modified, the abnormal index condition is determined from a plurality of sql index conditions, and the modified index condition corresponding to the abnormal index condition is determined. The modified index condition is the sql index condition that needs to be modified due to the index exception. The remaining sql index conditions except the abnormal index condition in the plurality of sql index conditions are integrated with the modified index condition to obtain a modified sql index statement. Finally, the modified index result is determined according to the modified sql index statement, and the target reply statement is generated if the modified index result represents a normal question and answer index. By verifying the sql index condition corresponding to the user query statement, the abnormal index condition that may have an abnormal index result is determined, the modified index condition is determined according to the abnormal index condition, and the modified sql index statement composed of the modified index condition and the non-abnormal index condition is verified again. If the verification is normal, it means that the modified sql index statement is a normal index statement, which can modify the incorrect natural language question proposed by the user, so that the reply result obtained is more consistent with the question proposed by the user, thereby improving the accuracy of the user question and answer and the satisfaction of the user.

[0132] Embodiments of the application also provide a computer program product comprising program code for causing an electronic device to perform the steps of the methods according to the various exemplary embodiments of the application described above when the program product is run on the electronic device.

[0133] In addition, although the various steps of the methods in the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired result. Additionally or alternatively, certain steps can be omitted, a plurality of steps can be combined into one step, and / or one step can be divided into a plurality of steps, etc.

[0134] Those skilled in the art can clearly understand that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash disk, a mobile hard disk, etc.) or a network, and includes a number of instructions to make a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) execute the methods according to the embodiments of the present disclosure.

[0135] In the example embodiments of the present disclosure, an electronic device capable of implementing the above method is also provided.

[0136] Those skilled in the art can understand that each aspect of the present disclosure can be implemented as a system, a method or a program product. Therefore, each aspect of the present disclosure can be embodied in the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.), or an embodiment combining software and hardware aspects, which can be generally referred to as a "circuit", a "module" or a "system".

[0137] The electronic device according to this embodiment of the present disclosure. The electronic device is merely an example, and should not bring any limitation to the functions and use range of the embodiments of the present disclosure.

[0138] The electronic device is in the form of a general computing device. The components of the electronic device can include, but are not limited to, the above-mentioned at least one processor, the above-mentioned at least one storage, a bus connecting different system components (including storage and processor).

[0139] The storage stores program codes which can be executed by the processor, so that the processor executes the steps according to various example embodiments of the present disclosure described in the above "example method" section of the present specification.

[0140] The storage can include a readable medium in the form of a volatile storage, such as a random access memory (RAM) and / or a cache storage, and can further include a read-only memory (ROM).

[0141] The storage can further include programs / utilities with a set of (at least one) program modules, such as an operating system, one or more application programs, other program modules, and program data, each of which or some combination of which can include the implementation of a network environment.

[0142] The bus can be one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, a graphics bus, a processor or local bus using any of a variety of bus architectures.

[0143] The electronic device can also communicate with one or more external devices such as a keyboard or a pointing device, a Bluetooth device, etc.; other devices that enable a user to interact with the electronic device; and / or one or more devices that enable the electronic device to communicate with one or more other computing devices. Such communication can occur via an input / output (I / O) interface. Still yet, the electronic device can communicate with one or more networks such as a local area network (LAN), a general wide area network (WAN), and / or a public network (e.g., the Internet) via the network adapter.

[0144] Those skilled in the art will readily understand that the example embodiments described herein can be implemented by software and / or by hardware combined with software essential for the embodiments. Thus, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (e.g., a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or a network, and includes a number of instructions for causing a computing device (e.g., a personal computer, a server, a terminal device, or a network device, etc.) to perform the methods according to the embodiments of the present disclosure.

[0145] In the example embodiments of the present disclosure, a computer readable storage medium is also provided, which stores a program product capable of implementing the above-mentioned method of the present disclosure. In some possible embodiments, various aspects of the present disclosure can also be implemented in the form of a program product, which includes program codes for causing a terminal device to perform the steps according to various example embodiments of the present disclosure described in the above-mentioned “example method” section of the present disclosure when the program product is run on the terminal device.

[0146] The program product can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0147] A computer readable signal medium can include a propagated data signal with computer executable program code embodied therein. The propagated data signal can take any of a variety of forms, including but not limited to radio frequency signals, light signals, infrared signals, and any suitable combination thereof. The computer readable signal medium can be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate or transport program code.

[0148] Program code embodied on a computer readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0149] Computer program code for carrying out operations for aspects of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, such as through the Internet using an Internet Service Provider. The application program code can be downloaded to the user's computing device from an external computing device or server through any type of network, including a local area network, a wide area network, or the Internet using a browser or other applet -executing software. Alternatively, the program code can be downloaded to the user's computing device from the external computing device or server as a stand-alone software package, a portion of a

[0150] Furthermore, the above-described diagrams merely illustrate a schematic of the processes included in the method according to the exemplary embodiments of the present application, and are not intended for a limiting purpose. It is readily understood that the processes shown in the above-described diagrams do not indicate or limit the time sequence of the processes. In addition, it is readily understood that the processes can be executed synchronously or asynchronously, for example, in a plurality of modules.

[0151] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, such a division is not mandatory. Indeed, according to embodiments of the present disclosure, the features and functionalities of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functionalities of one module or unit described above can be further divided into embodied by a plurality of modules or units.

[0152] The above merely illustrates the specific embodiments of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of the changes or replacements within the technical range disclosed by the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for correcting a question and answer based on an SQL language, characterized by, The method comprises the following steps: Step S100, in response to receiving a user query sentence, performing splitting processing on the user query sentence to obtain a plurality of user query keywords included in the user query sentence; Step S200, performing sql language conversion on each of the user query keywords to obtain an initial sql index sentence corresponding to the user query sentence; the initial sql index sentence comprises a plurality of sql index conditions; each of the sql index conditions corresponds to an index identifier, and the index identifier represents an index type of the corresponding sql index condition; Step S300, determining an initial index result from an information database according to the initial sql index sentence; Step S400, if the initial index result represents a question and answer index exception, determining an abnormal index condition from the plurality of sql index conditions; Step S500, according to the index identifier corresponding to the abnormal index condition, determining a modified index condition corresponding to the abnormal index condition from a preset index identifier list; The index identifier list stores a mapping relationship between index conditions having similar association relationships; Step S600, integrating the remaining sql index conditions except the abnormal index condition in the plurality of sql index conditions with the modified index condition to obtain a modified sql index sentence; Step S700, determining a modified index result from the information database according to the modified sql index sentence; Step S800, if the modified index result represents a normal question and answer index, generating a target reply sentence according to the modified index result and the user query sentence and outputting the target reply sentence.

2. The method of claim 1, wherein, The step S100 comprises: Step S110, performing multi-round rewriting processing on the user query sentence to obtain a corresponding target query sentence; Step S120, performing semantic analysis on the target query sentence to obtain a semantic identifier corresponding to each target query word included in the target query sentence; Step S130, traversing each of the target query words, if the semantic identifier corresponding to the target query word is a preset key semantic identifier, determining the target query word as a user query keyword.

3. The method of claim 2, wherein, The step S200 comprises: Step S210, according to the semantic identifier corresponding to each of the user query keywords, determining an index identifier corresponding to each of the user query keywords from a preset semantic identifier mapping table; the semantic identifier mapping table stores a mapping relationship between a plurality of semantic identifiers and index identifiers corresponding to the semantic identifiers; Step S220, performing sql language conversion on the plurality of user query keywords to obtain a sql index condition corresponding to each of the user query keywords; Step S230, according to a preset index sentence composition rule, sorting the index identifiers corresponding to the plurality of sql index conditions; the index sentence composition rule comprises a composition order of index types in an index sentence; Step S240, according to the order of the plurality of index identifiers, integrating the sql index condition corresponding to each index identifier to obtain an initial sql index sentence.

4. The method of claim 3, wherein, The step S220 comprises: Step S221: Obtain the character length of each of the user-asked keywords, and obtain the first character length list B = (B1, B2, ..., B...). g ,...,B h ); where g = 1, 2, ..., h; h is the number of keywords in the user's question; B g The length of the g-th user-asked keyword; Step S222, traversing the first character length list B, if B g ≥B0, the gth user question keyword is determined as the target user question keyword, to obtain a plurality of target user question keywords; wherein, B0 is a preset character length threshold. The step S223 comprises: rewriting each of the target user query keywords according to a preset character abbreviation rule to obtain a rewritten user query keyword corresponding to each of the target user query keywords; the rewritten user query keyword has a character length shorter than that of the target user query keyword corresponding to the rewritten user query keyword; Step S224: Obtain the information entropy of each keyword asked by the target user, and obtain the first information entropy list C = (C1, C2, ..., C...). a ,...,C b ); where a = 1, 2, ..., b; b is the number of keywords asked by the target user; C a The information entropy of the keywords asked to the a-th target user; Step S225: Obtain the information entropy of each of the rewritten user query keywords to obtain the second information entropy list D = (D1, D2, ..., D...). a ,...,D b ); where D a The information entropy of the rewritten user question keyword is obtained by rewriting the target user question keyword of the a-th term. Step S226, traversing the first information entropy list C and the second information entropy list D, if |D a -C a |≤d, determining the rewritten user query keyword corresponding to the a-th target user query keyword as the sql index condition corresponding to the a-th target user query keyword; wherein d is a preset information entropy difference threshold.

5. The method of claim 4, wherein, The step S222 further comprises: Step S2221, if B g If B0, obtain the information entropy R of the gth user question keyword g ; Step S2222, if R g ≥ R0, the gth user question keyword is determined as the SQL index condition; otherwise, step S2223 is performed; wherein R0 is a preset information entropy threshold. The step S2223 comprises: deleting the gth user query keyword.

6. The method of claim 5, wherein, The step S300 comprises: Step S310, obtaining the index identifier corresponding to each of the sql index conditions in the initial sql index statement, to obtain an index identifier list T=(T1, T2,..., T m ,...,T q ); wherein m=1, 2,..., q; q is the number of sql index conditions; T m is the index identifier corresponding to the mth sql index condition in the initial sql index statement. Step S320, traversing the index identification list T, and determining the response data of the same type as the index type through T m According to the index type, the information database determines a plurality of response data of the same type as the index type. Step S330, according to T m corresponding sql index condition, traversing each of the response data, if there is a response data corresponding to the sql index condition, the response data is determined as the index data corresponding to the mth sql index condition, and step S340 is executed; otherwise, a question and answer exception identifier is generated, and T m and the question and answer exception identifier are determined as the initial index result; The step S340 comprises: integrating a plurality of the index data according to a plurality of the sql index conditions in the initial sql index statement to obtain an integration result; The step S350 comprises: if the integration result is abnormal, generating a question and answer abnormality identifier, and determining a plurality of the index data corresponding to the integration result and the question and answer abnormality identifier as the initial index result; otherwise, determining the integration result as the initial index result.

7. The method of claim 6, wherein, The step S400 comprises: The step S411 comprises: if the initial index result includes the question and answer abnormality identifier, determining whether the initial index result includes index data; if the initial index result includes index data, executing the step S412; otherwise, executing the step S413; The step S412 comprises: determining a plurality of the sql index conditions corresponding to a plurality of the index data included in the initial index result as abnormal index conditions; The step S413 comprises: determining a sql index condition that does not have a corresponding relationship with any of the response data from a plurality of the sql index conditions as an abnormal index condition.

8. The method of claim 7, wherein, The step S800 further comprises: The step S810 comprises: if the modified index result represents a question and answer index abnormality, deleting the modified index condition and the abnormal index condition, and integrating the remaining sql index conditions to obtain a target sql index statement; The step S820 comprises: determining a target index result from an information database according to the target sql index statement; The step S830 comprises: generating a target reply statement according to the target index result and the user query statement; The step S840 comprises: performing natural language conversion on the abnormal index condition to obtain an abnormal index statement; The step S850 comprises: outputting the target reply statement and the abnormal index statement. 9.A non-transitory computer-readable storage medium having stored therein at least one instruction or at least one piece of program, characterized in that, The at least one instruction or the at least one program is loaded and executed by the processor to implement the sql language-based question and answer modification method according to any one of claims 1-8.

10. An electronic device, comprising: The processor and the non-transitory computer readable storage medium of claim 9. The processor and the non-transitory computer readable storage medium of claim 9.

Citation Information

Patent Citations

  • SQL query-oriented refined scoring method

    CN112132420A

  • Language conversion method and device, electronic equipment and storage medium

    CN114722069A