A method, apparatus, and device for generating a structured query language statement

By generating a target dependency syntax tree and determining a semantic dependency structure, the problem of being unable to accurately generate structured query statements in the prior art is solved, and the ability of non-technical users to access big data is realized.

CN112835927BActive Publication Date: 2025-06-17INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110317852.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-25
Publication Date
2025-06-17
Estimated Expiration
2041-03-25

AI Technical Summary

Technical Problem

The prior art cannot accurately generate corresponding structured query statements based on user input statements, making it difficult for business personnel with non-technical background to access big data in an easy way.

Method used

By obtaining the target text, a target dependency syntax tree is generated, the semantic dependency structure of the target text is determined, the structured query parameter set is determined using the semantic dependency structure, and a structured query statement is generated based on these parameter sets and semantic dependency structures.

Benefits of technology

It realizes the accurate generation of structured query statements based on semantic dependency structure, so that business personnel with non-technical backgrounds can easily access big data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112835927B_ABST
    Figure CN112835927B_ABST
Patent Text Reader

Abstract

The embodiments of this specification provide a method, apparatus, and device for generating structured query statements, which relate to the field of big data technology. Among them, the method includes: obtaining a target text; generating a target dependency syntactic tree based on the target text; determining the semantic dependency structure of the target text based on the target dependency syntactic tree; using the semantic dependency structure to determine a set of structured query parameters; where the set of structured query parameters contains multiple structured query parameter values required for generating a structured query statement corresponding to the target text; and generating a structured query statement corresponding to the target text according to the set of structured query parameters and the semantic dependency structure. In the embodiments of this specification, a structured query statement of the target text can be accurately generated based on the semantic dependency structure, enabling business personnel without a technical background to conveniently access big data using structured query statements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of big data technology, and particularly to a method, apparatus, and device for generating structured query statements. Background Art

[0002] With the rapid development and wide application of big data technology, data has become one of the production factors. The daily work of many business personnel has been inseparable from big data. There are more and more scenarios of querying data lakes through structured query statements. Many business personnel without a technical background also need to write structured query statements to access big data in order to obtain the required information. However, writing structured query statements is not an easy task for business personnel without a technical background and requires a learning process to master proficiently, thus bringing inconvenience to many business personnel.

[0003] In the prior art, structured query statements are usually generated based on syntactic analysis technology. However, due to the diversity of syntactic structures, when a user inputs sentences with different syntactic structures, the system may not be able to correctly understand its deep semantic information beyond the constraints of the surface syntactic structure of the sentence, and thus generate correct structured query statements. It can be seen that the technical solutions in the prior art cannot accurately generate corresponding structured query statements based on the sentences input by users.

[0004] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention

[0005] The embodiments of this specification provide a method, apparatus, and device for generating structured query statements to solve the problem in the prior art that corresponding structured query statements cannot be accurately generated based on the sentences input by users.

[0006] The embodiments of this specification provide a method for generating structured query statements, including: obtaining a target text; generating a target dependency syntactic tree based on the target text; determining a semantic dependency structure of the target text based on the target dependency syntactic tree, where the semantic dependency structure is used to represent the semantic association between components in the target text; using the semantic dependency structure to determine a structured query parameter set, where the structured query parameter set contains structured query parameter values required for generating multiple structured query statements corresponding to the target text; and generating a structured query statement corresponding to the target text according to the structured query parameter set and the semantic dependency structure.

[0007] An embodiment of this specification also provides a device for generating a structured query statement, including: an acquisition module, configured to acquire a target text; a conversion module, configured to generate a target dependency syntax tree based on the target text; a first determination module, configured to determine a semantic dependency structure of the target text based on the target dependency syntax tree, where the semantic dependency structure is used to represent the semantic association between components in the target text; a second determination module, configured to determine a structured query parameter set by using the semantic dependency structure, where the structured query parameter set includes structured query parameter values required for generating a structured query statement corresponding to the target text; and a generation module, configured to generate a structured query statement corresponding to the target text according to the structured query parameter set and the semantic dependency structure.

[0008] An embodiment of this specification also provides a device for generating a structured query statement, including a processor and a memory for storing processor-executable instructions, where the processor implements the steps of the method for generating a structured query statement when executing the instructions.

[0009] An embodiment of this specification also provides a computer-readable storage medium, on which computer instructions are stored, and the steps of the method for generating a structured query statement are implemented when the instructions are executed.

