CN109542929B - Voice query method and device and electronic equipment - Google Patents

Voice query method and device and electronic equipment Download PDF

Info

Publication number
CN109542929B
CN109542929B CN201811440115.7A CN201811440115A CN109542929B CN 109542929 B CN109542929 B CN 109542929B CN 201811440115 A CN201811440115 A CN 201811440115A CN 109542929 B CN109542929 B CN 109542929B
Authority
CN
China
Prior art keywords
sql statement
col
vocabulary
text
preset
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.)
Expired - Fee Related
Application number
CN201811440115.7A
Other languages
Chinese (zh)
Other versions
CN109542929A (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.)
Shandong Technology and Business University
Original Assignee
Shandong Technology and Business University
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 Shandong Technology and Business University filed Critical Shandong Technology and Business University
Priority to CN201811440115.7A priority Critical patent/CN109542929B/en
Publication of CN109542929A publication Critical patent/CN109542929A/en
Application granted granted Critical
Publication of CN109542929B publication Critical patent/CN109542929B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention provides a voice query method, a voice query device and electronic equipment, wherein the method is applied to a server and comprises the following steps: acquiring user voice, and converting the voice into a Chinese text; processing the Chinese text to obtain a text vector; inputting the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training; inputting the output result into a preset SQL statement template, and obtaining a formalized SQL statement according to a preset semantic dependency relationship; acquiring domain information; and obtaining the executable SQL statement according to the domain information and the formalized SQL statement. The invention converts the voice into the text vector, converts the text vector into the executable SQL sentence by utilizing the pre-established conversion model, the SQL sentence template and the domain information, and queries the database by utilizing the executable SQL sentence, thereby simplifying the query mode of the database, being applicable to the database query of different service systems and improving the portability of the database query.

Description

Voice query method and device and electronic equipment
Technical Field
The invention relates to the technical field of database query, in particular to a voice query method, a voice query device and electronic equipment.
Background
The database management system is a collection of relational data and programs, is widely applied to management systems of various industries and is used for storing and retrieving data, if the database system is required to be operated, certain computer foundation or even certain SQL sentence compiling capability is required, if a non-professional user wants to query the database system, the database management system is difficult, the query of the non-professional user on the database can be simplified to a certain extent by utilizing a database natural language query interface, but the database management system is usually limited by vocabularies in the professional field, and has poor portability for service systems of different industries.
Disclosure of Invention
In view of this, an object of the present invention is to provide a voice query method, apparatus and electronic device, so as to simplify a query manner of a database, so that the method can be adapted to database queries of different service systems, and improve portability of the database queries.
In a first aspect, an embodiment of the present invention provides a voice query method, where the method is applied to a server, and the method includes: acquiring user voice, and converting the voice into a Chinese text; processing the Chinese text to obtain a text vector; inputting the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training; inputting the output result into a preset SQL statement template, and obtaining a formalized SQL statement according to a preset semantic dependency relationship; acquiring domain information; and obtaining the executable SQL statement according to the domain information and the formalized SQL statement.
With reference to the first aspect, an embodiment of the present invention provides a first possible implementation manner of the first aspect, where the step of processing the text of the chinese text to obtain a text vector includes: preprocessing a Chinese text to obtain a plurality of vocabularies; the preprocessing comprises word stopping, punctuation and word segmentation; performing part-of-speech tagging on each vocabulary to obtain the part-of-speech of each vocabulary; and coding each vocabulary according to a preset rule to obtain a text vector.
With reference to the first possible implementation manner of the first aspect, an embodiment of the present invention provides a second possible implementation manner of the first aspect, where the step of encoding each vocabulary according to a preset rule includes: the following processing steps are performed for each vocabulary: acquiring the part of speech of a vocabulary; acquiring the part of speech of adjacent words of the words; coding the vocabulary according to the part of speech of the vocabulary and the part of speech of the adjacent vocabulary of the vocabulary; and collecting coding results of a plurality of words of the Chinese text to obtain a text vector.
With reference to the first aspect, an embodiment of the present invention provides a third possible implementation manner of the first aspect, where the step of obtaining the conversion model through attention model training includes: acquiring a Chinese text sample; processing the Chinese text sample to obtain a text vector sample; and inputting the text vector sample into a pre-established attention model for training to obtain a conversion model.
With reference to the third possible implementation manner of the first aspect, an embodiment of the present invention provides a fourth possible implementation manner of the first aspect, where the method further includes: and adjusting the conversion model by adopting a cross verification method.
With reference to the first aspect, an embodiment of the present invention provides a fifth possible implementation manner of the first aspect, where the domain information includes multiple kinds of database table structures, table fields, field descriptions, field types, field value ranges, and field common expressions.
In a second aspect, an embodiment of the present invention further provides a voice query apparatus, where the apparatus is disposed in a server, and the apparatus includes: the conversion module is used for acquiring the voice of the user and converting the voice into a Chinese text; the processing module is used for processing the Chinese text to obtain a text vector; the first output module is used for inputting the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training; the second output module is used for inputting the output result into a preset SQL statement template and obtaining a formalized SQL statement according to a preset semantic dependency relationship; and the third output module is used for obtaining the executable SQL statement according to the domain information and the formalized SQL statement.
With reference to the second aspect, an embodiment of the present invention provides a first possible implementation manner of the second aspect, where the processing module further includes: the preprocessing module is used for preprocessing the Chinese text to obtain a plurality of vocabularies; the preprocessing comprises word stopping, punctuation and word segmentation; the part-of-speech tagging module is used for performing part-of-speech tagging on each vocabulary to obtain the part-of-speech of each vocabulary; and the coding module is used for coding each vocabulary according to a preset rule to obtain a text vector.
In a third aspect, an embodiment of the present invention further provides an electronic device, which includes a memory and a processor, where the memory stores a computer program that is executable on the processor, and when the processor executes the computer program, the steps of the method in the first aspect are implemented.
In a fourth aspect, the present invention also provides a computer-readable medium having non-volatile program code executable by a processor, where the program code causes the processor to execute the method of the first aspect.
The embodiment of the invention has the following beneficial effects:
the invention provides a voice query method, a voice query device and electronic equipment, wherein the method is applied to a server and comprises the following steps: acquiring user voice, and converting the voice into a Chinese text; processing the Chinese text to obtain a text vector; inputting the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training; inputting the output result into a preset SQL statement template, and obtaining a formalized SQL statement according to a preset semantic dependency relationship; acquiring domain information; and obtaining the executable SQL statement according to the domain information and the formalized SQL statement. The invention converts the voice into the text vector, converts the text vector into the executable SQL sentence by utilizing the pre-established conversion model, the SQL sentence template and the domain information, and queries the database by utilizing the executable SQL sentence, thereby simplifying the query mode of the database, being applicable to the database query of different service systems and improving the portability of the database query.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention as set forth above.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a voice query method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a process for processing a chinese text according to an embodiment of the present invention;
FIG. 3 is a structural diagram of a semantic dependency relationship according to an embodiment of the present invention;
FIG. 4 is a flowchart of obtaining a transformation model according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a transformation model according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a voice query apparatus according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
At present, most of existing database natural language query interfaces adopt technologies such as keyword matching, pattern matching, vocabulary driving and the like, but the technologies are generally limited by vocabularies in professional fields, are generally only applied to special fields, are not suitable for other fields, have poor portability, and users can only interact with a system according to rules preset by the system, and the error rate can be greatly improved if the system has slight deviation. Based on this, the voice query method, the voice query device and the electronic equipment provided by the embodiment of the invention can be applied to database query in different fields.
To facilitate understanding of the embodiment, a detailed description is first given of a voice query method disclosed in the embodiment of the present invention.
Referring to fig. 1, a flow chart of a voice query method is shown, wherein the method is applied to a server, and the method comprises the following steps:
step S102, acquiring user voice, and converting the voice into a Chinese text;
when a user queries a database, a voice input mode is adopted, voice information of the user is converted into a Chinese text by adopting voice conversion software, and voices of various languages of the user can be converted into the Chinese text by adopting voice conversion software such as science news and news, dog searching, dictation and the like. By adopting voice input, a user can inquire the data desired by the user through simple voice input without necessarily mastering a certain computer foundation and the compiling capability of SQL sentences, thereby simplifying the mode of inquiring the database by the user.
Step S104, processing the Chinese text to obtain a text vector;
in step S104, the step of processing the text in the chinese is shown in fig. 2, and the specific steps are as follows:
step S202, preprocessing the Chinese text to obtain a plurality of vocabularies; the preprocessing comprises word stopping, punctuation and word segmentation;
the method comprises the steps of preprocessing Chinese text obtained through voice conversion for removing stop words, punctuation and word segmentation, wherein the word removal means that certain words or words such as word strength auxiliary words, and sound-imitating words which have no clear meaning are automatically filtered when the Chinese text is processed in order to save storage space and improve processing efficiency, the processing amount is reduced during subsequent processing, and the processing efficiency is improved; the word segmentation is to perform word segmentation on the Chinese text by using algorithms such as Markov hypothesis and Vibert algorithm according to a pre-established word bank to obtain a plurality of words and realize the preprocessing of the Chinese text.
Step S204, performing part-of-speech tagging on each vocabulary to obtain the part-of-speech of each vocabulary;
after preprocessing the Chinese text, a set of a plurality of vocabularies is obtained, and each vocabulary is labeled with the part of speech to obtain the part of speech of each vocabulary, namely, the process of determining whether each vocabulary is a noun, a verb, an adjective or other parts of speech is carried out.
And S206, coding each vocabulary according to a preset rule to obtain a text vector.
When each vocabulary is coded, the following processing steps are executed:
step (1), acquiring the part of speech of a current vocabulary to be coded;
step (2), acquiring the part of speech of the adjacent vocabulary of the current vocabulary to be coded;
and (3) coding the vocabulary according to the part of speech of the vocabulary to be coded currently and the part of speech of the adjacent vocabulary of the vocabulary.
The vocabulary is encoded according to the self-defined part of speech by a pre-established encoder and is encoded into a number form, such as noun 1, verb 2 and the like, and the division granularity is too coarse due to the limited part of speech types, so that the current vocabulary is encoded by combining the self-defined part of speech with the context part of speech.
And collecting the coding results of all the words of the current Chinese text to obtain a text vector corresponding to the current Chinese text.
The above steps S202 to S206 describe the steps of processing the text to obtain a text vector, and the following steps continue to describe the steps of the voice query method.
Step S106, inputting the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training;
and inputting the text vector subjected to coding processing into a pre-established conversion model, wherein the conversion model is obtained based on attention model training, and the digital output result is obtained by processing the text vector in the digital form.
Step S108, inputting the output result into a preset SQL statement template, and obtaining a formalized SQL statement according to a preset semantic dependency relationship;
pre-establishing an SQL statement template, converting the automatic generation problem of the SQL statement into a semantic understanding slot filling problem, and filling the SQL statement template according to a preset semantic dependency relationship by using an output result of a conversion model, wherein the pre-established SQL statement template is as follows:
SELECT($COL)*,($AGG$COL)*
WHERE$COL$OP$VALUE
($LINK$COL$OP$VALUE)*
where, denotes 0 or more, $ AGG denotes a function in the SQL statement, such as sum (), avg (), max (), etc.; $ COL denotes the column name in the database; $ VALUE represents the query VALUE; LINK is a connection word, such as and, or, etc.; $ OP is the comparison operator. And the symbol marking part is a part which needs to be filled according to the output result of the conversion model, and a formalized SQL statement is obtained by filling the SQL statement template.
Step S110, obtaining domain information;
the domain information comprises a plurality of database table structures, table fields, field descriptions, field types, field value ranges and field common expressions; the domain information may be obtained after the formalized SQL statement is obtained, or the domain information may be obtained while the user voice is obtained in step S102, as long as the executable SQL statement is obtained by processing the formalized SQL statement.
Taking table 1 as an example to explain the domain information in detail, wherein table 1 includes four tables, namely a transformer parameter table, a station parameter table, a region parameter table and a voltage class table, each table corresponds to a plurality of fields, and each field has a field type, a field common expression and a field value range corresponding to each field.
Table 1 database table description
Figure BDA0001883054830000081
Figure BDA0001883054830000091
Note: in the field value range, E represents that the field value can be enumerated, and then an enumerated value is listed; r represents that the field has a value range, and then lists the upper and lower bounds of the value.
And step S112, obtaining an executable SQL statement according to the domain information and the formalized SQL statement.
And carrying out further refinement processing on the formalized SQL statement, replacing $ COL, $ OP, $ AGG with standardized SQL elements, then finding a specific column name in the SELECT statement and $ COL hidden in the WHERE statement, supplementing, then finding a table corresponding to the $ COL in the database, and if the table is dispersed in a plurality of tables, finding the association among the tables.
Taking the table 1 as an example to explain a processing procedure for finding a specific column name in a SELECT statement, performing form matching and semantic matching on a word needing to be subjected to column name concretization in a formalized SQL statement and fields and field common expressions in the table 1 respectively, scoring a matching result, taking a field with the highest score as a concretized column name, if a plurality of similar scores exist, introducing a question-answering mechanism to perform secondary questioning on a user, and confirming which column name the concretization should be performed by the user.
Still taking table 1 as an example to explain the processing procedure of finding $ COL hidden in WHERE statement, judging the data type of column dereferencing in a formalized SQL statement, filtering out fields with unmatched data types according to the data types, matching through the field dereferencing range in table 1, scoring the matching result, taking the result with the highest score as a result, if a plurality of similar scores exist, introducing a question-answering mechanism to ask a user for a second time, and confirming the result by the user.
For the processing procedure of finding the association between the tables, table 2 is taken as an example for explanation, wherein the transformer parameter table "plant site name" is associated with the plant site parameter table "number"; the 'area name' of the station parameter table is associated with the 'number' of the area parameter table; the "high-side voltage class" of the transformer parameter table is associated with the "voltage class" of the voltage class table.
Table 2 database table associations
TABLE 1 name Attribute/field TABLE 2 name of Attribute/field
Transformer parameter table Name of factory station Station parameter table Numbering
Station parameter table Name of area Regional parameter table Numbering
Transformer parameter table High end voltage class Voltage class meter Voltage class
According to the information such as table fields, field descriptions, field types, field common expressions, field value ranges and the like of each table in the domain information, the conversion from $ COL, $ OP, $ AGG to standardized SQL elements is realized, and executable SQL statements are obtained.
Taking "please find how many 110kV transformers exist in each district" as an example for explanation, the formalized SQL statement obtained after processing is:
FUN (Transformer) where 110kV is located in select areas
According to step S112, replacing $ COL, $ OP, $ FUN with standardized SQL elements yields:
(1) local office of Select, count (Transformer) where 110kV
For the count function in the Select statement, there are words before and after which they can be modified: each office and transformer, but the count function only modifies one word, at this time, the dependency relationship of the words in the natural language at the semantic level is analyzed by means of a semantic dependency graph, as shown in fig. 3, "find" is a core node of the whole sentence, and is marked as "Root", "please be the emotional state mark of" find ", and is marked as" mMOD "," having "and" find "are guest matters, and is marked as" dCont "," office "and" having "are lead matters, and is marked as" pos "," each zone "is a range role of" office ", and is marked as" Sco "," transformer "is a" having "subordinate role, and is marked as" Belg "," number is a number array of "transformers", and is marked as "Qp", "how many" is a number role of "and is marked as" Quan "," 110kV ", and is the character mark of" 110kV "," is marked as "Desc", "role, record as "mAUx". As can be seen from FIG. 3, "how many" is used to modify "transformers", the number of transformers is counted by a count function.
(2) Finding the $ COL hidden in the where statement, supplemented, results in:
in each local area of Select, the voltage of the ground (transformer) is 110kV
Finding the table corresponding to $ COL in the database, if the table is dispersed in a plurality of tables, finding the association among the tables to obtain:
select area parameter table name, count (Voltage class table name)
From region parameter table, transformer parameter table, voltage grade table and station parameter table
The power station parameter list is a power station parameter list, a region name AND voltage grade list, a high-end voltage grade AND voltage grade list, a voltage grade AND power station parameter list, AND a power station name
The method comprises the steps of calculating functions corresponding to the FUN specifically based on text similarity of a phonetic-configurational code, calculating operational characters corresponding to the OP specifically based on text semantic similarity, and finally converting from the COL and the OP to standardized SQL elements according to information such as table fields, field descriptions, field types and field value ranges in specific domain information to obtain executable SQL sentences.
The embodiment of the invention provides a voice query method, wherein the method is applied to a server and comprises the following steps: acquiring user voice, and converting the voice into a Chinese text; processing the Chinese text to obtain a text vector; inputting the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training; inputting the output result into a preset SQL statement template, and obtaining a formalized SQL statement according to a preset semantic dependency relationship; acquiring domain information; and obtaining the executable SQL statement according to the domain information and the formalized SQL statement. The embodiment of the invention converts the voice into the text vector, converts the text vector into the executable SQL sentence by utilizing the pre-established conversion model, the SQL sentence template and the domain information, and queries the database by utilizing the executable SQL sentence, thereby simplifying the query mode of the database, being suitable for the database query of different service systems and improving the portability of the database query.
Corresponding to the above method embodiment, the embodiment of the present invention mainly describes the specific training process of the conversion model in step S106 of the above embodiment of the present invention, as shown in fig. 4, the specific steps are as follows:
step S402, obtaining a Chinese text sample;
the method comprises the steps of obtaining a plurality of voice samples of a user in advance, and converting the voice samples by using voice conversion software to obtain each Chinese text sample corresponding to each voice sample.
Step S404, processing the Chinese text sample to obtain a text vector sample;
and preprocessing, part-of-speech tagging and coding each Chinese text sample to obtain a text vector sample corresponding to each Chinese text sample.
And step S406, inputting the text vector sample into a pre-established attention model for training to obtain a conversion model.
And inputting the text vector sample into a pre-established attention model, comparing an actual output result with an ideal output result, and adjusting each parameter of the attention model according to the comparison result until the model converges to obtain a conversion model.
The conversion model can be verified and adjusted by using a cross verification method, a certain number of Chinese text samples are obtained, the Chinese text samples are divided into designated parts, the Chinese text samples are processed to obtain text vector samples corresponding to the Chinese text samples, at least one text vector sample corresponding to the Chinese text sample is input into the conversion model in turn to obtain an actual output result, and the accuracy and the recall rate of the conversion model are calculated according to the comparison between the actual output result and an ideal output result.
The accuracy rate is the ratio of the number of the Chinese text samples with the actual output result and the ideal output result both being true to the number of the Chinese text samples with the actual output result being true; the recall ratio is the ratio of the number of Chinese text samples for which the actual output result and the ideal output result are both true to the number of Chinese text samples for which the ideal output result is true.
And adjusting the conversion model according to the accuracy and the recall rate, so that the result is more accurate in the process of processing the text vector.
The attention model does not require the encoder to encode all the input information into a fixed length vector, but instead the encoder needs to encode the input information into a sequence of vectors, and each step selectively selects a subset of the sequence of vectors for further processing during decoding. In this way, when each output is generated, the information carried by the input sequence can be fully utilized, and therefore, the attention model is trained to obtain the conversion model.
Referring to the conversion model shown in fig. 5, the conversion model is described by taking "the number of 110KV transformers in each local area is queried" as a chinese text, each vocabulary and part-of-speech corresponding to each vocabulary of the chinese text are obtained by processing the chinese text, each vocabulary is encoded according to a preset rule to obtain a text vector, the text vector is processed by using the conversion model to obtain an output result, when the attention model is output, an "attention range" is also generated to indicate which parts of the text vector are focused when the attention model is output next, then the next output is generated according to the concerned area, and the output result corresponding to the text vector is obtained by repeating the steps.
The method comprises the steps of obtaining a Chinese text sample, preprocessing the Chinese text sample, labeling the part of speech and coding to obtain a text vector sample, inputting the text vector sample into a pre-established attention model to obtain an actual output result, comparing the actual output result with an ideal actual result, continuously adjusting each parameter of the attention model according to the comparison result to obtain a conversion model, and further verifying and adjusting the conversion model by adopting a cross verification method to improve the conversion accuracy of the conversion model and lay a foundation for the accuracy of subsequent processing.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a voice query apparatus, as shown in fig. 6, where the apparatus is disposed in a server, and the apparatus includes:
a conversion module 60, configured to obtain a user voice and convert the voice into a chinese text;
the processing module 61 is used for processing the Chinese text to obtain a text vector;
the first output module 62 is configured to input the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training;
the second output module 63 is configured to input the output result into a preset SQL statement template, and obtain a formalized SQL statement according to a preset semantic dependency relationship;
an obtaining module 64, configured to obtain domain information;
and a third output module 65, configured to obtain an executable SQL statement according to the domain information and the formalized SQL statement.
The processing module 61 further includes: the preprocessing module is used for preprocessing the Chinese text to obtain a plurality of vocabularies; the preprocessing comprises word stopping, punctuation and word segmentation; the part-of-speech tagging module is used for performing part-of-speech tagging on each vocabulary to obtain the part-of-speech of each vocabulary; and the coding module is used for coding each vocabulary according to a preset rule to obtain a text vector.
The voice query device provided by the embodiment of the invention converts voice to obtain a text vector, obtains a formal SQL statement by using a pre-established conversion model and an SQL statement template, further standardizes the formal SQL statement by using domain information to obtain an executable SQL statement, and queries a database by using the executable SQL statement, so that the query mode of the database is simplified, the voice query device can be suitable for database queries of different service systems, the portability of database queries is improved, and meanwhile, a user can query the database by inputting voice, and the use convenience and experience of the user are improved.
The voice query device provided by the embodiment of the invention has the same technical characteristics as the voice query method provided by the embodiment, so that the same technical problems can be solved, and the same technical effects can be achieved.
As shown in fig. 7, the electronic device 7 includes a memory 71 and a processor 72, where the memory 71 stores a computer program that can be executed on the processor 72, and the processor executes the computer program to implement the steps of the method provided in the embodiment of the present invention.
Referring to fig. 7, the electronic device further includes: a bus 73 and a communication interface 74, the processor 72, the communication interface 74 and the memory 71 being connected by the bus 73; the processor 72 is arranged to execute executable modules, such as computer programs, stored in the memory 71.
The Memory 71 may include a high-speed Random Access Memory (RAM) and may further include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 74 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, etc. may be used.
Bus 73 can be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 7, but this does not indicate only one bus or one type of bus.
The memory 71 is used for storing a program, and the processor 72 executes the program after receiving an execution instruction, and the method performed by the apparatus defined by the process disclosed in any of the foregoing embodiments of the present invention may be applied to the processor 72, or implemented by the processor 72.
The processor 72 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by instructions in the form of hardware, integrated logic circuits, or software in the processor 72. The Processor 72 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 71, and the processor 72 reads the information in the memory 71 and performs the steps of the above method in combination with the hardware thereof.
Embodiments of the present invention also provide a computer readable medium having non-volatile program code executable by a processor, where the program code causes the processor to execute the method described in the foregoing embodiments of the present invention.
The computer readable medium having the processor-executable nonvolatile program code according to the embodiments of the present invention has the same technical features as the log recording method and the log recording apparatus according to the embodiments, so that the same technical problems can be solved, and the same technical effects can be achieved.
The voice query method, the voice query device, and the computer program product of the electronic device provided in the embodiments of the present invention include a computer-readable storage medium storing a nonvolatile program code executable by a processor, where instructions included in the program code may be used to execute the method described in the foregoing method embodiments, and specific implementation may refer to the method embodiments, and will not be described herein again.
The functions, if implemented in the form of software functional units 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 invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (10)

1. A voice query method is applied to a server, and comprises the following steps:
acquiring user voice, and converting the voice into a Chinese text;
processing the Chinese text to obtain a text vector;
inputting the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training;
inputting the output result into a preset SQL statement template, and obtaining a formalized SQL statement according to a preset semantic dependency relationship;
acquiring domain information;
obtaining an executable SQL statement according to the domain information and the formalized SQL statement;
the step of inputting the output result into a preset SQL statement template and obtaining a formalized SQL statement according to a preset semantic dependency relationship comprises the following steps:
converting the automatic generation problem of the SQL statement into a semantic understanding slot filling problem, and filling the SQL statement template according to the preset semantic dependency relationship by using the output result to obtain the formalized SQL statement; the SQL statement template comprises: SELECT ($ COL) ($ AGG $ COL); WHERE $ COL $ OP $ VALUE; ($ LINK $ COL $ OP $ VALUE);
wherein the x represents 0 or more, the $ AGG represents a function in an SQL statement; the $ COL represents the column name in the database; the $ VALUE represents a query VALUE; the $ LINK represents a nexus; the $ OP represents the compare operator; the part marked by the symbol needs to be filled according to the output result of the conversion model;
the step of obtaining an executable SQL statement according to the domain information and the formalized SQL statement comprises the following steps:
replace $ COL, $ OP, $ AGG with standardized SQL elements; finding out the specific column name in the SELECT statement and the $ COL hidden in the WHERE statement for supplementation; finding the table corresponding to the $ COL in the database, and if the $ COL is dispersed in a plurality of tables, finding the association among the tables;
and according to the information of table fields, field descriptions, field types, field common expressions and field value ranges of each table in the domain information, realizing the conversion from $ COL, $ OP, $ AGG to standardized SQL elements to obtain the executable SQL statement.
2. The method of claim 1, wherein the step of processing the chinese text to obtain a text vector comprises:
preprocessing the Chinese text to obtain a plurality of vocabularies; the preprocessing comprises word stopping, punctuation and word segmentation;
performing part-of-speech tagging on each vocabulary to obtain the part-of-speech of each vocabulary;
and coding each vocabulary according to a preset rule to obtain the text vector.
3. The method according to claim 2, wherein the step of encoding each vocabulary according to a preset rule comprises:
for each of said words, performing the following processing steps:
acquiring the part of speech of the vocabulary;
acquiring the part of speech of adjacent words of the words;
coding the vocabulary according to the part of speech of the vocabulary and the part of speech of the adjacent vocabulary of the vocabulary;
and collecting the coding results of the plurality of words of the Chinese text to obtain the text vector.
4. The method of claim 1, wherein the step of the transformation model training by attention model comprises:
acquiring a Chinese text sample;
processing the Chinese text sample to obtain a text vector sample;
and inputting the text vector sample into the pre-established attention model for training to obtain the conversion model.
5. The method of claim 4, further comprising: and adjusting the conversion model by adopting a cross verification method.
6. The method of claim 1, wherein the domain information includes a plurality of database table structures, table fields, field descriptions, field types, field value ranges, and field common expressions.
7. A voice query apparatus, the apparatus being disposed in a server, the apparatus comprising:
the conversion module is used for acquiring user voice and converting the voice into a Chinese text;
the processing module is used for processing the Chinese text to obtain a text vector;
the first output module is used for inputting the text vector into a preset conversion model to obtain an output result; the conversion model is obtained through attention model training;
the second output module is used for inputting the output result into a preset SQL statement template and obtaining a formalized SQL statement according to a preset semantic dependency relationship;
the acquisition module is used for acquiring domain information;
the third output module is used for obtaining an executable SQL statement according to the domain information and the formalized SQL statement;
the second output module is further configured to: converting the automatic generation problem of the SQL statement into a semantic understanding slot filling problem, and filling the SQL statement template according to the preset semantic dependency relationship by using the output result to obtain the formalized SQL statement; the SQL statement template comprises: SELECT ($ COL) ($ AGG $ COL); WHERE $ COL $ OP $ VALUE; ($ LINK $ COL $ OP $ VALUE);
wherein the x represents 0 or more, the $ AGG represents a function in an SQL statement; the $ COL represents the column name in the database; the $ VALUE represents a query VALUE; the $ LINK represents a nexus; the $ OP represents the compare operator; the part marked by the symbol needs to be filled according to the output result of the conversion model;
the third output module is further configured to: replace $ COL, $ OP, $ AGG with standardized SQL elements; finding out the specific column name in the SELECT statement and the $ COL hidden in the WHERE statement for supplementation; finding the table corresponding to the $ COL in the database, and if the $ COL is dispersed in a plurality of tables, finding the association among the tables; and according to the information of table fields, field descriptions, field types, field common expressions and field value ranges of each table in the domain information, realizing the conversion from $ COL, $ OP, $ AGG to standardized SQL elements to obtain the executable SQL statement.
8. The apparatus of claim 7, wherein the processing module further comprises:
the preprocessing module is used for preprocessing the Chinese text to obtain a plurality of vocabularies; the preprocessing comprises word stopping, punctuation and word segmentation;
the part-of-speech tagging module is used for performing part-of-speech tagging on each vocabulary to obtain the part-of-speech of each vocabulary;
and the coding module is used for coding each vocabulary according to a preset rule to obtain the text vector.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program operable on the processor, and wherein the processor implements the steps of the method of any of claims 1 to 6 when executing the computer program.
10. A computer-readable medium having non-volatile program code executable by a processor, wherein the program code causes the processor to perform the method of any of claims 1 to 6.
CN201811440115.7A 2018-11-28 2018-11-28 Voice query method and device and electronic equipment Expired - Fee Related CN109542929B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811440115.7A CN109542929B (en) 2018-11-28 2018-11-28 Voice query method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811440115.7A CN109542929B (en) 2018-11-28 2018-11-28 Voice query method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN109542929A CN109542929A (en) 2019-03-29
CN109542929B true CN109542929B (en) 2020-11-24

