A query statement generation method and device

By extracting query keywords from text information and determining slot types, query statements are generated, solving the problems of low accuracy and difficulty in cross-domain migration in existing technologies, and achieving efficient and accurate query statement generation.

CN114064861BActive Publication Date: 2026-01-23ALIBABA GROUP HOLDING LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010761820.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-31
Publication Date
2026-01-23
Estimated Expiration
2040-07-31

AI Technical Summary

Technical Problem

Existing technologies have low accuracy and are difficult to transfer across domains when converting text information into computer-understandable query statements, especially when not in a pre-defined information-query statement pair, and end-to-end models have strong domain dependencies.

Method used

By extracting query keywords from text information and determining their corresponding slot types, a query statement is generated. The query statement is then generated by using the results information from a preset database, including steps such as entity word matching, data type determination, and syntactic analysis.

Benefits of technology

It improves the processing efficiency and accuracy of query statement generation, and can adapt to query needs in various fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114064861B_ABST
    Figure CN114064861B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a query statement generation method and device, comprising: obtaining text information; extracting a query keyword from the text information; determining a slot type corresponding to the query keyword according to the text information; and generating a query statement using the query keyword and the slot type corresponding to the query keyword. The query keyword and the slot type corresponding to the query keyword can be directly determined from the text information, and a query statement can be generated to query a database, which can improve processing efficiency and obtain a higher accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of text processing, in particular to a query statement generation method and a query statement generation device. BACKGROUND

[0002] In the prior art, in order to realize the interaction between a person and a computer, the computer can usually obtain text information input by the person, convert the text information into a query statement that can be understood by the computer, and return an answer corresponding to the query statement.

[0003] However, in order to convert the text information into a query statement that can be understood by the computer, a large number of preset text information-query statement pairs are usually required to train a model or establish a grammar database. However, if the obtained text information does not exist in the preset text information-query statement pairs, the accuracy is likely to be reduced. In addition, end-to-end model training has strong dependence on the field, and it is difficult to migrate a model trained in one field to a new field. SUMMARY

[0004] In view of the above problems, the present application is proposed to provide a query statement generation and a corresponding query statement generation device to overcome the above problems or at least partially solve the above problems.

[0005] In order to solve the above problems, the present application discloses a query statement generation method, comprising:

[0006] obtaining text information;

[0007] extracting a query keyword from the text information;

[0008] determining a slot type corresponding to the query keyword according to the text information;

[0009] generating a query statement by using the query keyword and the slot type corresponding to the query keyword;

[0010] finding query result information corresponding to the query statement in a preset database.

[0011] Optionally, the step of extracting a query keyword from the text information comprises:

[0012] extracting a candidate keyword and a data type corresponding to the candidate keyword from the text information;

[0013] determining a target keyword as a query keyword from the candidate keyword according to the data type corresponding to the candidate keyword.

[0014] Optionally, the database includes at least one preset entity data and the data type corresponding to the preset entity data;

[0015] The step of extracting candidate keywords and their corresponding data types from the text information includes:

[0016] Extract candidate entity words from the text information that match preset entity data in the database;

[0017] The target entity word is determined from the candidate entity words as candidate keywords, and the data type corresponding to the candidate keywords is determined.

[0018] Optionally, the step of determining the target entity word from the candidate entity words as candidate keywords, and determining the data type corresponding to the candidate keywords, includes:

[0019] Based on the similarity between the candidate entity words and the preset entity data, target entity words are determined from the candidate entity words as candidate keywords;

[0020] The data type corresponding to the preset entity data that matches the candidate keyword is taken as the data type corresponding to the candidate keyword.

[0021] Optionally, the step of determining the target entity word as a candidate keyword from the candidate entity words based on the similarity between the candidate entity words and the preset entity data includes:

[0022] A preset entity annotation model is used to determine the entity type probability corresponding to candidate entity words in the text information;

[0023] Based on the similarity between the candidate entity words and the preset entity data, and the entity type probability corresponding to the candidate entity words, target entity words are determined from the candidate entity words as candidate keywords.

[0024] Optionally, the step of determining the target keyword from the candidate keywords as the query keyword based on the data type corresponding to the candidate keywords includes:

[0025] Replace the candidate keywords in the text information with the data types corresponding to the candidate keywords to obtain candidate language information;

[0026] A preset language model is used to determine the grammatical probability corresponding to the candidate language information;

[0027] Based on the grammatical probabilities, the target keyword is determined from the candidate keywords and used as the query keyword.

[0028] Optionally, the step of determining the slot type corresponding to the query keyword based on the text information includes:

[0029] Replace the query keywords in the text information with the data types corresponding to the query keywords to obtain query language information;

[0030] Perform syntactic analysis on the query language information to determine the corresponding syntax tree;

[0031] The syntactic tree is used to determine the slot type corresponding to the query keyword.

[0032] Optionally, the data type includes at least one of metadata, dimension attributes, metrics, dimension enumeration values, and time values;

[0033] The step of determining the slot type corresponding to the query keyword based on the text information includes:

[0034] Determine whether the data type corresponding to the query keyword contains metadata;

[0035] If the data type corresponding to the query keyword contains metadata, then the slot type corresponding to the query keyword is determined based on the text information.

[0036] Optionally, the step of determining the slot type corresponding to the query keyword further includes:

[0037] If the data type corresponding to the query keyword does not contain metadata, then determine whether the historical text information contains historical query keywords whose data type is metadata;

[0038] If the historical text information contains historical query keywords with data type metadata, then the historical query keywords and the slot type of the query keywords are determined based on the historical text information.

[0039] If the historical text information does not contain historical query keywords with data type metadata, then the query keywords are used to determine metadata keywords with data type metadata; based on the text information, the slot type of the metadata keywords and the query keywords is determined.

[0040] Optionally, the method further includes:

[0041] A preset text classification model is used to determine the intent category corresponding to the text information.

[0042] This application also discloses a query statement generation apparatus, comprising:

[0043] The acquisition module is used to acquire text information;

[0044] The extraction module is used to extract query keywords from the text information;

[0045] The slot type determination module is used to determine the slot type corresponding to the query keyword based on the text information.

[0046] The generation module is used to generate a query statement using the query keywords and the slot type corresponding to the query keywords;

[0047] The search module is used to search for the query result information corresponding to the query statement in a preset database.

[0048] Optionally, the extraction module includes:

[0049] The candidate keyword extraction submodule is used to extract candidate keywords and the data types corresponding to the candidate keywords from the text information.

[0050] The query keyword determination submodule is used to determine the target keyword from the candidate keywords based on the data type corresponding to the candidate keywords, and use it as the query keyword.

[0051] Optionally, the database includes at least one preset entity data and the data type corresponding to the preset entity data;

[0052] The candidate keyword extraction submodule includes:

[0053] The candidate entity word extraction unit is used to extract candidate entity words from the text information that match preset entity data in the database;

[0054] The candidate keyword extraction unit is used to identify target entity words from the candidate entity words as candidate keywords, and to determine the data type corresponding to the candidate keywords.

[0055] Optionally, the candidate keyword extraction unit includes:

[0056] The candidate keyword extraction subunit is used to determine the target entity word as a candidate keyword based on the similarity between the candidate entity word and the preset entity data.

[0057] The data type determination unit is used to determine the data type corresponding to the preset entity data that matches the candidate keyword as the data type corresponding to the candidate keyword.

[0058] Optionally, the candidate keyword extraction subunit is specifically used to use a preset entity annotation model to determine the entity type probability corresponding to the candidate entity words in the text information; based on the similarity between the candidate entity words and the preset entity data, and the entity type probability corresponding to the candidate entity words, to determine the target entity words as candidate keywords.

[0059] Optionally, the query keyword determination submodule includes:

[0060] A candidate language information acquisition unit is used to replace candidate keywords in the text information with the data type corresponding to the candidate keywords to obtain candidate language information;

[0061] The syntax probability determination unit is used to determine the syntax probability corresponding to the candidate language information using a preset language model;

[0062] The query keyword determination unit is used to determine the target keyword from the candidate keywords based on the grammatical probability, and use it as the query keyword.

[0063] Optionally, the slot type determination module includes:

[0064] The query language information acquisition submodule is used to replace the query keywords in the text information with the data types corresponding to the query keywords to obtain query language information.

[0065] The syntax tree determination submodule is used to perform syntactic analysis on the query language information and determine the syntax tree corresponding to the query language information.

[0066] The slot type determination submodule is used to determine the slot type corresponding to the query keyword using the syntax tree.

[0067] Optionally, the data type includes at least one of metadata, dimension attributes, metrics, dimension enumeration values, and time values;

[0068] The slot type determination submodule includes:

[0069] Metadata determination unit, used to determine whether the data type corresponding to the query keyword contains metadata;

[0070] The first slot type determination unit is used to determine the slot type corresponding to the query keyword based on the text information if the data type corresponding to the query keyword contains metadata.

[0071] Optionally, the slot type determination submodule further includes:

[0072] The historical query keyword determination unit is used to determine whether the historical text information contains historical query keywords whose data type is metadata if the data type corresponding to the query keyword does not contain metadata.

[0073] The second slot type determination unit determines the historical query keywords and their slot types based on the historical text information if the historical text information contains historical query keywords of data type metadata.

[0074] The third slot type determination unit, if the historical text information does not contain historical query keywords with data type metadata, then uses the query keywords to determine metadata keywords with data type metadata; and determines the slot type of the metadata keywords and the query keywords based on the text information.

[0075] Optionally, the device further includes:

[0076] The intent category determination module is used to determine the intent category corresponding to the text information using a preset text classification model.

[0077] This application also discloses an apparatus, including:

[0078] One or more processors; and

[0079] One or more machine-readable media having instructions stored thereon, which, when executed by the one or more processors, cause the apparatus to perform one or more methods as described in the embodiments of this application.

[0080] This application also discloses one or more machine-readable media storing instructions that, when executed by one or more processors, cause the processors to perform one or more methods as described in this application.

[0081] The embodiments of this application have the following advantages:

[0082] The query statement generation method of this application involves obtaining text information; extracting query keywords from the text information; determining the slot type corresponding to the query keywords based on the text information; and generating a query statement using the query keywords and the corresponding slot type. This method allows for direct determination of query keywords and their corresponding slot types from text information, and the generation of a query statement to query the database, improving processing efficiency and achieving higher accuracy. Attached Figure Description

[0083] Figure 1 This is a flowchart illustrating the steps of an embodiment of a query statement generation method according to this application;

[0084] Figure 2 This is a flowchart illustrating the steps of another embodiment of the query statement generation method of this application;

[0085] Figure 3 This is a schematic diagram of a syntax tree according to this application;

[0086] Figure 4 This is a structural block diagram of an embodiment of a query statement generation device according to this application. Detailed Implementation

[0087] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0088] This application generates query statements by extracting query keywords from text information and determining the slot type corresponding to the query keywords. Based on the query keywords and their corresponding slot types, it can generate query statements for various fields. The query statement generation method of this application can be used in natural language query systems, intelligent data interaction, intelligent chatbots, and other fields, enabling interaction between users and computers through text input.

[0089] For example, when users shop online and need to check logistics status, inquire about product information, order products, or obtain after-sales support, they can communicate with an intelligent chatbot by inputting text. The intelligent chatbot can extract query keywords from the text information, determine the slot type corresponding to the query keywords, generate query statements based on the query keywords and the slot type corresponding to the query keywords, obtain query results corresponding to the content that the user wants to query, and interact with the user based on the query results.

[0090] Reference Figure 1 The diagram illustrates a flowchart of an embodiment of a query statement generation method according to this application, which may specifically include the following steps:

[0091] Step 101: Obtain text information;

[0092] In this embodiment, text information input by the user can be obtained. Specifically, the user can input voice through a voice input device such as a microphone, and the system can perform voice recognition to obtain text information. Alternatively, the user can input text through external input devices such as a keyboard, mouse, or touchscreen to obtain text information.

[0093] Optionally, the text information can be language information that naturally arises with the development of human society and is used by people in daily communication, such as Chinese, English, Japanese, etc.

[0094] Step 102: Extract query keywords from the text information;

[0095] In this embodiment of the application, query keywords used for querying in the database can be extracted from the text information.

[0096] In a specific implementation, the text information may include entity words, which can be words with specific meanings in the text information. For example, names of people, places, organizations, dates and times, proper nouns, etc.

[0097] The information that a user wants to query can be information that contains keywords related to entity words. Therefore, entity words can be extracted from the text information as query keywords, and information related to entity words can be queried in the database.

