A method, system, device and medium for generating database query statements

By building a star schema and a vocabulary in the financial field, and combining it with a large language model to process natural language text, it solves the problem of logic errors in financial analysis, generates accurate database query statements, and improves the accuracy of conversational analysis in the financial field.

CN118467682BActive Publication Date: 2024-09-24INSPUR GENERSOFT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410926042.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-09-24
Estimated Expiration
2044-07-11

AI Technical Summary

Technical Problem

The use of existing natural language processing frameworks in the field of financial analysis leads to logical errors and inaccuracies in analysis results, and fails to fully integrate the characteristics of data models in professional fields for optimization.

Method used

By building a star schema, adding financial indicator annotations, building a vocabulary in the financial field, and generating an initial database query statement based on a large language model, the matching word segmentation is detected after word segmentation processing, and the target database query statement is modified to improve accuracy.

Benefits of technology

It effectively improves the accuracy of conversational analysis in the financial field, corrects the illusion of artificial intelligence, and generates database query statements that conform to the business logic in the financial field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118467682B
    Figure CN118467682B
Patent Text Reader

Abstract

The present invention relates to the technical field of data analysis, and discloses a method, system, device and medium for generating a database query statement. The method comprises: constructing a plurality of star models according to the association relationship between each dimension table and each fact table; adding annotations containing financial indicators to all fields in each star model to construct a financial domain vocabulary; generating an initial database query statement for a natural language text input by a user based on a large language model, and performing word segmentation processing on the natural language text based on the financial domain vocabulary; in response to the presence of a target word segmentation matching at least one database field in the financial domain vocabulary in the natural language text after word segmentation processing, limiting all target word segments with preset symbols and adding annotations of the database fields matched therein within the limited range of the preset symbols to generate an intermediate statement, and correcting the initial database query statement with the intermediate statement to obtain the target database query statement. The present invention improves the accuracy of the database query statement in the financial domain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data analysis, and in particular to a method, system, device and medium for generating a database query statement. Background Art

[0002] Data analysis has evolved from manually writing SQL (Structured Query Language) to drag-and-drop analysis based on data model visualization, and now it can be analyzed based on large language model technology and understanding natural language input. The natural language processing framework in related technologies is mostly based on the meaning of the language itself, and is not fully optimized in combination with the characteristics of professional data models. For example, in the field of financial analysis, this will cause the use of conversational analysis technology based on the natural language processing framework in related technologies in the field of financial analysis to cause logical errors in the analysis results and inaccurate analysis.

[0003] Therefore, it is urgent to propose a method for generating database query statements to solve the above defects. Summary of the invention

[0004] In view of this, the present invention proposes a method, system, computer device and computer-readable medium for generating database query statements, which solve the problem of inaccurate analysis of indicators in the financial field during natural language processing leading to generation of erroneous database query statements, correct the illusion problem of artificial intelligence, and improve the accuracy of database query statements.

[0005] Based on the above purpose, an embodiment of the present invention provides a method for generating a database query statement, which specifically includes the following steps:

[0006] Construct several star models based on the association between each dimension table and each fact table;

[0007] Adding annotations containing financial indicators to all fields in each of the star models, and building a financial domain vocabulary based on all the annotated fields;

[0008] In response to receiving a natural language text input by a user, generating an initial database query statement based on a large language model, and performing word segmentation processing on the natural language text based on the financial domain vocabulary;

[0009] Detecting whether there is a target segmentation word matching at least one database field in the financial domain vocabulary in the natural language text after the segmentation processing;

[0010] In response to the existence of a target segmentation word that matches at least one database field in the financial field vocabulary, all the target segmentations are limited by preset symbols and annotations of the database fields matched by each target segmentation word are added within the range limited by the preset symbols to generate an intermediate statement, and the initial database query statement is corrected based on the intermediate statement to generate a target database query statement.

[0011] In some implementations, the step of adding annotations containing financial indicators to all fields in each of the star models includes:

[0012] Marking the fields from the dimension tables and / or the dimension columns in the fact tables as dimension classes, and marking the numerical fields in the fact tables as measurement classes;