[0010] An embodiment of this specification provides a method for generating a structured query statement. A target text can be acquired, and a target dependency syntax tree can be generated based on the target text, so that the syntax structure of the target text can be determined. Since semantic information is closely related to the syntax and word meaning information of a sentence, in order to obtain deep semantic information across the constraints of the surface grammar structure of the sentence, semantic dependency analysis can be performed based on the above target dependency syntax tree to determine the semantic dependency structure of the target text, where the above semantic dependency structure is used to represent the semantic association between components in the target text. Further, the semantic dependency structure can be used to determine structured query parameter values required for generating a structured query statement corresponding to the target text, and a structured query parameter set can be obtained. And a structured query statement corresponding to the target text can be generated according to the structured query parameter set and the semantic dependency structure. Thus, a structured query statement of the target text can be accurately generated based on the semantic dependency structure, enabling business personnel without a technical background to conveniently access big data using the structured query statement. Description of the Drawings

[0011] The drawings described herein are used to provide a further understanding of the embodiments of this specification, and constitute a part of the embodiments of this specification, but do not limit the embodiments of this specification. In the drawings:

[0012] Figure 1It is a schematic diagram of the steps of the method for generating a structured query statement provided by an embodiment of this specification;

[0013] Figure 2 It is a schematic diagram of the semantic dependency structure provided by a specific embodiment of an embodiment of this specification;

[0014] Figure 3 It is a schematic diagram of the structure of the device for generating a structured query statement provided by an embodiment of this specification;

[0015] Figure 4 It is a schematic diagram of the structure of the device for generating a structured query statement provided by an embodiment of this specification. Specific Embodiments

[0016] Next, the principles and spirit of the embodiments of this specification will be described with reference to several exemplary embodiments. It should be understood that these embodiments are given only to enable those skilled in the art to better understand and then implement the embodiments of this specification, rather than limiting the scope of the embodiments of this specification in any way. On the contrary, these embodiments are provided to make the disclosure of the embodiments of this specification more thorough and complete, and to be able to convey the scope of this disclosure fully to those skilled in the art.

[0017] Those skilled in the art know that the embodiments of the embodiments of this specification can be implemented as a system, a device, a method, or a computer program product. Therefore, the disclosure of the embodiments of this specification can be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0018] Although the following described processes include multiple operations that appear in a specific order, it should be clearly understood that these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel (for example, using a parallel processor or a multi-threaded environment).

[0019] Please refer to Figure 1 , this embodiment can provide a method for generating a structured query statement. The method for generating a structured query statement can be used to accurately generate a corresponding structured query statement based on the target text. The above method for generating a structured query statement may include the following steps.

[0020] S101: Obtain the target text.

[0021] In this embodiment, the target text can be obtained. The above target text can be the text for which a structured query statement needs to be generated, and it can be input by the user or automatically captured by the system. Specifically, it can be determined according to the actual situation, and the embodiments of this specification do not limit this.

[0022] In this embodiment, the above-mentioned target text may contain at least two characters, and the above-mentioned target text may be a piece of natural language. For example: I want to query the average daily deposit balance of the Shanghai Branch in 2020. Of course, the target text is not limited to the above example. Those skilled in the art may make other changes under the inspiration of the technical essence of the embodiments of this specification. However, as long as the functions and effects achieved are the same as or similar to those of the embodiments of this specification, they should all be covered within the protection scope of the embodiments of this specification.

[0023] In this embodiment, the method for obtaining the target text may include: receiving the target sample input by the user, or it may be retrieved from a preset database. Among them, the above-mentioned preset database may be a database storing the data submitted and generated by the user in real time, and the acquisition channels may be WEB (World Wide Web) pages, emails or other user interfaces. Of course, it can be understood that other possible methods may also be used to obtain the above-mentioned sample dataset. For example, searching for the target text according to certain search conditions on the WEB page, which can be specifically determined according to the actual situation, and this specification embodiment does not limit this.

[0024] S102: Generate a target dependency syntax tree based on the target text.

[0025] In this embodiment, dependency syntax analysis can be performed on the target text first to generate a target dependency syntax tree. Among them, syntactic parsing is one of the key technologies in natural language processing. It is a processing process of analyzing the input text sentence to obtain the syntactic structure of the sentence.

[0026] In this embodiment, dependency syntax analysis may include syntactic structure analysis and dependency relationship analysis. The function of syntactic structure analysis is to identify the phrase structure in the sentence and the hierarchical syntactic relationship between phrases. The function of dependency relationship analysis is to identify the interdependent relationship between words in the sentence. Dependency syntax analysis can analyze a sentence into a dependency syntax tree, describing the dependency relationship between each word, that is, pointing out the syntactic collocation relationship between words, and this collocation relationship is associated with semantics. Dependency syntax believes that the verb in the "predicate" is the center of a sentence, and other components are directly or indirectly related to the verb.