[0098] Step 103: Determine the slot type corresponding to the query keyword based on the text information;

[0099] In this embodiment of the application, the slot type corresponding to the query keyword can be determined based on the text information, and the position where the query keyword needs to be filled in the query statement can be determined.

[0100] In practical implementation, querying information in the database typically requires using database-specific query statements, such as SQL queries. These query statements may have a preset query syntax format and at least one slot, each slot corresponding to a slot type. The query syntax format can be a fixed expression format for the query statement. The slot type can be the function type corresponding to the slot in the query statement.

[0101] Text information can also be composed of various sentence components, such as subject, predicate, object, complement, attributive, adverbial, and appositive. Therefore, the query keyword in the text information can correspond to different types of sentence components. Different types of sentence components, and their positions within the text information, can correspond to different slot types in the query statement. Thus, based on the sentence component to which the query keyword belongs and its position within the text information, the slot type corresponding to the query keyword can be determined, and the query keyword can be filled into the slots of different slot types to form the query statement.

[0102] As an example of this application, the query statement may include a SELECT statement. The query syntax of the SELECT statement can be "SELECT column_name to query FROM table_name WHERE restriction_condition". In the SELECT statement, "SELECT", "FROM", and "WHERE" can be components of the SELECT statement, and each component can have a different slot type. "SELECT" is used to determine the column names to be queried, "FROM" is used to determine the name of the data table to be queried, and "WHERE" is used to further restrict the query statement.

[0103] The text information can be "Query the names and ages in the employee table", where the query keywords include "name", "age", and "employee table". The query keywords "name" and "age" are located at the end of the text information, serving as the object. The query keyword "employee table" is located in the middle of the text information, serving as a modifier of the object. It can be determined that the slot type corresponding to the query keywords "name" and "age" is the query column name, and the slot type corresponding to the query keyword "employee table" is the table name. The query keywords are then filled into the slots of different slot types to form the query statement.

[0104] Step 104: Generate a query statement using the query keywords and the slot type corresponding to the query keywords;

[0105] In this embodiment of the application, after determining the slot type corresponding to the query keyword, the query keyword and the slot type corresponding to the query keyword can be used to generate a query statement that can be used to query in the database.

[0106] Specifically, based on the query syntax format of the query statement, the query keywords can be filled into the query statement according to the slot type corresponding to the query keywords.

[0107] As an example of this application, as described above, the slot type corresponding to the query keywords "name" and "age" is the query column name, and the slot type corresponding to the query keyword "employee table" is the table name. The query syntax format of the SELECT statement can be "SELECT column name to be queried FROM table name WHERE restriction condition". Therefore, according to the slot type corresponding to the query keyword, the query keyword can be filled into different slots of the SELECT statement to obtain the query statement "SELECT name, age FROM employee table".

[0108] In this embodiment of the application, the query statement can be used to query in a preset database to obtain the query result information corresponding to the query statement.

[0109] In this embodiment, after determining the query result information corresponding to the query statement, the query result information can be directly displayed to the user. Alternatively, interactive information expressed in natural language can be generated based on the query result information and displayed to the user. This enables natural language interaction between the user and the computer.

[0110] The query statement generation method of this application involves obtaining text information; extracting query keywords from the text information; determining the slot type corresponding to the query keywords based on the text information; and generating a query statement using the query keywords and the corresponding slot type. This method allows for direct determination of query keywords and their corresponding slot types from text information, and the generation of a query statement to query the database, improving processing efficiency and achieving higher accuracy.

[0111] Reference Figure 2 The diagram illustrates a flowchart of an embodiment of a query statement generation method according to this application, which may specifically include the following steps:

[0112] Step 201: Obtain text information;

[0113] In this embodiment, text information input by the user can be obtained. Specifically, the user can input voice through a voice input device such as a microphone, and the system can perform voice recognition to obtain text information. Alternatively, the user can input text through external input devices such as a keyboard, mouse, or touchscreen to obtain text information.

[0114] Optionally, the text information can be language information that naturally arises with the development of human society and is used by people in daily communication, such as Chinese, English, Japanese, etc.

[0115] Step 202: Extract candidate keywords and the data types corresponding to the candidate keywords from the text information;

[0116] In this embodiment of the application, the text information may include entity words, which can be words with specific meanings in the text information. For example, personal names, place names, organization names, dates and times, proper nouns, etc.

[0117] In this embodiment, the preset database can be a multidimensional database, and the data in the database can be stored using multiple N-dimensional arrays. An N-dimensional array can be referred to as a cube, and the database can have various data types at different levels, such as metadata, dimension attributes, metrics, dimension enumeration values, and time values.

[0118] Metadata can include the cube's description, instance information, project information, table information, dictionary information, etc. Dimension attributes can be attribute information for a specific dimension within the cube. Metrics can be aggregated analysis information for a specific dimension within the cube. Dimension enumeration values ​​can be the specific values ​​of each data point within a specific dimension of the cube. Time values ​​can be the values ​​of the data in the cube expressed in time format.

[0119] In this embodiment of the application, entity words can be extracted from the text information, and the entity words can be used as candidate keywords. The data type corresponding to the candidate keywords can be determined, so as to further determine the target keywords based on the data type of the candidate keywords.

[0120] In a specific implementation, based on the preset database, it can be determined whether there are entity words in the text information that have a high degree of similarity to the data in the preset database, which can be used as candidate keywords, and further, based on the database, the data type corresponding to the candidate keywords can be determined.

[0121] In one embodiment of this application, the database includes at least one preset entity data and the data type corresponding to the preset entity data;

[0122] In this embodiment of the application, the database may include at least one preset entity data. The preset entity data may be data information with specific meaning in the database, such as metadata information, dimension attribute information, indicator information, dimension enumeration value information, time value information, etc.

[0123] In this embodiment of the application, the preset entity data may correspond to a data type. For example, the data type may be metadata, dimension attributes, indicators, dimension enumeration values, time values, etc.

[0124] The step of extracting candidate keywords and their corresponding data types from the text information includes:

[0125] S11, Extract candidate entity words from the text information that match preset entity data in the database;

[0126] In this embodiment, entity words that match preset entity data in the database can be extracted from the text information and used as candidate entity words. These candidate entity words may have a certain degree of similarity to the preset entity data, and target entity words can be further filtered from the candidate entity words.

[0127] In a specific implementation, string matching can be used to match at least one word in the text information with preset entity data in the database to obtain at least one candidate entity word that matches the preset entity data in the database.

[0128] S12, determine the target entity word from the candidate entity words as the candidate keyword, and determine the data type corresponding to the candidate keyword.

[0129] In this embodiment of the application, entity words that have a high degree of similarity to data in a preset database can be further filtered from the candidate entity words as candidate keywords, and the data type corresponding to the candidate keywords can be determined based on the database.

[0130] In one embodiment of this application, the step of determining a target entity word from the candidate entity words as a candidate keyword, and determining the data type corresponding to the candidate keyword, includes:

[0131] S21, Based on the similarity between the candidate entity words and the preset entity data, determine the target entity word from the candidate entity words as a candidate keyword;

[0132] In this embodiment, after extracting candidate entity words from the text information that match preset entity data in the database, the similarity between the candidate entity words and the preset entity data can be further determined. Subsequently, based on the similarity between the candidate entity words and the preset entity data, target entity words can be determined from the candidate entity words as candidate keywords.

[0133] In practical implementation, text similarity calculation methods such as minimum edit distance and cosine similarity can be used to determine the similarity between the candidate entity words and the preset entity data. Subsequently, based on the order of similarity from high to low, at least one candidate entity word can be selected sequentially as the target entity word and used as the candidate keyword.

[0134] S22, the data type corresponding to the preset entity data that matches the candidate keyword is taken as the data type corresponding to the candidate keyword.

[0135] In this embodiment, the preset entity data may have a corresponding data type. Candidate keywords matching the preset entity data can be considered to be substantially the same as the preset entity data; therefore, the data type corresponding to the preset entity data can also be the data type corresponding to the candidate keyword. Thus, the data type corresponding to the preset entity data matching the candidate keyword can be used as the data type corresponding to the candidate keyword.

[0136] In one embodiment of this application, the step of determining a target entity word as a candidate keyword from the candidate entity words based on the similarity between the candidate entity words and the preset entity data includes:

[0137] S31, using a preset entity annotation model, determine the entity type probability corresponding to the candidate entity words in the text information;

[0138] In this embodiment, a preset entity annotation model can be used to perform entity recognition on the text information, identify entity words in the text information, annotate the entity words, and give the probability that the entity words belong to a certain entity type, thereby obtaining the entity type probability. The entity words may include candidate entity words, thereby obtaining the entity type probability corresponding to the candidate entity words.

[0139] In the embodiments of this application, the entity type may include personal names, place names, organization names, dates and times, proper nouns, etc., and this application does not impose any restrictions on this.

[0140] In this embodiment, the entity annotation model can be an HMM (Hidden Markov Model), a CRF (Conditional Random Fields) model, a Bi-LSTM (Bi-directional Long Short-Term Memory) model, or a Bi-LSTM+CRF model, etc., and this application does not impose any restrictions. The entity annotation model can be trained using samples that already annotate entity words and their corresponding entity types. Optionally, based on training with general samples, the entity annotation model can be further trained using samples from the application domain where users interact with computers using natural language, thereby improving the entity annotation accuracy of the model in a specific domain. The application domain can be divided into e-commerce, finance, entertainment, personal assistant, map navigation, smart home, etc., according to actual needs, and this application does not impose any restrictions.

[0141] S32, Based on the similarity between the candidate entity words and the preset entity data, and the entity type probability corresponding to the candidate entity words, determine the target entity word from the candidate entity words as the candidate keyword.

[0142] In this embodiment of the application, based on the similarity between the candidate entity words and the preset entity data, and the entity type probability corresponding to the candidate entity words, a target entity word that is more similar to the preset entity data can be determined from the candidate entity words as a candidate keyword.

[0143] In a specific implementation, the similarity between the candidate entity words and the preset entity data, and the weighted average between the entity type probabilities corresponding to the candidate entity words, can be determined. Based on the order of the weighted average from high to low, at least one candidate entity word is selected in sequence, determined as the target entity word, and used as the candidate keyword.

[0144] Step 203: Based on the data type corresponding to the candidate keywords, determine the target keyword from the candidate keywords as the query keyword.

[0145] In this embodiment, the candidate keywords are not necessarily the content the user wants to query. For example, if the text information is "query the movie Spider-Man," it may match the candidate keywords "spider" and "Spider-Man," where the candidate keyword "spider" does not match the content the user wants to query. Therefore, based on the data type corresponding to the candidate keyword and its position in the text information, it can be determined whether the candidate keyword is the content the user wants to query, and thus the target keyword can be determined from the candidate keywords as the query keyword.

[0146] In one embodiment of this application, the step of determining the target keyword from the candidate keywords as the query keyword based on the data type corresponding to the candidate keywords includes:

[0147] S41, replace the candidate keywords in the text information with the data type corresponding to the candidate keywords to obtain candidate language information;

[0148] In this embodiment, candidate keywords in the text information can be replaced with the data types corresponding to the candidate keywords to obtain candidate language information, thereby determining whether the candidate language information conforms to the grammatical rules of the text information and belongs to normal sentences. For example, between the text information "Hello, the weather is nice today" and "Hello, the weather is bad today", "Hello, the weather is nice today" conforms more to the grammatical rules of the text information and is closer to normal sentences.

[0149] As an example of this application, the text information is "Querying the movie Spider-Man," which can match the candidate keywords "movie," "spider," and "Spider-Man." The data type of "spider" and "Spider-Man" can be a dimension enumeration value, marked as #dimEnum; the data type of "movie" can be a dimension, marked as #dimension. The candidate keywords in the text information can be replaced with their corresponding data types to obtain candidate language information, thus yielding the candidate language information "Query #dimension#dimEnumSpider" and "Query #dimension#dimEnum."

[0150] S42, using a preset language model, determine the grammatical probability corresponding to the candidate language information;

[0151] In this embodiment of the application, a preset language model can be used to determine the grammatical probability corresponding to the candidate language information, thereby determining whether the candidate language information conforms to the grammatical rules of the text and is close to normal sentences based on the grammatical probability.

[0152] In the embodiments of this application, the language model can be an n-gram model, an NNLM (Neural Network Language Models) model, etc., and this application does not limit it. Based on the sentence structures that the text information may involve, several samples of text information partially replaced with data types are pre-designed, and these samples are used to train the language model to be trained, thereby obtaining the language model.