[0013] The financial indicators corresponding to the fields of all measurement classes are labeled based on the financial analysis model. The financial indicators include point-in-time type, period-in-time type, percentage-in-time type and cumulative type.

[0014] In some implementations, the step of constructing a financial domain vocabulary based on all the annotated fields includes:

[0015] Constructing an association relationship table including all the annotated fields and their corresponding star models;

[0016] Creating a number of database fields with the names of the fields annotated after each annotation as field names to construct a financial vocabulary table, and recording the dimension class information of each database field and the star model information to which it belongs;

[0017] Based on the association table, the data value in the dimension table corresponding to each database field is obtained, and several data values ​​of different database fields with common attributes are stored as a group of data groups in the financial vocabulary table, and the dimension class information and the star model information to which each data value belongs are recorded respectively to construct the financial field vocabulary.

[0018] In some implementations, the step of constructing a plurality of star models according to the association relationship between each dimension table and each fact table includes:

[0019] Respectively obtain the associated fields of all dimension tables and all fact tables in the database, and determine the association relationship between each dimension table and each fact table and / or between each dimension table according to the associated fields;

[0020] Determine whether each of the association relationships satisfies the structural relationship of the snowflake model;

[0021] If the association relationship satisfies the structural relationship of the snowflake model, the association relationship is converted into a structural relationship that satisfies the star model, and several star models are constructed based on the converted association relationship.

[0022] If the association relationship does not satisfy the structural relationship of the snowflake model, a star model including the dimension table and several fact tables having the association relationship therewith is constructed for each dimension table.

[0023] In some implementations, the step of modifying the initial database query statement based on the intermediate statement to generate a target database query statement includes:

[0024] The intermediate statement is identified according to preset rules to generate a plurality of query clauses, and the pseudocode clauses in the initial database query statement are modified according to all the query clauses to obtain an executable target database query statement.

[0025] In some implementations, the method for generating a database query statement further includes:

[0026] The target database query statement is executed, and based on the execution result and the preset chart recommendation rule engine, a visual chart that meets the corresponding requirements of the natural language text is generated and displayed.

[0027] In some implementations, the method for generating a database query statement further includes:

[0028] Label the names of all the fields according to the language type used by the user when entering natural language text.

[0029] Another aspect of the embodiment of the present invention further provides a system for generating a database query statement, including:

[0030] A model building unit is used to build several star models based on the association between each dimension table and each fact table;

[0031] A word library construction unit is used to add annotations containing financial indicators to all fields in each of the star models, and to construct a financial domain word library based on all the annotated fields;

[0032] A processing unit, configured to generate an initial database query statement based on a large language model in response to receiving a natural language text input by a user, and perform word segmentation processing on the natural language text based on the financial domain vocabulary;

[0033] A detection unit, used to detect whether there is a target segmentation word matching at least one database field in the financial domain vocabulary in the natural language text after the segmentation processing;

[0034] A generating unit is used for, in response to the existence of a target segmentation word matching at least one database field in the financial field vocabulary, limiting all the target segmentations with preset symbols and adding annotations of the database fields matched by each target segmentation word within the range limited by the preset symbols to generate an intermediate statement, and correcting the initial database query statement based on the intermediate statement to generate a target database query statement.

[0035] According to another aspect of an embodiment of the present invention, a computer device is provided, comprising: at least one processor; and a memory, wherein the memory stores a computer program executable on the processor, and the computer program implements the steps of the above method when executed by the processor.

[0036] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, which stores a computer program that implements the above method steps when executed by a processor.

[0037] The present invention has at least the following beneficial technical effects: corresponding financial indicators and other information are annotated on all fields in a star model to construct a financial field vocabulary with detailed financial indicator markings, segmentation words in natural language texts used by users are matched based on the financial field vocabulary, and an intermediate language is generated for natural language texts with successfully matched segmentation words, and a number of query clauses are generated according to the intermediate language to correct the initial database query statement in pseudocode form generated based on a large language model, so as to obtain a target database query statement that can be accurately executed and conforms to the business logic in the financial field. The present invention replaces the original natural language description with annotations with business connotations of financial indicators through an intermediate language representation method, and accurately identifies the correct query clause through a rule engine to correct and output the final result, thereby correcting the illusion problem of artificial intelligence and effectively improving the accuracy of conversational analysis in the financial field. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.