[0027] In this embodiment, a third-party product such as the Language Technology Platform LTP, etc. can be used to generate a target dependency syntax tree based on the target text. Of course, it can be understood that other possible methods may also be used to generate a target dependency syntax tree based on the target text, such as deep learning algorithms, etc., which can be specifically determined according to the actual situation, and this specification embodiment does not limit this.

[0028] S103: Based on the target dependency syntax tree, determine the semantic dependency structure of the target text; wherein, the semantic dependency structure is used to represent the semantic associations between the components in the target text.

[0029] In this embodiment, since semantic information is closely related to the syntactic and lexical information of a sentence, in order to obtain deep semantic information by breaking through the constraints of the surface grammar structure of the sentence, semantic dependency analysis can be performed based on the above-mentioned target dependency syntax tree to determine the semantic dependency structure of the target text, wherein the above-mentioned semantic dependency structure is used to represent the semantic associations between the components in the target text.

[0030] In this embodiment, the semantic structure and the syntactic structure are two independent structures, and any structure includes two aspects: one is the component, and the other is the component relationship. In terms of components, the semantic structure has components such as agent, patient, predicate, etc., and the syntactic structure has components such as subject, predicate, object, etc. The smallest unit of the semantic structure is the semantic word (also called sememe), and the largest unit is the semantic sentence; the smallest unit of the syntactic structure is the lexical word (also called lexeme). Components with a direct grammatical structure relationship may not have a connection in the semantic structure, while components without a direct grammatical structure relationship may have a direct semantic relationship in semantics. Therefore, semantic orientation analysis can better reflect the relationship between the grammatical structure and the semantic structure, so that the combination of form and meaning can be carried out to better reveal the internal structural rules of the sentence.

[0031] In this embodiment, semantic dependency analysis is a deep semantic analysis theory that integrates the dependency structure and semantic information of a sentence, and better expresses the structure and implicit information of the sentence. The rules for establishing the dependency structure used in semantic dependency analysis and dependency syntax analysis are different. Semantic dependency analysis directly reflects semantic information, so word pairs with semantic relationships directly form arcs without going through prepositions or auxiliary words. For a parallel structure, semantic dependency analysis takes the last parallel component as the core node, while dependency syntax analysis takes the first parallel component as the core node. Another difference between semantic dependency and syntactic dependency analysis lies in the influence of word order. Some relationships in semantic dependency are not affected by word order, such as agent, patient, content, etc.

[0032] In this embodiment, the above-mentioned semantic dependency structure can be displayed in the form of a picture or in the form of a text description. Of course, it can be understood that other possible forms can also be used for display, such as: tables, etc., which can be specifically determined according to the actual situation, and the embodiments of this specification do not limit this.

[0033] In this embodiment, a third-party product such as an NLP (Natural Language Processing) product can be used to determine the semantic dependency structure of the target text. Of course, it can be understood that other possible methods can also be adopted to determine the semantic dependency structure of the target text, such as the Language Technology Platform LTP, deep learning algorithms, etc. Specifically, it can be determined according to the actual situation, and the embodiments of this specification do not limit this.

[0034] S104: Using the semantic dependency structure, determine a structured query parameter set; wherein, the structured query parameter set contains multiple structured query parameter values required for generating structured query statements corresponding to the target text.

[0035] In this embodiment, since the above semantic dependency structure can represent the deep semantics of the target text, therefore, the above semantic dependency structure can be used to determine multiple structured query parameter values required for generating structured query statements corresponding to the target text, so as to obtain a structured query parameter set.

[0036] In this embodiment, a structured query statement (SQL statement) is mainly composed of a Select statement, a From statement, and a Where statement. Among them, the Select statement represents the query content, including the columns to be queried and the aggregation operations on these columns (such as summation, counting, average value, etc.); the From statement represents the table to be queried; the Where statement represents the query condition, including the condition column, the condition operator (such as greater than, less than, equal to), and the condition value. It is possible to first determine which structured query parameters are required to generate a structured query statement corresponding to the target text according to the above semantic dependency structure, and then the values of these structured query parameters can be obtained from a preset database, so as to obtain a structured query parameter set.

[0037] In this embodiment, a structured query statement (SQL statement) is mainly composed of a Select statement, a From statement, and a Where statement. Therefore, the above structured query parameter set can contain structured query parameters such as table names, field names, and structured query function names. Of course, the structured query parameters are not limited to the above examples. Those skilled in the art may make other changes under the inspiration of the technical essence of the embodiments of this specification, but as long as the functions and effects achieved by them are the same as or similar to those of the embodiments of this specification, they should all be covered within the protection scope of the embodiments of this specification.