[0153] As an example of this application, the text information that is partially replaced with a data type sample can be "#cube", "#dimEnum", "#time", "#measure", "#cube's #measure is", "#time#cube#dimEnum's #measure is", etc.

[0154] S43, Based on the grammatical probability, determine the target keyword from the candidate keywords as the query keyword.

[0155] In this embodiment of the application, candidate language information with a high grammatical probability and belonging to normal sentences can be determined based on the grammatical probability, and candidate keywords contained in the candidate language information belonging to normal sentences can be determined as target keywords, and the target keywords can be used as query keywords.

[0156] In this embodiment of the application, there may be multiple candidate language information that have a high grammatical probability and belong to normal sentences. In this case, depending on the actual needs, the candidate keyword in the candidate language information with the highest grammatical probability can be used as the target keyword. Alternatively, based on the candidate keywords in the candidate language information with high grammatical probability, further interaction with the user can be conducted to determine the target keyword from the candidate keywords by ascertaining the user's intent and allowing the user to select the target keyword from the candidate keywords.

[0157] Step 204: Determine the slot type corresponding to the query keyword based on the text information;

[0158] In this embodiment of the application, the slot type corresponding to the query keyword can be determined based on the text information, and the position where the query keyword needs to be filled in the query statement can be determined.

[0159] In practical implementation, querying information in the database typically requires using database-specific query statements, such as SQL queries. These query statements may have a preset query syntax format and at least one slot, each slot corresponding to a slot type. The query syntax format can be a fixed expression format for the query statement. The slot type can be the function type corresponding to the slot in the query statement.

[0160] Text information can also be composed of various sentence components, such as subject, predicate, object, complement, attributive, adverbial, and appositive. Therefore, the query keyword in the text information can correspond to different types of sentence components. Different types of sentence components, and their positions within the text information, can correspond to different slot types in the query statement. Thus, based on the sentence component to which the query keyword belongs and its position within the text information, the slot type corresponding to the query keyword can be determined, and the query keyword can be filled into the slots of different slot types to form the query statement.

[0161] In one embodiment of this application, the step of determining the slot type corresponding to the query keyword based on text information includes:

[0162] S51, replace the query keywords in the text information with the data type corresponding to the query keywords to obtain query language information;

[0163] In this embodiment, to further determine the slot type corresponding to the query keyword, the query keyword in the text information can be replaced with the data type corresponding to the query keyword to obtain query language information. This allows determining the data type corresponding to the query keyword to be converted into determining the slot type corresponding to the data type, avoiding the increased analysis difficulty caused by directly performing syntactic analysis on text information generated from a large number of different query keywords.

[0164] S52, perform syntactic analysis on the query language information to determine the syntax tree corresponding to the query language information;

[0165] In this embodiment of the application, syntactic analysis can be performed on the query language information to determine the sentence components corresponding to each word in the query language information and generate the corresponding syntax tree.

[0166] In practical implementation, probabilistic context-free grammar (PCFG) can be used for syntactic analysis. A probabilistic context-free grammar can be defined as a quadruple {N, E, S, R}. Here, N represents the set of non-terminal symbols, E represents the set of terminal symbols, S represents the initial symbol, and R represents a set of grammar rules, with each rule in the set having a probability P.

[0167] Subsequently, the CYK (CockeYounger-Kasami algorithm) can be used to perform dynamic programming based on probabilistic context-free grammars to obtain at least one syntax tree corresponding to the query language information. The probability of each syntax tree can be the product of the probabilities of all used grammar rules. The higher the probability of a syntax tree, the more likely it is to be a correct syntax tree. Thus, the target syntax tree can be determined from these syntax trees as the syntax tree corresponding to the query language information.

[0168] S53, using the syntax tree, determine the slot type corresponding to the query keyword.

[0169] In this embodiment of the application, the syntax tree can be used to determine the slot type corresponding to the query keyword, so as to form a query statement from the query keyword. The slot type can be the function type corresponding to each component in the query statement.

[0170] In practical implementations, when processing text information, the syntax tree can usually annotate the phrase structure in the text information, as well as the part-of-speech tag of each word in the text information.

[0171] For example, for the text information "The teacher was amused by the late student", where "the teacher" belongs to a noun phrase, and "was amused by the late student" belongs to a verb phrase. The verb phrase "was amused by the late student" can further include the prepositional phrase "by the late student" and the verb phrase "was amused". The prepositional phrase "by the late student" can include the preposition "by" and the noun phrase "the late student". The noun phrase "the late student" can include the verb phrase "was late", the function word "的", and the noun phrase "student". The verb phrase "was amused" can include the verb phrase "amused" and the function word "了", thereby dividing the phrase structure in the text information. Also, in the text information "The teacher was amused by the late student", "the teacher" and "student" belong to nouns, "by" belongs to a preposition, and "was late" and "amused" belong to verbs.

[0172] Since the query keywords in the query language information have been replaced with data types, a custom quadruple can be designed for the query language information, so that the corresponding slot types can be determined for the data types in the query language information to determine the slot types corresponding to the query keywords.

[0173] Specifically, for the non-terminal symbol set and terminal symbol set in the quadruple, originally the non-terminal symbol set and terminal symbol set usually can include词性标注符号 such as nouns, noun phrases, verbs, conjunctions, etc., so that the words in the text information can be词性标注, while in this application, some词性标注符号 in the non-terminal symbol set and terminal symbol set can be replaced with slot types and data types. For the grammar rules in the quadruple, based on the common sentence patterns of the query language information, the grammar rules for the query language information can be set. Thus, this application can use the syntax tree to annotate the slot types corresponding to the data types in the query language information.

[0174] As a specific example of this application, the non-terminal symbol set can include:

[0175] S (initial symbol), and slot types such as TABLE_SLOT, SELECT_TARGET, SELECT_C ONCAT, SELECT_COLUMN, SELECT_AGG_MAX_PREFIX, SELECT_A GG_MAX_SUFFIX, WHERE_CLAUSE, WHERE_CONDITION, WHERE_CONCAT_AND, WHERE_CONCAT_OR WHERE_SLOT, WHERE_VALUE, WHERE_OPERATOR_EQUAL_PREFIX, etc.

[0176] It should be noted that there are some unclear parts in the original text marked as "词性标注符号" which need to be further clarified in the source text for a more accurate translation.As a specific example of this application, the set of terminal symbols may include:

[0177] Connectives, modifiers, auxiliary words, punctuation marks, and data types such as #cube (metadata), #dimension (dimension attribute), #dimenum (dimension enumeration value), #measure (metric), #time (time), and #number (number).

[0178] As a specific example of this application, the syntax rules may include:

[0179] S→TABLE_SLOT WHERE_CLAUSE SELECT_TARGET

[0180] TABLE_→#cube

[0181] WHERE→WHERE_CONDITION aux

[0182] WHERE_CONDITION→#dimEnum

[0183] Aux→SELECT_TARGET→

[0184] As a specific example of this application, Figure 3 This is a schematic diagram of a syntax tree for this application. The text information is "resolution rate of member inquiries for a certain product". The query keywords "certain product", "member inquiries", and "resolution rate" can be extracted. Furthermore, the data type corresponding to the query keyword "certain product" is determined to be metadata, the data type corresponding to the query keyword "member inquiries" is a dimension enumeration value, and the data type corresponding to the query keyword "resolution rate" is an indicator, thereby generating the query language information "#cube#dimenum of #measure". Syntactic analysis is performed on the query language information to determine the corresponding syntax tree. Here, S is the initial symbol, and the query language information is divided into "table name", "whereClause", and "selectTarget". "whereClause" is further divided into "whereCondition" and "aux". Here, #cube belongs to table name, #dimenum belongs to whereCondition, and #measure belongs to selectTarget.

[0185] In one embodiment of this application, the data type includes at least one of metadata, dimension attributes, metrics, dimension enumeration values, and time values.

[0186] Metadata can include the cube's description, instance information, project information, table information, dictionary information, etc. Dimension attributes can be attribute information for a specific dimension within the cube. Metrics can be aggregated analysis information for a specific dimension within the cube. Dimension enumeration values ​​can be the specific values ​​of each data point within a specific dimension of the cube. Time values ​​can be the values ​​of the data in the cube expressed in time format.

[0187] In one embodiment of this application, the step of determining the slot type corresponding to the query keyword based on text information includes:

[0188] S61, determine whether the data type corresponding to the query keyword contains metadata;

[0189] In this embodiment, metadata can include cube description information, cube instance information, project information, table information, dictionary information, etc. Therefore, metadata typically points to the cube containing the data the user wishes to query. If the query keyword does not contain metadata, the query accuracy may be reduced. Therefore, after determining the data type corresponding to the query keyword, it can be determined whether the data type corresponding to the query keyword contains metadata.

[0190] S62, if the data type corresponding to the query keyword contains metadata, then determine the slot type corresponding to the query keyword based on the text information.

[0191] In this embodiment of the application, if the data type corresponding to the query keyword contains metadata, then the cube containing the data that the user wants to query can be determined, and the slot type corresponding to the query keyword can be determined based on the text information.

[0192] In one embodiment of this application, the step of determining the slot type corresponding to the query keyword further includes:

[0193] S71, if the data type corresponding to the query keyword does not contain metadata, then determine whether the historical text information contains historical query keywords whose data type is metadata;

[0194] In this embodiment of the application, if the data type corresponding to the query keyword does not contain metadata, then during multiple rounds of interaction between the user and the computer, the query keyword with the data type of metadata may be present in the user's historical text input information from previous interactions with the computer. Therefore, it can be determined whether the historical text information contains historical query keywords with the data type of metadata.

[0195] S72, if the historical text information contains historical query keywords of data type metadata, then determine the historical query keywords and the slot type of the query keywords based on the historical text information;

[0196] In this embodiment, if the historical text information contains historical query keywords with data type metadata, then based on the data type of the query keyword, the historical query keyword with the same data type as the current query keyword in the historical text information can be replaced with the current query keyword, thereby obtaining new text information containing historical query keywords with data type metadata. Subsequently, the new text information can be used to determine the historical query keywords with data type metadata and the slot type of the query keyword. Thus, multi-round interaction between the user and the computer can be achieved without the user repeatedly inputting text information containing metadata.

[0197] S73, if the historical text information does not contain historical query keywords with data type metadata, then the query keywords are used to determine metadata keywords with data type metadata; based on the text information, the slot type of the metadata keywords and the query keywords is determined.

[0198] In this embodiment, if the historical text information does not contain historical query keywords of data type metadata, then the query keywords contained in the current text information can be used to determine the cube containing the query keywords, and based on the metadata of the cube, the metadata keywords of data type metadata can be determined. Subsequently, the metadata keywords can be displayed to the user as needed to determine if the metadata keywords are correct, or the metadata keywords can be directly added to the text information, and the slot types of the metadata keywords and the query keywords can be determined based on the text information.

[0199] Step 205: Generate a query statement using the query keywords and the slot type corresponding to the query keywords;

[0200] In this embodiment of the application, after determining the slot type corresponding to the query keyword, the query keyword and the slot type corresponding to the query keyword can be used to generate a query statement that can be used to query in the database.

[0201] Specifically, based on the query syntax format of the query statement, the query keywords can be filled into the query statement according to the slot type corresponding to the query keywords.

[0202] In this embodiment of the application, the query statement can be used to query in a preset database to obtain the query result information corresponding to the query statement.

[0203] In this embodiment, after determining the query result information corresponding to the query statement, the query result information can be directly displayed to the user. Alternatively, interactive information expressed in text can be generated based on the query result information and displayed to the user. This enables text interaction between the user and the computer.

[0204] In one embodiment of this application, the method further includes:

[0205] S81, using a preset text classification model, determine the intent category corresponding to the text information.

[0206] In this embodiment, a preset text classification model can be used to identify the intent of the text information and determine the intent category corresponding to the text information. As an optional implementation of this application, the intent category may include data query, factor analysis, anomaly detection, time series prediction, etc., and this application does not limit it.

[0207] The text classification model can be a TextCNN (Convolutional Neural Networks for Text Classification) model, a classifier based on BERT (Bidirectional Encoder Representation from Transformers), etc., and this application does not limit it.

[0208] In this embodiment, after determining that the query result information has been obtained, the query result information can be analyzed based on the intent category corresponding to the text information to determine whether the query result information is abnormal. If an anomaly is found, the entity annotation model, syntax type, and syntactic tree partitioning algorithm used in the query statement generation process can be further adjusted to further improve the accuracy of the query result information.