[0039] Figure 1 A block diagram of an embodiment of a method for generating a database query statement provided by the present invention;

[0040] Figure 2 A schematic diagram of a flow chart of an embodiment of a process for generating a database query statement provided by the present invention;

[0041] Figure 3 A schematic diagram of an embodiment of a system for generating database query statements provided by the present invention;

[0042] Figure 4 A schematic diagram of the structure of an embodiment of a computer device provided by the present invention;

[0043] Figure 5 A schematic diagram of the structure of an embodiment of a computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION

[0044] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0045] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. The subsequent embodiments will not explain this one by one.

[0046] In the related technologies, the processing of natural language only considers the information of language features such as word position relationship, stop words, syntax trees or keywords, that is, it only combines the context information of the language, can achieve correct word segmentation and correct understanding of semantics, but cannot further understand the connotation and logic of various business indicators in the financial field. For example, if the AI ​​(Artificial Intelligence) in the related technology is asked "Suppose I have a database table that stores balance sheet data on a monthly basis, and now I want to see the asset situation every year, how should I write SQL", then the SQL statement generated by the AI ​​based on the large language model is "SELECT year, SUM (profit) AS total_profit_per_year FROM monthly_profit_table GROUP BY year ORDER BY year;", where monthly_profit_table is the database table name and profit is the total assets. It can be seen that the logic of the generated SQL statement is to sum the total assets of each month by year, and use the sum result as the asset situation of that year. In fact, the balance sheet in the financial field records a point-in-time asset status. It is obviously incorrect to add up the total assets by month. The correct SQL statement logic should be to query the total assets in December of each year as the asset status of that year.

[0047] In order to solve the problem of inaccurate analysis of indicators in the financial field by the conversational analysis method as mentioned above, the present invention is based on a financial analysis model, combines financial field knowledge with natural language processing, corrects the illusion problem of artificial intelligence, and improves the accuracy of conversational analysis results in the field of financial analysis.

[0048] Based on the above purpose, the first aspect of the embodiment of the present invention provides an embodiment of a method for generating a database query statement. Figure 1 As shown, it includes the following steps:

[0049] Step S100, constructing several star models according to the association relationship between each dimension table and each fact table;

[0050] Step S200, adding annotations containing financial indicators to all fields in each star model, and building a financial domain vocabulary based on all the annotated fields;

[0051] Step S300, in response to receiving the natural language text input by the user, generating an initial database query statement based on the large language model, and performing word segmentation processing on the natural language text based on the financial domain vocabulary;

[0052] Step S400, detecting whether there is a target segmentation in the natural language text after the segmentation processing that matches at least one database field in the financial domain vocabulary;

[0053] Step S500, in response to the existence of a target word segmentation that matches at least one database field in the financial field vocabulary, all target word segmentations are limited by preset symbols and annotations of the database fields matched by each target word segmentation are added within the range limited by the preset symbols to generate an intermediate statement, and the initial database query statement is corrected based on the intermediate statement to generate a target database query statement.

[0054] In some embodiments, the star model is a non-normalized data model that is widely used in developing data warehouses and dimensional data marts. It consists of a fact table and a set of dimension tables, where the fact table contains numerical or other data that can be calculated, and the dimension table contains descriptive information for classifying and analyzing facts. In the star model, each field has its own specific metadata. Metadata is data about data, which provides descriptive information about the data, including the source, format, meaning, purpose, etc. of the data. In the star model, the metadata of the field is crucial to understanding and using the data. Figure 2A flowchart of an embodiment of the process of generating a database query statement provided by the present invention. The present invention first associates the dimension tables that need to be analyzed, such as the information of the accounting unit, the region and the industry, with the fact table of the financial statement data, by writing SQL through the modeling tool of the BI (Business Intelligence) system to obtain the corresponding snowflake model, and converts the snowflake model into one or more star models, and forms metadata that records each field in the star model. If the star model is directly obtained after the above association, it is only necessary to record each field in the star model. Further, in combination with the financial analysis model, the annotation with business connotation is used to replace the original natural language description to obtain the intermediate language, and the correct SQL fragment is accurately identified by the rule engine, and the overall SQL statement is corrected based on the identified SQL fragment, and the finally generated SQL statement is output and executed. The above method can improve the accuracy of conversational natural language processing and analysis in the field of financial analysis.