[0038] S105: Generate a structured query statement corresponding to the target text according to the structured query parameter set and the semantic dependency structure.

[0039] In this embodiment, since the structured query parameter set contains multiple structured query parameter values required for generating a structured query statement corresponding to the target text, and the semantic dependency structure can represent the deep semantics of the target text, a structured query statement corresponding to the target text can be generated according to the structured query parameter set and the semantic dependency structure.

[0040] In this embodiment, Structured Query Language (SQL) is a database query and programming language used to access data and query, update, and manage relational database systems.

[0041] In this embodiment, a structured query statement can be generated based on the template format of the structured query language, in combination with multiple structured query parameter values required for generating a structured query statement corresponding to the target text and the semantic associations between the various components in the target text. For example: if the target text is "I want to query the average daily deposit balance of the Shanghai Branch in 2020", the generated structured query language can be "Select avg(balance) from DCM_SAVING_ACCT where year = '2020' and org_name = 'Shanghai Branch'". Among them, the above balance is the field name of the data lake table corresponding to the customer fact entity "balance", avg() is the structured query function corresponding to the operator entity "average daily", DCM_SAVING_ACCT is the data lake table name corresponding to the financial product entity "deposit", year is the field name corresponding to the date entity "2020", and org_name is the field name corresponding to the organization entity "branch".

[0042] In this embodiment, after determining that the structured query statement corresponding to the target text is successfully generated, the generated structured query statement can be fed back to the user so that the user can access the big data based on the generated structured query statement to obtain the required information, enabling business personnel without a technical background to conveniently use the structured query statement to access the big data.

[0043] From the above description, it can be seen that the embodiment of this specification realizes the following technical effects: by acquiring the target text, a target dependency syntax tree can be generated based on the target text, so that the syntactic structure of the target text can be determined. Since semantic information is closely related to the syntax and word meaning information of the sentence, in order to cross the constraints of the surface grammatical structure of the sentence to obtain deep semantic information, a semantic dependency analysis can be performed based on the above target dependency syntax tree to determine the semantic dependency structure of the target text, wherein the above semantic dependency structure is used to characterize the semantic association between the components in the target text. Further, the semantic dependency structure can be used to determine the structured query parameter values ​​required for generating structured query statements corresponding to the target text, and obtain a structured query parameter set. And according to the structured query parameter set and the semantic dependency structure, a structured query statement corresponding to the target text is generated. Thus, the structured query statement of the target text can be accurately generated based on the semantic dependency structure obtained by the target text, so that business personnel with non-technical backgrounds can also conveniently use structured query statements to access big data.

[0044] In one embodiment, generating a target dependency syntax tree based on a target text may include: preprocessing the target text to obtain a preprocessing result; wherein the preprocessing includes: word segmentation and part-of-speech tagging. Performing named entity recognition on the preprocessing result to obtain a recognition result. Further, grammatical component analysis may be performed based on the preprocessing result and the recognition result to obtain a target dependency syntax tree.

[0045] In this embodiment, the target text can be preprocessed first, and the target text can be reasonably segmented and marked with parts of speech. The Chinese corpus vocabulary can be used to determine the association probability between each Chinese character in the target text, and phrases with high probability are formed to form a segmentation result and mark the part of speech. The above-mentioned Chinese corpus can be the CCL (Center for Chinese Linguistics) corpus of Peking University, etc. The Chinese corpus can contain a large amount of Chinese corpus, which can be used to count the association relationship and association probability between each Chinese character. For example, the segmentation result of "I want to check the average daily deposit balance of Shanghai Branch in 2020" can be "I want to check the average daily deposit balance of Shanghai Branch in 2020".

[0046] In this embodiment, part of speech refers to the characteristics of a word as the basis for dividing the word class. Part of speech tagging is to determine the grammatical category of each word in a given sentence. Words can be divided into content words and function words. Content words include body words, predicates, etc., and body words can be divided into nouns and pronouns. Third-party products such as language technology platform LTP can be used for word segmentation and part of speech tagging. Of course, it can be understood that other possible ways can also be used for word segmentation and part of speech tagging, such as stuttering word segmentation, deep learning algorithm, etc., which can be determined according to actual conditions, and this specification embodiment does not limit this.

[0047] In this embodiment, named entity recognition can be performed according to the word segmentation result and the part-of-speech tagging result, and all proper nouns that may appear in the target text can be recognized as entities. Named entities generally can include personal names, place names, organization names, time, dates, currencies, percentages, etc. In some embodiments, the entity scope can be further expanded according to the application scenario, such as proper nouns in various fields. The proper nouns that need to be expanded in the financial scenario can include: financial products (deposits, loans, intermediate business, etc.), indicator names (balances, transaction amounts, occurrence amounts, etc.), statistical operators (summarization, daily average, number of times, etc.), accounting subjects, etc.

[0048] In this embodiment, the target text can be analyzed for syntactic components according to the word segmentation result, the part-of-speech tagging result, and the named entity recognition result, which can include syntactic components such as subject, predicate, object, attribute, adverbial, complement, etc., and presented in the form of a syntax tree, so that the target dependency syntax tree can be accurately obtained.

[0049] In one embodiment, using the semantic dependency structure, a set of structured query parameters can be determined, which can include: converting the semantic dependency structure into an Extensible Markup Language (XML) format to obtain the target semantic dependency structure information. Further, according to the correspondence between the named entity and the structured query parameter, the structured query parameter values corresponding to each named entity included in the target semantic dependency structure information can be queried from the preset knowledge graph to obtain the set of structured query parameters.

[0050] In this embodiment, since the XML (Extensible Markup Language) message form is a common structured text format and is easy to save and parse, therefore, the semantic dependency structure can be transmitted in the form of Extensible Markup Language. Correspondingly, the set of structured query parameters can also be transmitted in the form of Extensible Markup Language. Of course, it can be understood that other possible forms can also be used for transmission, which can be specifically determined according to the actual situation, and the embodiments of this specification do not limit this.

[0051] In this embodiment, according to the correspondence between the named entity and the structured query parameter, the structured query parameter values corresponding to each named entity included in the target semantic dependency structure information can be queried from the preset knowledge graph. Since the structured query statement has its special language structure, different named entities in the text can each have corresponding structured query parameters in the structured query statement. For example: the structured query parameter corresponding to the financial product entity is the data lake table name, the structured query parameter corresponding to the operator entity (daily average) retrieval is the structured query function name, the structured query parameter corresponding to the customer entity is the field name of the data lake table, etc.

[0052] In this embodiment, the correspondence between named entities and structured query parameters can be pre-configured and stored in a preset database for timely invocation when needed. In a financial scenario, the named entities that may be involved in the target text include financial product entities, metric name entities, date entities, institution entities, operator entities, etc. For these entities, the table name, field name, and SQL function name can be retrieved respectively in the preset knowledge graph. If the application scenario is further expanded, the scope of named entities (and corresponding retrieval targets) can be further expanded.

[0053] In this embodiment, the SQL statement is mainly composed of a Select statement, a From statement, and a Where statement. Among them, when the target text is "I want to query the average daily deposit balance of Shanghai Branch in 2020", the column to be queried in the Select statement is the field name of the data lake table corresponding to the customer fact entity (balance) in the target semantic dependency structure information, and the aggregation operation on this column is the SQL function name corresponding to the operator entity (average daily); the table to be queried in the From statement is the data lake table name corresponding to the financial product entity (deposit) in the target semantic dependency structure information; the column names corresponding to the date entity (2020) and the institution entity (branch) in the target semantic dependency structure information need to be queried in the Where statement. Of course, the correspondence between named entities and structured query parameters is not limited to the above examples. Those skilled in the art may make other changes under the inspiration of the technical essence of the embodiments of this specification, but as long as the functions and effects achieved are the same or similar to those of the embodiments of this specification, they should all be covered within the protection scope of the embodiments of this specification.

[0054] In this embodiment, the above knowledge graph is a large-scale semantic network knowledge base, adopting a symbolic knowledge representation method, using triples to describe specific knowledge, and representing and storing it in the form of a directed graph, which has the advantages of rich semantics, friendly structure, and easy to understand. The preset knowledge graph can be constructed based on the data lake table name, field name, and function names supported by the data lake SQL engine used, so that the structured query parameter values corresponding to each named entity included in the target semantic dependency structure information can be accurately queried based on the preset knowledge graph.

[0055] In one embodiment, the above structured query parameters may include: table name, field name, structured query function name, etc. Of course, the structured query parameters are not limited to the above examples. Those skilled in the art may make other changes under the inspiration of the technical essence of the embodiments of this specification, but as long as the functions and effects achieved are the same or similar to those of the embodiments of this specification, they should all be covered within the protection scope of the embodiments of this specification.

