CN109408526B - SQL sentence generation method, device, computer equipment and storage medium - Google Patents

SQL sentence generation method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN109408526B
CN109408526B CN201811187964.6A CN201811187964A CN109408526B CN 109408526 B CN109408526 B CN 109408526B CN 201811187964 A CN201811187964 A CN 201811187964A CN 109408526 B CN109408526 B CN 109408526B
Authority
CN
China
Prior art keywords
sql
information
sentences
sentence
keywords
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811187964.6A
Other languages
Chinese (zh)
Other versions
CN109408526A (en
Inventor
鲁宁
蔡宁
程诚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811187964.6A priority Critical patent/CN109408526B/en
Publication of CN109408526A publication Critical patent/CN109408526A/en
Application granted granted Critical
Publication of CN109408526B publication Critical patent/CN109408526B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application relates to data processing, in particular to a method and a device for generating SQL sentences, computer equipment and a storage medium, wherein the method comprises the following steps of: acquiring dialogue information with a user, wherein the dialogue information is text information for data query; processing the dialogue information according to a natural language processing technology to obtain user speaking information; according to a pre-trained SQL sentence model, inquiring the SQL sentence corresponding to the user speaking information from the SQL sentence in a preset database; and accessing a corresponding database according to the SQL statement to complete data query. The method can help the salesmen to automatically generate SQL sentences and complete related data inquiry, thereby meeting the demands of the salesmen and reducing the workload of developers.

Description

SQL sentence generation method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a method and apparatus for generating an SQL statement, a computer device, and a storage medium.
Background
At present, in the technical field of the internet, as business scenes become variable, required data support is also random. The traditional mode is to meet the service requirement through data acquisition, but the data acquisition flow is generally complex, so that the data acquisition time delay is caused. For example, the data requirement of supporting the service through the data acquisition mode needs to go through the process examination and approval, the requirement communication between the developer and the service personnel, the repeated development of the developer and submitting SQL (Chinese: structured query language, english: structured Query Language) sentences, etc., finally, the extracted data is handed over to the service personnel, the service personnel performs verification, and if the verification does not pass, the process is repeated. The whole process is complex and trivial, so that the timeliness of data support is low, the user experience is poor, and the development pressure is high.
Disclosure of Invention
The application provides a method, a device, computer equipment and a storage medium for generating SQL sentences, which are used for helping business personnel to automatically generate the SQL sentences and query a database according to the generated SQL sentences.
The application provides a SQL sentence generation method, which comprises the following steps:
acquiring dialogue information with a user, wherein the dialogue information is text information for data query;
processing the dialogue information according to a natural language processing technology to obtain user speaking information;
according to a pre-trained SQL sentence model, inquiring the SQL sentence corresponding to the user speaking information from the SQL sentence in a preset database;
and accessing a corresponding database according to the SQL statement to complete data query.
The application provides an SQL sentence generating device, which comprises:
the information acquisition unit is used for acquiring dialogue information with a user, wherein the dialogue information is text information for data query;
the information processing unit is used for processing the dialogue information according to a natural language processing technology so as to obtain user speaking information;
the sentence query unit is used for querying the SQL sentences corresponding to the user speaking information from the SQL sentences in the preset database according to a pre-trained SQL sentence model;
and the data access unit is used for accessing the corresponding database according to the SQL statement to complete data query.
The application also provides a computer device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the steps of any one of the SQL sentence generating methods provided by the application when executing the program.
The present application also provides a computer storage medium, where the computer storage medium stores a computer program, where the computer program when executed by a processor causes the processor to execute the steps of the SQL statement generation method according to any embodiment of the present application.
The embodiment of the application provides a SQL sentence generation method, a device, computer equipment and a storage medium, wherein dialogue information with a user is acquired, and the dialogue information is text information for data query; processing the dialogue information according to a natural language processing technology to obtain user speaking information; according to a pre-trained SQL sentence model, inquiring the SQL sentence corresponding to the user speaking information from the SQL sentence in a preset database; and accessing a corresponding database according to the SQL statement to complete data query. The method can help the salesmen to automatically generate SQL sentences and complete related data inquiry, thereby meeting the demands of the salesmen and reducing the workload of developers.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a method for generating SQL statements according to an embodiment of the application;
FIG. 2 is a schematic flow chart of the steps for training an SQL statement model provided by an embodiment of the application;
FIG. 3 is a schematic flow chart of sub-steps of the step of training the SQL statement model in FIG. 2;
FIG. 4 is a schematic flow chart of a method for generating SQL statements according to another embodiment of the application;
FIG. 5 is a schematic flow chart of sub-steps of the SQL statement generation method of FIG. 4;
FIG. 6 is a schematic block diagram of an SQL statement generating device according to an embodiment of the application;
FIG. 7 is a schematic block diagram of an SQL statement generating device according to another embodiment of the application;
fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
The embodiment of the application provides a SQL sentence generation method, a device, computer equipment and a storage medium.
Referring to fig. 1, fig. 1 is a schematic flowchart of an SQL statement generation method according to an embodiment of the application. The SQL sentence generating method is applied to a terminal, wherein the terminal is an intelligent robot, and the terminal can be an electronic device such as a smart phone, a tablet personal computer, a notebook computer, a desktop computer, a personal digital assistant, a wearable device and the like. The SQL statement generating method is used for helping a salesman to complete automatic generation of the SQL statement and data query. As shown in fig. 1, the method for generating the SQL statement includes steps S101 to S104.
S101, dialogue information with a user is acquired, wherein the dialogue information is text information for data query.
The user refers to a service staff, and the service staff is not a developer because the service requirement needs to query a corresponding database to acquire related data, so that the development of SQL sentences is not understood, the related SQL sentences can be written with the assistance of the developer in general, and the workload of the developer is increased.
In this embodiment, the salesman can automatically generate related SQL sentences and complete the data query of the corresponding database only by performing related dialogue with the intelligent robot.
For example, the salesman wants to know the last half year of loan of the company (xx bank), which can say to the intelligent robot "I want to know the sum of loans of the last half year of xx bank 208". The intelligent robot converts the voice information into text information, and the text information 'i want to know the sum of loans of xx banks in the first half of 2018' is the dialogue information between the user and the intelligent robot.
The intelligent robot is preconfigured with an SQL sentence model, and the SQL sentence model is used for helping a salesman to search or generate SQL sentences required by the salesman and complete related data query.
S102, processing the dialogue information according to a natural language processing technology to obtain user speaking information.
The processing the dialogue information according to the natural language processing technology to obtain user dialogue information comprises the following steps: and performing word segmentation on the dialogue information according to a natural language processing technology, and extracting the word segmentation keyword as the user word segmentation information.
Specifically, the dialogue information is processed by using a natural language processing technology (Natural Language Processing, abbreviated as NLP technology), specifically, word segmentation processing is performed to extract keywords in the dialogue information, and the keywords are user speaking information.
For example, keyword extraction is performed on dialogue information "i want to know the sum of loans in the first half of 2018 of xx bank", and keywords such as "xx bank", "first half of 2018" and "sum of loans" can be extracted as user dialogue information.
S103, according to a pre-trained SQL sentence model, inquiring the SQL sentence corresponding to the user speaking information from the SQL sentence in a preset database.
The preset database stores a large number of SQL sentences developed by developers before, and the SQL sentences are used for querying data in the related database. The pre-trained SQL statement model is stored in the intelligent robot to help the salesman search for the SQL statement he needs and complete the relevant data query.
Specifically, keywords in the user speaking information can be used as input of an SQL sentence model, and SQL sentences including the most keywords can be queried from SQL sentences in a preset database according to the SQL sentence model, wherein the SQL sentences are the SQL sentences corresponding to the user speaking information.
S104, accessing a corresponding database according to the SQL statement to complete data query.
Specifically, the SQL statement which is queried is executed to access a corresponding database for data query so as to acquire related data, and the extracted data is pushed to a salesman. Thus meeting the demands of the operators and reducing the workload of the developers.
For example, the relevant data is displayed by the intelligent robot or sent to the mailbox of the business personnel.
In the embodiment, the method obtains dialogue information with a user, wherein the dialogue information is text information for data query; processing the dialogue information according to a natural language processing technology to obtain user speaking information; according to a pre-trained SQL sentence model, inquiring the SQL sentence corresponding to the user speaking information from the SQL sentence in a preset database; and accessing a corresponding database according to the SQL statement to complete data query. The method can help the salesmen to automatically generate SQL sentences and complete related data inquiry, thereby meeting the demands of the salesmen and reducing the workload of developers.
In one embodiment, before the implementation of the above method for generating an SQL statement, the method further includes a step of training an SQL statement model, as shown in fig. 2, and the step specifically includes steps S201 to S203.
S201, collecting a Chinese description corresponding to an SQL sentence as a training sample.
In order to improve the accuracy of the SQL statement model, as shown in FIG. 3, step S201 includes substeps S201a to S201c.
S201a, selecting databases corresponding to different service types as sample databases; s201b, reading a table structure and Chinese description of a data table of the sample database, generating SQL sentences according to the SQL sentence patterns according to the table structure, and storing the SQL sentences in the preset database; s201c, acquiring SQL sentences and Chinese descriptions corresponding to the SQL sentences in a preset database, and establishing a mapping relation between the SQL sentences and the Chinese descriptions to obtain training samples.
Specifically, selecting different business types to refer to business related to a company, wherein a database corresponding to the business is used as a sample database; reading the table structure and Chinese description of the data table of the sample database, and automatically generating a batch of SQL sentences according to the SQL sentence formula rule by utilizing the read table structure, wherein an automatic generating tool such as Navicat can be adopted to generate the batch of SQL sentences. Simultaneously, correspondingly storing the generated SQL sentence and the Chinese description in the preset database; collecting SQL sentences and Chinese descriptions corresponding to the SQL sentences in a preset database, and establishing a mapping relation between the SQL sentences and the Chinese descriptions, wherein the SQL sentences, the Chinese descriptions and the corresponding mapping relation are training samples.
S202, based on the selected deep neural network model, performing model training according to the training sample to obtain an SQL sentence model, and storing the SQL sentence model.
The selected deep neural network model is specifically a sequence-to-sequence model in an open-source deep learning framework Pytorch (the sequence-to-sequence model is a neural network model for machine translation), a training sample formed by SQL sentences and Chinese description is taken as input, a packaged model is called to encode the input into a feature vector, mathematical expression corresponding to the feature vector is a matrix, and the feature vector is decoded into output. The process of encoding the input into feature vectors may use LSTM technology (Long Short-term memory, long-term memory network), thereby improving the accuracy of translating Chinese speech into SQL statements. Thus, an SQL sentence model is obtained and stored in the intelligent robot for calling.
Referring to fig. 4, fig. 4 is a schematic flowchart of an SQL statement generation method according to another embodiment of the application. The method is applied to the intelligent robot, and as shown in fig. 4, the SQL sentence generation method comprises steps S301 to S308.
S301, dialogue information with a user is acquired.
Specifically, the salesman wants to know the loan situation of the last half year of the company (xx bank), which can say to the intelligent robot "i want to know the sum of loans of the last half year of xx bank 208 years". The intelligent robot converts the voice information into text information, and the text information 'i want to know the sum of loans of xx banks in the first half of 2018' is the dialogue information between the user and the intelligent robot.
S302, word segmentation is carried out on the dialogue information according to a natural language processing technology, and the word segmentation keyword is extracted to serve as the user word segmentation information.
Specifically, the dialogue information is processed by using a natural language processing technology (Natural Language Processing, abbreviated as NLP technology), specifically, word segmentation processing is performed to extract keywords in the dialogue information, which are speaking keywords.
For example, keyword extraction is performed on dialogue information "i want to know the sum of loans in the first half of 2018 of xx bank", and words such as "xx bank", "first half of 2018" and "sum of loans" can be extracted as user words.
S303, inquiring the SQL sentence corresponding to the user speaking information from the SQL sentence in a preset database according to a pre-trained SQL sentence model.
The preset database stores a large number of SQL sentences developed by developers before, and the SQL sentences are used for querying data in the related database. The pre-trained SQL statement model is stored in the intelligent robot to help the salesman search for the SQL statement he needs and complete the relevant data query.
Specifically, keywords in the user speaking information can be used as input of an SQL sentence model, and SQL sentences including the most keywords can be queried from SQL sentences in a preset database according to the SQL sentence model, wherein the SQL sentences are the SQL sentences corresponding to the user speaking information.
S304, acquiring Chinese description of the SQL sentence corresponding to the user speaking information, and processing the Chinese description according to the natural language processing technology to acquire description keywords.
Specifically, since different chinese utterances may express the same meaning, they correspond to the same SQL statement. The Chinese description of the SQL sentence, i.e. the Chinese label of the SQL sentence, is also required to be obtained, and can be understood as annotation information. The Chinese description is subjected to word segmentation processing by utilizing a natural language processing technology to obtain corresponding description keywords, namely, keywords of two sentences (dialogue information and Chinese description) are extracted.
S305, calculating the matching coefficient of the SQL sentence and the user speaking information according to the speaking keywords and the description keywords based on a preset matching degree calculation formula.
The preset matching degree calculation formula may be a weight formula, where the weight formula is specifically x=0.4×n+0.4×m+0.2×i, where n represents the number of identical keywords, m represents the number of keywords with similar meaning, and i represents the number of completely different keywords.
Based on the weight formula, the matching coefficient of the SQL sentence and the user speaking information can be calculated according to the speaking keywords and the description keywords.
S306, judging whether the matching coefficient is larger than a preset coefficient value.
The preset system value is used for judging the approximation degree of the SQL sentence and the user speaking information. Specifically, the SQL sentence can be set to 90%, and if the matching coefficient of the SQL sentence and the user speaking information reaches more than 90%, the two sentences are considered to express the same meaning.
Specifically, judging whether the matching coefficient is larger than a preset coefficient value or not; if the matching coefficient is not greater than the preset coefficient value, executing step S307; if the matching coefficient is greater than the preset coefficient value, step S308 is performed.
For example, if the matching coefficient is not greater than the preset coefficient value, that is, the matching coefficient is less than 90%, it indicates that there is no matched SQL statement, and thus step S307 is executed to generate an SQL statement according to the speaking keyword generation rule using the preset SQL statement generation rule.
S307, generating an SQL sentence through a preset SQL sentence generation rule according to the speaking keywords.
Specifically, a preset SQL sentence generation rule is adopted to generate an SQL sentence according to a speaking keyword generation rule. As shown in fig. 5, step S307 includes substeps S307a to S307c.
S307a searches SQL sentences matched with the speaking keywords according to the speaking keywords; s307b, performing one-bit effective coding on the speaking keywords and the key sentences in the searched SQL sentences; s307c, determining key sentences corresponding to the speaking keywords according to the coding results corresponding to the one-bit effective codes, and combining the key sentences into SQL sentences according to the sequence of the speaking keywords.
Specifically, the speaking keywords comprise a plurality of keywords, and SQL sentences similar to the speaking keywords are searched according to each keyword, and the matching refers to SQL sentences with the same meaning or similar meaning to the speaking keywords. For example, 10 SQL sentences similar to the SQL sentences are searched, and the SQL sentences required by the salesman are approximately synthesized according to the 10 SQL sentences.
The One-bit effective code is also called One-hot code, in order to facilitate synthesizing a new SQL sentence, one-hot code is needed for the speech key words and the key words in the searched SQL sentence, the connection processing of the speech key words and the key words in the SQL sentence is convenient after the encoding according to the encoding result, and meanwhile, the LSTM (Long Short-Term Memory) is also convenient to train to obtain a verification model, and the correctness of the newly synthesized SQL sentence is verified according to the verification model so as to improve the efficiency of data query.
S308, accessing a corresponding database according to the SQL statement to complete data query.
Specifically, the SQL statement which is queried or generated is executed to access the corresponding database for data query so as to acquire related data, and the extracted data is pushed to a salesman. For example, the relevant data is displayed by the intelligent robot or sent to the mailbox of the business personnel. Therefore, the service personnel can realize data query without the help of research personnel, thereby meeting the requirements of the service personnel, improving the query experience of the service personnel and reducing the workload of the developer.
Fig. 6 is a schematic block diagram of an SQL statement generation apparatus provided in an embodiment of the application. As shown in fig. 6, the present application also provides an SQL statement generation device corresponding to the above SQL statement generation method. The SQL sentence generating device comprises a unit for executing the SQL sentence method, and can be configured in a terminal, wherein the terminal can be an intelligent robot.
Specifically, as shown in fig. 6, the SQL statement apparatus 400 includes: a sample acquisition unit 401, a training saving unit 402, an information acquisition unit 403, an information processing unit 404, a sentence query unit 405, and a data access unit 406.
The sample collection unit 401 is configured to collect an SQL statement and a chinese description corresponding to the SQL statement as a training sample.
Wherein the sample acquisition unit 401 includes: a data selecting subunit 4011, a reading generating subunit 4012, and an acquisition establishing subunit 4013. The data selecting subunit 4011 is configured to select databases corresponding to different service types as a sample database; the reading generation subunit 4012 is configured to read a table structure and a chinese description of a data table of the sample database, generate an SQL statement according to the table structure according to an SQL statement sentence pattern, and store the SQL statement in the preset database; the collection and establishment subunit 4013 is configured to collect an SQL statement and a chinese description corresponding to the SQL statement in a preset database, and establish a mapping relationship between the SQL statement and the chinese description to obtain a training sample.
A training storage unit 402, configured to perform model training according to the training sample based on the selected deep neural network model to obtain an SQL statement model; and saving the SQL sentence model.
An information obtaining unit 403, configured to obtain dialogue information with a user, where the dialogue information is text information used for data query.
An information processing unit 404, configured to process the dialogue information according to a natural language processing technology to obtain user speaking information.
And the sentence query unit 405 is configured to query, according to a pre-trained SQL sentence model, an SQL sentence corresponding to the user speaking information from the SQL sentences in the preset database.
And the data access unit 406 is used for accessing the corresponding database according to the SQL statement to complete data query.
Fig. 7 is a schematic block diagram of an SQL statement generation device according to an embodiment of the present application. As shown in fig. 7, the present application also provides an SQL statement generation device corresponding to the above SQL statement generation method. The SQL sentence generating device comprises a unit for executing the SQL sentence method, and the device can be configured in a terminal.
Specifically, as shown in fig. 7, the SQL statement apparatus 500 includes: an information acquisition unit 501, an information processing unit 502, a sentence query unit 503, a description processing unit 504, a coefficient calculation unit 505, a coefficient judgment unit 506, a sentence generation unit 507, and a sentence query unit 508.
An information obtaining unit 501 is configured to obtain dialogue information with a user, where the dialogue information is text information used for data query.
The information processing unit 502 is configured to perform word segmentation on the dialogue information according to a natural language processing technology, and extract the word segmentation keyword as the user word segmentation information.
And the sentence query unit 503 is configured to query, according to a pre-trained SQL sentence model, an SQL sentence corresponding to the user speech information from the SQL sentences in the preset database.
And the description processing unit 504 is configured to obtain a chinese description of an SQL statement corresponding to the user speech information, and process the chinese description according to the natural language processing technique to obtain a description keyword.
And a coefficient calculating unit 505, configured to calculate, based on a preset matching degree calculation formula, a matching coefficient between the SQL statement and the user speaking information according to the speaking keyword and the description keyword.
And a coefficient judgment unit 506, configured to judge whether the matching coefficient is greater than a preset coefficient value.
Specifically, if the matching coefficient is not greater than the preset coefficient value, invoking a sentence generating unit 507; and if the matching coefficient is greater than the preset coefficient value, calling a statement query unit 508.
The sentence generating unit 507 is configured to generate an SQL sentence according to the speaking keyword through a preset SQL sentence generating rule.
Wherein the sentence generating unit 507 includes: a sentence search sub-unit 5071, a code setting sub-unit 5072, and a determination combining sub-unit 5073. A sentence search subunit 5071, configured to search, according to the speaking keyword, an SQL sentence that matches the speaking keyword; a code setting subunit 5072, configured to perform one-bit efficient coding on the speech keyword and the key sentence in the searched SQL sentence; and the determining and combining subunit 5073 is configured to determine a key sentence corresponding to the speaking keyword according to the encoding result corresponding to the one-bit valid encoding, and combine the key sentences into an SQL sentence according to the order of the speaking keywords.
And the statement query unit 508 is used for accessing the corresponding database according to the SQL statement to complete data query.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the above-described SQL statement device and unit may refer to the corresponding process in the foregoing method embodiment, which is not repeated herein.
The above-described apparatus may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 8.
Referring to fig. 8, fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 700 may be a terminal.
With reference to FIG. 8, the computer device 700 includes a processor 720, a memory, and a network interface 750, which are connected by a system bus 710, wherein the memory may include a non-volatile storage medium 730 and an internal memory 740.
The non-volatile storage medium 730 may store an operating system 731 and computer programs 732. The computer program 732, when executed, causes the processor 720 to perform any one of the SQL statement device methods.
The processor 720 is used to provide computing and control capabilities to support the operation of the overall computer device 700.
The internal memory 740 provides an environment for the execution of a computer program 732 in the non-volatile storage medium 730, which when executed by the processor 720, causes the processor 720 to perform any of the SQL statement means methods.
The network interface 750 is used for network communications such as sending assigned tasks and the like. It will be appreciated by those skilled in the art that the architecture shown in fig. 8 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting of the computer device 700 to which the present inventive arrangements may be implemented, as a particular computer device 700 may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components. Wherein the processor 720 is configured to execute the program code stored in the memory to implement the following steps:
acquiring dialogue information with a user, wherein the dialogue information is text information for data query; processing the dialogue information according to a natural language processing technology to obtain user speaking information; according to a pre-trained SQL sentence model, inquiring the SQL sentence corresponding to the user speaking information from the SQL sentence in a preset database; and accessing a corresponding database according to the SQL statement to complete data query.
In one embodiment, when the processor 720 executes the program code stored in the memory to implement the processing of the dialogue information according to the natural language processing technology to obtain the user dialogue information, the following steps are specifically implemented:
and performing word segmentation on the dialogue information according to a natural language processing technology, and extracting the word segmentation keyword as the user word segmentation information.
In an embodiment, the processor 720 is configured to execute the program code stored in the memory to implement the step of, after querying the SQL statement corresponding to the user speech information from the SQL statements in the preset database according to the pre-trained SQL statement model, further implementing the following steps:
acquiring Chinese description of SQL sentences corresponding to the user speaking information, and processing the Chinese description according to the natural language processing technology to acquire description keywords; calculating the matching coefficient of the SQL sentence and the user speaking information according to the speaking keywords and the description keywords based on a preset matching degree calculation formula; judging whether the matching coefficient is larger than a preset coefficient value or not; and if the matching coefficient is larger than the preset coefficient value, executing the step of accessing the corresponding database according to the SQL sentence to finish data query.
In one embodiment, after the processor 720 executes the program code stored in the memory to perform the determining whether the matching coefficient is greater than a preset coefficient value, the following steps are further performed:
and if the matching coefficient is not greater than the preset coefficient value, generating an SQL sentence according to the speaking keyword through a preset SQL sentence generation rule, and executing the step of accessing a corresponding database according to the SQL sentence to complete data query.
In an embodiment, when the processor 720 executes the program code stored in the memory to implement the generating an SQL statement according to the speaking keyword through a preset SQL statement generating rule, the following steps are specifically implemented:
searching SQL sentences matched with the speaking keywords according to the speaking keywords; performing one-bit effective coding on the speaking keywords and the key sentences in the searched SQL sentences; and determining key sentences corresponding to the speaking keywords according to the coding results corresponding to the one-bit effective codes, and combining the key sentences into SQL sentences according to the sequence of the speaking keywords.
In one embodiment, before the processor 720 executes the program code stored in the memory to obtain the dialogue information between the user and the intelligent robot, the following steps are further implemented:
collecting SQL sentences and Chinese descriptions corresponding to the SQL sentences as training samples; based on the selected deep neural network model, performing model training according to the training sample to obtain an SQL sentence model; and configuring the trained SQL sentence model in the intelligent robot.
In an embodiment, when the processor 720 runs the program code stored in the memory to implement the collection of the SQL statement and the chinese description corresponding to the SQL statement as the training sample, the following steps are specifically implemented:
selecting databases corresponding to different service types as sample databases; reading a table structure and Chinese description of a data table of the sample database, generating SQL sentences according to the table structure and SQL sentence patterns, and storing the SQL sentences in the preset database; collecting SQL sentences and Chinese descriptions corresponding to the SQL sentences in a preset database, and establishing a mapping relation between the SQL sentences and the Chinese descriptions to obtain training samples.
It should be appreciated that in embodiments of the present application, the processor 720 may be a central processing unit (Central Processing Unit, CPU), the processor 720 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf Programmable gate arrays (FPGAs) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Those skilled in the art will appreciate that the computer device 700 structure shown in fig. 8 is not limiting of the computer device 700 and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
It will be appreciated by those skilled in the art that implementing all or part of the above-described embodiment methods may be implemented by a computer program for instructing relevant hardware, and the computer program may be stored in a storage medium, where the storage medium is a computer readable storage medium. In an embodiment of the present application, the computer program may be stored in a storage medium of a computer system and executed by at least one processor in the computer system to implement the steps of the flow including the embodiments of the methods as described above.
The computer readable storage medium may be a magnetic disk, an optical disk, a usb disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk, etc. various media capable of storing program codes.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In several embodiments provided by the present application, it should be understood that the disclosed SQL statement apparatus and method may be implemented in other ways. For example, the SQL statement device embodiment described above is merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed.
The steps in the method of the embodiment of the application can be sequentially adjusted, combined and deleted according to actual needs.
The units in the device of the embodiment of the application can be combined, divided and deleted according to actual needs.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a terminal, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application.
While the application has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (7)

1. A method for generating an SQL statement, comprising:
collecting SQL sentences and Chinese descriptions corresponding to the SQL sentences as training samples;
based on the selected deep neural network model, performing model training according to the training sample to obtain an SQL sentence model, and storing the SQL sentence model;
acquiring dialogue information with a user, wherein the dialogue information is text information for data query;
processing the dialogue information according to a natural language processing technology to obtain user speaking information;
performing word segmentation on the dialogue information according to a natural language processing technology, and extracting word segmentation keywords as user word segmentation information;
according to a pre-trained SQL sentence model, inquiring the SQL sentence corresponding to the user speaking information from the SQL sentence in a preset database;
accessing a corresponding database according to the SQL statement to complete data query;
acquiring Chinese description of SQL sentences corresponding to the user speaking information, and processing the Chinese description according to the natural language processing technology to acquire description keywords;
calculating the matching coefficient of the SQL sentence and the user speaking information according to the speaking keywords and the description keywords based on a preset matching degree calculation formula;
judging whether the matching coefficient is larger than a preset coefficient value or not;
and if the matching coefficient is larger than the preset coefficient value, executing the step of accessing the corresponding database according to the SQL sentence to finish data query.
2. The method for generating SQL statement according to claim 1, wherein after the determining whether the matching coefficient is greater than a preset coefficient value, further comprising:
and if the matching coefficient is not greater than the preset coefficient value, generating an SQL sentence according to the speaking keyword through a preset SQL sentence generation rule, and executing the step of accessing a corresponding database according to the SQL sentence to complete data query.
3. The method for generating SQL statements according to claim 2, wherein said generating SQL statements from said spoken keywords by preset SQL statement generation rules comprises:
searching SQL sentences matched with the speaking keywords according to the speaking keywords;
performing one-bit effective coding on the speaking keywords and the key sentences in the searched SQL sentences;
and determining key sentences corresponding to the speaking keywords according to the coding results corresponding to the one-bit effective codes, and combining the key sentences into SQL sentences according to the sequence of the speaking keywords.
4. The method for generating SQL statement according to claim 1, wherein the collecting the SQL statement and the chinese description corresponding to the SQL statement as training samples comprises:
selecting databases corresponding to different service types as sample databases;
reading a table structure and Chinese description of a data table of the sample database, generating SQL sentences according to the table structure and SQL sentence patterns, and storing the SQL sentences in the preset database;
collecting SQL sentences and Chinese descriptions corresponding to the SQL sentences in the preset database, and establishing a mapping relation between the SQL sentences and the Chinese descriptions to obtain training samples.
5. An SQL statement generation device, comprising:
the sample acquisition unit is used for acquiring SQL sentences and Chinese descriptions corresponding to the SQL sentences as training samples;
the training storage unit is used for carrying out model training according to the training samples based on the selected deep neural network model to obtain an SQL sentence model; storing the SQL sentence model;
the information acquisition unit is used for acquiring dialogue information with a user, wherein the dialogue information is text information for data query;
the information processing unit is used for processing the dialogue information according to a natural language processing technology so as to obtain user speaking information;
the word segmentation processing unit is used for carrying out word segmentation processing on the dialogue information according to a natural language processing technology, and extracting the word segmentation processed word operation keywords as user word operation information;
the sentence query unit is used for querying the SQL sentences corresponding to the user speaking information from the SQL sentences in the preset database according to a pre-trained SQL sentence model;
the data access unit is used for accessing the corresponding database according to the SQL statement to finish data query;
the description processing unit is used for acquiring Chinese description of the SQL sentence corresponding to the user speaking information, and processing the Chinese description according to the natural language processing technology to acquire description keywords;
the coefficient calculation unit is used for calculating the matching coefficient of the SQL sentence and the user speaking information according to the speaking keywords and the description keywords based on a preset matching degree calculation formula;
the coefficient judging unit is used for judging whether the matching coefficient is larger than a preset coefficient value or not;
and the judging and executing unit is used for executing the step of accessing the corresponding database according to the SQL sentence to finish data query if the matching coefficient is larger than the preset coefficient value.
6. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method according to any one of claims 1 to 4 when the computer program is executed.
7. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program which, when executed by a processor, causes the processor to perform the steps of the method according to any one of claims 1 to 4.
CN201811187964.6A 2018-10-12 2018-10-12 SQL sentence generation method, device, computer equipment and storage medium Active CN109408526B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811187964.6A CN109408526B (en) 2018-10-12 2018-10-12 SQL sentence generation method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811187964.6A CN109408526B (en) 2018-10-12 2018-10-12 SQL sentence generation method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109408526A CN109408526A (en) 2019-03-01
CN109408526B true CN109408526B (en) 2023-10-31

Family

ID=65467048

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811187964.6A Active CN109408526B (en) 2018-10-12 2018-10-12 SQL sentence generation method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109408526B (en)

Families Citing this family (28)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112035506A (en) * 2019-10-28 2020-12-04 竹间智能科技(上海)有限公司 Semantic recognition method and equipment
CN110888876A (en) * 2019-10-31 2020-03-17 平安科技(深圳)有限公司 Method and device for generating database script, storage medium and computer equipment
CN110993093B (en) * 2019-11-15 2023-02-24 北京邮电大学 Deep learning-based ophthalmic pre-interrogation method and device
CN110968601A (en) * 2019-11-28 2020-04-07 中国银行股份有限公司 Data query processing method and device
CN111104422B (en) * 2019-12-10 2023-08-29 北京明略软件系统有限公司 Training method, device, equipment and storage medium of data recommendation model
CN111159227B (en) * 2019-12-20 2023-04-14 建信金融科技有限责任公司 Data query method, device, equipment and storage medium
CN111221947B (en) * 2019-12-26 2023-11-24 北京邮电大学 Multi-round dialogue realization method and device of ophthalmologic pre-consultation device
CN111209297A (en) * 2019-12-31 2020-05-29 深圳云天励飞技术有限公司 Data query method and device, electronic equipment and storage medium
CN111159220B (en) * 2019-12-31 2023-06-23 北京百度网讯科技有限公司 Method and apparatus for outputting structured query statement
CN111309991B (en) * 2020-01-16 2023-03-31 广州三七互娱科技有限公司 Query statement generation method and device and data query method and system
CN111382253B (en) * 2020-03-02 2022-07-15 思必驰科技股份有限公司 Semantic parsing method and semantic parser
CN111427911A (en) * 2020-03-25 2020-07-17 平安医疗健康管理股份有限公司 Data query method and device, computer equipment and storage medium
CN111581229B (en) * 2020-03-25 2023-04-18 平安科技(深圳)有限公司 SQL statement generation method and device, computer equipment and storage medium
CN112069206B (en) * 2020-03-31 2022-02-22 北京来也网络科技有限公司 Data query method, device, medium and computing device based on RPA and AI
CN111651474B (en) * 2020-06-02 2023-07-25 东云睿连(武汉)计算技术有限公司 Method and system for converting natural language into structured query language
CN112380238A (en) * 2020-11-16 2021-02-19 平安科技(深圳)有限公司 Database data query method and device, electronic equipment and storage medium
CN112463819A (en) * 2020-11-26 2021-03-09 北京宏景世纪软件股份有限公司 Computing method, device and equipment based on Chinese expression and storage medium
CN112559716A (en) * 2020-12-24 2021-03-26 北京百度网讯科技有限公司 Recognition method and device of conversation state, electronic equipment and storage medium
CN112732741A (en) * 2020-12-31 2021-04-30 平安科技(深圳)有限公司 SQL statement generation method, device, server and computer readable storage medium
CN112989011B (en) * 2021-04-26 2021-08-24 广州思迈特软件有限公司 Data query method, data query device and electronic equipment
CN113282724A (en) * 2021-05-21 2021-08-20 北京京东振世信息技术有限公司 Interaction method and device for intelligent customer service
CN113448980A (en) * 2021-06-18 2021-09-28 青岛海尔科技有限公司 Method and device for generating SQL (structured query language) statement and electronic equipment
CN113254619A (en) * 2021-06-21 2021-08-13 北京沃丰时代数据科技有限公司 Automatic reply method and device for user query and electronic equipment
CN113779215A (en) * 2021-08-25 2021-12-10 海南硬壳科技有限公司 Data processing platform
CN114461665B (en) * 2022-01-26 2023-01-24 北京百度网讯科技有限公司 Method, apparatus and computer program product for generating a statement transformation model
CN115878659B (en) * 2023-02-01 2023-06-02 云账户技术(天津)有限公司 Method, device and equipment for generating SQL (structured query language) sentences and readable storage medium
CN116049294B (en) * 2023-03-27 2023-06-27 北京大学深圳研究生院 Excel operation method, device, equipment and storage medium
CN117271553A (en) * 2023-09-08 2023-12-22 上海浦东发展银行股份有限公司 Method for generating and operating supervision report data quality rule

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103646032A (en) * 2013-11-11 2014-03-19 漆桂林 Database query method based on body and restricted natural language processing
CN104021198A (en) * 2014-06-16 2014-09-03 北京理工大学 Relational database information retrieval method and device based on ontology semantic index
CN107451153A (en) * 2016-05-31 2017-12-08 北京京东尚科信息技术有限公司 The method and apparatus of export structure query statement

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103646032A (en) * 2013-11-11 2014-03-19 漆桂林 Database query method based on body and restricted natural language processing
CN104021198A (en) * 2014-06-16 2014-09-03 北京理工大学 Relational database information retrieval method and device based on ontology semantic index
CN107451153A (en) * 2016-05-31 2017-12-08 北京京东尚科信息技术有限公司 The method and apparatus of export structure query statement

Also Published As

Publication number Publication date
CN109408526A (en) 2019-03-01

Similar Documents

Publication Publication Date Title
CN109408526B (en) SQL sentence generation method, device, computer equipment and storage medium
CN110210029B (en) Method, system, device and medium for correcting error of voice text based on vertical field
CN108363790B (en) Method, device, equipment and storage medium for evaluating comments
CN110162627B (en) Data increment method and device, computer equipment and storage medium
US20190163691A1 (en) Intent Based Dynamic Generation of Personalized Content from Dynamic Sources
CN107437417B (en) Voice data enhancement method and device based on recurrent neural network voice recognition
CN108536807B (en) Information processing method and device
CN110347908B (en) Voice shopping method, device, medium and electronic equipment
CN112256860A (en) Semantic retrieval method, system, equipment and storage medium for customer service conversation content
CN114580382A (en) Text error correction method and device
CN111310440A (en) Text error correction method, device and system
CN111274797A (en) Intention recognition method, device and equipment for terminal and storage medium
CN114840671A (en) Dialogue generation method, model training method, device, equipment and medium
US20200012650A1 (en) Method and apparatus for determining response for user input data, and medium
CN111274822A (en) Semantic matching method, device, equipment and storage medium
CN111159381A (en) Data searching method and device
CN112100360B (en) Dialogue response method, device and system based on vector retrieval
CN111898363B (en) Compression method, device, computer equipment and storage medium for long and difficult text sentence
CN110309513B (en) Text dependency analysis method and device
CN112949293A (en) Similar text generation method, similar text generation device and intelligent equipment
CN112559711A (en) Synonymous text prompting method and device and electronic equipment
CN114742062B (en) Text keyword extraction processing method and system
CN111460117A (en) Dialog robot intention corpus generation method, device, medium and electronic equipment
JP5293607B2 (en) Abbreviation generation apparatus and program, and abbreviation generation method
CN109727591B (en) Voice search method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant