Parsing method and system for natural language temporal descriptions

By compiling natural language time descriptions into domain-specific language instruction sequences and performing structured parsing and chained evaluation, the problems of lost logical order and context tracking in time parsing in existing technologies are solved, achieving efficient and reliable time information processing.

CN121390037BActive Publication Date: 2026-04-14GOLDCARD HIGH TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-26
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing technologies in human-computer interaction and intelligent assistants suffer from problems such as the inability to preserve the semantic and logical order of time operation processes, difficulty in tracking and updating context, poor interactive experience, and high computational cost.

Method used

By using a large language model, the natural language temporal description is compiled into a domain-specific language instruction sequence, parsed into a structured list of instruction components, and evaluated in a chained manner according to the order of instructions. This ensures the logical order and reliability of the temporal operation process and reduces the dependence on the large language model.

Benefits of technology

It achieves highly reliable and unambiguous time resolution, ensuring the absolute reliability and full traceability of calculation results, improving processing efficiency and reducing costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121390037B_ABST
    Figure CN121390037B_ABST
Patent Text Reader

Abstract

The application discloses a natural language time description analysis method, which comprises the following steps: compiling a natural language time description into a domain-specific language instruction sequence through a large language model, wherein the domain-specific language instruction sequence reflects the time operation links and the inherent time operation sequence of the natural language time description; analyzing the domain-specific language instruction sequence to obtain a structured instruction component list, wherein the structured instruction component list comprises at least one instruction component and the sequence of the instruction components; and sequentially performing chain evaluation on the instruction components in the instruction component list according to the sequence of the instruction components to obtain target standardized time information corresponding to the natural language time description. The method separates AI semantic understanding and deterministic calculation by taking a domain-specific language as an intermediate layer, ensures the absolute reliability and full traceability of the calculation result, reduces the dependence on a large language model, improves the efficiency and reduces the cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language time processing, and in particular to a method and system for parsing natural language time descriptions. Background Technology

[0002] In fields such as human-computer interaction, intelligent assistants, and automated task processing, natural language time parsing is a crucial link connecting user intent with computer execution. Related technologies primarily employ the "Large Language Model (LLM) + Tool Invocation" paradigm, where the LLM directly extracts time entities or parameters from user input and then invokes pre-defined tools for calculation. However, this approach has several limitations: it typically compresses continuous time operations (such as "first to next Friday, then back one day") into isolated parameters, losing the semantics and logical order of the calculation process; during multi-turn dialogues, corrections (such as "no, it's...") or follow-up questions are difficult to reliably track and update the context, easily leading to accumulated errors; the entire processing is a black box, making it impossible to distinguish between semantic understanding and logical combination errors, resulting in debugging difficulties; and it heavily relies on the memory and generalization capabilities of the large model, often resorting to guessing or abandoning ambiguous expressions like "next Wednesday or Thursday," resulting in a poor user experience and high computational costs. Summary of the Invention

[0003] This application provides a method and system for parsing natural language time descriptions. This method can achieve highly reliable, unambiguous time parsing that can completely preserve the user's intent.

[0004] Firstly, this application provides a method for parsing natural language time descriptions, the method comprising:

[0005] Through a large language model, the natural language time description is compiled into a domain-specific language instruction sequence, which reflects the time operation links and inherent time operation order of the natural language time description.

[0006] Parse the domain-specific language instruction sequence to obtain a structured list of instruction components. The list of instruction components includes at least one instruction component and the order of the instruction components. Each instruction component represents a time operation step in the natural language time description.

[0007] Following the order of the instruction components, the instruction components in the instruction component list are evaluated in a chain to obtain the target standardized time information corresponding to the natural language time description.

[0008] In one embodiment, compiling a natural language temporal description into a domain-specific language instruction sequence includes:

[0009] The prompt words are constructed based on the task scenario and dialogue context. The prompt words include relevant examples and grammatical rules for domain-specific language instruction sequences.

[0010] Input the prompt words and natural language temporal descriptions into the large language model to obtain domain-specific language instruction sequences.

[0011] In one embodiment, the method further includes constructing grammatical rules for domain-specific language instruction sequences, comprising the following steps:

[0012] We use a large language model to process natural language corpora containing time descriptions, and locate and extract time-related text fragments.

[0013] Text fragments are standardized, and an original time representation library is built based on the standardized text fragments.

[0014] The text fragments in the original temporal representation library are grouped by similarity to obtain at least two intent clusters;

[0015] Extract the core operation intent for each intent cluster to obtain the operation intent for the corresponding intent cluster;

[0016] Based on the operational intent, a syntax rule is used to generate a domain-specific language instruction sequence corresponding to the operational intent.

[0017] In one embodiment, chained evaluation of instruction components in the instruction component list includes:

[0018] Create an initial computation state and an empty checkpoint stack;

[0019] Push the first instruction component in the instruction component list onto the checkpoint stack. Use the initial calculation state as the time operation benchmark of the checkpoint stack, call the calculation function, perform time calculation on the first instruction component based on the time operation benchmark, obtain the stage time, and update the time operation benchmark of the checkpoint stack based on the stage time.

[0020] Starting with the first instruction component in the instruction component list, each instruction component in the instruction component list is pushed onto the checkpoint stack in an orderly manner. The execution time is calculated based on the time operation benchmark of the previous update to obtain the stage time of the corresponding instruction component. The stage time output by the last instruction component in the instruction component list is used as the target standardized time information.