[0056] In one embodiment, generating a structured query statement corresponding to the target text according to a set of structured query parameters and a semantic dependency structure may include: when it is determined that the set of structured query parameters contains at least one structured query parameter value, generating a structured query statement corresponding to the target text according to the set of structured query parameters and the semantic dependency structure. When it is determined that there is no structured query parameter value in the set of structured query parameters, an exception prompt message may be fed back.

[0057] In this embodiment, before generating a structured query statement corresponding to the target text, it may first be determined whether the retrieved set of structured query parameters contains corresponding data. When it is determined that there is at least one structured query parameter value, an SQL statement may be assembled according to the semantic dependency structure and the set of structured query parameters, so as to generate a structured query statement corresponding to the target text.

[0058] In this embodiment, if it is determined that there is no structured query parameter value in the set of structured query parameters, a default answer may be given to feed back an exception prompt message to the user. Among them, the above exception prompt message may be: Sorry, no relevant data can be found! Of course, the exception prompt message is not limited to the above example. Those skilled in the art may make other changes under the inspiration of the technical essence of the embodiments of this specification, but as long as the functions and effects achieved are the same or similar to those of the embodiments of this specification, they should all be covered within the protection scope of the embodiments of this specification.

[0059] In this embodiment, before generating a structured query statement corresponding to the target text, it may first be determined whether the retrieved set of structured query parameters contains corresponding data, and then corresponding information may be fed back based on the determined result, thereby further improving the accuracy and effectiveness of generating the structured query statement.

[0060] In one embodiment, determining the semantic dependency structure of the target text based on the target dependency syntax tree may include: performing semantic role labeling on the target dependency syntax tree to obtain a semantic role labeling result; wherein, the semantic role labeling result is used to represent the argument structure of the predicate of the target text. Further, semantic dependency analysis may be performed based on the target dependency syntax tree and the semantic role labeling result to obtain the semantic dependency structure of the target text.

[0061] In this embodiment, semantic role labeling may be performed on the target dependency syntax tree. Semantic role labeling may analyze the predicate-argument structure in the target text and use semantic roles to describe the relationship between each component in the sentence and the predicate, which is shallow semantic analysis. The task of semantic role labeling is to find the corresponding semantic role components of the predicate in the sentence, including core semantic roles (such as agent, patient, etc.) and adjunct semantic roles (such as location, time, manner, reason, etc.).

[0062] In this embodiment, an argument is only a participant in the event scenario indicated by a predicate, and is introduced into the syntactic structure by the functional category that extends the predicate. The relationship between this participant and the predicate can be close or loose, and the introduced participants constitute the argument structure of the predicate. An argument can be understood as a noun phrase with a referential function, including names, variables, anaphors, pronouns, etc. In addition, it can also include clauses.

[0063] In this embodiment, semantic dependency analysis can be performed based on the target dependency syntactic tree and the semantic role annotation results to obtain the semantic dependency structure of the target text. Semantic dependency analysis can analyze the semantic associations between the components of the target text (not limited to those between a predicate and an argument), so as to obtain deep semantic information across the constraints of the surface grammar structure of the sentence, which is deep semantic analysis. In one embodiment, when the target text is "I want to query the average daily deposit balance of the Shanghai Branch in 2020", the above semantic dependency structure can be as Figure 2 shown below. Among them, the predicate "query" is the core of the sentence; "I" is the agent (AGT); "balance" is the patient (CONT), and is also a named entity - an index name entity; "2020", "average daily", "deposit", and "branch" are all modifiers (FEAT) of the patient, and these modifiers themselves are also named entities. "2020" is a date entity (TIME), "average daily" is an operator entity, "deposit" is a financial product entity, and "branch" is an institutional entity; Root is the root node, mDEPD is the attachment marker, and mPUNC is the punctuation marker. Of course, the semantic dependency structure is not limited to the above example. Those skilled in the art may make other changes under the inspiration of the technical essence of the embodiments of this specification, but as long as the functions and effects achieved are the same as or similar to those of the embodiments of this specification, they should all be covered within the protection scope of the embodiments of this specification.

[0064] In one embodiment, the above semantic dependency structure includes the semantic associations between the various words in the target text (not limited to those between a predicate and an argument), and the semantic associations include: agent, patient, modifiers of the patient, etc. Of course, the semantic associations are not limited to the above example. Those skilled in the art may make other changes under the inspiration of the technical essence of the embodiments of this specification, but as long as the functions and effects achieved are the same as or similar to those of the embodiments of this specification, they should all be covered within the protection scope of the embodiments of this specification.