[0055] In an example, the process of generating the intermediate language is explained: when a segmentation word in the financial domain vocabulary appears in the natural language text input by the user, it is enclosed in "[ ]" (i.e., preset symbols), and the annotation information of the corresponding segmentation word is added in "[ ]" according to the field annotation corresponding to the segmentation word in the financial domain vocabulary. For example, if the natural language text is "query the asset status of software companies with a founding time less than 5 years each year", where "founding time", "software company" and "assets" are segmentations stored in the financial domain vocabulary, the generated intermediate language is "query [founding time: field.dimension] less than 5 years, [software company: field value.dimension] annual [asset: field.measurement.time point type] status", where "field", "dimension", "field value" and "time point type" are field annotation information.

[0056] Continuing with the above example, the process of identifying intermediate statements to generate several query clauses is explained: when the intermediate statement is "query [establishment time: field. dimension] less than 5 years, [software company: field value. dimension] annual [asset: field. measurement. time point type] situation", the time point type field in the intermediate statement can be identified according to the configured rules, and the intermediate statement contains the keyword "yearly", then the query clause formed includes a where condition fragment, a select fragment and COL ([asset: field. measurement. time point type]) = '12' fragment. The column name of the data column read in the COL function depends on the actual column name of the database field corresponding to the extracted word "asset" in the financial domain vocabulary. The COL function fragment specifies that the database field corresponding to the asset should take the value of December each year instead of the monthly cumulative total according to the annual statistics. Other word segmentations such as period-type or time point-type business nature are also converted accordingly through preset rules.

[0057] Continuing with the above example, the process of correcting the initial database query statement is explained: the initial SQL statement generated by the large language model for the natural language text input by the user is corrected using the query clause identified above. For example, the initial SQL statement is "select company name, year, sum(assets) from financial star model where (current time - establishment time) < 5 and company category = 'software company' group by company name, year order by year", which will be corrected to "select company name, year, assets from financial star model where (current time - establishment time) < 5 and company category = 'software company' and accounting period = '12' order by year" according to the query clause, and the data table and data column to be read in the corrected statement are replaced according to the actual table name and actual column name stored in the financial domain vocabulary to obtain an executable SQL statement. For example, the actual column name of the database field corresponding to "company name" in the financial domain vocabulary is "CompanyName," then the "select company name" segment is replaced accordingly and the SQL statement of this part is "select CompanyName,".

[0058] In some embodiments, the step of adding annotations containing financial indicators to all fields in each star model includes: annotating the fields from the dimension columns of each dimension table and / or each fact table as dimension classes, and annotating the numerical fields of each fact table as measurement classes; annotating the financial indicators corresponding to the fields of all measurement classes based on the financial analysis model, and the financial indicators include point-in-time type, period type, percentage type, and cumulative type. In some embodiments, this further includes: annotating the names of all the fields according to the language type used by the user when inputting the natural language text.

[0059] In some embodiments, the financial analysis model usually marks the financial indicators in detail, such as whether the financial indicator is a period type or a point type, whether it is an amount type or a value type, whether it is a percentage type or a common value type, etc. Marking the fields in the star model includes:

[0060] (1) According to the language used by the user when asking questions, label each field in the star model according to the information recorded in its metadata. For example, if the conversation is in Chinese, the field should be named in Chinese.

[0061] (2) Based on the metadata of the star schema, the fields from the dimension table and / or dimension columns in the fact table are marked as dimensions, and the numerical fields used for measurement are marked as measures;