[0021] In one embodiment, the instruction component list also includes the instruction type and instruction value corresponding to the instruction component, and the instruction type includes deterministic instruction type and non-deterministic instruction type;

[0022] Before calculating the execution time of the instruction component, check the instruction type of the instruction component.

[0023] When the instruction type of the instruction component is a deterministic instruction type, the calculation function is called to calculate the stage time of the corresponding deterministic instruction component based on the previously updated time operation benchmark.

[0024] When the instruction type of the instruction component is an indeterminate instruction type, a lazy evaluation strategy is executed, including:

[0025] Pause the time calculation process for the instruction component;

[0026] All computational contexts at the current moment are encapsulated and saved as an ambiguity checkpoint. All computational contexts at the current moment include the time operation baseline, the instruction components that have performed time calculations, and the stage time generated by the instruction components that have performed time calculations.

[0027] Based on ambiguity checkpoints, traverse all possible paths in the uncertain instruction component, independently pre-compute the result of each path, and construct the execution tree;

[0028] A selection-based clarification question is generated based on the execution tree. Time calculation is performed based on the selection result of the clarification question, and the stage time of the corresponding uncertain instruction component is output. The time calculation process for the instruction component is resumed, and the time calculation for the next instruction component is continued. Alternatively, the target standardized time information is output.

[0029] In one embodiment, the deterministic instruction component includes: a relative offset instruction component, an absolute target instruction component, and an ordinal and position instruction component;

[0030] The relative offset instruction component represents the time operation of time translation intention, indicating an operation to add or subtract one time unit at a specified time base point;

[0031] The absolute target instruction component represents a time operation with an absolutely specified intent, indicating that a specified portion of time is directly set to a specific value;

[0032] The ordinal and position instruction components represent temporal operations that indicate the order or position of an entity's time within a time set.

[0033] In one embodiment, parsing a domain-specific language instruction sequence to obtain a structured list of instruction components further includes:

[0034] Perform syntax self-correction verification on the domain-specific language instruction sequence. If the domain-specific language instruction sequence conforms to the syntax rules of the domain-specific language instruction sequence, parse the domain-specific language instruction sequence to obtain a structured list of instruction components. Otherwise, generate error message questions based on the error information in the domain-specific language instruction sequence. The error message questions are used to describe the prompt information needed to resolve the error information.

[0035] In one embodiment, the parsing method further includes: performing business rule verification on the target standardized time information; if the business rule verification fails, generating a prompt message based on the failed business rule.

[0036] If the business rule verification is successful, the target standardized time information is calibrated using a real-world model. If the knowledge calibration fails, a suggested time for the task scenario is generated based on the real-world model and the target standardized time information.

[0037] In one embodiment, in a multi-turn dialogue scenario, the domain-specific language instruction sequence of a single-turn dialogue is saved. When an additional time correction instruction is received in a subsequent dialogue, the additional time correction instruction is compiled into an additional domain-specific language instruction sequence based on a large language model. The additional domain-specific language instruction sequence is concatenated to the end of the most recently saved domain-specific language instruction sequence. Based on the concatenated domain-specific language instruction sequence, the parsed instruction component list is evaluated in a chain to obtain the target standardized time information corresponding to the additional time correction instruction.

[0038] Secondly, this application also provides a parsing system for natural language time description, which applies the parsing method for natural language time description in the first aspect.

[0039] The aforementioned method for parsing natural language temporal descriptions compiles the natural language temporal description into a domain-specific language instruction sequence using a large language model. This sequence preserves all temporal operations and their inherent logical order within the natural language temporal description. The domain-specific language instruction sequence is then parsed to generate a structured, ordered list of instruction components, each corresponding to a temporal operation. The components are then evaluated in a chain-like manner according to the list order, outputting deterministic and standardized time information. This method separates AI semantic understanding from deterministic computation by using a domain-specific language as an intermediate layer, ensuring absolute reliability and full traceability of the computation results, reducing the continuous strong dependence on large language models, improving processing efficiency, and lowering costs. Attached Figure Description

[0040] Figure 1 This is a flowchart of a natural language temporal description parsing method in one embodiment;

[0041] Figure 2 A flowchart illustrating the grammar rules for constructing a domain-specific language instruction sequence in one embodiment;

[0042] Figure 3 This is a flowchart of chained evaluation of instruction components in a list of instruction components in one embodiment;

[0043] Figure 4 This is a flowchart illustrating the lazy evaluation strategy implemented in one embodiment.

[0044] Figure 5 This is a flowchart illustrating the business rule verification process in one embodiment;

[0045] Figure 6 This is a flowchart illustrating a multi-turn dialogue scenario in one embodiment. Detailed Implementation

[0046] The present application will be described in detail below with reference to the specific embodiments shown in the accompanying drawings. However, these embodiments do not limit the present application. Any structural, methodological, or functional modifications made by those skilled in the art based on these embodiments are included within the protection scope of the present application.

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

[0048] In one embodiment, such as Figure 1 As shown, a method for parsing natural language temporal descriptions is provided, which includes the following steps:

[0049] Step 101: Using a large language model, the natural language temporal description is compiled into a domain-specific language instruction sequence. The domain-specific language instruction sequence reflects the temporal operation links and inherent temporal operation order of the natural language temporal description.