[0065] Based on the same inventive concept, an apparatus for generating a structured query statement is also provided in the embodiments of this specification, as described in the following embodiments. Since the principle of the apparatus for generating a structured query statement to solve problems is similar to that of the method for generating a structured query statement, the implementation of the apparatus for generating a structured query statement can refer to the implementation of the method for generating a structured query statement, and the repeated parts will not be elaborated here. As used hereinafter, the term "unit" or "module" may be a combination of software and / or hardware that can implement a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated. Figure 3 is a structural block diagram of the apparatus for generating a structured query statement according to an embodiment of this specification, as Figure 3 shown, and may include: an acquisition module 301, a conversion module 302, a first determination module 303, a second determination module 304, and a generation module 305. The following is an explanation of this structure.

[0066] The acquisition module 301 may be used to acquire a target text;

[0067] The conversion module 302 may be used to generate a target dependency syntax tree based on the target text;

[0068] The first determination module 303 may be used to determine the semantic dependency structure of the target text based on the target dependency syntax tree; wherein, the semantic dependency structure is used to represent the semantic association between the components in the target text;

[0069] The second determination module 304 may be used to determine a structured query parameter set by using the semantic dependency structure; wherein, the structured query parameter set contains multiple structured query parameter values required for generating a structured query statement corresponding to the target text;

[0070] The generation module 305 may be used to generate a structured query statement corresponding to the target text according to the structured query parameter set and the semantic dependency structure.

[0071] The embodiments of this specification also provide an electronic device, which can be specifically referred to Figure 4Schematic diagram of the composition structure of an electronic device based on the method for generating a structured query statement provided in the embodiments of this specification. Specifically, the electronic device may include an input device 41, a processor 42, and a memory 43. Among them, the input device 41 may specifically be used to input a target text. The processor 42 may specifically be used to obtain the target text; generate a target dependency syntax tree based on the target text; determine the semantic dependency structure of the target text based on the target dependency syntax tree, where the semantic dependency structure is used to represent the semantic association between the components in the target text; use the semantic dependency structure to determine a set of structured query parameters, where the set of structured query parameters contains structured query parameter values required for generating a structured query statement corresponding to the target text; and generate a structured query statement corresponding to the target text according to the set of structured query parameters and the semantic dependency structure. The memory 43 may specifically be used to store data such as the structured query statement corresponding to the target text.

[0072] In this embodiment, the input device may specifically be one of the main devices for information exchange between the user and the computer system. The input device may include a keyboard, a mouse, a camera, a scanner, a light pen, a handwriting input board, a voice input device, etc.; the input device is used to input the original data and the program for processing these data into the computer. The input device may also obtain and receive data transmitted from other modules, units, and devices. The processor may be implemented in any suitable manner. For example, the processor may take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, etc. The memory may specifically be a memory device used to store information in modern information technology. The memory may include multiple levels. In a digital system, as long as it can store binary data, it can be a memory; in an integrated circuit, a circuit without a physical form but with a storage function is also called a memory, such as a RAM, a FIFO, etc.; in a system, a storage device with a physical form is also called a memory, such as a memory module, a TF card, etc.

[0073] In this embodiment, the functions and effects specifically implemented by the electronic device may be explained in comparison with other embodiments and will not be elaborated here.

[0074] In an embodiment of this specification, a computer storage medium for a method of generating based on structured query statements is further provided. The computer storage medium stores computer program instructions, and when the computer program instructions are executed, the following can be achieved: obtaining a target text; generating a target dependency syntax tree based on the target text; determining a semantic dependency structure of the target text based on the target dependency syntax tree, where the semantic dependency structure is used to represent the semantic association between components in the target text; using the semantic dependency structure to determine a set of structured query parameters, where the set of structured query parameters contains structured query parameter values required for generating a structured query statement corresponding to the target text; and generating a structured query statement corresponding to the target text according to the set of structured query parameters and the semantic dependency structure.

[0075] In this embodiment, the above storage medium includes, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a cache, a hard disk drive (HDD), or a memory card. The memory can be used to store computer program instructions. The network communication unit can be set according to standards specified by a communication protocol and is an interface for network connection communication.

[0076] In this embodiment, the functions and effects specifically implemented by the program instructions stored in the computer storage medium can be explained in comparison with other embodiments and will not be elaborated here.

[0077] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the embodiments of this specification can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order than here, or they can be separately made into individual integrated circuit modules, or multiple of them can be made into a single integrated circuit module to implement. Thus, the embodiments of this specification are not limited to any specific combination of hardware and software.

