SQL (Structured Query Language) query statement generation method and device, computer equipment and storage medium
Through intent recognition, dimension analysis and problem parsing, SQL query statements are generated using a preset SQL data table library, which solves the problems of high cost and low efficiency in existing technologies and achieves fast and accurate conversion of natural language to SQL query statements.
Patent Information
- Application Number
- CN202510708329.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-10-21
AI Technical Summary
In the prior art, converting query text into SQL query statements is costly and inefficient, requiring professional technicians to perform annotation and development.
Through intent recognition, dimension analysis, statement splitting and question parsing, SQL query statements are generated using the preset SQL data table library, including intent recognition module, dimension analysis module, statement splitting module and question parsing module, which can quickly and accurately convert natural language questions into SQL query statements.
It can quickly and accurately convert natural language questions into SQL query statements, improve generation efficiency and reduce development costs.
Smart Images

Figure CN120821740A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of SQL query statement generation, and in particular to a method, device, computer equipment and storage medium for generating SQL query statements. Background Art
[0002] In recent years, with the rapid development of intelligent technologies, users in the marketing field have increasingly demanded faster and more flexible data queries. The existing data query method, which relies on professional technicians manually writing SQL (Structured Query Language) statements, is no longer able to meet these needs. Therefore, automatically converting query text into SQL statements has become a research topic in the data query field.
[0003] Existing research on developing parsers that convert query text into SQL statements primarily relies on collecting large amounts of annotated data and using supervised learning to train models. However, annotating SQL requires deep programming knowledge, requiring highly skilled programmers to perform the annotation. This results in high parser development costs and a long development period. In other words, converting query text into SQL statements is both costly and inefficient. Summary of the Invention
[0004] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for generating SQL query statements to address the above technical problems, so as to solve the problem of high cost and low efficiency in converting query text into SQL query statements in the prior art.
[0005] A method for generating an SQL query statement, comprising: Obtaining a query statement, performing intent recognition on the query statement, and obtaining an intent recognition result; When the intention recognition result indicates that the query statement is an answerable statement, performing dimensional analysis on the query statement to obtain dimensional data of the query statement; Splitting the query statement according to the dimension data and the indicator data to obtain at least two question sub-statements; Based on the preset SQL data table library, the dimension data and the indicator data, all the question sub-statements are parsed, and an SQL parsing statement is generated for each of the question sub-statements; Generate an SQL query statement corresponding to the query question statement based on all the SQL parsing statements.
[0006] A device for generating SQL query statements, comprising: An intent recognition module is used to obtain a query question statement, perform intent recognition on the query question statement, and obtain an intent recognition result; a dimensionality analysis module, configured to perform dimensionality analysis on the query statement to obtain dimensional data of the query statement when the intention recognition result indicates that the query statement is an answerable statement; A statement splitting module is used to perform statement splitting processing on the query question statement according to the dimension data and the indicator data to obtain at least two question sub-statements; A question parsing module, configured to parse all the question sub-statements based on a preset SQL data table library, the dimension data, and the indicator data, and generate an SQL parsing statement for each of the question sub-statements; The SQL query statement module is used to generate an SQL query statement corresponding to the query question statement based on all the SQL parsing statements.
[0007] A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the above-mentioned SQL query statement generation method is implemented.
[0008] One or more readable storage media storing computer-readable instructions, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors execute the above-mentioned SQL query statement generation method.
[0009] The above-mentioned SQL query statement generation method, device, computer equipment and storage medium, the method includes: obtaining a query question statement, performing intent recognition on the query question statement, and obtaining an intent recognition result; when the intent recognition result indicates that the query question statement is an answerable statement, performing dimension analysis on the query question statement to obtain dimension data of the query question statement; performing statement splitting processing on the query question statement based on the dimension data and indicator data to obtain at least two question sub-statements; based on a preset SQL data table library, the dimension data and the indicator data, performing question parsing on all the question sub-statements, and generating an SQL parsing statement for each of the question sub-statements; generating an SQL query statement corresponding to the query question statement based on all the SQL parsing statements. This embodiment can convert natural language questions into SQL query statements that can accurately answer user questions, so as to retrieve relevant data from the corresponding information library. In this way, natural language questions can be quickly and accurately converted into SQL query statements, thereby improving the efficiency of generating SQL query statements. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0011] Figure 1 This is a schematic diagram of an application environment of a method for generating SQL query statements in one embodiment of the present invention; Figure 2 This is a flow chart of a method for generating an SQL query statement according to an embodiment of the present invention; Figure 3 It is a structural diagram of a device for generating SQL query statements in one embodiment of the present invention; Figure 4 FIG. 1 is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0012] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0013] The SQL query statement generation method provided in this embodiment can be applied to Figure 1 In an application environment, a client communicates with a server. Clients include, but are not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented as a standalone server or a server cluster consisting of multiple servers.
[0014] In one embodiment, if Figure 2 As shown, a method for generating SQL query statements is provided, which is applied in Figure 1 The server in the example is used as an example to illustrate the following steps: S10: Obtain a query statement, perform intent recognition on the query statement, and obtain an intent recognition result.
[0015] Understandably, a query question statement refers to a natural language question received from the user end. For example, the query question statement may be "Query the volume of Xiaomi cars on the Douyin platform". Intent recognition refers to the process of analyzing the intent of the query question statement through natural language processing technology to obtain the intent recognition result. Among them, the intent recognition result includes information such as indicator keywords, entity words, and contextual semantics that indicate the question intent of the query question statement. For example, the query question statement may be "Query the volume of car A on platform B", then the intent recognition result may include the contextual semantics that the intent of the query question statement is a volume query, and may also include entity words: car A and platform B, and may also include indicator keywords: volume.
[0016] S20. When the intention recognition result indicates that the query statement is an answerable statement, perform dimensional analysis on the query statement to obtain dimensional data of the query statement.
[0017] Understandably, when the contextual semantics of a query statement indicate that the query statement is malicious or unanswerable, the query statement is considered unanswerable. When the contextual semantics of a query statement indicate that the query statement is intended to be a rule-compliant query, such as a volume query, the query statement is considered answerable. An answerable statement is one that can be answered. Dimensional analysis is the process of analyzing key dimensions in a query statement to obtain dimensional data. This dimensional data includes information on each dimension involved in the query statement (including platform, brand, industry, and activity dimensions) and related attribute information. For example, if the query statement is "Query the volume of Xiaomi cars on the Douyin platform," the dimensional data for this query statement includes the brand (Xiaomi) dimension, the platform (Douyin) dimension, and the related attribute (volume).
[0018] S30: Split the query statement according to the dimension data and the indicator data to obtain at least two question sub-statements.
[0019] Understandably, statement splitting processing refers to breaking down the query statement into smaller, more understandable parts, with each question sub-statement corresponding to a sub-part of the query statement. Among them, the question sub-statements refer to the various parts after the question is decomposed, and each question sub-statement can independently generate an SQL parsing statement. Index data refers to the relevant index information corresponding to the query statement. Specifically, the index data is determined by querying the relevant index data in the index database based on the indicator keywords in the intent recognition results. Among them, the indicator database refers to a database that stores several indicator data related to the indicator keywords. According to the dimension data and the indicator data obtained by the query, the query statement is split into several question sub-statements.
[0020] Specifically, for a query like "Query Xiaomi's total reach, total buzz, and total interactions on Douyin and Bilibili over the past 30 days," intent recognition results for the query may include entity words (Bilibili, Douyin, and Xiaomi), indicator keywords (total buzz and total interactions), and contextual semantics indicating that the query is answerable. Dimensional analysis is then performed based on the entity words and indicator keywords to generate dimensional data. Based on the indicator keywords (total buzz and total interactions), the indicator database is searched for indicator data (time, total buzz, and total interactions) corresponding to total buzz and total interactions. Finally, based on the indicator data and dimension data, "Query Xiaomi's total reach in the past 30 days, its total voice on the Douyin platform, its total voice on the Bilibili platform, and its total interaction volume" can be divided into multiple question sub-statements such as "Query Xiaomi's total reach in the past 30 days", "Query Xiaomi's total voice on the Douyin platform in the past 30 days", "Query Xiaomi's total voice on the Bilibili platform in the past 30 days", "Query Xiaomi's total interaction volume in the past 30 days", and "Query Xiaomi's total interaction volume on the Bilibili platform in the past 30 days".
[0021] S40: Based on the preset SQL data table library, the dimension data and the indicator data, all the question sub-statements are parsed, and an SQL parsing statement is generated for each of the question sub-statements.
[0022] It can be understood that the preset SQL data table library refers to a pre-set SQL data table library, including several SQL data tables. Among them, the SQL data table refers to a table used to generate SQL parsing statements, and the SQL parsing statement of each question sub-statement is based on one or more SQL data tables. Question parsing refers to the process of mapping the question sub-statements to the SQL data tables and columns in the preset SQL data table library based on dimensional data and indicator data, and determining the SQL data tables and columns required for the query. The SQL parsing statement refers to a simplified representation of the SQL query generated for each question sub-statement, which contains the required tables and columns, but does not contain specific values. That is, the SQL parsing statement includes information about the SQL data table corresponding to the question sub-statement. For example, if the question sub-statement is "Query the total reach of Xiaomi in the past 30 days", the generated SQL parsing statement can be: reach-metrics(brand-name, period, total-reach).
[0023] S50: Generate an SQL query statement corresponding to the query question statement based on all the SQL parsing statements.
[0024] It can be understood that after the SQL parsing statements are generated, all SQL parsing statements are assembled to obtain SQL query statements.
[0025] Preferably, after determining the SQL query statement, an SQL query is performed according to a preset query strategy.
[0026] Specifically, you can start the query from the From statement in the SQL query statement, then query the Where statement, and then query the Select statement. In this way, you can ensure the accuracy of the query.
[0027] In steps S0-S50, a query question statement is obtained, and the query question statement is subjected to intent recognition to obtain an intent recognition result; when the intent recognition result indicates that the query question statement is an answerable statement, the query question statement is subjected to dimension analysis to obtain dimension data of the query question statement; based on the dimension data and the indicator data, the query question statement is subjected to statement splitting processing to obtain at least two question sub-statements; based on the preset SQL data table library, the dimension data and the indicator data, all the question sub-statements are subjected to question parsing, and an SQL parsing statement is generated for each of the question sub-statements; based on all the SQL parsing statements, an SQL query statement corresponding to the query question statement is generated. This embodiment can convert natural language questions into SQL query statements that can accurately answer user questions, so as to retrieve relevant data from the corresponding information library. In this way, natural language questions can be quickly and accurately converted into SQL query statements, thereby improving the efficiency of generating SQL query statements.
[0028] In one embodiment, in step S10, performing intent recognition on the query statement to obtain an intent recognition result includes: S101, performing word segmentation processing on the query statement to obtain a word segmentation text; S102, performing intent recognition on the segmented text to obtain at least one entity word and at least one indicator keyword; S103. Generate intent recognition results based on all the entity words and all the indicator keywords.
[0029] Generally speaking, word segmentation refers to the process of breaking down a user's query into words or phrases. Word segmentation is typically performed using natural language processing tools or libraries (such as NLTK and SpaCy). The goal of word segmentation is to convert a continuous text sequence into a discrete sequence of words or phrases for easier analysis and processing. Segmented text refers to the text obtained after word segmentation, in which each word or phrase is independent and can be further analyzed. Intent identification refers to the process of performing intent analysis on segmented text to determine the core intent of the user's query. Intent identification involves identifying key entities and key metrics in the query. Entity words are words that represent specific things, concepts, or objects in the query. For example, in the query "Which advertising platform should I choose to promote my new product?", "advertising platform" is an entity word. Metric keywords are words that represent key performance indicators or metrics in the query. For example, in the query "Which advertising platform should I choose to promote my new product?", "promote" may be a metric keyword because it indicates the query intent is about promotion. Intent recognition results identify the core intent of a user's query based on entity words and indicator keywords, generating a result that accurately reflects the user's query intent. This intent recognition result includes information such as indicator keywords, entity words, and contextual semantics that indicate the query's intent. Steps S101-S103 extract key information for generating SQL queries, making the resulting SQL query more accurate.
[0030] In one embodiment, that is, step S103, after generating the intent recognition result based on all the entity words and all the indicator keywords, the following steps are included: S1031, performing context analysis on all the entity words, all the indicator keywords, and the query statement to obtain the context semantics of the query statement; S1032: Determine whether the query statement is an answerable statement based on the context semantics; S1033: When the query question statement is a non-answerable statement, generate a preset answer template.
[0031] Generally speaking, context analysis refers to the process of analyzing the relationship between entity words, indicator keywords, and the entire query statement using a language model to understand the complete meaning and context of the statement. Context analysis helps determine the specific intent and focus of the query statement. Contextual semantics refers to the semantic understanding of the query statement based on context analysis, including understanding the relationship between entity words and indicator keywords within the query statement. Here, context analysis of the query statement considers the relationship between entity words and indicator keywords, making the resulting contextual semantics more accurate and clear. Generally speaking, when the contextual semantics indicate that the query statement is unanswerable (for example, because it is too vague, lacks sufficient data support, or exceeds the knowledge scope of the information database) or is malicious, indicating that the query statement may require further clarification or may be unanswerable, the query statement is determined to be unanswerable. In this case, a preset answer template is obtained to answer the query statement. Preset answer templates are pre-set answer templates. These templates may be general, such as "I need more information to answer this question," or customized for specific situations. Here, when a query statement is unanswerable, a preset answer template is directly generated for the query statement, eliminating the need to generate SQL query statements and avoiding unnecessary SQL query generation. Furthermore, when a question cannot be answered directly, using a preset answer template to generate an appropriate response can improve the user experience.
[0032] In one embodiment, that is, step S102, the entity word and indicator keyword recognition processing is performed on the segmented text to obtain at least one entity word and at least one indicator keyword, including: S1021, calculating the word frequency similarity of the segmented text; S1022, determining a part-of-speech classification result of the segmented text according to the word frequency similarity; S1023. Determine at least one entity word and at least one indicator keyword according to the part-of-speech classification result.
[0033] It can be understood that word frequency similarity refers to the frequency of occurrence of each word or phrase in the segmented text in the query question statement. The calculation of word frequency similarity helps to identify which words or phrases are most important in the query. Part-of-speech classification refers to classifying words or phrases in the segmented text into different parts of speech, such as nouns, verbs, adjectives, entity words, etc. It should be understood that part-of-speech classification helps to understand the role and meaning of words or phrases in the query. Here, based on word frequency similarity, it is possible to determine which words or phrases are most important in the query, and classify each word or phrase into the corresponding part of speech to obtain a part-of-speech classification result. In this way, key information for generating SQL queries can be extracted, making the generated SQL query statement more accurate.
[0034] In one embodiment, that is, step S40, all the question sub-statements are parsed based on a preset SQL data table library, the dimension data, and the indicator data, and an SQL parsing statement is generated for each question sub-statement, including: S401: Determine the SQL meta-statement of each query statement based on the dimension data and the indicator data; S402: Query the SQL data table corresponding to each of the SQL meta-statements in the preset SQL data table library; S403: According to the SQL data table, assemble each of the SQL meta-statements into the SQL parsing statement.
[0035] Understandably, an SQL metastatement refers to a metastatement of an SQL query of a question substatement. An SQL data table refers to a table used to generate an SQL parsing statement, and the SQL parsing statement of each question substatement is based on one or more SQL data tables. The system searches for an SQL data table corresponding to each SQL metastatement in a preset SQL library table. Assembling each of the SQL metastatements into the SQL parsing statement refers to using the table and column information in the SQL data table to replace the placeholders in the SQL metastatement with specific table names and column names to generate a complete SQL parsing statement. An SQL parsing statement refers to a complete SQL query statement corresponding to a question substatement, which contains table names, column names, and query conditions, and can be executed to retrieve data from a database. In this way, natural language questions can be converted into SQL query statements that can accurately answer user questions, so as to retrieve relevant data from the corresponding information base. In this way, natural language questions can be quickly and accurately converted into SQL query statements, thereby improving the efficiency of generating SQL query statements.
[0036] In one embodiment, that is, step S50, after generating an SQL query statement corresponding to the query question statement based on all the SQL parsing statements, the following steps are included: S501, receiving a modification instruction for modifying the SQL query statement; S502: Update the SQL query statement according to the modification content in the modification instruction to generate a new SQL query statement.
[0037] Understandably, a modification instruction refers to an instruction for modifying, deleting, adding, or other editing operations on an already generated SQL query statement. Understandably, a modification instruction is generated based on a user modifying an SQL query statement through text input, a graphical user interface (GUI), or a command line interface (CLI).
[0038] Modifications refer to changes that users wish to make to SQL query statements, including but not limited to changes to table names, column names, conditions, aggregate functions, and so on. Updates involve modifying the original SQL query statement accordingly to generate a new SQL query statement. The modified SQL query statement takes into account the user's modifications and meets their specific needs. This makes the generated SQL query statement more accurate and consistent with the user's intent. Furthermore, the query results generated by this SQL query statement are more accurate and consistent with the user's intent.
[0039] It should be understood that the order of execution of the steps in the above embodiments does not necessarily mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0040] In one embodiment, a device for generating SQL query statements is provided, which corresponds to the method for generating SQL query statements in the above embodiment. Figure 3 As shown, the SQL query statement generation device includes an intention recognition module 10, a dimension analysis module 20, a statement splitting module 30, a question analysis module 40 and an SQL query statement module 50. The functional modules are described in detail as follows: The intent recognition module 10 is used to obtain a query statement, perform intent recognition on the query statement, and obtain an intent recognition result; A dimension analysis module 20 is configured to perform dimension analysis on the query statement to obtain dimension data of the query statement when the intention recognition result indicates that the query statement is an answerable statement; A statement splitting module 30 is used to perform statement splitting processing on the query question statement based on the dimension data and the indicator data to obtain at least two question sub-statements; A question parsing module 40 is configured to parse all the question sub-statements based on a preset SQL data table library, the dimension data, and the indicator data, and generate an SQL parsing statement for each of the question sub-statements; The SQL query statement module 50 is used to generate an SQL query statement corresponding to the query question statement based on all the SQL parsing statements.
[0041] Optionally, the intention recognition module 10 includes: A word segmentation text unit is used to perform word segmentation processing on the query question sentence to obtain a word segmentation text; An intention recognition unit, configured to perform intention recognition on the segmented text to obtain at least one entity word and at least one indicator keyword; The intent recognition result unit is used to generate an intent recognition result based on all the entity words and all the indicator keywords.
[0042] Optionally, the SQL query statement generating device includes: A semantic unit, configured to perform context analysis on all the entity words, all the indicator keywords, and the query statement to obtain contextual semantics of the query statement; A judging unit, configured to judge whether the query statement is an answerable statement based on the context semantics; The answer template unit is used to generate a preset answer template when the query question statement is a non-answerable statement.
[0043] In one embodiment, that is, step S102, the entity word and indicator keyword recognition processing is performed on the segmented text to obtain at least one entity word and at least one indicator keyword, including: A similarity unit, used to calculate the word frequency similarity of the segmented text; A part-of-speech classification result unit, configured to determine a part-of-speech classification result of the segmented text according to the word frequency similarity; The keyword unit is used to determine at least one entity word and at least one indicator keyword according to the part-of-speech classification result.
[0044] In one embodiment, that is, step S40, all the question sub-statements are parsed based on a preset SQL data table library, the dimension data, and the indicator data, and an SQL parsing statement is generated for each question sub-statement, including: A meta-statement unit, configured to determine an SQL meta-statement of each query question statement based on the dimension data and the indicator data; An SQL data table unit, configured to query the SQL data table corresponding to each of the SQL meta-statements in the preset SQL data table library; The parsing statement unit is used to assemble each of the SQL meta-statements into the SQL parsing statement according to the SQL data table.
[0045] In one embodiment, that is, step S50, after generating an SQL query statement corresponding to the query question statement based on all the SQL parsing statements, the following steps are included: A modification instruction module, configured to receive a modification instruction for modifying the SQL query statement; An update module is used to update the SQL query statement according to the modification content in the modification instruction to generate a new SQL query statement.
[0046] For the specific definition of the SQL query statement generation device, please refer to the definition of the SQL query statement generation method above, and will not be repeated here. The various modules in the above-mentioned SQL query statement generation device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0047] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, memory, network interface, display screen and input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer-readable instructions. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer-readable instructions are executed by the processor, a method for generating an SQL query statement is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0048] In one embodiment, a computer device is provided, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the following steps are implemented: Obtaining a query statement, performing intent recognition on the query statement, and obtaining an intent recognition result; When the intention recognition result indicates that the query statement is an answerable statement, performing dimensional analysis on the query statement to obtain dimensional data of the query statement; Splitting the query statement according to the dimension data and the indicator data to obtain at least two question sub-statements; Based on the preset SQL data table library, the dimension data and the indicator data, all the question sub-statements are parsed, and an SQL parsing statement is generated for each of the question sub-statements; Generate an SQL query statement corresponding to the query question statement based on all the SQL parsing statements.
[0049] In one embodiment, one or more computer-readable storage media storing computer-readable instructions are provided. The computer-readable storage media provided in this embodiment include non-volatile computer-readable storage media and volatile computer-readable storage media. The computer-readable storage media store computer-readable instructions that, when executed by one or more processors, implement the following steps: Obtaining a query statement, performing intent recognition on the query statement, and obtaining an intent recognition result; When the intention recognition result indicates that the query statement is an answerable statement, performing dimensional analysis on the query statement to obtain dimensional data of the query statement; Splitting the query statement according to the dimension data and the indicator data to obtain at least two question sub-statements; Based on the preset SQL data table library, the dimension data and the indicator data, all the question sub-statements are parsed, and an SQL parsing statement is generated for each of the question sub-statements; Generate an SQL query statement corresponding to the query question statement based on all the SQL parsing statements.
[0050] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through computer-readable instructions. The computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0051] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0052] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for generating an SQL query statement, characterized in that: include: Obtaining a query statement, performing intent recognition on the query statement, and obtaining an intent recognition result; When the intention recognition result indicates that the query statement is an answerable statement, performing dimensional analysis on the query statement to obtain dimensional data of the query statement; Splitting the query statement according to the dimension data and the indicator data to obtain at least two question sub-statements; Based on the preset SQL data table library, the dimension data and the indicator data, all the question sub-statements are parsed, and an SQL parsing statement is generated for each of the question sub-statements; Generate an SQL query statement corresponding to the query question statement based on all the SQL parsing statements.
2. The method for generating an SQL query statement according to claim 1, wherein: The performing intent recognition on the query question statement to obtain an intent recognition result includes: Performing word segmentation processing on the query question statement to obtain a word segmentation text; Performing intent recognition on the segmented text to obtain at least one entity word and at least one indicator keyword; Generate intent recognition results based on all the entity words and all the indicator keywords.
3. The method for generating an SQL query statement according to claim 2, wherein: After generating the intent recognition result based on all the entity words and all the indicator keywords, the method includes: Performing context analysis on all the entity words, all the indicator keywords, and the query statement to obtain the context semantics of the query statement; Determining whether the query statement is an answerable statement based on the contextual semantics; When the query question statement is a non-answerable statement, a preset answer template is generated.
4. The method for generating an SQL query statement according to claim 2, wherein: The performing entity word and indicator keyword recognition processing on the segmented text to obtain at least one entity word and at least one indicator keyword includes: Calculating the word frequency similarity of the segmented text; Determining the part-of-speech classification result of the segmented text according to the word frequency similarity; At least one entity word and at least one indicator keyword are determined according to the part-of-speech classification result.
5. The method for generating an SQL query statement according to claim 1, wherein: Based on the preset SQL data table library, the dimension data and the indicator data, all the question sub-statements are parsed, and an SQL parsing statement is generated for each question sub-statement, including: Determine the SQL meta-statement of each query question statement according to the dimension data and the indicator data; Querying the SQL data table corresponding to each of the SQL meta-statements in the preset SQL data table library; According to the SQL data table, each of the SQL meta-statements is assembled into the SQL parsing statement.
6. The method for generating an SQL query statement according to claim 1, wherein: After generating an SQL query statement corresponding to the query question statement based on all the SQL parsing statements, the method includes: receiving a modification instruction for modifying the SQL query statement; According to the modification content in the modification instruction, the SQL query statement is updated to generate a new SQL query statement.
7. A device for generating SQL query statements, characterized in that: include: An intent recognition module is used to obtain a query question statement, perform intent recognition on the query question statement, and obtain an intent recognition result; a dimensionality analysis module, configured to perform dimensionality analysis on the query statement to obtain dimensional data of the query statement when the intention recognition result indicates that the query statement is an answerable statement; A statement splitting module is used to perform statement splitting processing on the query question statement according to the dimension data and the indicator data to obtain at least two question sub-statements; A question parsing module, configured to parse all the question sub-statements based on a preset SQL data table library, the dimension data, and the indicator data, and generate an SQL parsing statement for each of the question sub-statements; The SQL query statement module is used to generate an SQL query statement corresponding to the query question statement based on all the SQL parsing statements.
8. The SQL query statement generating device according to claim 7, wherein: The intention recognition module includes: A word segmentation unit is used to perform word segmentation processing on the query question sentence to obtain a word segmentation text; A part-of-speech recognition unit is used to perform entity word and indicator keyword recognition processing on the segmented text to obtain at least one entity word and at least one indicator keyword; The intention recognition unit is used to generate an intention recognition result based on all the entity words and all the indicator keywords.
9. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein: When the processor executes the computer-readable instructions, the method for generating an SQL query statement according to any one of claims 1 to 6 is implemented.
10. One or more computer-readable storage media storing computer-readable instructions, characterized in that: When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the SQL query statement generating method according to any one of claims 1 to 6.
Citation Information
Cited By
Intelligent approval method and system, readable storage medium and computer equipment
CN121073404A