[0050] Specifically, leveraging the analytical capabilities of large language models, a deep understanding is achieved of users' descriptions of natural language time (e.g., "the Wednesday or Thursday of the second week of next month"). Instead of directly outputting a time answer, the large language model acts as a compiler, transforming (compiling) the natural language time description into a structured sequence of instructions composed of domain-specific vocabulary. Here, the domain-specific language (DSL) can refer to a formalized, structured instruction language specifically designed for time semantic parsing, encoding the time manipulation intentions (such as offsets, settings, and selections) in natural language into a machine-resolvable sequence of symbols.

[0051] Domain-specific language (DSAR) instruction sequences capture multiple time-related operations (such as setting a baseline, offsetting, and selecting) implicit in user descriptions through the arrangement and order of instructions. They also specify the inherent time operation order among these operations, i.e., the sequential dependencies that must be followed. For example, the DSAR instruction "+1M WEEK2 (WD3|WD4)" lists three time operation steps: "Move to next month," "Locate to the second week," and "Select from Wednesday or Thursday." The execution logic is "Move month first, then locate week, and finally process day."

[0052] Step 102: Parse the domain-specific language instruction sequence to obtain a structured list of instruction components. The list of instruction components includes at least one instruction component and the order of the instruction components. The instruction component represents a time operation step in the natural language time description.

[0053] Specifically, the domain-specific language instruction sequence is parsed using deterministic lexical and grammatical methods, decomposed, and transformed into a list of instruction components composed of structured data objects. Each object in the instruction component list is called an instruction component, and each instruction component can uniquely correspond to and represent a temporal operation in the natural language description through its own instruction type and instruction value. The instruction component type can be a semantic label assigned to each structured instruction component after the domain-specific language parsing.

[0054] Step 103: Following the order of the instruction components, perform chained evaluation on the instruction components in the instruction component list to obtain the target standardized time information corresponding to the natural language time description.

[0055] Specifically, following the predetermined order of the instruction component list, each instruction component in the list is calculated sequentially from beginning to end. The calculation of each instruction component strictly depends on the latest time result calculated by the previous instruction component as its input basis, and passes the new time result generated by its own calculation to the next instruction component, thus forming a calculation chain that is closely connected and whose state is passed sequentially.

[0056] By strictly adhering to the order of operations, this computational chain progressively transforms the initial time state (such as the current moment) into target standardized time information. The target standardized time information, which is the output of the last instruction component, precisely corresponds to the user's original intent, thus completing the conversion from complex and ambiguous natural language to definite and reliable time information.

[0057] In this embodiment, the method compiles a natural language time description into a domain-specific language instruction sequence using a large language model. This sequence preserves all time operation steps and their inherent logical order within the natural language time description. The domain-specific language instruction sequence is then parsed to generate a structured, ordered list of instruction components, each corresponding to a time operation. The components are then evaluated in a chain-like manner according to the list order, outputting deterministic and standardized time information. This method separates AI semantic understanding from deterministic computation by using a domain-specific language as an intermediate layer, ensuring absolute reliability and full traceability of the computation results, reducing the continuous strong dependence on large language models, improving processing efficiency, and lowering costs.

[0058] In one embodiment, compiling a natural language temporal description into a domain-specific language instruction sequence includes:

[0059] The prompt words are constructed based on the task scenario and dialogue context. The prompt words include relevant examples and grammatical rules for domain-specific language instruction sequences.

[0060] Input the prompt words and natural language temporal descriptions into the large language model to obtain domain-specific language instruction sequences.

[0061] Specifically, based on the current business scenario of the interaction and the existing dialogue history, a structured prompt word is assembled in real time. This prompt word can systematically provide two things: first, annotated standard transformation examples related to the current scenario, which demonstrate how to map natural language in similar contexts into formal instructions; and second, a complete and unambiguous set of grammatical rules for the domain-specific language (DSL).

[0062] Once the large language model receives this prompt and the user's natural language time description, its role transforms from a general text generator to a controlled semantic compiler. Within the framework of the prompt words, based on the given grammatical rules and example patterns, it parses the input natural language time description text and outputs a sequence of instructions that conforms to the domain-specific language grammar and represents the user's time operation logic.

[0063] In one embodiment, the instruction component list also includes the instruction type and instruction value corresponding to the instruction component, and the instruction type includes deterministic instruction type and non-deterministic instruction type;

[0064] Before calculating the execution time of the instruction component, check the instruction type of the instruction component.

[0065] When the instruction type of the instruction component is a deterministic instruction type, the calculation function is called to calculate the stage time of the corresponding deterministic instruction component based on the execution time of the previously updated time operation benchmark.

[0066] Specifically, each instruction component is a structured data object, whose key attributes include the instruction type that clearly identifies the operation category (such as Offset, Target, Ambiguity) and the instruction value that carries specific parameters (such as "+1M", "WD5").

[0067] Instruction types are pre-divided into deterministic instruction types (whose operations can be mapped to a single, deterministic mathematical calculation, such as Offset (time shift), Target (absolute setting), and Ordinal (ordinal positioning)) and non-deterministic instruction types (whose operations represent multiple possible paths, such as Ambiguity).