[0078] Although the embodiments of this specification provide method operation steps as described in the above embodiments or flowcharts, more or fewer operation steps may be included in the method based on routine or non-creative labor. In steps where there is no necessary causal relationship logically, the execution order of these steps is not limited to the execution order provided in the embodiments of this specification. When the actual device or terminal product of the described method is executed, it may be executed in the method order shown in the embodiments or the drawings or in parallel (for example, in an environment of parallel processors or multi-threaded processing).

[0079] It should be understood that the above description is for illustrative purposes and not for limitation. Many embodiments and many applications other than the examples provided will be apparent to those skilled in the art upon reading the above description. Therefore, the scope of the embodiments of this specification should not be determined with reference to the above description, but should be determined with reference to the full scope of the foregoing claims and the equivalents thereof.

[0080] The above are only the preferred embodiments of the embodiments of this specification and are not used to limit the embodiments of this specification. For those skilled in the art, various changes and modifications can be made to the embodiments of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of this specification shall be included within the protection scope of the embodiments of this specification.

Claims

1. A method for generating a structured query statement, characterized in that, including: Obtain a target text; Generate a target dependency syntax tree based on the target text; Based on the target dependency syntax tree, use a deep learning algorithm to determine the semantic dependency structure of the target text; wherein, the semantic dependency structure is used to characterize the semantic association between components in the target text; the rule for establishing the dependency structure used by the semantic dependency structure and the target dependency syntax tree is different; Utilize the semantic dependency structure to determine a structured query parameter set; wherein, the structured query parameter set contains structured query parameter values required for generating multiple structured query statements corresponding to the target text; Generate a structured query statement corresponding to the target text according to the structured query parameter set and the semantic dependency structure.

2. The method according to claim 1, characterized in that, Generating a target dependency syntax tree based on the target text includes: Preprocess the target text to obtain a preprocessing result; wherein, the preprocessing includes: word segmentation and part-of-speech tagging; Perform named entity recognition on the preprocessing result to obtain a recognition result; Perform syntactic component analysis according to the preprocessing result and the recognition result to obtain the target dependency syntax tree.

3. The method according to claim 2, characterized in that, Utilizing the semantic dependency structure to determine a structured query parameter set includes: Convert the semantic dependency structure into an Extensible Markup Language format to obtain target semantic dependency structure information; According to the correspondence between named entities and structured query parameters, query the structured query parameter values corresponding to each named entity included in the target semantic dependency structure information from a preset knowledge graph to obtain a structured query parameter set.

4. The method according to claim 3, characterized in that, The structured query parameters include: table name, field name, structured query function name.

5. The method according to claim 2, characterized in that, Generating a structured query statement corresponding to the target text according to the structured query parameter set and the semantic dependency structure includes: In the case where it is determined that the structured query parameter set contains at least one structured query parameter value, generate a structured query statement corresponding to the target text according to the structured query parameter set and the semantic dependency structure; In the case where it is determined that there is no structured query parameter value in the structured query parameter set, feedback an exception prompt message.

6. The method according to claim 1, characterized in that, Based on the target dependency syntax tree, determining the semantic dependency structure of the target text includes: Perform semantic role annotation on the target dependency syntax tree to obtain a semantic role annotation result; wherein, the semantic role annotation result is used to characterize the argument structure of the predicate in the target text; Perform semantic dependency analysis based on the target dependency syntax tree and the semantic role annotation result to obtain the semantic dependency structure of the target text.

7. The method according to claim 1, characterized in that, The semantic dependency structure contains the semantic association between each word in the target text, and the semantic association includes: agent, patient, modification of the patient.

8. An apparatus for generating a structured query statement, characterized in that, including: An acquisition module, configured to acquire a target text; A conversion module, configured to generate a target dependency syntax tree based on the target text; A first determination module, configured to determine a semantic dependency structure of the target text based on the target dependency syntax tree by using a deep learning algorithm; wherein, the semantic dependency structure is used to characterize the semantic association between components in the target text; the rule for establishing the semantic dependency structure and the dependency structure used by the target dependency syntax tree is different; A second determination module, configured to determine a structured query parameter set by using the semantic dependency structure; wherein, the structured query parameter set includes structured query parameter values required for generating a plurality of structured query statements corresponding to the target text; A generation module, configured to generate a structured query statement corresponding to the target text according to the structured query parameter set and the semantic dependency structure.

9. A device for generating a structured query statement, characterized in that, It includes a processor and a memory for storing instructions executable by the processor, and when the processor executes the instructions, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that, Computer instructions are stored thereon, and when the instructions are executed, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method and device for outputting structured query statements

    CN107451153A

  • Chinese structured event extraction method

    CN112183059A