Data query method, data query device and electronic equipment
By receiving natural language questions and using deep learning models and sentence templates to determine the set of query sentence fragments, the problem of inconvenient data query is solved, and the reasonable presentation of data and user-friendly query experience are achieved.
Patent Information
- Application Number
- CN202110450909.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-26
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2041-04-26
AI Technical Summary
In the prior art, data query methods are not convenient enough, and data query is particularly difficult for business personnel who do not have data query knowledge.
By receiving natural language questions input by the user, the deep learning model and preset sentence templates are used to determine the set of query sentence fragments, find the target data, and determine the target presentation method from multiple presentation methods based on the target data, including charts, ad hoc query tables and pivot tables, and send the query results to the user terminal.
It achieves the convenience of data query and reasonable data presentation, improves the user experience, and makes data query more intuitive and easy to view.
Smart Images

Figure CN112989010B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data query method, a data query device, and an electronic device. Background Art
[0002] With the advent of the data age, efficient data utilization has become increasingly important. Data is typically stored in databases. When needed, relevant personnel can query data from the database by writing query statements.
[0003] However, this data query method is not convenient enough, especially for business personnel who do not have data query knowledge, data query is difficult. Summary of the Invention
[0004] The present application provides a data query method, a data query device, and an electronic device.
[0005] In a first aspect, a data query method is provided. The data query method includes: receiving a natural language question input by a user through a user terminal; determining a query statement fragment set based on the natural language question, wherein the query statement fragment set includes fragments of statements in a database query language; searching for target data based on the query statement fragment set; determining a target presentation mode from multiple presentation modes based on the target data, wherein the multiple presentation modes include a chart form, an ad hoc query table form, and a pivot table form; and sending a query result including the target data and the target presentation mode to the user terminal, so that the user terminal displays the target data according to the target presentation mode. In conjunction with the first aspect, in some embodiments, the target presentation mode includes a chart, an ad hoc query table, and a pivot table.
[0006] In combination with the first aspect, in some embodiments, determining the target presentation mode from multiple presentation modes based on the target data includes: determining whether the number of fields contained in the target data exceeds a first threshold; if it is determined that the number of fields of the target data does not exceed the first threshold, determining the target presentation mode as a chart form; if it is determined that the number of fields contained in the target data exceeds the first threshold, determining whether the number of data items contained in the target data exceeds a second threshold; if it is determined that the number of data items contained in the target data does not exceed the second threshold, determining the target presentation mode as an ad hoc query table form; if it is determined that the number of data items contained in the target data exceeds the second threshold, determining the target presentation mode as a pivot table form.
[0007] In combination with the first aspect, in some embodiments, determining a set of query statement fragments based on the natural language question includes: based on the natural language question, determining a first set of query statement fragments using a deep learning model; based on the natural language question, determining a second set of query statement fragments using a preset sentence template; and determining the query statement fragment set based on the first set of query statement fragments and the second set of query statement fragments.
[0008] In combination with the first aspect, in some embodiments, the data query method further includes: determining the target data set based on the natural language question, wherein determining the target data set based on the natural language question includes: determining the similarity of each data set in multiple data sets relative to the natural language question; and determining the target data set from the multiple data sets based on the similarity of each data set relative to the natural language question.
[0009] In combination with the first aspect, in some embodiments, determining the similarity of each of the multiple data sets relative to the natural language question includes: determining multiple keywords from the natural language question; performing similarity comparison between the field names and field members of each of the multiple data sets and the multiple keywords respectively to obtain multiple similarities of each data set relative to the multiple keywords; for each data set, weightedly averaging the multiple similarities of the data set relative to the multiple keywords to obtain a weighted average similarity of each data set; and using the weighted average similarity as the similarity of each data set relative to the natural language question.
[0010] In a second aspect, a data query method is provided. The method includes: sending a natural language question input by a user to a server, so that the server determines a set of query statement fragments based on the natural language question; searching for target data based on the set of query statement fragments; and determining a target presentation mode from multiple presentation modes based on the target data, wherein the set of query statement fragments includes fragments of statements in a database query language, and the multiple presentation modes include a chart form, an ad hoc query table form, and a pivot table form; receiving a query result from the server, the query result including the target data and the target presentation mode; and displaying the target data according to the target presentation mode.
[0011] In a third aspect, a data query device is provided. The data query device includes: a receiving module for receiving a natural language question input by a user through a user terminal; a first determining module for determining a set of query sentence fragments based on the natural language question, wherein the set of query sentence fragments includes fragments of statements in a database query language; a query module for searching for target data based on the set of query sentence fragments; a second determining module for determining a target presentation mode from multiple presentation modes based on the target data, wherein the multiple presentation modes include a chart form, an ad hoc query table form, and a pivot table form; and a sending module for sending a query result including the target data and the target presentation mode to the user terminal, so that the user terminal displays the target data according to the target presentation mode.
[0012] In a fourth aspect, a data query device is provided. The data query device includes: a sending module for sending a natural language question input by a user to a server, so that the server determines a set of query statement fragments based on the natural language question, searches for target data based on the set of query statement fragments, and determines a target presentation mode from multiple presentation modes based on the target data, wherein the set of query statement fragments includes fragments of statements in a database query language, and the multiple presentation modes include a chart form, an ad hoc query table form, and a pivot table form; a receiving module for receiving query results from the server, wherein the query results include the target data and the target presentation mode; and a display module for displaying the target data according to the target presentation mode.
[0013] In a fifth aspect, an electronic device is provided, comprising: a processor coupled to a memory, configured to execute the data query method according to the first aspect or the second aspect based on instructions stored in the memory.
[0014] Querying data based on natural language input makes it more convenient. Determining the target presentation method based on the queried data makes the data presentation more reasonable and easier for users to view. This method of data querying can improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 Shown is a schematic diagram of an application environment of a data query method according to an embodiment of the present application.
[0016] Figure 2 FIG2 is a schematic flow chart of a data query method according to an embodiment of the present application.
[0017] Figure 3Shown is a schematic flowchart of determining a target presentation method of target data according to an embodiment of the present application.
[0018] Figure 4 FIG2 is a schematic flow chart of a method for determining a target data set according to an embodiment of the present application.
[0019] Figure 5 FIG2 is a schematic flow chart of a method for determining the similarity between a data set and a natural language question according to an embodiment of the present application.
[0020] Figure 6 Shown is a flow chart of a method for determining user intention according to an embodiment of the present application.
[0021] Figure 7 Shown is a schematic flow chart of a data query method according to an example of the present application.
[0022] Figure 8 Shown is a schematic flow chart of a data query method according to another embodiment of the present application.
[0023] Figure 9 FIG2 is a schematic structural diagram of a data query device according to an embodiment of the present application.
[0024] Figure 10 Shown is a structural diagram of a data query device according to another embodiment of the present application.
[0025] Figure 11 FIG2 is a schematic structural diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] The following describes embodiments of the present application in more detail with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are for illustrative purposes only and are not intended to limit the scope of protection of the present application.
[0027] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "according to" means "at least in part according to." The term "one embodiment" means "at least one embodiment," and the term "another embodiment" means "at least one additional embodiment." Definitions of other terms are provided in the following description.
[0028] Figure 1 The data query method provided by this application can be applied to Figure 1 In the application environment shown.
[0029] like Figure 1 As shown, the data query method provided in the embodiment of the present application involves a user terminal 100 and a server 200. The user terminal 100 and the server 200 are in communication connection.
[0030] The user terminal 100 may be, for example, but not limited to, a desktop computer, a laptop computer, a tablet computer, a smart phone, etc. The server end 200 may be implemented by, for example, a local server device or a cloud server.
[0031] It should be understood that Figure 1 The application environment shown is merely exemplary and should not constitute any limitation on the functionality and scope of the embodiments described herein.
[0032] Figure 2 FIG2 is a schematic flow chart of a data query method according to an embodiment of the present application.
[0033] like Figure 2 As shown, the data query method S100 may include steps S110 to S150. The data query method S100 may be implemented by a server, for example.
[0034] In step S110 , a natural language question input by a user through a user terminal is received.
[0035] For example, the user terminal may display an interactive interface for the user to input a natural language question. After the user inputs the natural language question, the user terminal may send the natural language question to the server.
[0036] The natural language question input by the user can be in text form or voice form. If the natural language question input by the user is in voice form, it will be converted into text form.
[0037] In step S120 , a query sentence fragment set is determined based on the natural language question.
[0038] The query statement fragment set may include fragments of statements in a database query language.
[0039] The database query language is not specifically limited in the embodiments of the present application. In some embodiments, it may be Structured Query Language (SQL). In some embodiments, it may be Multi-Dimensional Expressions (MDX), a query language for multidimensional databases. In some embodiments, it may be other types of database query languages.
[0040] A query statement fragment set includes fragments of statements in a database query language. A query statement fragment set may include one or more fragments. These fragments can be spliced together to form a complete statement in the database query language. Alternatively, these fragments are code snippets that constitute a complete statement in the database query language.
[0041] Taking structured query language as an example, a complete SQL statement usually includes multiple clauses, such as a select clause, a where clause, and a having clause, etc. In some embodiments, a clause in an SQL statement is a fragment, and a query statement fragment set may include one or more clauses.
[0042] There are various methods for obtaining a set of query fragments based on natural language questions, which are not specifically limited in the present embodiments. For example, a deep learning model with natural language processing capabilities can be used to process natural language questions to obtain a set of query fragments. Alternatively, a set of query fragments can be obtained by manually creating sentence templates (or sentence rules) to establish a sentence template library, and then using the sentence template library to perform semantic analysis on natural language questions to obtain a set of query fragments.
[0043] In step S130 , target data is searched based on the query statement fragment set.
[0044] For example, the server can splice the query statement fragment set to obtain a data query statement. Then, the data query statement can be used to query data from the database, and the data found is the target data.
[0045] In step S140 , a target presentation mode is determined from a plurality of presentation modes according to the target data.
[0046] In existing data query methods, users query data from the database by writing data query statements. The data query results are usually presented in the form of a cross-tab. Then, users can process the query results according to their actual needs to obtain the target presentation method that meets their needs.
[0047] After a user enters a natural language question, if the query results are only presented in a crosstab format, the user needs to process the query results to obtain the desired presentation format. Given that natural language-based data queries are typically targeted at business users who lack data processing skills, changing the target presentation format for query results is difficult for such business users.
[0048] In view of this, after completing the data query, the server can determine a target presentation mode from multiple presentation modes according to the target data. The multiple presentation modes may include, but are not limited to, chart form, ad hoc query table form, and pivot table form.
[0049] In step S150, the query result is sent to the user terminal. The query result includes target data and target presentation mode, so that the server can display the target data according to the target presentation mode.
[0050] It should be understood that the method of presenting data in the form of a chart, an ad hoc query table or a pivot table can refer to the existing technology, and the embodiments of the present application do not make specific limitations on this.
[0051] Querying data based on natural language input makes it more convenient. Determining the target presentation method based on the queried data makes the data presentation more reasonable and easier for users to view. This method of data querying can improve the user experience.
[0052] The present application does not specifically limit how to determine the target presentation method from multiple presentation methods. This can be achieved in a variety of ways, such as by determining the target presentation method based on the data type of the fields contained in the target data, or by determining the target presentation method based on the table name of the data table where the target data is located.
[0053] An exemplary implementation is given below with reference to the accompanying drawings.
[0054] Figure 3 Shown is a schematic flowchart of determining a target presentation method of target data according to an embodiment of the present application.
[0055] refer to Figure 3 In step S141, it is determined whether the number of fields included in the target data exceeds a first threshold.
[0056] A field refers to a column in a data table. A column of data can be called a field.
[0057] It should be understood that the first threshold is not specifically limited in the present embodiment, and those skilled in the art can set it according to actual conditions. The first threshold can be, for example, 2, or 3 or more.
[0058] If the number of fields included in the target data does not exceed the first threshold, step S142 is executed; if the number of fields included in the target data exceeds the first threshold, step S143 is executed.
[0059] It should be understood that not exceeding may mean less than or equal to, and exceeding may mean greater than.
[0060] In step S142 , the target presentation mode is determined to be a chart form.
[0061] When the data contains fewer fields, you can present it in the form of a chart. Presenting the target data in the form of a chart can make the data more intuitive and easier for users to view.
[0062] The chart form may include, but is not limited to, a bar chart, a pie chart, a line chart, etc. The present embodiment does not specifically limit the chart form, and those skilled in the art can set it according to actual needs.
[0063] In step S143 , it is determined whether the number of data items included in the target data exceeds a second threshold.
[0064] A data item refers to the smallest data unit in a data table. A field usually includes multiple data items.
[0065] For example, suppose a data table has two fields: "Year" and "City." The "Year" field contains three data items: "2018," "2019," and "2020." The "City" field contains three data items: "Beijing," "Shanghai," and "Shenzhen." This data table has two fields and six data items.
[0066] It should be understood that the second threshold value is not specifically limited in the present embodiment, and those skilled in the art can set it according to actual conditions. The second threshold value can be, for example, 100, or 200 or more.
[0067] If the number of data items included in the target data does not exceed the second threshold, step S144 is executed; if the number of data items included in the target data exceeds the second threshold, step S145 is executed.
[0068] In step S144 , the target presentation mode is determined to be in the form of an ad hoc query table.
[0069] When the data contains many fields and the amount of data is not particularly large, an ad hoc query table is a better way to present the data target.
[0070] Ad hoc query tables typically include a custom filter area and a data display area. Users can set filter conditions in the custom filter area to quickly obtain the required data.
[0071] In step S145 , the target presentation mode is determined to be a pivot table format.
[0072] When data contains many fields and contains a large amount of data, PivotTables are the best way to present the target data. With PivotTables, users can quickly summarize, analyze, browse, and display data according to actual needs.
[0073] Determining the target presentation method of target data in this way can make the data presentation more reasonable, thereby facilitating user viewing and improving user experience.
[0074] There are many ways to determine a set of query fragments based on a natural language question. The following provides examples to illustrate this.
[0075] In some embodiments, a set of query sentence fragments may be determined based on a natural language question using a deep learning model.
[0076] Specifically, after receiving the natural language question, the server can concatenate the natural language question and the field name of the target dataset to obtain a concatenation result. Then, the concatenation result is input into the deep learning model to obtain a set of query statement fragments output by the deep learning model.
[0077] A dataset refers to a data table stored in a database. A dataset can consist of a single table or multiple tables. A table can be either physical or logical. The target dataset is the dataset corresponding to the natural language question entered by the user. In other words, the user enters a natural language question to find the target data, which is stored in the target dataset.
[0078] In most cases, there are many data tables in the database. In this case, it is necessary to determine the target data set from the database.
[0079] There are many ways to determine the target data set, which is not specifically limited in the embodiments of the present application.
[0080] In some embodiments, the target dataset may be determined based on a natural language question. In some embodiments, an interactive interface may be displayed on the user terminal, displaying multiple datasets for selection, so that the user can manually select the target dataset.
[0081] It should be understood that in some embodiments, the target dataset may not be determined. For example, a database may contain only one data table, or only a few data tables. In this case, there is no need to determine the target dataset; instead, all field names in the database need to be concatenated with the natural language question and the concatenated result input into the deep learning model.
[0082] The server can concatenate the natural language question with the field names of all fields in the target dataset. The concatenation result can be in the form of [CLS], Q, [SEP], C1, T1, [SEP], C2, T2,…, [SEP], Cn,Tn, [SEP].
[0083] [CLS] is the flag, [SEP] is the separator, Q is the natural language question, Ci is the field name of each field in the target dataset, Ti is the data type of each field in the target dataset, i∈(1,n), where n is the number of fields in the target dataset. Data type of a dataset field can include string type (i.e., text type) and numeric type (i.e., real type).
[0084] The deep learning model may include, for example, a BERT model and multiple fully connected layers. The multiple fully connected layers may include, for example, a first fully connected layer, a second fully connected layer, and a third fully connected layer.
[0085] The BERT model can be used to obtain the vector corresponding to the overall splicing result based on the input splicing result , the vector corresponding to the natural language question Q , the vector corresponding to the field name and data type of each field , and the vector corresponding to the flag [CLS] The flag [CLS] is initially a random number and records the vector during the learning process of the deep model. and vector The relationship between so that the BERT model determines the vector corresponding to the flag bit [CLS] based on the input splicing result .
[0086] The vector Input the first fully connected layer, the second fully connected layer, and the third fully connected layer respectively, and transform the vector Input the first fully connected layer and transform the vector Input the second and third fully connected layers. Take the vector of the output result of the first fully connected layer , use the softmax function to predict the connectors between the conditions in the Where clause. Take the vector of the output result of the second fully connected layer , use the softmax function to predict the Select clause and aggregation function. Take the vector of the output result of the third fully connected layer , use the softmax function to predict the Where clause.
[0087] In this way, after inputting the splicing result into the deep learning model, the output results of the Select clause, Where clause, the connectors between the conditions in the Where clause, and the aggregation function output by the deep learning model can be obtained. These output results are the set of query statement fragments. By splicing these output results, a SQL statement capable of data query can be obtained.
[0088] The training method of the deep learning model is a prior art, and the embodiments of the present application do not make specific limitations thereto. Exemplarily, a training set including multiple training samples can be established, and the deep learning model can be trained using the training samples in the training set. Each training sample can include input data and output results. The input data can be the splicing result of a natural language question sentence and the field names and field data types of the target data set, and the output result can be the set of query statement fragments.
[0089] Although, in this embodiment, the data type of the field is added when splicing the natural language question sentence and the field name. However, in other embodiments of the present application, it is also possible to only splice the natural language question sentence and the field name without splicing the data type of the field. Through practical research, it is found that adding the data type of the field when splicing the natural sentence and the field name can significantly improve the accuracy of the query statement elements output by the deep learning model.
[0090] The method for determining the set of query statement fragments based on the natural language question sentence is not limited to this one.
[0091] In some embodiments, based on the natural language question sentence, a preset sentence pattern template can be used to determine the set of query statement fragments.
[0092] The sentence pattern template can be composed of placeholder symbols and empty positions. For example, in the sentence pattern template "X year X", "year" is a placeholder symbol, and "X" before and after "year" represents empty positions.
[0093] There can be many such sentence pattern templates. For example, it can also include "X year X month X" or "X of X", etc.
[0094] These sentence pattern templates can be obtained, for example, by manual writing. By fully analyzing the common expression ways of users, many sentence pattern templates can be summarized and established into a sentence pattern template library.
[0095] It should be understood that the above sentence pattern templates are only for illustrative purposes. The sentence pattern template library does not only include these sentence pattern templates, nor does it necessarily include these templates. Those skilled in the art can write a sufficient number of sentence pattern templates according to this rule to meet the actual requirements.
[0096] After receiving a natural language question, it can be matched with a sentence template to determine a sentence template combination with the highest matching degree from multiple sentence templates. The sentence template combination can include only one sentence template or multiple sentence templates.
[0097] Since most languages, such as Chinese and English, satisfy the projectivity assumption, the matching process described above can find a sentence template combination with the highest matching degree from the sentence template library. This combination covers every word in the natural language question without duplication, omission, or overlap, maximizing the sum of the logarithms of the probabilities of the sentence template combination (i.e., minimizing the sum of the information content).
[0098] For example, the natural language question sentence can be segmented to obtain a segmentation result, and then the segmentation result is matched with the sentence template. Specifically, the matching can be performed based on the placeholders of the sentence template.
[0099] For example, multiple sentence templates in the sentence template library can be matched with natural language questions in a separate and combined comparison mode to obtain a matching score (or similarity score) for each sentence template combination. Optionally, this matching process can be implemented using a recursive algorithm.
[0100] To make the matching process faster, in some embodiments, the sentence template can be read into a Trie tree, and the word segmentation results can be scanned using the Trie to quickly determine the sentence template with the highest matching degree with the natural language question from the sentence template library.
[0101] After the matching is complete, the segmentation results can be segmented based on the matched sentence template combination. Segmentation refers to dividing the segmentation results into multiple word chunks. Each word chunk can include one or more word chunks.
[0102] Then, each word block set can be compared with the field names and field members of the target dataset for similarity to find field names and field members with similarity greater than a preset threshold. Field members refer to the data items contained in each column in the data table.
[0103] Based on the matched field names, the fields to be queried can be determined, from which the Select clause can be derived. Based on the matched field members, the filter conditions (i.e., which field members under a given field are queried) can be determined. Based on this, the Where clause and the connectors between the conditions in the Where clause can be derived. In this way, the second query statement fragment set can be obtained.
[0104] For the purpose of clarity, the above solution is described in detail below by way of examples.
[0105] For example, for the question sentence "sales volume in 2019", word segmentation can be performed first to obtain the word segmentation results: "2019", "year", and "sales volume". Then, the word segmentation results can be matched with the templates in the sentence pattern library, and the template "X year X" is matched. According to this template, the word segmentation results can be segmented into: the word block "2019 year" and the word block "sales volume". By matching the word block "2019 year" and the word block "sales volume" with the field names and field members of the target data set respectively, the field with the field name "year" and the field member "2019 year" of this field, as well as the field with the field name "sales volume" can be matched. In this way, query statement fragments such as the Select clause and the Where clause can be obtained.
[0106] For example, for the question sentence "sales volume of Toyota cars in 2019", word segmentation can be performed first to obtain the word segmentation results: "2019", "year", "Toyota", "car", "of", and "sales volume". Then, the word segmentation results can be matched with the templates in the sentence pattern library, and the template "X year X" and the template "X of X" are combined to obtain the template "X year X of X". According to this template, the word segmentation results can be segmented into: the word block "2019 year", the word block "Toyota cars", and the word block "sales volume". By matching these word blocks with the field names and field members of the target data set respectively, the field with the field name "year" and the field member "2019 year" of this field, the field with the field name "sales volume", as well as the field with the field name "automobile manufacturer" and the field member "Toyota" under this field can be matched. In this way, the corresponding query statement fragments can be obtained.
[0107] Considering the complexity of data query requirements, in order to meet complex query requirements, in some embodiments, the sentence pattern template can include a first type of template and a second type of template. If the matched sentence pattern template combination only includes the first type of template, the above scheme can be used for processing; if it includes the second type of template, it needs to be processed according to the preset processing rules.
[0108] Specifically, multiple processing rules can be set so that each second type of template has a corresponding processing rule. In this way, when the second type of template is matched, it can be processed according to the corresponding processing rule.
[0109] For example, the second type of template can include "in the past X months X", "X before X of X", and so on.
[0110] For example, the question "Sales volume in the last three months" can be matched to the template "X in the last X months." After segmentation, the resulting chunks are "last three months" and "sales volume." The rule corresponding to this type of sentence template is a replacement rule, which replaces at least one of the chunks after segmentation. Specifically, if the current month is March, the chunk "last three months" can be replaced with the chunks "January," "February," and "March." The replaced chunks are then matched with the field names and field members of the target dataset to obtain the corresponding query statement fragments.
[0111] For example, the question "Top 5 car companies by sales in 2019" can be matched to the combination of the template "X year X" and the template "X before X of X", that is, "X year X before X of X". After segmentation, the resulting chunks are "2019", "Top 5 sales", and "car companies". The chunks "2019" and "car companies" can be directly matched with the field names and field members of the target dataset. Specifically, the chunk "2019" can be used to identify the field named "Year" and the field member "2019"; the chunk "car companies" can be used to identify the field named "car companies", thus obtaining the query fragments corresponding to these two chunks. For the chunk "Top 5 sales", after matching, the field named "Sales" can be determined, resulting in a Select clause. Then, the top 5 field members sorted under this field can be identified, resulting in a Where clause, thus obtaining the corresponding query fragment.
[0112] It should be understood that the embodiments of the present application do not specifically limit the second type of templates and the corresponding processing rules, and those skilled in the art can set them according to actual needs.
[0113] In some embodiments, two sets of query fragments may be obtained using a deep learning model and a sentence template, respectively, and then the two sets of query fragments may be merged to obtain a merged set of query fragments. The merged set of query fragments may then be used to perform data query.
[0114] Combining deep learning models and sentence templates can improve the accuracy and comprehensiveness of query statement fragment sets, thereby improving the accuracy and effectiveness of data query results.
[0115] Exemplarily, a deep learning model can be used to obtain a first set of query statement fragments, and a sentence template can be used to obtain a second set of query statement fragments. Then, the first set of query statement fragments and the second set of query statement fragments are merged. The merging method can be, for example: retaining portions that are unique to the first set of query statement fragments or the second set of query statement fragments; performing deduplication processing on portions that are identical to and shared by both the first set of query statement fragments and the second set of query statement fragments; and deleting portions that are different from and shared by both the first set of query statement fragments and the second set of query statement fragments, based on either the first set of query statement fragments or the second query condition.
[0116] Taking the Structured Query Language as an example, if the first query statement fragment set includes: Select clause (S1) and Where clause (W1), and the second query statement fragment set includes: Where clause (W2) and ORDER BY clause (O1), S1 and O1 are parts unique to the first query statement fragment set and the second query statement fragment set, respectively. If the contents of W1 and W2 are the same, then W1 and W2 are the same parts that both the first query statement fragment set and the second query statement fragment set have; if the contents of W1 and W2 are different, then W1 and W2 are different parts that both the first query statement fragment set and the second query statement fragment set have.
[0117] Practice has shown that query fragment sets obtained using sentence templates are more accurate than deep learning models. Therefore, in certain preferred embodiments, when merging the first and second query fragment sets, for any portions that differ between the first and second query fragment sets, the second query fragment set may be used as the primary control, i.e., retaining those portions of the second query fragment set and deleting those portions of the first query fragment set.
[0118] Considering that in some application scenarios, it is necessary to determine a target dataset from multiple datasets in a database, in some embodiments, the data query method of the aforementioned embodiment may further include the step of determining the target dataset based on a natural language question.
[0119] Figure 4 FIG2 is a schematic flow chart of a method for determining a target data set according to an embodiment of the present application.
[0120] like Figure 4 As shown, the method S400 for determining a target data set may include steps S410 and S420. The method S400 may be implemented by a server.
[0121] In step S410 , the similarity of each of the plurality of data sets with respect to the natural language question is determined.
[0122] Specifically, the server can perform similarity comparisons between multiple data sets in the database and the natural language questions, thereby determining the similarity of each data set with respect to the natural language questions.
[0123] There are many methods for determining the similarity of each data set to a natural language question, which are not specifically limited in the present embodiment. An exemplary implementation is given below in conjunction with the accompanying drawings.
[0124] Figure 5 4 is a schematic flowchart of a method for determining the similarity between a data set and a natural language question according to an embodiment of the present application.
[0125] like Figure 5 As shown, the method includes steps S411 to S414. The method can be implemented by the server.
[0126] In step S411 , a plurality of keywords are determined from the natural language question.
[0127] For example, if the natural language question is "Check the sales in Shanghai in 2020", the keywords "2020", "Shanghai" and "sales" can be determined.
[0128] There are many ways to determine keywords, which are not specifically limited in the embodiments of the present application. For example, the TF-IDF (Term Frequency-Inverse Document Frequency) algorithm can be used to extract keywords from natural language questions.
[0129] In step S412 , the field names and field members of each of the multiple data sets are respectively compared with the multiple keywords for similarity, so as to obtain multiple similarities of each data set with respect to the multiple keywords.
[0130] Specifically, all field names and field members in each dataset can be compared for similarity with each keyword in the multiple keywords. A field name refers to the identifier of each column in a data table, or the name of each column. A field member refers to the data items contained in each column in a data table.
[0131] For example, if a dataset only contains the fields "Year" and "City," the "Year" field only contains the three field members "2018," "2019," and "2020." The "City" field only contains the three field members "Beijing," "Shanghai," and "Shenzhen."
[0132] When comparing the similarity between the dataset and a keyword, the keyword can be compared with the field names "year" and "city" respectively, and the keyword can be compared with the field members "2018", "2019", "2020", "Beijing", "Shanghai" and "Shenzhen" respectively. In this way, the similarities a1 and a2 of the keyword relative to the field names "year" and "city" can be obtained, as well as the similarities b1, b2, b3, b4, b5 and b6 of the keyword relative to the field members "2018", "2019", "2020", "Beijing", "Shanghai" and "Shenzhen". Finally, by adding a1, a2, b1, b2, b3, b4, b5 and b6, the similarity R of the dataset relative to the keyword can be obtained. i In this way, multiple phase velocities R1, R2, ... R of the data set relative to multiple keywords can be obtained. n , where n is the number of keywords.
[0133] In step S413 , for each data set, a weighted average of multiple similarities with respect to multiple keywords is performed to obtain a weighted average similarity of each data set.
[0134] Specifically, if the similarity of a data set to each keyword in multiple keywords is R1, R2...R n , then R1, R2...R n Weighted average is performed to obtain the weighted average similarity R of the data set.
[0135] In step S414 , the weighted average similarity is used as the similarity of each data set to the natural language question.
[0136] After the server determines the weighted average similarity of each data set, the weighted average similarity can be used as the similarity of each data set relative to the natural language question.
[0137] Optionally, in some embodiments, steps S412 and S413 can be implemented by a SIM-BERT model. Specifically, the correspondence between the field names and field members contained in each data set can be sorted into a knowledge graph, and the knowledge graph can be input into the trained SIM-BERT model to obtain a vector corresponding to each data set. Then, multiple keywords determined from the natural language question can be input into the SIM-BERT model to obtain a vector corresponding to each keyword. Then, the corresponding vector of each data set and the vector corresponding to each keyword are matched separately using the SIM-BERT model. The matching rule can be to calculate the similarity of each keyword with the field name and field member of each data set, thereby performing a weighted average of the multiple similarities of each data set relative to the multiple keywords to obtain a weighted average similarity of each data set.
[0138] By comparing the similarity of all field names and all field members of each dataset with each keyword, the similarity between each dataset and the natural language question can be accurately determined, thereby improving the accuracy of determining the target dataset.
[0139] In step S420, the target dataset is determined from the multiple datasets based on the similarity of each dataset to the natural language question.
[0140] In some embodiments, the dataset with the highest similarity to the natural language question among the multiple datasets can be determined as the target dataset. This setting can ensure the accuracy of the data contained in the target dataset.
[0141] In some embodiments, a similarity threshold may be set to determine one or more datasets among multiple datasets whose similarity to the natural language question is greater than the threshold as the target dataset. This setting can ensure the comprehensiveness of the data contained in the target dataset.
[0142] By determining the similarity of multiple data sets relative to natural language questions, a target data set is determined from multiple data sets.
[0143] Considering that in some application scenarios, the user's intention is not to query data, if the natural language question is directly processed as a data query, it is very likely that no data query results will be obtained. Since the user's intention is not to query data, even if a data query result is obtained by chance, it still cannot meet the user's actual needs.
[0144] To solve this problem, in some embodiments, the data query method of the aforementioned embodiment may further include the step of determining the user's intention based on a natural language question.
[0145] There may be multiple user intentions. A careful study shows that user intentions may include: querying data and / or opening existing reports and / or chatting, etc.
[0146] Optionally, in some embodiments, step S120 of method S100 may include: when the server determines that the user's intention is to query data, determining a set of query sentence fragments based on a natural language question.
[0147] That is, when it is determined that the user's intention is to query data, steps S120 to S150 in method S100 may be executed to implement data query.
[0148] Optionally, in some embodiments, method S100 may further include the steps of: when the server determines that the user's intention is to find an existing report, determining a target existing report corresponding to the natural language question, and sending the target existing report to the user terminal for display on the user terminal.
[0149] Existing reports are reports created by the current user or other users. Unlike querying data, identifying an existing report simply requires finding the target report from multiple existing reports, without generating a query statement.
[0150] Optionally, in some embodiments, method S100 may further include the steps of: when the server determines that the user's intention is to chat, determining a response corresponding to the natural language question, and sending the determined response to the user terminal for display on the user terminal.
[0151] Small talk refers to answers to frequently asked questions (FAQs). A knowledge base can be established for these questions, and then corresponding answers can be found in the knowledge base based on natural language questions. For implementation of FAQs, please refer to the prior art and are not specifically limited in this embodiment.
[0152] By determining the user's intention, the user's actual needs are better met and the user experience is improved.
[0153] There are many ways to determine the user's intention, which are not specifically limited in the present embodiment. An exemplary implementation is given below in conjunction with the accompanying drawings.
[0154] Figure 6 Shown is a flow chart of a method for determining user intention according to an embodiment of the present application.
[0155] like Figure 6 As shown, method S600 includes steps S610 to S660. Method S600 can be implemented by the server.
[0156] In step S610 , it is determined whether a preset indicator word exists in the natural language question sentence.
[0157] For example, the server may extract multiple keywords from a natural language question, and then determine whether a preset indicator word exists among the multiple keywords.
[0158] The preset indicator word is used to indicate that the user's intention is to find an existing report.
[0159] The present embodiment does not specifically limit the preset indicator words. For example, the preset indicator words may include "open". For example, the preset indicator words may also include "report".
[0160] If the preset indicator word exists in the natural language question, step S620 is executed; if not, step S640 is executed.
[0161] In step S620 , it is determined whether a target existing report exists in the plurality of existing reports.
[0162] For example, if a preset indicator word exists in a natural language question, the server can determine whether there is a target existing report in the multiple existing reports based on the similarity of each existing report in the multiple existing reports to the natural language question. The similarity of the target existing report to the natural language question is greater than a preset threshold.
[0163] Specifically, the server may first determine the similarity of each existing report to the natural language question, and then compare the similarity of each existing report to the natural language question with the preset threshold to determine whether the target existing report exists in the multiple existing reports.
[0164] The method for determining the similarity of each existing report to the natural language question can be found in Figure 5 The method for determining the similarity between a dataset and a natural language question is shown. Specifically, the field names and field members of each existing report can be compared with multiple keywords for similarity to determine multiple similarities of each existing report with respect to the multiple keywords. Then, for each existing report, the multiple similarities with respect to the multiple keywords are weighted averaged to obtain a weighted average similarity for each existing report. Finally, the weighted average similarity of each existing report is used as the similarity of each existing report with respect to the natural language question.
[0165] If the target existing report exists in the multiple existing reports, step S630 is executed; if not, step S640 is executed.
[0166] In step S630 , the user's intention is determined to be to search for an existing report.
[0167] For example, if the target report exists among the multiple reports, the server determines that the user's intention is to search for the existing report, and then sends the target report to the user terminal so that the target report is displayed on the user terminal.
[0168] In step S640 , it is determined whether a target data set exists in the plurality of data sets.
[0169] Specifically, the server may first determine the similarity of each data set to the natural language question, and then compare the similarity of each data set to the natural language question with a preset threshold, thereby determining whether the target data set exists in the multiple data sets.
[0170] The method for determining the similarity of each dataset relative to the natural language question can be found in Figure 5 The method for determining the similarity between a dataset and a natural language question is shown. Specifically, the field names and field members of each dataset can be compared with multiple keywords for similarity to determine multiple similarities of each dataset with respect to the keywords. Then, for each dataset, the multiple similarities with respect to the keywords are weighted averaged to obtain a weighted average similarity for each dataset. Finally, the weighted average similarity of each dataset is used as the similarity of each dataset with respect to the natural language question.
[0171] If the target data set exists in the multiple data sets, step S650 is executed; if not, step S660 is executed.
[0172] In step S650 , the user's intention is determined as query data.
[0173] For example, if the target dataset exists in the plurality of datasets, the server may determine the user's intention as querying data, and then execute the data query method according to the aforementioned embodiment.
[0174] In step S660, the user's intention is determined to be small talk.
[0175] For example, if the target dataset does not exist in the multiple datasets, the server may determine that the user's intention is to chat. The server may then determine a response corresponding to the natural language question and send the response to the user terminal so that the response is displayed on the user terminal.
[0176] The method for determining user intention provided by this embodiment can accurately determine the user intention, meet actual usage needs, and improve user experience.
[0177] Figure 7 Shown is a schematic flow chart of a data query method according to an example of the present application.
[0178] like Figure 7 As shown, the example S700 includes steps S710 to S770. This example can be implemented by the server.
[0179] In step S710 , a natural language question is received from a user terminal.
[0180] In step S720, it is determined whether a preset indicator word exists in the natural language question sentence. If yes, step S730 is executed; if not, step S750 is executed.
[0181] The method for determining whether a preset indicator word exists in a natural language question can be referred to the aforementioned embodiment, and for the sake of simplicity, it is not described here in detail.
[0182] In step S730, it is determined whether the target existing report exists in the plurality of existing reports. If so, step S740 is executed; if not, step S750 is executed.
[0183] The method for determining whether a target existing report exists among multiple existing reports can be found in the aforementioned embodiment, and for the sake of brevity, it will not be described in detail here.
[0184] In step S740 , the target existing report is sent to the user terminal so that the user terminal displays the target existing report.
[0185] In step S750, it is determined whether the target data set exists in the plurality of data sets, and if so, step S760 is executed; if not, step S770 is executed.
[0186] The method for determining whether a target data set exists in multiple data sets can be found in the aforementioned embodiment, and for the sake of simplicity, it is not described here in detail.
[0187] In step S760 , a query statement fragment set is determined, a data query is performed, and the data query result is sent to the user terminal.
[0188] The method of generating a query statement can be found in the aforementioned embodiment, and for the sake of simplicity, it will not be described here in detail.
[0189] In step S770, a response corresponding to the natural language question is determined, and the determined response is sent to the user terminal.
[0190] The method for determining the answer corresponding to the natural language question can be found in the above embodiment, and for the sake of simplicity, it is not described here in detail.
[0191] Combined with the above Figures 2 to 7 , describes in detail the embodiment of the data query method on the server side of the present application, and the following is combined with Figure 8, describes in detail an embodiment of the data query method on the user terminal side of the present application. The descriptions on the user terminal side and the server side correspond to each other, and for the sake of brevity, repeated descriptions are appropriately omitted.
[0192] Figure 8 Shown is a schematic flow chart of a data query method according to another embodiment of the present application.
[0193] like Figure 8 As shown, the data query method S800 includes steps S810 to S830. The data query method S800 can be implemented by a user terminal.
[0194] In step S810, the natural language question input by the user is sent to the server.
[0195] After receiving the natural language question, the server can determine a set of query fragments based on the natural language question. The server can then search for target data based on the set of query fragments. The server can then determine a target presentation method from among multiple presentation methods based on the target data.
[0196] In step S820, the query result is received from the server.
[0197] The query result may include, for example, target data and target presentation mode determined by the server.
[0198] In step S830, the target data is displayed according to the target presentation mode.
[0199] Querying data based on natural language input makes it more convenient. Determining the target presentation method based on the queried data makes the data presentation more reasonable and easier for users to view. This method of data querying can improve the user experience.
[0200] In some embodiments, the target presentation manner may include, for example, a chart form, an ad hoc query table form, and a pivot table form.
[0201] Combined with the above Figures 2 to 7 , describes in detail the server-side method embodiment of the present application, and the following is combined with Figure 9 , describes in detail the device embodiment of the server side of the present application. The description of the method embodiment corresponds to the description of the device embodiment. For the sake of brevity, repeated descriptions are appropriately omitted.
[0202] Figure 9 FIG2 is a schematic structural diagram of a data query device according to an embodiment of the present application.
[0203] like Figure 9As shown, the data query device 900 includes: a receiving module 910 , a first determining module 920 , a query module 930 , a second determining module 940 and a sending module 950 .
[0204] The receiving module 910 is configured to receive a natural language question input by a user through a user terminal.
[0205] The first determining module 920 is configured to determine a set of query sentence segments based on a natural language question.
[0206] The query module 930 is used to search for target data based on a set of query statement fragments.
[0207] The second determining module 940 is configured to determine a target presentation mode from a plurality of presentation modes according to the target data.
[0208] The sending module 950 is configured to send the query result including the target data and the target presentation mode to the user terminal, so that the user terminal can display the target data according to the target presentation mode.
[0209] Querying data based on natural language input makes it more convenient. Determining the target presentation method based on the queried data makes the data presentation more reasonable and easier for users to view. This method of data querying can improve the user experience.
[0210] In some embodiments, the various presentation modes may include, for example but not limited to, a chart form, an ad hoc query table form, and a pivot table form.
[0211] In some embodiments, the second determination module 940 can be used to: determine whether the number of fields contained in the target data exceeds a first threshold; when it is determined that the number of fields contained in the target data does not exceed the first threshold, determine the target presentation mode as a chart form; when it is determined that the number of fields contained in the target data exceeds the first threshold, determine whether the number of data items contained in the target data exceeds a second threshold; when it is determined that the number of data items contained in the target data does not exceed the second threshold, determine the target presentation mode as an ad hoc query table form; when it is determined that the number of data items contained in the target data exceeds the second threshold, determine the target presentation mode as a pivot table form.
[0212] In some embodiments, the first determination module 920 can be used to: determine a first query statement fragment set based on a natural language question using a deep learning model; determine a second query statement fragment set based on a natural language question using a preset sentence template; and determine a query statement fragment set based on the first query statement fragment set and the second query statement fragment set.
[0213] In some embodiments, the data query apparatus 900 may further include a target dataset determination module, which may include a similarity determination unit and a dataset determination unit.
[0214] The similarity determination unit may be configured to determine a similarity between each of the plurality of data sets and the natural language question.
[0215] Specifically, the similarity determination unit can be used to: determine multiple keywords from a natural language question; compare the field names and field members of each of the multiple data sets with the multiple keywords respectively to obtain multiple similarities of each data set relative to the multiple keywords; for each data set, weighted average the multiple similarities of the data set relative to the multiple keywords to obtain a weighted average similarity of each data set; and use the weighted average similarity as the similarity of each data set relative to the natural language question.
[0216] The data set determining unit may be configured to determine a target data set from a plurality of data sets according to a similarity of each data set to a natural language question.
[0217] Combined with the above Figure 8 , describes in detail the method embodiment of the user terminal side of the present application, and the following is combined with Figure 10 , describes in detail the device embodiment of the user terminal side of the present application. The description of the method embodiment corresponds to the description of the device embodiment, and for the sake of brevity, repeated descriptions are appropriately omitted.
[0218] Figure 10 Shown is a structural diagram of a data query device according to another embodiment of the present application.
[0219] like Figure 10 As shown, the data query device 1000 includes: a sending module 1010 , a receiving module 1020 and a display module 1030 .
[0220] The sending module 1010 is configured to send the natural language question input by the user to the server. Upon receiving the natural language question, the server may determine a set of query fragments based on the natural language question. The server may then search for target data based on the set of query fragments. The server may then determine a target presentation method from among multiple presentation methods based on the target data.
[0221] The server side can determine the target presentation method of the target data.
[0222] The receiving module 1020 is used to receive the query result from the server. The query result may include target data and target presentation mode.
[0223] The display module 1030 is used to display the target data according to the target presentation mode.
[0224] Querying data based on natural language input makes it more convenient. Determining the target presentation method based on the queried data makes the data presentation more reasonable and easier for users to view. This method of data querying can improve the user experience.
[0225] In some embodiments, the various presentation modes may include, for example, a chart form, an ad hoc query table form, and a pivot table form.
[0226] Figure 11 FIG2 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
[0227] like Figure 11 As shown, the electronic device 1100 includes: a processor 1120 coupled to the memory 1110 , configured to execute the data query method or query statement generation method in the aforementioned embodiment based on instructions stored in the memory 1110 .
[0228] Other embodiments of the present application further provide a computer-readable storage medium storing instructions for executing the data query method or query statement generation method in the aforementioned embodiments.
[0229] Another embodiment of the present application further provides a computer program product, which includes codes for executing the data query method or query statement generation method in the aforementioned embodiments.
[0230] It should be understood that although the terms "first" or "second" may be used in this application to describe various elements (such as a set of query statement fragments), these elements are not limited by these terms, and these terms are only used to distinguish one element from another.
[0231] In the above embodiments, all or part of the embodiments can be implemented using software, hardware, firmware, or any other combination. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with the embodiments of the present invention are fully or partially generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0232] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0233] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0234] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0235] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0236] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A data query method, characterized in that: include: Receiving a natural language question input by a user through a user terminal; Determine a splicing result based on the natural language question and the target dataset, wherein the splicing result includes the natural language question and the field name and data type of each field of the target dataset; Inputting the splicing result into a deep learning model to obtain a first query statement fragment set, and using a sentence template to obtain a second query language fragment set based on the splicing result; Merging the first query statement fragment set and the second query statement fragment set to determine the query statement fragment set, wherein the query statement fragment set includes fragments of statements in a database query language; Searching for target data based on the query statement fragment set; Determining a target presentation mode from a plurality of presentation modes according to the number of fields and the number of data items included in the target data, wherein the plurality of presentation modes include a chart form, an ad hoc query table form, and a pivot table form; as well as sending a query result including the target data and the target presentation mode to the user terminal so that the user terminal displays the target data according to the target presentation mode, The method further includes: determining the target data set based on the natural language question, wherein The determining the target data set based on the natural language question includes: determining a plurality of keywords from the natural language question; performing similarity comparisons on the field names and field members of each data set in the plurality of data sets and the plurality of keywords respectively, so as to obtain a plurality of similarities of each data set with respect to the plurality of keywords; For each of the data sets, performing a weighted average of multiple similarities with respect to multiple keywords to obtain a weighted average similarity of each data set; Taking the weighted average similarity as the similarity of each data set relative to the natural language question; The target data set is determined from the multiple data sets according to the similarity of each data set to the natural language question.
2. The data query method according to claim 1, characterized in that: The determining of a target presentation mode from a plurality of presentation modes according to the number of fields and the number of data items included in the target data includes: Determining whether the number of fields included in the target data exceeds a first threshold; If it is determined that the number of fields of the target data does not exceed the first threshold, determining the target presentation mode to be a chart form; If it is determined that the number of fields included in the target data exceeds the first threshold, determining whether the number of data items included in the target data exceeds a second threshold; If it is determined that the number of data items included in the target data does not exceed the second threshold, determining the target presentation mode to be an ad hoc query table form; When it is determined that the number of data items included in the target data exceeds the second threshold, the target presentation mode is determined to be a pivot table format.
3. A data query device, characterized in that: include: A receiving module, configured to receive a natural language question input by a user through a user terminal; A first determining module is configured to determine a query statement fragment set based on the natural language question, wherein the query statement fragment set includes fragments of statements in a database query language; A query module, configured to search for target data based on the query statement fragment set; a second determining module, configured to determine a target presentation mode from a plurality of presentation modes according to the number of fields and the number of data items included in the target data, wherein the plurality of presentation modes include a chart form, an ad hoc query table form, and a pivot table form; as well as a sending module, configured to send a query result including the target data and the target presentation mode to the user terminal, so that the user terminal displays the target data according to the target presentation mode, wherein The first determining module is configured to determine a splicing result based on the natural language question and the target dataset, wherein the splicing result includes the natural language question and the field name and data type of each field of the target dataset; Inputting the splicing result into a deep learning model to obtain a first query statement fragment set, and using a sentence template to obtain a second query language fragment set for the splicing result; merging the first query statement fragment set and the second query statement fragment set to determine the query statement fragment set, The first determination module is further configured to determine the target data set based on the natural language question, wherein determining the target data set based on the natural language question comprises: determining a plurality of keywords from the natural language question; performing a similarity comparison between the field names and field members of each of the plurality of data sets and the plurality of keywords, respectively, to obtain a plurality of similarities of each data set relative to the plurality of keywords; for each data set, weightedly averaging the plurality of similarities relative to the plurality of keywords, to obtain a weighted average similarity of each data set; using the weighted average similarity as the similarity of each data set relative to the natural language question; and determining the target data set from the plurality of data sets based on the similarity of each data set relative to the natural language question.
4. An electronic device, characterized in that: include: A processor coupled to the memory is configured to execute the data query method according to claim 1 or 2 based on instructions stored in the memory.
Citation Information
Patent Citations
Method and device for determining answers of question data
CN110245240A
Index data acquisition method and device, computer equipment and storage medium
CN111324716A
Database query method and device and computer readable storage medium
CN111274267A