[0068] Before performing time calculations, the instruction type of the current instruction component is checked. This determination is the sole basis for deciding the subsequent execution path (continue calculation or trigger ambiguity management). Only when the instruction type is determined to be a deterministic instruction type does the standard calculation process described in this section begin. This involves calling a pure function calculation module strictly bound to that type (e.g., a function that handles offsets). This function takes as input the time operation benchmark updated after the execution of the previous instruction component and stored at the top of the checkpoint stack, and performs a deterministic time calculation (e.g., adding one month to the benchmark date) according to the parameters encoded by the instruction value (e.g., decoding "+1M" as {direction:+, magnitude:1, unit:month}). The time calculation produces a precise, unambiguous stage time result, which is then used to update the time operation benchmark in the current checkpoint. In this embodiment, the time operation benchmark is a key state variable in the time calculation process, used to record the time point after the execution of the previous instruction component and to use this time point as the starting point for subsequent time calculations, ensuring the continuity and accuracy of the time calculations. In one embodiment, the deterministic instruction component includes: a relative offset instruction component, an absolute target instruction component, and an ordinal and position instruction component;

[0069] The relative offset instruction component represents the time operation of time translation intention, indicating an operation to add or subtract one time unit at a specified time base point;

[0070] The absolute target instruction component represents a time operation with an absolutely specified intent, indicating that a specified portion of time is directly set to a specific value;

[0071] The ordinal and position instruction components represent temporal operations that indicate the order or position of an entity's time within a time set.

[0072] Specifically, the relative offset instruction component corresponds to the operational intent extracted from the time translation cluster, representing "an operation to add or subtract one time unit at a certain time base point". Its DSL form (such as the Offset instruction [+-]\\d+[YMWD]) encodes the direction, magnitude and unit. The calculation is essentially performing deterministic time algebraic addition, for example, compiling "three months later" as "+3M".

[0073] The absolute target instruction component corresponds to the operation intent of the absolute specified cluster, which means "to directly set a certain part of time (such as month or day) to a specific value". Its DSL form (such as the Target instruction [MWDTH]\\d+) identifies the component through prefix letters and represents the value with numbers. The calculation essence is to overwrite the time component, such as compiling "Friday" into "WD5".

[0074] The ordinal and position instruction component corresponds to the operational intent of the ordinal positioning cluster, indicating "describing the order or position of an entity in a set". Its DSL form (such as the Ordinal instruction ORD\\d+ or WEEK\\d+) is used to locate entities in a time set based on ordinal index, for example, compiling "Week 2" as "WEEK2".

[0075] In one embodiment, such as Figure 2 As shown, the grammar rules for constructing domain-specific language instruction sequences include the following steps:

[0076] Step 201: Use a large language model to process the natural language corpus containing time descriptions, locate and extract time-related text fragments;

[0077] Specifically, by guiding the large language model with specific instructions, it can accurately understand the context, locate explicit or implicit time expressions (such as "next Monday" or "around 3 p.m.") from complex sentences in natural language corpora, and directly output these original fragments, effectively filtering out non-time metaphors and covering diverse spoken expressions.

[0078] Step 202: Standardize the text fragments and construct the original time expression library based on the standardized text fragments;

[0079] Specifically, the text fragments are first deduplicated to eliminate identical repeated fragments; then, word form restoration and normalization are performed to unify expressions with different surface forms but the same meaning into a standard form (for example, "next Monday" and "next Monday" are both standardized to "next Monday"); and common spelling variations can be corrected, number formats can be unified (such as "three o'clock" and "3 o'clock"), and irrelevant modifiers or modifiers can be removed (such as "approximately" and "around" may be marked but the core time words are retained).

[0080] Based on standardized text fragments, a searchable and analyzable original time expression library is systematically organized and constructed according to a predefined structure (such as fields for storing the original text of the fragment, standardized form, and occurrence context index).

[0081] Step 203: Group the text fragments in the original time expression library based on similarity to obtain at least two intent clusters;

[0082] Specifically, a pre-trained sentence embedding model is used to convert each text fragment (e.g., "tomorrow," "June," "Wednesday," or "Thursday") in the original time expression library into a high-dimensional vector representing its deep semantics. Furthermore, an unsupervised clustering algorithm (e.g., K-means or hierarchical clustering) is employed to analyze all vectors. This unsupervised clustering algorithm automatically groups expressions with similar meanings into different sets based on the semantic similarity between vectors, thus forming multiple preliminary intent clusters.

[0083] Step 204: Extract the core operation intent for each intent cluster to obtain the operation intent of the corresponding intent cluster;

[0084] Specifically, the core operational intent of the "time translation" cluster (such as the cluster that includes "tomorrow" and "three months later") can be summarized as "to perform an operation of adding or subtracting a unit of time at a certain time base point," which is essentially a relative time arithmetic operation.

[0085] The core operational intent of "absolutely specified" clusters (such as clusters including "June" and "Friday") can be summarized as "directly setting a part of time (such as month or day) to a specific value", and its core is an absolute assignment operation.

[0086] The core operational intent of "ordinal positioning" clusters (such as clusters including "second" and "third") can be summarized as "describing the order or position of an entity in a set," and its core is to use ordinal relationships for index positioning.

[0087] The core operational intent of the “uncertainty” cluster (such as clusters including “Wednesday or Thursday”, “3 to 5 o’clock”) can be summarized as “expressing an uncertain point in time or range”, which is essentially dealing with the ambiguity of discrete options or continuous intervals.

[0088] Step 205: Based on the operation intent, generate the syntax rules for the domain-specific language instruction sequence corresponding to the operation intent.

[0089] For example, the operation intent corresponding to the intent cluster of "time translation" is formalized as the Offset instruction, and the syntax rule is defined as [+-]\\d+[YMWD]. This syntax rule can encode the three semantic elements of direction, magnitude and unit into compact symbols. Specific examples include +1Y (corresponding to "next year"), -2M (corresponding to "two months ago"), +3W (corresponding to "three weeks later") and +1D (corresponding to "tomorrow").