[0209] The query statement generation method of this application involves obtaining text information; extracting candidate keywords and their corresponding data types from the text information; determining target keywords as query keywords based on the data types of the candidate keywords; and generating query statements using the query keywords and their corresponding slot types. This method allows for direct determination of query keywords and their corresponding slot types from text information, and the generation of query statements to query the database, improving processing efficiency and achieving higher accuracy.

[0210] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.

[0211] Reference Figure 4 The diagram shows a structural block diagram of an embodiment of a query statement generation apparatus according to this application, which may specifically include the following modules:

[0212] Module 401 is used to acquire text information;

[0213] Extraction module 402 is used to extract query keywords from the text information;

[0214] The slot type determination module 403 is used to determine the slot type corresponding to the query keyword based on the text information;

[0215] The generation module 404 is used to generate a query statement using the query keywords and the slot type corresponding to the query keywords;

[0216] The search module 405 is used to search for the query result information corresponding to the query statement in a preset database.

[0217] Optionally, the extraction module includes:

[0218] The candidate keyword extraction submodule is used to extract candidate keywords and the data types corresponding to the candidate keywords from the text information.

[0219] The query keyword determination submodule is used to determine the target keyword from the candidate keywords based on the data type corresponding to the candidate keywords, and use it as the query keyword.

[0220] Optionally, the database includes at least one preset entity data and the data type corresponding to the preset entity data;

[0221] The candidate keyword extraction submodule includes:

[0222] The candidate entity word extraction unit is used to extract candidate entity words from the text information that match preset entity data in the database;

[0223] The candidate keyword extraction unit is used to identify target entity words from the candidate entity words as candidate keywords, and to determine the data type corresponding to the candidate keywords.

[0224] Optionally, the candidate keyword extraction unit includes:

[0225] The candidate keyword extraction subunit is used to determine the target entity word as a candidate keyword based on the similarity between the candidate entity word and the preset entity data.

[0226] The data type determination unit is used to determine the data type corresponding to the preset entity data that matches the candidate keyword as the data type corresponding to the candidate keyword.

[0227] Optionally, the candidate keyword extraction subunit is specifically used to use a preset entity annotation model to determine the entity type probability corresponding to the candidate entity words in the text information; based on the similarity between the candidate entity words and the preset entity data, and the entity type probability corresponding to the candidate entity words, to determine the target entity words as candidate keywords.

[0228] Optionally, the query keyword determination submodule includes:

[0229] A candidate language information acquisition unit is used to replace candidate keywords in the text information with the data type corresponding to the candidate keywords to obtain candidate language information;

[0230] The syntax probability determination unit is used to determine the syntax probability corresponding to the candidate language information using a preset language model;

[0231] The query keyword determination unit is used to determine the target keyword from the candidate keywords based on the grammatical probability, and use it as the query keyword.

[0232] Optionally, the slot type determination module includes:

[0233] The query language information acquisition submodule is used to replace the query keywords in the text information with the data types corresponding to the query keywords to obtain query language information.

[0234] The syntax tree determination submodule is used to perform syntactic analysis on the query language information and determine the syntax tree corresponding to the query language information.

[0235] The slot type determination submodule is used to determine the slot type corresponding to the query keyword using the syntax tree.

[0236] Optionally, the data type includes at least one of metadata, dimension attributes, metrics, dimension enumeration values, and time values;

[0237] The slot type determination submodule includes:

[0238] Metadata determination unit, used to determine whether the data type corresponding to the query keyword contains metadata;

[0239] The first slot type determination unit is used to determine the slot type corresponding to the query keyword based on the text information if the data type corresponding to the query keyword contains metadata.

[0240] Optionally, the slot type determination submodule further includes:

[0241] The historical query keyword determination unit is used to determine whether the historical text information contains historical query keywords whose data type is metadata if the data type corresponding to the query keyword does not contain metadata.

[0242] The second slot type determination unit determines the historical query keywords and their slot types based on the historical text information if the historical text information contains historical query keywords of data type metadata.

[0243] The third slot type determination unit, if the historical text information does not contain historical query keywords with data type metadata, then uses the query keywords to determine metadata keywords with data type metadata; and determines the slot type of the metadata keywords and the query keywords based on the text information.

[0244] Optionally, the device further includes:

[0245] The intent category determination module is used to determine the intent category corresponding to the text information using a preset text classification model.

[0246] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0247] This application also provides an apparatus, including:

[0248] One or more processors; and

[0249] One or more machine-readable media having instructions stored thereon, which, when executed by the one or more processors, cause the device to perform the methods described in the embodiments of this application.

[0250] This application also provides one or more machine-readable media storing instructions that, when executed by one or more processors, cause the processors to perform the methods described in this application.

[0251] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0252] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0253] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0254] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0255] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0256] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.

[0257] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0258] The above provides a detailed description of a query statement generation method and a query statement generation apparatus provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for generating query statements, characterized in that, include: Obtain text information entered by the user during the conversation; Extract query keywords from the text information; The query keywords are determined from the candidate keywords based on the grammatical probability corresponding to the candidate language information. The candidate keywords in the text information are replaced with the data types corresponding to the candidate keywords to obtain the candidate language information. The candidate keywords are entity words in the text information. The data types include at least one of metadata, dimension attributes, indicators, dimension enumeration values, and time values. Based on the text information, determine the slot type corresponding to the query keyword; Using the query keywords and the slot types corresponding to the query keywords, a query statement is generated. The query statement is used to retrieve data from the database and provide feedback to the user.

2. The method according to claim 1, characterized in that, The step of extracting query keywords from the text information includes: Extract candidate keywords and their corresponding data types from the text information; Based on the data type corresponding to the candidate keywords, the target keyword is determined from the candidate keywords and used as the query keyword.

3. The method according to claim 2, characterized in that, The database includes at least one preset entity data and the data type corresponding to the preset entity data; The step of extracting candidate keywords and their corresponding data types from the text information includes: Extract candidate entity words from the text information that match preset entity data in the database; The target entity word is determined from the candidate entity words as candidate keywords, and the data type corresponding to the candidate keywords is determined.

4. The method according to claim 3, characterized in that, The step of determining the target entity word from the candidate entity words as candidate keywords, and determining the data type corresponding to the candidate keywords, includes: Based on the similarity between the candidate entity words and the preset entity data, target entity words are determined from the candidate entity words as candidate keywords; The data type corresponding to the preset entity data that matches the candidate keyword is taken as the data type corresponding to the candidate keyword.