Family

ID=65851196

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811440115.7A Expired - Fee Related CN109542929B (en) 2018-11-28 2018-11-28 Voice query method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN109542929B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112650916A (en) * 2019-10-12 2021-04-13 青岛海信移动通信技术股份有限公司 Communication terminal and information query method
CN110888897B (en) * 2019-11-12 2020-07-14 杭州世平信息科技有限公司 Method and device for generating SQ L statement according to natural language
CN111177180A (en) * 2019-12-11 2020-05-19 北京百分点信息科技有限公司 Data query method and device and electronic equipment
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
CN111324628A (en) * 2020-02-20 2020-06-23 山东爱城市网信息技术有限公司 Unified SQL query method based on Spark SQL
CN111538818B (en) * 2020-03-26 2023-05-12 深圳云天励飞技术有限公司 Data query method, device, electronic equipment and storage medium
CN111813989B (en) * 2020-07-02 2023-07-18 中国联合网络通信集团有限公司 Information processing method, apparatus and storage medium
CN112447300B (en) * 2020-11-27 2024-02-09 平安科技(深圳)有限公司 Medical query method and device based on graph neural network, computer equipment and storage medium
CN113051875B (en) * 2021-03-22 2024-02-02 北京百度网讯科技有限公司 Training method of information conversion model, and text information conversion method and device
CN113407534B (en) * 2021-06-02 2023-11-28 广州零端科技有限公司 Medical data recording method, query method and device
CN113986958B (en) * 2021-11-10 2024-02-09 北京有竹居网络技术有限公司 Text information conversion method and device, readable medium and electronic equipment
CN117271553A (en) * 2023-09-08 2023-12-22 上海浦东发展银行股份有限公司 Method for generating and operating supervision report data quality rule

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101415259A (en) * 2007-10-18 2009-04-22 三星电子株式会社 System and method for searching information of embedded equipment based on double-language voice enquiry
CN104021198A (en) * 2014-06-16 2014-09-03 北京理工大学 Relational database information retrieval method and device based on ontology semantic index
CN106980689A (en) * 2017-03-31 2017-07-25 邢加和 A kind of method that data visualization is realized by interactive voice
CN108287822A (en) * 2018-01-23 2018-07-17 北京容联易通信息技术有限公司 A kind of Chinese Similar Problems generation System and method for

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160255139A1 (en) * 2016-03-12 2016-09-01 Yogesh Chunilal Rathod Structured updated status, requests, user data & programming based presenting & accessing of connections or connectable users or entities and/or link(s)

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101415259A (en) * 2007-10-18 2009-04-22 三星电子株式会社 System and method for searching information of embedded equipment based on double-language voice enquiry
CN104021198A (en) * 2014-06-16 2014-09-03 北京理工大学 Relational database information retrieval method and device based on ontology semantic index
CN106980689A (en) * 2017-03-31 2017-07-25 邢加和 A kind of method that data visualization is realized by interactive voice
CN108287822A (en) * 2018-01-23 2018-07-17 北京容联易通信息技术有限公司 A kind of Chinese Similar Problems generation System and method for

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于语音识别与文字理解的导购机器人设计与实现;程志强;《中国优秀硕士学位论文全文数据库 信息科技辑》;20150315(第03(2015)期);第I140-462页 *