[0090] For the operation intent corresponding to the "absolutely specified" intent cluster, it is formalized as the Target instruction, with the syntax rule [MWDTH]\\d+. This syntax rule can identify the time component by prefixing a letter and setting the specific value by following a number. Specific examples include M6 (corresponding to "June"), D15 (corresponding to "15th"), WD5 (corresponding to "Friday"), and T14 (corresponding to "2 PM").

[0091] For the operational intents corresponding to the "order positioning" intent cluster, they are formalized as Ordinal / Positional type instructions, using keyword formats such as ORD\\d+ (representing "the Nth"), WEEK\\d+ (representing "the Nth week"), and LAST (representing "the last"). Specific examples include ORD2 (corresponding to "the second") and WEEK3 (corresponding to "the third week"). For example, the natural language "the second Tuesday of next month" is fully compiled into the instruction sequence +1M ORD2 WD2. This example combines the Offset, Ordinal, and Target instructions.

[0092] For the operational intents corresponding to the "uncertainty" intent cluster, they are formalized into special AmbiguityOperator instructions. For discrete options (such as "OR" logic), the syntax format (...|...) is used, for example (WD3|WD4) (corresponding to "Wednesday or Thursday"), and for continuous ranges, the syntax format [start]..[end] is used, for example T15..T17 (corresponding to "3 p.m. to 5 p.m.").

[0093] For example, if a user inputs something like "the second Wednesday or Thursday of next month from 3 p.m. to 5 p.m.", it can be compiled into a domain-specific language instruction sequence of +1M WEEK2 (WD3|WD4) T15..T17. This sequence not only fully preserves the time operation steps of the natural language time description, but its instruction arrangement itself also specifies the logical order of execution and encapsulates ambiguities.

[0094] In one embodiment, such as Figure 3 As shown, chained evaluation is performed on the instruction components in the instruction component list sequentially, including the following steps:

[0095] Step 301: Create an initial computation state and create an empty checkpoint stack;

[0096] Specifically, before any time-based calculations begin, an initial calculation state is created. Creating this initial state means initializing a structured context environment (usually the current system time by default, or a reference time point set according to the dialogue context). This context can include metadata such as time zone and calculation start flags, thus providing a clear and unique time starting point and computational baseline for all subsequent sequential calculations. Simultaneously, a last-in-first-out (LIFO) stack data structure, i.e., a checkpoint stack, is initialized. This stack is initially empty, and its purpose is to temporarily and completely save the entire calculation context at the current moment (including the base time, the sequence of executed instructions, and their intermediate results).

[0097] Step 302: Push the first instruction component in the instruction component list onto the checkpoint stack. Using the initial calculation state as the time operation benchmark of the checkpoint stack, call the calculation function to perform time calculation on the first instruction component based on the time operation benchmark to obtain the stage time. Update the time operation benchmark of the checkpoint stack based on the stage time.

[0098] Specifically, pushing the first instruction component in the instruction component list onto the checkpoint stack is not a simple storage action, but rather the establishment of the first checkpoint with a complete context for the entire sequential execution process. This checkpoint object includes the instruction to be executed and the current initial computation state.

[0099] Furthermore, the time operation reference saved at this checkpoint is obtained, which can be the start time set in the initial calculation state (such as the current time). Further still, based on the type of the first instruction component (e.g., Offset), the deterministic calculation function bound to it is called, and the obtained time operation reference and instruction parameters (e.g., "+1M") are passed to the calculation function. The calculation function then generates the first stage time through time mathematics operations (e.g., adding one month to the reference date); using this stage time result, the time operation reference saved at the corresponding checkpoint at the top of the checkpoint stack is updated.

[0100] Step 303: Starting from the first instruction component in the instruction component list, push each instruction component in the instruction component list onto the checkpoint stack in an orderly manner. Calculate the execution time based on the time operation benchmark of the previous update to obtain the stage time of the corresponding instruction component. Use the stage time output by the last instruction component in the instruction component list as the target standardized time information.

[0101] Specifically, starting from the first item in the instruction component list, each component is traversed in order. Before executing each component, it is first pushed onto the checkpoint stack. The purpose of this operation is to establish a checkpoint for each step of the computation, which includes the instruction to be executed and the latest computation context before execution.

[0102] Furthermore, the time operation benchmark, calculated and updated by the previous operation instruction, is retrieved from the checkpoint corresponding to the top of the checkpoint stack as the current input. A deterministic function matching the current instruction type is then called to perform the calculation, generating a precise stage time. This result is then used to update the time operation benchmark within the checkpoint corresponding to the top of the checkpoint stack, causing the context state to advance synchronously with the calculation progress.

[0103] This cycle of "push onto stack -> fetch baseline -> calculate -> update baseline" continues until the last instruction component in the instruction component list is processed. The stage time output by the last instruction component is the final time after all operations are applied sequentially, and this time can be output as the target normalized time information.

[0104] In one embodiment, such as Figure 4 As shown, when the instruction type of the instruction component is an indeterminate instruction type, a lazy evaluation strategy is executed, including the following steps:

[0105] Step 401: Pause the time calculation process for the instruction component;