[0062] (3) Further label the fields marked as measurements according to the business logic or accounting standards in the financial field. For example, the financial indicators of the fields that disclose the end-of-period figures in the monthly financial report are labeled as point-in-time type, the financial indicators of the fields that disclose the current period's occurrence figures in the monthly financial report are labeled as period-type, the financial indicators of the fields that disclose percentages in the monthly financial report are labeled as percentage type, and the financial indicators of the fields that disclose the current month's cumulative figures in the monthly financial report are labeled as cumulative type.

[0063] In some embodiments, the step of constructing a financial domain vocabulary based on all annotated fields includes: constructing an association relationship table containing all annotated fields and their corresponding star models; creating a number of database fields with the name annotated by each annotated field as the field name to construct a financial domain vocabulary table, and recording the dimension class information and the corresponding star model information of each database field respectively; obtaining the data value in the dimension table corresponding to each database field based on the association relationship table, storing a number of data values ​​of different database fields with common attributes as a group of data groups in the financial domain vocabulary table, and recording the dimension class information and the corresponding star model information of each data value respectively to construct a financial domain vocabulary.

[0064] In some embodiments, the word segmentation stored in the financial domain word library is weighted by 1 times in the word segmentation model before the natural language text input by the user is segmented. The construction of the financial domain word library includes:

[0065] (1) Create a relationship table between word segmentation and its star model, which records the detailed information of specific word segmentation and star model;

[0066] (2) Add the names of all the fields marked on the star model to the financial word library table as the field names of the database fields (i.e. the stored word segments), and record the dimensions corresponding to the names and the star model information to which they belong;

[0067] (3) Add the data values ​​that appear in the dimension table in the star model to the corresponding database fields of the financial vocabulary table, and at the same time record the dimension of the data value and the star model information to which it belongs.

[0068] In some embodiments, the step of constructing several star models according to the association relationship between each dimension table and each fact table includes: respectively obtaining the association fields of all dimension tables and all fact tables in the database, and determining the association relationship between each dimension table and each fact table and / or between each dimension table according to the association field; judging whether each association relationship satisfies the structural relationship of the snowflake model; if the association relationship satisfies the structural relationship of the snowflake model, converting the association relationship into a structural relationship that satisfies the star model, and constructing several star models based on the converted association relationship; if the association relationship does not satisfy the structural relationship of the snowflake model, for each dimension table, constructing a star model including the dimension table and several fact tables that have an association relationship with it.

[0069] In some embodiments, the step of modifying the initial database query statement based on the intermediate statement to generate a target database query statement includes: identifying the intermediate statement according to preset rules to generate a number of query clauses, and modifying the pseudocode clauses in the initial database query statement according to all the query clauses to obtain an executable target database query statement.

[0070] In some embodiments, the method for generating a database query statement of the present invention further includes: executing a target database query statement, and generating and displaying a visual chart that meets the corresponding requirements of the natural language text based on the execution result and a preset chart recommendation rule engine.

[0071] In some implementations, the modified SQL statement is executed to obtain query results, and combined with a chart recommendation rule engine, a visualization chart is automatically formed to visualize the query results.

[0072] In some implementations, the step of classifying all fields into dimension categories and measurement categories includes: marking fields from dimension columns in each dimension table and / or each fact table as dimension categories, and marking numerical fields in each fact table as measurement categories.

[0073] The method for generating a database query statement of the present invention labels all fields in a star model with corresponding information such as financial indicators by combining a financial analysis model, so as to construct a financial field vocabulary with detailed financial indicator labels, matches the segmented words in the natural language text used by the user based on the financial field vocabulary, generates an intermediate language for the natural language text with successfully matched segmented words, generates a number of query clauses based on the intermediate language to correct the initial database query statement in pseudocode form generated based on the large language model, and obtains a target database query statement that can be accurately executed and conforms to the business logic in the financial field. The present invention replaces the original natural language description with a label with the business connotation of the financial indicator through an intermediate language representation method, and accurately identifies the correct query clause through a rule engine to correct and output the final result, thereby correcting the illusion problem of artificial intelligence and effectively improving the accuracy of conversational analysis in the financial field.

