Methods, systems, and media for generating structured query statements that incorporate time-based reasoning
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-26
- Publication Date
- 2026-08-14
AI Technical Summary
[0004]本发明实施例的目的在于提供一种融合时间推理的结构化查询语句生成方法、系统及介质,以解决现有技术中结构化查询语句生成准确性的问题
[0038]This invention, through problem decomposition of user queries, effectively extracts the required time information from the user query. By converting the required time information into absolute time, and by performing validity checks on the absolute time, the accuracy of time optimization is improved. By optimizing the time and the query question, structured query instructions can be effectively generated. Based on the structured query instructions, target structured query statements can be automatically generated. This invention, by separating time reasoning from SQL generation, reduces the complexity of SQL generation and allows for more intuitive checking and repair of various time errors, reducing time logic errors in target structured query statements and improving the accuracy of structured query statement generation.
Smart Images

Figure CN122570519A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of structured query language technology, and in particular to a method, system and medium for generating structured query statements that incorporate time reasoning. Background Technology
[0002] With the advancement of digital transformation across industries, databases have become the core carrier of data storage and management, leading to a continuous increase in the demand for data querying and analysis. Structured Query Language (SQL) is the standard language for manipulating databases, but it has a high professional threshold. Natural Language Processing (NLP) to SQL technology is gradually developing, leveraging NLP and large-scale models to automatically convert users' everyday expressions into standard query statements. This technology is widely used in intelligent data analysis, self-service data querying, and business report generation, and related statement generation methods have become a key research direction.
[0003] In existing structured query generation processes, user queries are typically matched with historical queries using a large model, and structured queries are generated based on the matching results. However, due to the limited time calculation capabilities of large models, time logic errors are prone to appear in the generated structured queries, reducing the accuracy of the generated structured queries. Summary of the Invention
[0004] The purpose of this invention is to provide a method, system, and medium for generating structured query statements that integrates time-based reasoning, so as to solve the problem of accuracy in generating structured query statements in the prior art.
[0005] This invention is implemented as follows: a method for generating structured query statements that incorporates time-based reasoning, the method comprising:
[0006] Obtain user query questions, and break down the user query questions into question segments to obtain the required time information and the questions to be queried;
[0007] The required time information is converted to an absolute time, and the absolute time is then checked for validity to obtain a time check result.
[0008] Based on the time check results, the absolute time is optimized to obtain an optimized time, and a structured query instruction is generated based on the optimized time and the query question.
[0009] Generate the target structured query statement based on the structured query instruction.
[0010] Preferably, the required time information is converted to absolute time, including:
[0011] Obtain the real-time time, time granularity, and time description from the required time information, and obtain the current time;
[0012] A time range is constructed based on the current time, the real-time time, the time granularity, and the time description, and the time range is formatted to obtain the absolute time.
[0013] Preferably, the required time information is converted to absolute time, including:
[0014] Obtain the comparison time, time granularity, and comparison object from the required time information, and obtain the object information of the comparison object;
[0015] The absolute time is obtained by constructing a time comparison group based on the comparison time, the time granularity, and the object information.
[0016] Preferably, the absolute time is subjected to a validity check to obtain the time check result:
[0017] Obtain the local data creation time and data update time, and compare the start time and end time in the absolute time with the data creation time and the data update time to obtain the time check result.
[0018] Preferably, the absolute time is optimized based on the time check results to obtain an optimized time, including:
[0019] If the start time is earlier than the data creation time, then the data creation time is used to replace the start time;
[0020] If the deadline is later than the data update time, then the deadline is replaced with the data update time.
[0021] Set the absolute time after time replacement as the optimized time.
[0022] Preferably, a structured query instruction is generated based on the optimization time and the query question, including:
[0023] Based on the optimized time, construct the time function code, execute the time function code, and obtain the time function result;
[0024] The query question is semantically identified to obtain the question semantics, and the question semantics are then vectorized to obtain the question vector.
[0025] The similarity between the problem vector and the historical vectors in the vector database is calculated to obtain the vector similarity, and the historical vector corresponding to the largest vector similarity is determined as the target vector.
[0026] The query instruction corresponding to the target vector is determined as a candidate query instruction, and the time position slot in the candidate query instruction is obtained;
[0027] In the candidate query instruction, the time function result is filled into the time position slot to obtain the structured query instruction.
[0028] Preferably, the user query question is broken down into question segments to obtain the required time information and the query question, including:
[0029] The user query question is segmented into words to obtain question words, and the question words are then identified to obtain word types.
[0030] Based on the vocabulary type, determine the time segment in the question segmentation, and determine the question statement corresponding to the time segment as a time statement;
[0031] The statements in the user query questions, excluding the time statements, are identified as the query questions to be queried.
[0032] The time statement is semantically recognized to obtain time semantics, and the required time information is determined based on the time semantics.
[0033] Another objective of this invention is to provide a structured query statement generation system that integrates time-based reasoning, the system comprising:
[0034] The problem splitting module is used to obtain user query questions and split the user query questions to obtain the required time information and the questions to be queried;
[0035] The time conversion module is used to convert the required time information to an absolute time, and to perform a validity check on the absolute time to obtain a time check result.
[0036] The time optimization module is used to optimize the absolute time based on the time check results to obtain an optimized time, and generate a structured query instruction based on the optimized time and the query question.
[0037] The statement generation module is used to generate a target structured query statement based on the structured query instruction.
[0038] This invention, through problem decomposition of user queries, effectively extracts the required time information from the user query. By converting the required time information into absolute time, and by performing validity checks on the absolute time, the accuracy of time optimization is improved. By optimizing the time and the query question, structured query instructions can be effectively generated. Based on the structured query instructions, target structured query statements can be automatically generated. This invention, by separating time reasoning from SQL generation, reduces the complexity of SQL generation and allows for more intuitive checking and repair of various time errors, reducing time logic errors in target structured query statements and improving the accuracy of structured query statement generation. Attached Figure Description
[0039] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.
[0040] The structures, proportions, sizes, etc. illustrated in this specification are only for the purpose of assisting those skilled in the art in understanding and reading the content disclosed herein, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.
[0041] Figure 1 This is a flowchart of the structured query statement generation method with fusion time reasoning provided in the first embodiment of the present invention;
[0042] Figure 2 This is a schematic diagram of the structure of the structured query statement generation system that integrates time-based reasoning provided in the second embodiment of the present invention;
[0043] Figure 3 This is a schematic diagram of the structure of the terminal device provided in the fourth embodiment of the present invention. Detailed Implementation
[0044] The following specific embodiments illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0045] The present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0046] Example 1
[0047] Please see Figure 1 This is a flowchart of a method for generating structured query statements with fusion time inference provided in the first embodiment of the present invention. This method can be applied to any device or system, and includes the following steps:
[0048] Step S10: Obtain the user's query question, and break down the user's query question to obtain the required time information and the query question;
[0049] The process involves inputting user queries into a large model for question decomposition, yielding required time information and the query to be performed. Since the large model learns time representations through training data and cannot be dynamically updated in real time, it is necessary to explicitly define the specific concept of time within the large model. An example is shown below:
[0050] Valid time: This refers to the time frame within which data is available for querying and analysis, excluding future time from the statistical scope;
[0051] Real-time query: This means that the time mentioned in the query is the real-time time, and the specific point in time or time range can only be determined by the current time (now);
[0052] Time granularity: year, half-year, quarter, month, week, day;
[0053] Year-on-year comparison: The percentage increase of the indicator's statistical value between the current period and the same period last year. Formula: (Current period - Same period last year) / Same period last year * 100%; Year-on-year calculation is only required when the user's question explicitly mentions "year-on-year comparison" or "comparison with the same period last year".
[0054] Month-on-month (MOB): The percentage increase of the indicator's statistical value between the current period and the previous adjacent period. Formula: (Current period - Previous adjacent period) / Previous adjacent period * 100%. MOB calculation is only required when the user's question explicitly mentions "month-on-month" or requires observation of the indicator's trend (growth / decline) within a specified continuous time range.
[0055] Optionally, the user query question can be broken down into query time information and the query question to be queried, including:
[0056] The user query question is segmented into words to obtain question words, and the question words are then identified by type to obtain vocabulary types. Specifically, the user query question is segmented into words according to a preset word segmentation dictionary to obtain question words, and the question words are matched with a type lookup table to obtain vocabulary types. The type lookup table stores the correspondence between different word segments and teammate vocabulary types.
[0057] Based on the vocabulary type, time segmentation words are determined in the question segmentation, and the question sentences corresponding to the time segmentation words are determined as time sentences; wherein, time-type question segmentation words are determined as time segmentation words, and the sentences in which each time segmentation word is located are determined as time sentences;
[0058] The statements in the user query questions, excluding the time statements, are identified as the query questions to be queried.
[0059] The time statement is semantically recognized to obtain time semantics, and the required time information is determined based on the time semantics; wherein, the required time information includes real-time time, time granularity and time description, and the time description is a time condition constraint for real-time time and / or time granularity.
[0060] Step S20: Convert the required time information to an absolute time, and perform a validity check on the absolute time to obtain a time check result;
[0061] Specifically, by converting the required time information to determine the absolute time based on user needs, and by performing a validity check on the absolute time to detect whether the time points in the absolute time need to be optimized, the accuracy of time in the generation of structured query statements is improved.
[0062] Optionally, the required time information is converted to obtain absolute time, including:
[0063] Obtain the real-time time, time granularity, and time description from the required time information, and obtain the current time;
[0064] A time range is constructed based on the current time, the real-time time, the time granularity, and the time description, and the time range is formatted to obtain the absolute time. Specifically, the time or time range referred to by the real-time query question is determined based on the current time, the real-time time, the time granularity, and the time description, and the calculation is performed strictly according to the time range and time precision specified by the user. The formatting of the time range facilitates the subsequent processing of time functions.
[0065] In this step, for some complex time formatting or situations with specific precision requirements, custom utility functions need to be used to improve the accuracy of the model-generated code. The following utility function examples are provided, and you can add, delete, or modify them according to your actual needs:
[0066] Function name: get_compare_list_format_string
[0067] Function Description: This function formats a list of time comparison groups into a string for output. It encapsulates the logic of the comparison group's description format and content. The time descriptions associated with the comparison groups are obtained by calling this function.
[0068] Function name: get_scope_format_string
[0069] Function Description: This function is used to obtain the formatted string of time data that is not based on the same period or the same time frame. The time will be formatted according to the specified time precision. The formatting of time ranges that are not based on the same period or the same time frame is obtained by calling this function.
[0070] Furthermore, the demand time information is converted to obtain absolute time, including: obtaining the comparison time, time granularity, and comparison object from the demand time information; obtaining the object information of the comparison object; constructing a time comparison group based on the comparison time, the time granularity, and the object information to obtain the absolute time; wherein, the object information is the parameter that needs to be compared between the comparison objects; based on the time granularity and the object information, a corresponding year-on-year or month-on-month comparison group is constructed for each time point or time range in the comparison time.
[0071] Furthermore, a validity check is performed on the absolute time to obtain the time check result: the local data creation time and data update time are obtained, and the start time and end time in the absolute time are compared with the data creation time and the data update time to obtain the time check result; wherein, after obtaining the absolute time, the time range of times that exceed the valid time, that is, times that exceed the "latest database statistics deadline" or "current time", is adjusted (filtered, truncated).
[0072] When a year-on-year comparison is explicitly required, the same-period comparison time should be adjusted for the year-on-year groups to ensure that the comparison time range between year-on-year groups is the same.
[0073] To avoid instruction ambiguity caused by the reasoning capabilities of large models, clearly defining precautions is crucial to ensuring accurate, controllable, safe, and compliant output. An example is shown below:
[0074] For real-time time inference of absolute time range, the reference must be the current time (now); be careful not to use the wrong reference time.
[0075] Ensure the validity verification steps are performed in the correct order: first obtain the absolute time range based on the current time (now), and then perform the validity check. The validity check cannot be performed in advance, nor can this step be omitted; otherwise, the reasoning result may not meet expectations.
[0076] In the validity check phase, adjustments to the year-on-year / month-on-month groups only require validity verification and truncation for the current period. If adjustments are made for the current period, the comparison period is then adjusted based on the adjusted current period time; a separate validity check for the comparison period is not necessary. Different data analysis tasks have varying requirements for time specifications; therefore, scenarios with specific time specifications are also supported.
[0077] Step S30: Optimize the absolute time based on the time check result to obtain an optimized time, and generate a structured query instruction based on the optimized time and the query question.
[0078] In particular, by optimizing the absolute time based on the time check results, the accuracy of the optimized time is improved, which in turn improves the accuracy of the generated structured query instructions.
[0079] Optionally, the absolute time is optimized based on the time check result to obtain an optimized time, including: if the start time is earlier than the data establishment time, the start time is replaced by the data establishment time; if the end time is later than the data update time, the end time is replaced by the data update time; and the absolute time after the time replacement is set as the optimized time.
[0080] Furthermore, a structured query instruction is generated based on the optimization time and the query question, including:
[0081] The time function code is constructed based on the optimized time, and the time function code is executed to obtain the time function result; wherein, based on the time function preset in the large model, the optimized time is filled into the time function, and the code of the filled time function is converted based on the large model to obtain the time function code;
[0082] The query question is semantically identified to obtain the question semantics, and then the question semantics are vectorized to obtain the question vector. In this way, the question semantics can be effectively converted into question vectors, which facilitates the subsequent similarity calculation between vectors.
[0083] The similarity between the problem vector and the historical vectors in the vector database is calculated to obtain the vector similarity, and the historical vector corresponding to the largest vector similarity is determined as the target vector.
[0084] The query instruction corresponding to the target vector is determined as a candidate query instruction, and the time position slot in the candidate query instruction is obtained; wherein, the time position slot is used to mark the instruction position where the time function result is filled;
[0085] In the candidate query instruction, the time function result is filled into the time position slot to obtain the structured query instruction.
[0086] Step S40: Generate a target structured query statement according to the structured query instruction;
[0087] Specifically, the large model is controlled by structured query instructions to generate query statements, thereby obtaining the target structured query statement.
[0088] In this embodiment, the code generation capability of a large model is utilized to solve complex time-related reasoning problems by defining and explaining time-related content and providing tools. High-precision time range expressions, such as overall time ranges and detailed year-on-year and month-on-month comparison time ranges, can be obtained through code calculation. No time-related training of the large model is required, which can quickly meet users' specific time reasoning needs and is easily scalable to various scenarios and tasks. It leverages both the excellent code generation capabilities of current mainstream large models and the rigorous logical reasoning capabilities of the code for numerical calculations, ensuring the highest possible accuracy of the generated time range. Based on the large model, structured query instructions are generated and executed. The time reasoning results after execution are obtained, and the high-precision time range after reasoning is injected into the SQL generation stage, thereby improving the accuracy of the SQL.
[0089] In this embodiment, by breaking down the user's query question, the required time information in the user's query question can be effectively extracted. By converting the required time information into absolute time, the accuracy of time optimization is improved by performing validity checks on the absolute time. By optimizing the time and the query question, structured query instructions can be effectively generated. Based on the structured query instructions, the target structured query statement can be automatically generated. In this embodiment of the invention, by separating time reasoning from SQL generation, the complexity of SQL generation is reduced, and various time errors can be checked and corrected more intuitively. This reduces the phenomenon of time logic errors in the target structured query statement and improves the accuracy of structured query statement generation.
[0090] Example 2
[0091] Please see Figure 2This is a schematic diagram of the structure of the structured query statement generation system 100 with integrated time-based reasoning provided in the second embodiment of the present invention, including:
[0092] The problem splitting module 10 is used to obtain user query questions and split the user query questions to obtain the required time information and the questions to be queried.
[0093] Optionally, the question segmentation module 10 is further configured to: segment the user query question into words to obtain question words, and perform type identification on the question words to obtain word types;
[0094] Based on the vocabulary type, determine the time segment in the question segmentation, and determine the question statement corresponding to the time segment as a time statement;
[0095] The statements in the user query questions, excluding the time statements, are identified as the query questions to be queried.
[0096] The time statement is semantically recognized to obtain time semantics, and the required time information is determined based on the time semantics.
[0097] The time conversion module 11 is used to convert the required time information to an absolute time, and to perform a validity check on the absolute time to obtain a time check result.
[0098] Optionally, the time conversion module 11 is further configured to: obtain the real-time time, time granularity, and time description from the required time information, and obtain the current time;
[0099] A time range is constructed based on the current time, the real-time time, the time granularity, and the time description, and the time range is formatted to obtain the absolute time.
[0100] Furthermore, the time conversion module 11 is also used to: obtain the comparison time, time granularity and comparison object in the required time information, and obtain the object information of the comparison object;
[0101] The absolute time is obtained by constructing a time comparison group based on the comparison time, the time granularity, and the object information.
[0102] Furthermore, the time conversion module 11 is also used to: obtain the local data creation time and data update time, and compare the start time and end time in the absolute time with the data creation time and the data update time to obtain the time check result.
[0103] The time optimization module 12 is used to optimize the absolute time according to the time check result to obtain the optimized time, and generate a structured query instruction according to the optimized time and the query question.
[0104] Optionally, the time optimization module 12 is further configured to: replace the start time with the data establishment time if the start time is earlier than the data establishment time;
[0105] If the deadline is later than the data update time, then the deadline is replaced with the data update time.
[0106] Set the absolute time after time replacement as the optimized time.
[0107] Furthermore, the time optimization module 12 is also used to: construct time function code based on the optimized time, and execute the time function code to obtain the time function result;
[0108] The query question is semantically identified to obtain the question semantics, and the question semantics are then vectorized to obtain the question vector.
[0109] The similarity between the problem vector and the historical vectors in the vector database is calculated to obtain the vector similarity, and the historical vector corresponding to the largest vector similarity is determined as the target vector.
[0110] The query instruction corresponding to the target vector is determined as a candidate query instruction, and the time position slot in the candidate query instruction is obtained;
[0111] In the candidate query instruction, the time function result is filled into the time position slot to obtain the structured query instruction.
[0112] The statement generation module 13 is used to generate a target structured query statement based on the structured query instruction.
[0113] In this embodiment, by breaking down the user's query question, the required time information in the user's query question can be effectively extracted. By converting the required time information into absolute time, the accuracy of time optimization is improved by performing validity checks on the absolute time. By optimizing the time and the query question, structured query instructions can be effectively generated. Based on the structured query instructions, the target structured query statement can be automatically generated. In this embodiment of the invention, by separating time reasoning from SQL generation, the complexity of SQL generation is reduced, and various time errors can be checked and corrected more intuitively. This reduces the phenomenon of time logic errors in the target structured query statement and improves the accuracy of structured query statement generation.
[0114] Example 3
[0115] Existing large models are suitable for generative tasks, but are inaccurate for time-range reasoning (i.e., converting relative time to absolute time).
[0116] The third embodiment of the present invention provides an absolute time generation module: it utilizes the excellent code generation capabilities of current mainstream large models and the rigorous logical reasoning capabilities of the code to perform numerical calculations, which can ensure that the generated time range is highly accurate to the greatest extent. It generates Python code based on the large model and executes the code, obtains the time inference results after the code is executed, and injects the high-precision time range after inference into the SQL generation stage, thereby improving the accuracy of SQL.
[0117] Specifically, the time reasoning problem is transformed into a code generation task. The time terms (absolute time / relative time) in the user's question are transformed into a code calculation problem. A large model generates a code function responsible for the transformation, and then the code function is executed. After precise calculation by the code, the absolute time range is obtained.
[0118] In this embodiment, time conversion can theoretically be set with a set of conversion rules, such as "the most recent N days". The corresponding reasoning rule is to subtract N days from the current date. However, because time words used to describe time are constantly changing, listing conversion rules is very laborious and time-consuming. Now, by utilizing the powerful semantic understanding capabilities of large models and excellent coding skills, the time reasoning problem can be solved well. After experimental testing, the accuracy rate can reach over 95%.
[0119] Example 4
[0120] Figure 3 This is a structural block diagram of a terminal device 2 provided in the fourth embodiment of this application. For example... Figure 3 As shown, the terminal device 2 in this embodiment includes a processor 20, a memory 21, and a computer program 22 stored in the memory 21 and executable on the processor 20, such as a program for a structured query statement generation method incorporating temporal reasoning. When the processor 20 executes the computer program 22, it implements the steps in the various embodiments of the structured query statement generation method incorporating temporal reasoning described above.
[0121] For example, the computer program 22 may be divided into one or more modules, which are stored in the memory 21 and executed by the processor 20 to complete this application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 22 in the terminal device 2. The terminal device may include, but is not limited to, the processor 20 and the memory 21.
[0122] The processor 20 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0123] The memory 21 can be an internal storage unit of the terminal device 2, such as a hard drive or memory of the terminal device 2. The memory 21 can also be an external storage device of the terminal device 2, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the terminal device 2. Furthermore, the memory 21 can include both internal and external storage units of the terminal device 2. The memory 21 is used to store the computer program and other programs and data required by the terminal device. The memory 21 can also be used to temporarily store data that has been output or will be output.
[0124] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0125] If an integrated module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. This computer-readable storage medium can be non-volatile or volatile. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable storage medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the contents of a computer-readable storage medium may be appropriately added to or subtracted from the contents as required by the legislation and patent practice in a jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, a computer-readable storage medium may not include electrical carrier signals and telecommunication signals.
[0126] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for generating structured query statements that integrates time-based reasoning, characterized in that, The method includes: Obtain user query questions, and break down the user query questions into question segments to obtain the required time information and the questions to be queried; The required time information is converted to an absolute time, and the absolute time is then checked for validity to obtain a time check result. Based on the time check results, the absolute time is optimized to obtain an optimized time, and a structured query instruction is generated based on the optimized time and the query question. Generate the target structured query statement based on the structured query instruction.
2. The method for generating structured query statements that incorporates time-based reasoning as described in claim 1, characterized in that, The required time information is converted to absolute time, including: Obtain the real-time time, time granularity, and time description from the required time information, and obtain the current time; A time range is constructed based on the current time, the real-time time, the time granularity, and the time description, and the time range is formatted to obtain the absolute time.
3. The method for generating structured query statements that incorporates time-based reasoning as described in claim 1, characterized in that, The required time information is converted to absolute time, including: Obtain the comparison time, time granularity, and comparison object from the required time information, and obtain the object information of the comparison object; The absolute time is obtained by constructing a time comparison group based on the comparison time, the time granularity, and the object information.
4. The method for generating structured query statements that incorporates time-based reasoning as described in claim 1, characterized in that, The absolute time is validated, and the time check result is obtained: Obtain the local data creation time and data update time, and compare the start time and end time in the absolute time with the data creation time and the data update time to obtain the time check result.
5. The method for generating structured query statements that incorporates time-based reasoning as described in claim 4, characterized in that, Based on the time check results, the absolute time is optimized to obtain an optimized time, including: If the start time is earlier than the data creation time, then the data creation time is used to replace the start time; If the deadline is later than the data update time, then the deadline is replaced with the data update time. Set the absolute time after time replacement as the optimized time.
6. The method for generating structured query statements that incorporates time-based reasoning as described in claim 1, characterized in that, Generate a structured query instruction based on the optimization time and the query question, including: Based on the optimized time, construct the time function code, execute the time function code, and obtain the time function result; The query question is semantically identified to obtain the question semantics, and the question semantics are then vectorized to obtain the question vector. The similarity between the problem vector and the historical vectors in the vector database is calculated to obtain the vector similarity, and the historical vector corresponding to the largest vector similarity is determined as the target vector. The query instruction corresponding to the target vector is determined as a candidate query instruction, and the time position slot in the candidate query instruction is obtained; In the candidate query instruction, the time function result is filled into the time position slot to obtain the structured query instruction.
7. The method for generating structured query statements that incorporates time-based reasoning as described in claim 1, characterized in that, The user query is broken down into query time information and the query question to be queried, including: The user query question is segmented into words to obtain question words, and the question words are then identified to obtain word types. Based on the vocabulary type, determine the time segment in the question segmentation, and determine the question statement corresponding to the time segment as a time statement; The statements in the user query questions, excluding the time statements, are identified as the query questions to be queried. The time statement is semantically recognized to obtain time semantics, and the required time information is determined based on the time semantics.
8. A structured query statement generation system integrating time-based reasoning, characterized in that, The system includes: The problem splitting module is used to obtain user query questions and split the user query questions to obtain the required time information and the questions to be queried; The time conversion module is used to convert the required time information to an absolute time, and to perform a validity check on the absolute time to obtain a time check result. The time optimization module is used to optimize the absolute time based on the time check results to obtain an optimized time, and generate a structured query instruction based on the optimized time and the query question. The statement generation module is used to generate a target structured query statement based on the structured query instruction.
9. The structured query statement generation system integrating time-based reasoning as described in claim 8, characterized in that, The time conversion module is also used for: Obtain the real-time time, time granularity, and time description from the required time information, and obtain the current time; A time range is constructed based on the current time, the real-time time, the time granularity, and the time description, and the time range is formatted to obtain the absolute time.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.