[0106] Specifically, when executing the instruction component list sequentially, if the instruction type of the current component is identified as an uncertain instruction type (such as Ambiguity), the time calculation process for that instruction component is paused. The purpose of pausing the calculation process is to prevent any unreliable guesses or arbitrary selection of a path to continue execution when information is incomplete, thereby avoiding the systemic risk that subsequent calculations might be based entirely on incorrect assumptions due to improper ambiguity handling.

[0107] Step 402: Encapsulate and save all computation contexts at the current moment as an ambiguity checkpoint. All computation contexts at the current moment include the time operation baseline, the instruction components that have performed time calculations, and the stage time generated by the instruction components that have performed time calculations.

[0108] Specifically, all computational contexts at the current moment are encapsulated and saved as an ambiguity checkpoint. All computational contexts can include: a time operation baseline, which is the definite time point on which the current computation depends, generated by all previous deterministic instructions; instruction components that have performed time computations, which is an ordered record of all instruction components that have been successfully executed sequentially from the beginning to the current ambiguity checkpoint; and stage times generated by the executed instruction components, which can be a sequence of intermediate computation results corresponding one-to-one with the above instruction components, together with the instruction record, forming a complete and verifiable chain of evidence from the initial state to the current baseline.

[0109] Step 403: Based on the ambiguity checkpoint, traverse all possible paths in the uncertain instruction component, pre-compute the result of each path independently, and construct the execution tree;

[0110] Specifically, using the ambiguous checkpoint as the common and deterministic starting point for all possibilities, all candidate paths defined by the current uncertain instruction component (e.g., (WD3|WD4)) are traversed. For each path (e.g., path one: WD3; path two: WD4), the deterministic computation function corresponding to the instruction type of the instruction component of the path is called independently and in parallel. Hypothetical extrapolation calculations are performed on the time operation basis saved at the checkpoint, thereby pre-calculating the future time result if the path is selected (e.g., calculating the specific date of choosing Wednesday or Thursday based on the context of the second week of a certain year and month).

[0111] Furthermore, these paths and their corresponding pre-computed results are organized into a tree-like, hierarchical data structure, namely the execution tree. The root node of the execution tree is the definite state represented by the ambiguity checkpoint, each branch represents a possible path, and the leaf nodes are the pre-computed results of each path.

[0112] Step 404: Generate a selection clarification question based on the execution tree, perform time calculations based on the selection result of the clarification question, output the stage time of the corresponding uncertain instruction component, resume the time calculation process for the instruction component, continue the time calculation for the next instruction component, or output the target standardized time information.

[0113] Specifically, a selection-based clarification question is automatically generated based on the execution tree. This question can directly list the pre-computed specific result options corresponding to the leaf nodes of the execution tree, rather than abstract instructions.

[0114] For example, regarding the uncertainty of "Wednesday or Thursday," the execution tree pre-calculates two leaf nodes: "2025-10-08 (Wednesday)" and "2025-10-09 (Thursday)," generating a clarifying question such as "Do you mean October 8th (Wednesday) or October 9th (Thursday)?" If the user makes a clear choice, there's no need to recalculate; the pre-calculated result (leaf node value) corresponding to that choice is directly used as the stage time output by the current uncertainty instruction component.

[0115] Furthermore, the complete computational context is restored from the previously saved ambiguity checkpoint, and this stage time is loaded as the new time operation baseline, thereby resuming the previously paused time computation process and continuing to execute the next component in the instruction component list. Here, the complete computational context can refer to restoring the entire, lossless computational state encapsulated by the previous ambiguity checkpoint, namely: the time operation baseline (the specific time value at that time); a complete ordered list of executed instruction components (historical operation path); and the stage time result corresponding to each executed component (historical state sequence). If the uncertain instruction happens to be the last component in the list, its output is used as the final target normalized time information.

[0116] In one embodiment, parsing a domain-specific language instruction sequence to obtain a structured list of instruction components further includes:

[0117] Perform syntax self-correction verification on the domain-specific language instruction sequence. If the domain-specific language instruction sequence conforms to the syntax rules of the domain-specific language instruction sequence, parse the domain-specific language instruction sequence to obtain a structured list of instruction components. Otherwise, generate error message questions based on the error information in the domain-specific language instruction sequence. The error message questions are used to describe the prompt information needed to resolve the error information.

[0118] Specifically, before parsing a domain-specific language instruction sequence (such as "+1W WD") into a structured list of instruction components, the input string is first subjected to strict validity validation based on predefined domain-specific language instruction sequence syntax rules (such as regular expression patterns). If the domain-specific language instruction sequence conforms to all syntax rules (e.g., "+1W WD5" can be successfully matched), lexical and syntactic analysis is performed, and a structured list of instruction components is output.

[0119] If a domain-specific language instruction sequence contains a syntax error (e.g., "+1W WD" is missing a weekday number), it will fail and throw a structured error message. This error message may include diagnostic information such as the error type (e.g., SYNTAX_ERROR), the problematic domain-specific language segment, specific error details (e.g., "Target instruction 'WD' is missing a required numeric value"), and the location of the error.

[0120] In one embodiment, the parsing method further includes: performing business rule verification on the target standardized time information; if the business rule verification fails, generating a prompt message based on the failed business rule.

[0121] If the business rule verification is successful, the target standardized time information is calibrated using a real-world model. If the knowledge calibration fails, a suggested time for the task scenario is generated based on the real-world model and the target standardized time information.