[0074] Based on the same inventive concept, according to another aspect of the present invention, Figure 3 As shown, an embodiment of the present invention further provides a system for generating a database query statement. The system for generating a database query statement specifically includes:

[0075] A model building unit 110 is used to build a plurality of star models according to the association relationship between each dimension table and each fact table;

[0076] The word library building unit 120 is used to add annotations containing financial indicators to all fields in each star model, and build a financial domain word library based on all the annotated fields;

[0077] The processing unit 130 is used to generate an initial database query statement based on the large language model in response to receiving the natural language text input by the user, and perform word segmentation processing on the natural language text based on the financial domain vocabulary;

[0078] A detection unit 140 is used to detect whether there is a target segmentation word matching at least one database field in the financial domain vocabulary in the natural language text after the segmentation process;

[0079] The generating unit 150 is used for, in response to the existence of a target segmentation word that matches at least one database field in the financial field vocabulary, limiting all target segmentations with preset symbols and adding annotations of the database fields matched by each target segmentation word within the range limited by the preset symbols to generate an intermediate statement, and correcting the initial database query statement based on the intermediate statement to generate a target database query statement.

[0080] The database query statement generation system of the present invention marks all fields in the star model with corresponding financial indicators and other information in combination with a financial analysis model to construct a financial field vocabulary with detailed financial indicator markings, matches the word segments in the natural language text used by the user based on the financial field vocabulary, and generates an intermediate language for the natural language text with successfully matched word segments, generates a number of query clauses based on the intermediate language to correct the initial database query statement in pseudocode form generated based on the large language model, and obtains the target database query statement that can be accurately executed and conforms to the business logic in the financial field. The present invention replaces the original natural language description with a mark with the business connotation of the financial indicator through the intermediate language representation method, and accurately identifies the correct query clause through a rule engine to correct and output the final result, thereby correcting the illusion problem of artificial intelligence and effectively improving the accuracy of conversational analysis in the financial field.

[0081] Based on the same inventive concept, according to another aspect of the present invention, Figure 4As shown, an embodiment of the present invention further provides a computer device 30, which includes a processor 310 and a memory 320. The memory 320 stores a computer program 321 that can be run on the processor. When the processor 310 executes the program, the steps of the above method are performed.

[0082] Based on the same inventive concept, according to another aspect of the present invention, Figure 5 As shown, an embodiment of the present invention further provides a computer-readable storage medium 40, which stores a computer program 410 for executing the above method when executed by a processor.

[0083] Finally, it should be noted that a person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium of the program can be a disk, an optical disk, a read-only storage memory (ROM) or a random access memory (RAM), etc. The above-mentioned computer program embodiments can achieve the same or similar effects as the corresponding above-mentioned any method embodiments.

[0084] It will also be appreciated by those skilled in the art that various exemplary logic blocks, modules, circuits and algorithm steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given to the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or hardware depends on specific applications and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the embodiments of the present invention.

[0085] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications may be made without departing from the scope of the embodiments disclosed in the present invention as defined in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. The serial numbers of the embodiments disclosed in the above embodiments of the present invention are for description only and do not represent the advantages and disadvantages of the embodiments. In addition, although the elements disclosed in the embodiments of the present invention may be described or required in individual form, they may also be understood as multiple unless explicitly limited to the singular.

[0086] It should be understood that, as used herein, the singular forms "a", "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" refers to any and all possible combinations including one or more of the associated listed items.

[0087] A person skilled in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the disclosure of the embodiments of the present invention (including the claims) is limited to these examples; under the concept of the embodiments of the present invention, the technical features in the above embodiments or different embodiments can also be combined, and there are many other changes in different aspects of the above embodiments of the present invention, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments of the present invention.

Claims