Also Published As

Publication number Publication date
CN109542929A (en) 2019-03-29

Similar Documents

Publication Publication Date Title
CN109542929B (en) Voice query method and device and electronic equipment
TWI636452B (en) Method and system of voice recognition
CN105095204B (en) The acquisition methods and device of synonym
Almeman et al. Automatic building of arabic multi dialect text corpora by bootstrapping dialect words
CN112800201B (en) Natural language processing method and device and electronic equipment
CN111813802A (en) Method for generating structured query statement based on natural language
CN104199965A (en) Semantic information retrieval method
CN110597844A (en) Heterogeneous database data unified access method and related equipment
CN112926345A (en) Multi-feature fusion neural machine translation error detection method based on data enhancement training
CN114817465A (en) Entity error correction method and intelligent device for multi-language semantic understanding
EP4339799A1 (en) Intelligent session method and server based on table data retrieval
CN114266256A (en) Method and system for extracting new words in field
Tasharofi et al. Evaluation of statistical part of speech tagging of Persian text
CN109522396B (en) Knowledge processing method and system for national defense science and technology field
CN116991875B (en) SQL sentence generation and alias mapping method and device based on big model
CN112036179B (en) Electric power plan information extraction method based on text classification and semantic frame
JP4005343B2 (en) Information retrieval system
CN110929514B (en) Text collation method, text collation apparatus, computer-readable storage medium, and electronic device
CN116050397B (en) Method, system, equipment and storage medium for generating long text abstract
CN104239292A (en) Method for acquiring translation of specialized words
CN112287657A (en) Information matching system based on text similarity
CN113822052A (en) Text error detection method and device, electronic equipment and storage medium
CN112434518B (en) Text report scoring method and system
CN116483314A (en) Automatic intelligent activity diagram generation method
CN115129843A (en) Dialog text abstract extraction 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
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20201124

Termination date: 20211128

CF01 Termination of patent right due to non-payment of annual fee