[0122] Specifically, business rule validation is performed. Based on the current task scenario (such as "scheduling a meeting"), the corresponding rule set (such as isWorkday (must be a weekday), isInBusinessHours (must be within business hours), isBookable (this time period is not occupied)) is loaded, and the calculated time points are validated one by one.

[0123] If verification fails (e.g., the date falls on a weekend), a targeted prompt message is generated based on the specific failure rule (e.g., "Sorry, October 11th is a Saturday, and we cannot schedule an appointment for you on a non-working day.") to guide the user to adjust. If business rule verification succeeds, an external authoritative knowledge source (e.g., the National Statutory Holiday API) is invoked to check the time point against dynamic reality rules (e.g., work schedule adjustments). If knowledge calibration fails (e.g., the date is a statutory holiday), dynamic calibration and intelligent calculation are performed based on the returned structured knowledge (e.g., holiday range). This not only marks the date as unavailable but also proactively calculates the next suitable time point (e.g., the first working day after the holiday ends), and generates a task suggestion time integrated with the contextual semantics (e.g., "We recommend the first working day after the holiday ends, which is May 6th (Wednesday). Is that okay?").

[0124] For example, such as Figure 5 As shown, when a user inputs "the second Friday of next month," the large language model compiles it into a domain-specific language instruction sequence "+1M WEEK2 WD5" and saves it. After execution, the output is "July 12, 2024." Business rule validation is performed to check whether the date is a holiday or weekend based on the current task scenario. If the business rule validation is successful, a confirmation message with details is output: "Okay, July 12th, may I ask...". If the business rule validation fails, a suggested time integrating the context's semantics is generated: "That day is a holiday, we recommend...".

[0125] In one embodiment, in a multi-turn dialogue scenario, the domain-specific language (DSL) instruction sequence of a single-turn dialogue is saved. When an additional time correction instruction is received in a subsequent dialogue, the additional time correction instruction is compiled into an additional DSL instruction sequence based on a large language model. The additional DSL instruction sequence is then concatenated to the end of the most recently saved DSL instruction sequence. Based on the concatenated DSL instruction sequence, the parsed instruction component list is parsed in a chain-like manner to obtain the target normalized time information corresponding to the additional time correction instruction.

[0126] Specifically, after parsing the first round of dialogue, what is saved is not the final date result, but rather the domain-specific language instruction sequence that fully represents the user's initial intention process (e.g., for "next Friday", save "+2W WD5"). When subsequent dialogues detect additional time correction instructions issued by the user (such as "postpone 3 days"), the large language model will be driven again.

[0127] At this point, thanks to the abstract representation of context, the large language model only needs to independently compile the incremental correction description of the current round (e.g., "postpone 3 days later") into a new domain-specific language instruction fragment (e.g., "+3D"), without having to backtrack or re-understand the entire dialogue history.

[0128] Furthermore, the newly compiled domain-specific language instruction sequence is seamlessly concatenated to the end of the most recently saved original instruction sequence, forming a new, complete compound instruction sequence (e.g., "+2W WD5 +3D"). Based on this concatenated complete instruction sequence, deterministic parsing is performed to obtain an updated list of instruction components, and chained evaluation is strictly performed from the beginning to obtain the target normalized time information corresponding to the appended time correction instructions.

[0129] For example, such as Figure 6As shown, in the first round of dialogue, the user inputs "Schedule a meeting for the Friday after next." The large language model compiles this into a domain-specific language instruction sequence "+2W WD5" and saves it. The output after execution is "The meeting is tentatively scheduled for November 10, 2023 (the Friday after next)." In the second round of dialogue (user correction), the user inputs "Oh no, it's 3 days after that time." This again drives the large language model, but this time the model doesn't need to understand the specific value of "that time." It only needs to independently compile the incremental description "3 days after that time" into a new domain-specific language fragment "+3D." The instruction stream is then concatenated, appending "+3D" to the end of the saved instruction stream to form a new complete sequence "+2W WD5 +3D". Based on the concatenated sequence, the chained evaluation is re-parsed and performed from the beginning. First, "+2W WD5" is calculated to obtain the intermediate date November 10, 2023. Then, "+3D" is executed on this basis to output the new target time "Meeting time updated to November 13, 2023".

[0130] Based on the same concept, this application also provides a parsing system for natural language time description, which applies the parsing method for natural language time description described above.

[0131] This system integrates the semantic understanding capabilities of a large language model with a deterministic "compile-execute" architecture, automatically transforming user-input natural language time descriptions (including expressions in complex, ambiguous, or multi-turn dialogues) into accurate and reliable standard time information. From semantic compilation, instruction parsing, sequential execution to business verification, it is solidified into a reliable, automatically running pipeline. While intelligently handling time ambiguities and supporting multi-turn corrections, it ensures high interpretability, traceability, and absolute reliability of the calculation results, thereby improving the intelligence level of human-computer interaction and task completion efficiency.

[0132] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a solid-state drive (SSD), etc.