1. A method for generating a database query statement, characterized in that: include: Construct several star models based on the association between each dimension table and each fact table; Adding annotations containing financial indicators to all fields in each of the star models, and building a financial domain vocabulary based on all the annotated fields; In response to receiving a natural language text input by a user, generating an initial database query statement based on a large language model, and performing word segmentation processing on the natural language text based on the financial domain vocabulary; Detecting whether there is a target segmentation word matching at least one database field in the financial domain vocabulary in the natural language text after the segmentation processing; In response to the existence of a target segmentation word that matches at least one database field in the financial field vocabulary, all the target segmentations are limited by a preset symbol and a mark of the database field matched by each target segmentation word is added within the range limited by the preset symbol to generate an intermediate statement, and the initial database query statement is modified based on the intermediate statement to generate a target database query statement; The step of modifying the initial database query statement based on the intermediate statement to generate a target database query statement includes: The intermediate statement is identified according to preset rules to generate a plurality of query clauses, and the pseudocode clauses in the initial database query statement are modified according to all the query clauses to obtain an executable target database query statement.

2. The method for generating a database query statement according to claim 1, characterized in that: The step of adding annotations containing financial indicators to all fields in each of the star models includes: Marking the fields from the dimension tables and / or the dimension columns in the fact tables as dimension classes, and marking the numerical fields in the fact tables as measurement classes; The financial indicators corresponding to the fields of all measurement classes are labeled based on the financial analysis model. The financial indicators include point-in-time type, period-in-time type, percentage-in-time type and cumulative type.

3. The method for generating a database query statement according to claim 1, characterized in that: The step of constructing a financial domain vocabulary based on all the annotated fields includes: Constructing an association relationship table including all the annotated fields and their corresponding star models; Creating a number of database fields with the names of the fields annotated after each annotation as field names to construct a financial vocabulary table, and recording the dimension class information of each database field and the star model information to which it belongs; Based on the association table, the data value in the dimension table corresponding to each database field is obtained, and several data values ​​of different database fields with common attributes are stored as a group of data groups in the financial vocabulary table, and the dimension class information and the star model information to which each data value belongs are recorded respectively to construct the financial field vocabulary.

4. The method for generating a database query statement according to claim 1, characterized in that: The step of constructing a plurality of star models according to the association relationship between each dimension table and each fact table includes: Respectively obtain the associated fields of all dimension tables and all fact tables in the database, and determine the association relationship between each dimension table and each fact table and / or between each dimension table according to the associated fields; Determine whether each of the association relationships satisfies the structural relationship of the snowflake model; If the association relationship satisfies the structural relationship of the snowflake model, the association relationship is converted into a structural relationship that satisfies the star model, and several star models are constructed based on the converted association relationship. If the association relationship does not satisfy the structural relationship of the snowflake model, a star model including the dimension table and several fact tables having the association relationship therewith is constructed for each dimension table.

5. The method for generating a database query statement according to claim 1, characterized in that: Also includes: The target database query statement is executed, and based on the execution result and the preset chart recommendation rule engine, a visual chart that meets the corresponding requirements of the natural language text is generated and displayed.

6. The method for generating a database query statement according to claim 2, characterized in that: Also includes: Label the names of all the fields according to the language type used by the user when entering natural language text.

7. A system for generating database query statements, characterized in that: include: A model building unit is used to build several star models based on the association between each dimension table and each fact table; A word library construction unit is used to add annotations containing financial indicators to all fields in each of the star models, and to construct a financial domain word library based on all the annotated fields; A processing unit, configured to generate an initial database query statement based on a large language model in response to receiving a natural language text input by a user, and perform word segmentation processing on the natural language text based on the financial domain vocabulary; A detection unit, used to detect whether there is a target segmentation word matching at least one database field in the financial domain vocabulary in the natural language text after the segmentation processing; A generating unit, configured to, in response to the existence of a target segmentation word matching at least one database field in the financial field vocabulary, limit all the target segmentations with preset symbols and add annotations of the database fields matched by each target segmentation word within the range limited by the preset symbols to generate an intermediate statement, and modify the initial database query statement based on the intermediate statement to generate a target database query statement; The generating unit is further configured to: The intermediate statement is identified according to preset rules to generate a plurality of query clauses, and the pseudocode clauses in the initial database query statement are modified according to all the query clauses to obtain an executable target database query statement.

8. A computer device comprising: at least one processor; as well as A memory storing a computer program executable on the processor, wherein the processor executes the steps of the method according to any one of claims 1 to 6 when executing the program.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are performed.