5. The method according to claim 4, characterized in that, The step of determining the target entity word as a candidate keyword from the candidate entity words based on the similarity between the candidate entity words and the preset entity data includes: A preset entity annotation model is used to determine the entity type probability corresponding to candidate entity words in the text information; Based on the similarity between the candidate entity words and the preset entity data, and the entity type probability corresponding to the candidate entity words, target entity words are determined from the candidate entity words as candidate keywords.

6. The method according to claim 2, characterized in that, The step of determining the target keyword from the candidate keywords based on the data type corresponding to the candidate keywords, as the query keyword, includes: A preset language model is used to determine the grammatical probability corresponding to the candidate language information; Based on the grammatical probabilities, the target keyword is determined from the candidate keywords and used as the query keyword.

7. The method according to claim 1, characterized in that, The step of determining the slot type corresponding to the query keyword based on the text information includes: Replace the query keywords in the text information with the data types corresponding to the query keywords to obtain query language information; Perform syntactic analysis on the query language information to determine the corresponding syntax tree; The syntactic tree is used to determine the slot type corresponding to the query keyword.

8. The method according to claim 2, characterized in that, The step of determining the slot type corresponding to the query keyword based on the text information includes: Determine whether the data type corresponding to the query keyword contains metadata; If the data type corresponding to the query keyword contains metadata, then the slot type corresponding to the query keyword is determined based on the text information.

9. The method according to claim 8, characterized in that, The step of determining the slot type corresponding to the query keyword further includes: If the data type corresponding to the query keyword does not contain metadata, then determine whether the historical text information contains historical query keywords whose data type is metadata; If the historical text information contains historical query keywords with data type metadata, then the historical query keywords and the slot type of the query keywords are determined based on the historical text information. If the historical text information does not contain historical query keywords with data type metadata, then the query keywords are used to determine metadata keywords with data type metadata; based on the text information, the slot type of the metadata keywords and the query keywords is determined.

10. The method according to claim 1, characterized in that, The method further includes: A preset text classification model is used to determine the intent category corresponding to the text information.

11. A query statement generation apparatus, characterized in that, include: The acquisition module is used to acquire text information entered by the user during the conversation; The extraction module is used to extract query keywords from the text information; The query keywords are determined from the candidate keywords based on the grammatical probability corresponding to the candidate language information. The candidate keywords in the text information are replaced with the data types corresponding to the candidate keywords to obtain the candidate language information. The candidate keywords are entity words in the text information. The data types include at least one of metadata, dimension attributes, indicators, dimension enumeration values, and time values. The slot type determination module is used to determine the slot type corresponding to the query keyword based on the text information. The generation module is used to generate a query statement using the query keywords and the slot type corresponding to the query keywords. The query statement is used to query data in the database and return the data to the user.

12. The apparatus according to claim 11, characterized in that, The extraction module includes: The candidate keyword extraction submodule is used to extract candidate keywords and the data types corresponding to the candidate keywords from the text information. The query keyword determination submodule is used to determine the target keyword from the candidate keywords based on the data type corresponding to the candidate keywords, and use it as the query keyword.

13. The apparatus according to claim 12, characterized in that, The database includes at least one preset entity data and the data type corresponding to the preset entity data; The candidate keyword extraction submodule includes: The candidate entity word extraction unit is used to extract candidate entity words from the text information that match preset entity data in the database; The candidate keyword extraction unit is used to identify target entity words from the candidate entity words as candidate keywords, and to determine the data type corresponding to the candidate keywords.

14. The apparatus according to claim 13, characterized in that, The candidate keyword extraction unit includes: The candidate keyword extraction subunit is used to determine the target entity word as a candidate keyword based on the similarity between the candidate entity word and the preset entity data. The data type determination unit is used to determine the data type corresponding to the preset entity data that matches the candidate keyword as the data type corresponding to the candidate keyword.

15. The apparatus according to claim 14, characterized in that, The candidate keyword extraction subunit is specifically used to determine the entity type probability corresponding to the candidate entity words in the text information using a preset entity annotation model; and to determine the target entity word as the candidate keyword based on the similarity between the candidate entity word and the preset entity data, as well as the entity type probability corresponding to the candidate entity word.

16. The apparatus according to claim 12, characterized in that, The query keyword determination submodule includes: The syntax probability determination unit is used to determine the syntax probability corresponding to the candidate language information using a preset language model; The query keyword determination unit is used to determine the target keyword from the candidate keywords based on the grammatical probability, and use it as the query keyword.

17. The apparatus according to claim 11, characterized in that, The slot type determination module includes: The query language information acquisition submodule is used to replace the query keywords in the text information with the data types corresponding to the query keywords to obtain query language information. The syntax tree determination submodule is used to perform syntactic analysis on the query language information and determine the syntax tree corresponding to the query language information. The slot type determination submodule is used to determine the slot type corresponding to the query keyword using the syntax tree.

18. The apparatus according to claim 12, characterized in that, The slot type determination module includes: Metadata determination unit, used to determine whether the data type corresponding to the query keyword contains metadata; The first slot type determination unit is used to determine the slot type corresponding to the query keyword based on the text information if the data type corresponding to the query keyword contains metadata.

19. The apparatus according to claim 18, characterized in that, The slot type determination module also includes: The historical query keyword determination unit is used to determine whether the historical text information contains historical query keywords whose data type is metadata if the data type corresponding to the query keyword does not contain metadata. The second slot type determination unit determines the historical query keywords and their slot types based on the historical text information if the historical text information contains historical query keywords of data type metadata. The third slot type determination unit, if the historical text information does not contain historical query keywords with data type metadata, then uses the query keywords to determine metadata keywords with data type metadata; and determines the slot type of the metadata keywords and the query keywords based on the text information.

20. The apparatus according to claim 11, characterized in that, The device further includes: The intent category determination module is used to determine the intent category corresponding to the text information using a preset text classification model.

21. A query statement generation apparatus, characterized in that, include: One or more processors; and One or more machine-readable media having instructions stored thereon, which, when executed by the one or more processors, cause the device to perform the method as described in any one of claims 1-10.

22. One or more machine-readable media having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the method as described in any one of claims 1-10.

Citation Information

Patent Citations

  • Method and device for outputting structured query statements

    CN107451153A

  • Structured query statement generation method and device, electronic equipment and medium

    CN111459967A