[0133] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. The above are merely preferred embodiments of this application and are not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A method for parsing natural language temporal descriptions, characterized in that, The parsing method includes the following steps: Through a large language model, the natural language time description is compiled into a domain-specific language instruction sequence, which reflects the time operation links and inherent time operation order of the natural language time description; The domain-specific language instruction sequence is parsed to obtain a structured list of instruction components. The structured list of instruction components includes at least one instruction component and the order of the instruction components. The instruction component represents a time operation step of the natural language time description. According to the order of the instruction components, the instruction components in the instruction component list are evaluated in a chain to obtain the target standardized time information corresponding to the natural language time description. The sequential chaining evaluation of the instruction components in the instruction component list includes: Create an initial computation state and an empty checkpoint stack; Push the first instruction component in the instruction component list onto the checkpoint stack. Use the initial calculation state as the time operation benchmark of the checkpoint stack. Call the calculation function to perform time calculation on the first instruction component based on the time operation benchmark to obtain the stage time. Update the time operation benchmark of the checkpoint stack based on the stage time. Starting from the first instruction component in the instruction component list, each instruction component in the instruction component list is pushed onto the checkpoint stack in an orderly manner. The execution time is calculated based on the previously updated time operation benchmark to obtain the stage time of the corresponding instruction component. The stage time output by the last instruction component in the instruction component list is used as the target standardized time information.

2. The method for parsing natural language temporal descriptions according to claim 1, characterized in that, The process of compiling a natural language temporal description into a domain-specific language instruction sequence includes: Prompt words are constructed based on the task scenario and dialogue context, and the prompt words include relevant examples and grammatical rules for domain-specific language instruction sequences; The prompt words and the natural language time description are input into the large language model to obtain the domain-specific language instruction sequence.

3. The method for parsing natural language temporal descriptions according to claim 2, characterized in that, The method also includes constructing grammatical rules for domain-specific language instruction sequences. Includes the following steps: We use a large language model to process natural language corpora containing time descriptions, and locate and extract time-related text fragments. The text fragments are subjected to text standardization processing, and an original time expression library is constructed based on the standardized text fragments; The text fragments in the original temporal representation library are grouped by similarity to obtain at least two intent clusters; Extract the core operation intent for each intent cluster to obtain the operation intent for the corresponding intent cluster; Based on the operational intent, a syntax rule is generated for a domain-specific language instruction sequence corresponding to the operational intent.

4. The method for parsing natural language temporal descriptions according to claim 1, characterized in that, The instruction component list also includes the instruction type and instruction value corresponding to the instruction component, and the instruction type includes deterministic instruction type and non-deterministic instruction type; Before calculating the execution time of the instruction component, the instruction type of the instruction component is checked first; If the instruction type of the instruction component is a deterministic instruction type, the calculation function is called to calculate the stage time of the corresponding deterministic instruction component based on the execution time of the previously updated time operation benchmark. When the instruction type of the instruction component is an indeterminate instruction type, a lazy evaluation strategy is executed, including: Pause the time calculation process for the instruction component; All computational contexts at the current moment are encapsulated and saved as an ambiguity checkpoint. The computational contexts at the current moment include the time operation baseline, the instruction components that have performed time calculations, and the stage time generated by the instruction components that have performed time calculations. Based on the ambiguity checkpoints, all possible paths in the uncertain instruction components are traversed, the results of each path are pre-calculated independently, and an execution tree is constructed. Based on the execution tree, a selection clarification question is generated, and time calculation is performed according to the selection result of the clarification question. The stage time corresponding to the uncertain instruction component is output, and the time calculation process for the instruction component is resumed to continue the time calculation for the next instruction component, or the target standardized time information is output.

5. The method for parsing natural language temporal descriptions according to claim 4, characterized in that, The deterministic instruction components include: a relative offset instruction component, an absolute target instruction component, and an ordinal and position instruction component; The relative offset instruction component represents the time operation of the time translation intention, indicating an operation of adding or subtracting one time unit at a specified time base point; The absolute target instruction component represents a time operation with an absolutely specified intent, indicating that a specified portion of the time is directly set to a specific value; The ordinal and position instruction components characterize the temporal operation of the sequence positioning intent, representing the order or position of an entity's time within a time set.

6. The method for parsing natural language temporal descriptions according to claim 1, characterized in that, The step of parsing the domain-specific language instruction sequence to obtain a structured list of instruction components further includes: The domain-specific language instruction sequence is subjected to grammatical self-correction verification. If the domain-specific language instruction sequence conforms to the grammatical rules of the domain-specific language instruction sequence, the domain-specific language instruction sequence is parsed to obtain a structured list of instruction components. Otherwise, an error message question is generated based on the error information in the domain-specific language instruction sequence. The error message question is used to describe the prompt information required to resolve the error information.

7. The method for parsing natural language temporal descriptions according to claim 6, characterized in that, The parsing method further includes: performing business rule verification on the target standardized time information; if the business rule verification fails, generating a prompt message based on the failed business rule. If the business rule verification is successful, the target standardized time information is subjected to knowledge calibration of the real-world model. If the knowledge calibration fails, a suggested time for the task scenario is generated based on the real-world model and the target standardized time information.

8. The method for parsing natural language temporal descriptions according to claim 1, characterized in that, In a multi-turn dialogue scenario, the domain-specific language instruction sequence of a single-turn dialogue is saved. When an additional time correction instruction is received in a subsequent dialogue, the additional time correction instruction is compiled into an additional domain-specific language instruction sequence based on the large language model. The additional domain-specific language instruction sequence is concatenated to the end of the most recently saved domain-specific language instruction sequence. Based on the concatenated domain-specific language instruction sequence, the parsed instruction component list is evaluated in a chain to obtain the target standardized time information corresponding to the additional time correction instruction.

9. A parsing system for natural language temporal description, characterized in that, The parsing system applies the parsing method for natural language time description as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Intelligent SQL query generation method and system based on large language model

    CN118861081A

  • Data analysis method and device, equipment and storage medium

    CN120911440A