Computational method for dynamically generating complex expressions based on natural language processing
Complex expressions are constructed through natural language processing, operators are extracted and semantics are parsed, dimensions are checked and saved as structured expressions. This solves the problems of complex operations and proneness to errors in existing technologies, achieves reusability and reliability, and is suitable for semantic verification in multi-table environments.
Patent Information
- Application Number
- CN202511024356.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2045-07-24
AI Technical Summary
The existing technology is complex and error-prone when constructing complex logical expressions, is difficult to implement self-checking and reuse, and cannot handle complex multi-step logical operations.
Through natural language processing, operator strings are extracted, operational semantic relationships are parsed, an overall abstract expression is constructed, and dimension checking is performed. The expression is saved as a structured expression, and an equivalence relationship mapping table is introduced to support cross-table semantic classification, automatically verify, and graphically prompt errors.
It achieves the reusability, stability, and interpretability of complex expressions, lowers the construction threshold, improves operational efficiency and result reliability, supports semantic matching and verification across tables, and prevents calculation errors.
Smart Images

Figure CN120523895B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing, and specifically to a calculation method for dynamically generating complex expressions by natural language processing. Background Art
[0002] Currently, in various business systems, data platforms, and billing reporting systems, users often need to dynamically calculate business data and construct complex calculation expressions to complete tasks such as financial accounting, performance statistics, and user billing. To meet these needs, existing technologies mainly complete expression construction and calculation through the following two methods:
[0003] One way is to use a preset template or formula editor, and have business personnel manually splice expressions, specifying calculation relationships by dragging controls or using scripting languages. Although it has a certain degree of flexibility, this method has the disadvantages of being complex to operate, prone to errors, unable to express complex business semantics, and unable to be reused, and requires users to have a certain professional background. Another way is to introduce a natural language recognition component to convert user-entered statements into calculation expressions for processing. However, most existing natural language to expression systems only support simple addition, subtraction, multiplication, and division instructions, making it difficult to integrate complex logic. Once more complex multi-step logical operations are involved, the order of operations is often not correctly identified. At the same time, it is even more impossible to verify the correctness of the expression.
[0004] Therefore, how to build reusable, self-checking, and error-prone expressions based on natural language input in complex logical scenarios is a technical problem that needs to be solved urgently. Summary of the Invention
[0005] The present disclosure provides a computing method and system for dynamically generating complex expressions based on natural language processing.
[0006] In a first aspect, the present disclosure provides a computing method for dynamically generating complex expressions based on natural language processing, comprising:
[0007] Extract all operator strings in the statement to be parsed;
[0008] Based on the statement to be parsed and all the operator strings, parsing the operation semantic relationship, and constructing an overall abstract expression, wherein the overall abstract expression includes at least one input parameter;
[0009] Performing dimension checking on all data associated with the operator string;
[0010] If the check result is correct, the overall abstract expression is saved as a structured expression;
[0011] If the check result is incorrect, the user will be prompted in the interactive interface that the statement to be parsed entered may be incorrect.
[0012] Optionally, the input parameters of the overall abstract expression include a data table name. The system automatically extracts multiple field values in the data table that are semantically related to the overall abstract expression based on the data table name, and substitutes the multiple field values into the overall abstract expression for calculation.
[0013] Optionally, the step of saving the overall abstract expression as a structured expression further includes:
[0014] naming the structured expression;
[0015] Constructing a keyword mapping table for searching the structured expression according to the keyword;
[0016] The keyword mapping table at least includes a set of field names that are semantically related to the overall abstract expression.
[0017] Optionally, the method further includes:
[0018] Constructing an equivalence relationship mapping table for semantically classifying multiple data tables, wherein the semantic classification indicates that different data tables are equivalent in field structure or business meaning;
[0019] When a user calls the structured expression and inputs a data table that is not classified or classified into different categories, the system determines whether its category matches based on the equivalence relationship mapping table;
[0020] If the categories do not match, a prompt message is generated to guide the user to choose whether to classify the data table into a category that matches the target expression before performing the calculation.
[0021] Optionally, the performing dimension checking on all data associated before and after the operator string further includes:
[0022] The system automatically records the dimensional relationship between fields during the execution of historical structured expressions;
[0023] When generating a new structured expression, the system verifies the dimensional consistency between the fields involved in the new structured expression based on the dimensional relationship of the historical records.
[0024] Optionally, the system automatically records the dimensional relationship between fields during execution of the historical structured expression, further comprising:
[0025] Two fields that are added or subtracted in a history structured expression are marked as dimensionally equal.
[0026] Optionally, if the check result is incorrect, prompting the user in the interactive interface that the statement to be parsed input may contain an error, further comprising:
[0027] Displaying the operation structure of the structured expression in a graphical manner in a user interface;
[0028] The system automatically locates the operation unit with dimensional error in the structured expression and prompts it in the user interface in a highlighted manner to guide the user to correct the expression logic.
[0029] In a second aspect, the present disclosure provides a computing system for dynamically generating complex expressions based on natural language processing, comprising:
[0030] Operator parsing module, used to extract all operator strings in the statement to be parsed;
[0031] An expression generation module, configured to parse the semantic relationship of operations based on the statement to be parsed and all the operator strings, and construct an overall abstract expression, wherein the overall abstract expression includes at least one input parameter;
[0032] A dimension checking module, used for performing dimension checking on the data associated with all the operator strings;
[0033] An expression saving module, configured to save the overall abstract expression as a structured expression if the check result is correct;
[0034] The error reporting module is used to prompt the user in the interactive interface that there may be an error in the statement to be parsed if the check result is incorrect.
[0035] In a third aspect, the present disclosure provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0036] Memory stores computer-executable instructions;
[0037] The processor executes the computer-executable instructions stored in the memory to implement the method of the present disclosure.
[0038] In a fourth aspect, the present disclosure provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method of the present disclosure.
[0039] The beneficial effects of the present disclosure are that, compared with the prior art, the present disclosure has the following advantages:
[0040] 1) This invention automatically constructs abstract expressions containing input parameters by performing structured semantic parsing of natural language. It also allows users to name and annotate these expressions with keywords, enabling complex expressions to be repeatedly called and quickly reused. Compared to existing template splicing or scripting methods, this invention significantly lowers the barrier to entry for expression construction, improving operational efficiency and stability.
[0041] 2) This invention introduces an equivalence mapping table mechanism to support semantic categorization of different data tables and performs semantic category matching and verification on input tables during expression execution. This mechanism avoids calculation errors caused by inconsistent field structures or business semantic deviations, enabling the universal expression of complex business expressions across cross-table structures, significantly improving the adaptability and robustness of expressions.
[0042] 3) During the expression construction and execution process, the present invention automatically infers the dimensional relationship between fields based on historical expression records and performs dimensional consistency checks on newly generated expressions. When errors are found, the system can automatically locate the problem field and highlight it graphically in the user interface, effectively preventing hidden errors such as unit conflicts and bracket mismatches, thereby improving the interpretability of expressions and the reliability of results. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0044] Figure 1 A schematic diagram of a method for dynamically generating complex expressions based on natural language processing provided in an embodiment of the present disclosure;
[0045] Figure 2 A schematic diagram of a method for saving structured expressions provided in an embodiment of the present disclosure;
[0046] Figure 3 A schematic diagram of a data table classification mapping method provided in an embodiment of the present disclosure.
[0047] Figure 4 A schematic diagram of a method for checking the dimension of data associated with operator strings provided in an embodiment of the present disclosure.
[0048] Figure 5 A schematic diagram of a computing system for dynamically generating complex expressions based on natural language processing provided in an embodiment of the present disclosure.
[0049] The above drawings illustrate specific embodiments of the present disclosure, which will be described in more detail below. These drawings and textual descriptions are not intended to limit the scope of the present disclosure in any way, but rather to illustrate the concepts of the present disclosure to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0050] The present disclosure is further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present disclosure and are not intended to limit the scope of protection of the present disclosure.
[0051] Figure 1 A schematic diagram of a method for dynamically generating complex expressions based on natural language processing. Figure 1 , each step is now discussed in detail in conjunction with this embodiment.
[0052] S100: Extract all operator strings in the statement to be parsed.
[0053] In this embodiment, the system first receives a natural language sentence input by the user, which is typically used to describe a certain data processing, statistical, or billing logic. The system parses the sentence based on natural language processing technology and extracts expressions with computational semantics. To achieve this goal, the system pre-builds an operator recognition model that supports the recognition and normalization of computational verbs, prepositional phrases, and domain-specific expressions in natural language. This recognition model can be built based on a rule engine, a part-of-speech tagging algorithm, and a contextual semantic analysis algorithm, and can extract language fragments with numerical computational significance from complex or nested expressions.
[0054] During the processing, the system first performs word segmentation on the sentence and identifies potential operational expressions based on the context. For example, for the sentence "Add the subscription fee to the shipping fee and subtract the management fee", the system recognizes that "plus" and "minus" correspond to addition and subtraction semantics respectively. Subsequently, the system maps the identified natural language fragments to internal standard operators for the subsequent construction of abstract expressions. This mapping process is completed based on a predefined operator mapping table, which defines the mapping relationship between natural language phrases and standard mathematical operators. For example, "plus", "total", and "addition" are mapped to "+", "minus", "reduce", and "difference from..." are mapped to "-", "multiply by", and "amplify" are mapped to "×", and "divide by" and "distribute equally" are mapped to "÷", etc.
[0055] To ensure accurate extraction, the system also determines the position of the operation phrase in the original sentence and marks its scope of action in the semantic structure. In particular, when there are multiple nested operations, the system identifies the master-slave relationship by calculating dependency paths and word distances. For example, in the sentence "All VIP users' subscription fees are multiplied by the discount and added to the subscription fees of ordinary users," the system can identify that "multiplied" applies to "VIP users' subscription fees" and "discount," and that "added" applies to the result of the entire discount and "ordinary users' subscription fees," thus establishing the correct order of precedence.
[0056] For example, suppose a user enters the following statement: "Add the subscription fees of all VIP customers in table a1, and then subtract a per capita management fee of 10 yuan per person." After word segmentation, the system identifies two keywords with operation semantics: "add" and "subtract," and maps them to "+" and "-," respectively. The system also records the relative position of each operator string in the original statement and any related data fields before and after it, laying the foundation for the subsequent construction of abstract expressions.
[0057] Ultimately, the output of this step is a sequentially ordered list of standardized operators, which is used in the next step to parse variables and construct the operation structure. This step not only makes the operation logic in natural language explicit and structured, but also provides foundational support for semantic combination, field mapping, and dimensionality verification in subsequent steps.
[0058] S200: Based on the statement to be parsed and all the operator strings, parse the operation semantic relationship and construct an overall abstract expression, where the overall abstract expression includes at least one input parameter.
[0059] In this embodiment, after extracting the operator strings, the system continues to parse the semantic structure of the operations within the original natural language sentence and the extracted operator information, thereby constructing a holistic abstract expression. This holistic abstract expression describes the user's complete computational intent and serves as the core semantic unit for subsequent parameter mapping, expression validation, and computation execution.
[0060] The system first analyzes the context surrounding the operator string in the statement using a semantic analysis model to identify the operands (variables or constant values) corresponding to each operator. This process relies on the calculation rules defined in the operator mapping table. For example, "plus" requires two variables to be located before and after the keyword, while "and the difference" requires the system to identify the two variables before and after the "and." Therefore, the system calibrates the semantic template for each operator, including the number of parameters, their relative positions, and their scope.
[0061] The system then combines the results of natural language word segmentation, part-of-speech tagging, and entity recognition to locate all candidate variable phrases and match them with the various operators to restore the computational relationships. During this process, the system not only identifies the textual form of the variables but also extracts their roles within the semantic structure, such as as addend, subtrahend, factor, or denominator, thereby accurately describing their logical relationships with the operators.
[0062] To enhance expression reusability and cross-table adaptability, the system abstracts identified variables into parameter forms and constructs an overall abstract expression consisting of one or more input parameters. These input parameters can be field names, table identifiers, fixed values, or conditional expressions. The system abstracts these using a unified expression structure that aligns with natural language semantics.
[0063] For example, for the statement "Multiply the subscription fees of all VIP customers in table a1 by 0.6, add the sum to the subscription fees of regular customers, and subtract a per capita management fee of 10 yuan," the system will recognize the three operators "multiply," "add," and "subtract" in S100. In this step, it will identify the following semantic relationship: multiply the VIP customer subscription fee by 0.6; add the result to the regular customer subscription fee; and subtract 10 yuan multiplied by the total number of customers. The system ultimately constructs the overall abstract expression: r = (v1 * 0.6 + v2) - v3, where v1 is the VIP customer subscription fee, v2 is the regular customer subscription fee, and v3 is the per capita management fee multiplied by the number of customers. The system maps v1, v2, and v3 as input parameters to data table fields or constant values, respectively, and uses r as the calculation result.
[0064] S300: Perform a dimension check on all data associated before and after the operator character string.
[0065] In this embodiment, after successfully constructing the overall abstract expression, the system enters the dimension checking phase. The main purpose of this step is to verify the consistency of the units of the fields or constants involved in various operations in the expression to prevent calculation logic errors caused by dimension mismatch. The so-called dimension refers to the physical properties or statistical caliber of a value, such as "amount (yuan)", "number of people (person)", "time (hours)", etc. Direct addition, subtraction, or certain multiplication and division operations cannot be performed between different dimensions.
[0066] The system first traverses each operator in the overall abstract expression and identifies the fields or constants involved in the operation before and after. Each field usually corresponds to a column in a data table. The system will further obtain the unit information or type identifier bound to the field in the original data source through the field mapping relationship. If the field itself does not explicitly mark the unit, the system can make intelligent inferences based on the usage context in the historical expression. For example, if the field name contains roots such as "amount", "cost", "quantity", "duration", etc., or semantic completion is performed through a joint relationship with other fields.
[0067] After obtaining the dimension information for the fields or constants on both sides of the operator, the system compares them using pre-set dimension rules. For example, for addition and subtraction operations, both operands must have the same dimension; otherwise, an exception is generated. However, for multiplication and division operations, different dimensions are permitted, and a new derived dimension is generated after the operation. For example, "amount ÷ number of people" can be converted into a new type called "amount per person."
[0068] For example, if the expression is "r = Total Fee - Discount Amount," the system recognizes that both "Total Fee" and "Discount Amount" come from data columns with a unit of "yuan." Therefore, the addition and subtraction operations are considered consistent in dimensionality and allowed. However, if the expression is "r = Total Fee - Number of Customers," a dimensionality inconsistency prompt will be triggered because the unit of "Number of Customers" is "person," which cannot be directly subtracted from the unit of "Total Fee" (yuan). In this case, the system will automatically mark the operation unit and prompt the user through the interactive interface in subsequent steps.
[0069] In more complex expressions, such as "r = VIP subscription fee * 0.6 + standard subscription fee - 10 * number of customers," the system will sequentially check whether each data item connected by the "*," "+," and "-" operators satisfies unit matching. In particular, in multiplication and division operations, the system also supports dimensional derivation and tracking, allowing for subsequent unit derivation and visualization of the entire expression calculation path.
[0070] S400: If the check result is correct, save the entire abstract expression as a structured expression.
[0071] In this embodiment, after the system completes the data dimension check for all operator-associated fields in the overall abstract expression, if all check items pass (i.e., there are no field unit conflicts, inconsistent dimensions, or expression logic errors), the system will persist the overall abstract expression as an executable expression structure, forming a structured expression. Structured expressions are the core expression unit in this invention that abstracts, standardizes, and reusably processes natural language input.
[0072] Specifically, structured expressions are based on components such as expression trees, operator sequences, field mappings, and input parameter placeholders, stored in a unified data structure within an expression knowledge base or configuration database. This structure not only preserves the expression's operator precedence, parenthesis nesting, field dependencies, and constant values, but also records the mapping logic to the input data, allowing the system to call it at any time and directly calculate the result after rebinding the data source.
[0073] When saving structured expressions, the system also supports naming them to enhance the convenience of subsequent retrieval and management. Expression names can be automatically generated by the system based on semantics, such as "Formula for calculating VIP subscription net profit," or they can be customized by the user. Furthermore, the system supports the establishment of a keyword indexing mechanism, automatically extracting the core field names, operation types, business scenario descriptions, and other information involved in the expression to form a keyword mapping table to support fuzzy search and prompt recommendation functions.
[0074] For example, suppose the user enters the following statement: "Multiply the subscription fees of all VIP customers in table a1 by 0.6, add this to the fees of regular customers, and then subtract a per capita management fee of 10 yuan per person." After steps S100 to S300, the system identifies a semantically correct and structurally sound expression relationship. The system then generates the structured expression r = (v1 * 0.6 + v2) - v3, where v1 represents the VIP fee field, v2 represents the regular fee field, and v3 represents the per capita management fee multiplied by the number of people. The system then stores this expression structure, along with the field mapping and semantic description, in the expression library.
[0075] S500: If the check result is incorrect, a prompt is given in the interactive interface indicating that the statement to be parsed input by the user may contain an error.
[0076] The operation structure of the structured expression is displayed graphically in a user interface; the system automatically locates the operation unit with dimensional error in the structured expression and highlights it in the user interface to guide the user to correct the expression logic.
[0077] In this embodiment, if the system detects any discrepancies with pre-set rules during the dimensional consistency check of the overall abstract expression in step S300, such as inconsistent units between the two operands of addition or subtraction operations, incompatible field types, missing variable positions, or an incomplete logical structure, the expression will be deemed invalid and will not meet the execution conditions. To prevent calculation anomalies caused by directly executing the incorrect expression, the system will activate an error prompt mechanism, providing clear feedback on the status of the current expression in the user interface.
[0078] Specifically, the system first locates the specific field or constant item with the error based on the inconsistent operator nodes. Then, based on the semantic location in the original natural language sentence, it generates prompts consistent with the user's expression habits. Prompts may include, but are not limited to, "The fields 'Total Expenses' and 'Number of Customers' cannot be directly subtracted. Please check the field meaning or units," "The units for 'Per Capita Expenses' are not clearly stated in the sentence. Please confirm if there is any ambiguity," etc., helping users quickly identify anomalies in the semantic structure.
[0079] To improve the readability and ease of use of error prompts, the system also presents error prompts graphically in the interactive interface. The system will highlight the operation units with dimensional conflicts in the expression structure tree or formula display area, or insert graphic symbols between operators and variables to indicate the conflict points, while simultaneously displaying diagnostic suggestions on the right side or bottom of the interface. For example, if the expression contains the incorrect combination "(250 yuan - 3 people)", the system will mark the subtraction node in red and pop up a prompt box stating that "yuan and people cannot be directly calculated."
[0080] In addition, the system supports prompting users to make corrections. Users can adjust the original statement, replace fields, add unit descriptions, or modify the expression's logical structure based on the system's suggestions. Each time the user modifies the input, the system automatically re-executes steps S100 to S300 and, once dimensional consistency requirements are met, enters the structured expression saving process, ensuring the expression's semantic integrity and logical consistency before execution.
[0081] In this embodiment, the input parameters of the overall abstract expression include a data table name. The system automatically extracts multiple field values in the data table that are semantically related to the overall abstract expression based on the data table name, and substitutes the multiple field values into the overall abstract expression to participate in the calculation.
[0082] The input parameters of holistic abstract expressions are no longer limited to specifying specific variables one by one. Instead, they support abstract input using a data table name, which the system then automatically extracts and maps field values. Specifically, when a user enters a natural language expression such as "Calculate..." in table a1 or "Add or subtract the relevant expense fields in table a2," the system first identifies the data table name as one of the expression's input parameters and, during the expression parsing phase, binds it to a registered structured data table within the system.
[0083] After identifying the table name, the system automatically matches each input parameter in the abstract expression with the fields in the target table based on pre-set field mapping rules and keyword matching mechanisms. For example, if the abstract expression contains semantic fragments such as "VIP customer subscription fee," "regular customer subscription fee," or "per capita management fee," the system searches the specified table for the fields that best match these semantic fragments and extracts their values as the values of the corresponding variables in the expression.
[0084] In a specific application, if the abstract expression structure is: r = (v1 * 0.6 + v2) - v3, where v1 represents the VIP customer subscription fee field, v2 represents the standard customer subscription fee field, and v3 represents the average management fee multiplied by the number of customers, then after the user specifies the table name "table a1," the system automatically extracts the following fields: v1 is mapped to a1.vip_fee, v2 is mapped to a1.std_fee, and v3 is mapped to a1.unit_admin_cost × a1.customer_count. This mapping is achieved through the collaborative work of the field semantic keyword library maintained in the system and the data type analysis model.
[0085] This mechanism makes expression execution more abstract and modular. Users no longer need to explicitly declare all field names each time. Instead, they can achieve semantically consistent field value filling by simply specifying a table identifier. This not only improves the reusability of expressions across different data table structures, but also reduces user dependence on field structure details, further enhancing the overall system's intelligent expression capabilities and ease of use.
[0086] At the same time, when users call this structured expression, the input parameters become very simple and convenient, and they only need to enter a table name.
[0087] Figure 2 A schematic diagram of a method for saving structured expressions provided by an embodiment of the present disclosure. Figure 2 , further elaborating on the specific embodiments of the present application.
[0088] S410: Name the structured expression.
[0089] In this embodiment, to improve the manageability and reusability of structured expressions, the system performs a naming operation on each structured expression that passes dimensionality verification after completing expression construction and verification. This naming process can be actively input by the user or automatically generated by the system based on the semantic structure of the expression. Naming structured expressions not only facilitates subsequent querying, calling, and classification management, but also provides a semantic anchor for keyword retrieval mechanisms and semantic prompting mechanisms.
[0090] When a user initiates a naming request, the system will pop up a naming suggestion window after the expression is saved, prompting the user to enter a semantically descriptive name for the expression. For example, if the user enters the natural language "Multiply the subscription fees of all VIP customers in Table a1 by 0.6, add this to the fees of regular customers, and subtract the per capita management fee," the system might suggest names like "Calculate Net Profit from Subscription Fees" or "VIP Discount Net Profit Formula." The user can confirm or modify this name based on their business preferences.
[0091] When the system automatically names an expression, it calls the expression naming module to analyze the operator combinations, keywords, field names, and semantic tags in the structured expression. For example, if the expression contains keywords such as "subscription fee," "discount," "addition," "subtraction," and "management fee," the system constructs naming options such as "Subscription fee discount net income expression" or "Subscription + management fee difference formula" and selects the most semantically representative name as the default name for saving.
[0092] During the naming process, the system also generates a unique expression identifier (Expression ID) and establishes a one-to-one mapping between the expression and the name, ensuring that expressions with the same name can be versioned and distinguished within the system. The system supports deduplication of expression names. If an identical expression name is detected, the user will be prompted to rename it to avoid confusion.
[0093] The named structured expression will be entered into the expression knowledge base and managed as a structured record together with the expression body, field mapping information, keyword index, dimension record, etc. It can be quickly retrieved, called or reused by the expression name in subsequent user operations.
[0094] S420: Construct a keyword mapping table for searching the structured expression according to keywords; wherein the keyword mapping table at least includes a set of field names semantically related to the overall abstract expression.
[0095] In this embodiment, to achieve efficient retrieval and semantic hinting of structured expressions, the system, after naming the structured expression, continues to construct a corresponding keyword mapping table. This keyword mapping table is used to establish a mapping relationship between the structured expression and the keywords involved in its semantics. Even if the user does not remember the full expression name in subsequent operations, they can still perform fuzzy search and quickly locate the expression by entering relevant keywords.
[0096] The construction process of the keyword mapping table is completed automatically by the system. After the structured expression is generated, the system will extract all the field names, constant descriptions, operator combinations and semantic labels referenced by the expression, and combine them with the business descriptive words appearing in the natural language sentence to form a unified keyword set. For example, for the expression "r = (VIP subscription fee × discount rate + ordinary subscription fee) - management fee × number of people", the system can automatically extract keywords such as "VIP subscription fee", "ordinary subscription fee", "discount rate", "management fee", and "number of people". At the same time, it can also identify the operation behavior keywords such as "net profit", "total cost", and "deduction", and bind these keywords to the structured expression for storage.
[0097] During the construction process, the system not only saves the original field names, but also expands keywords based on the preset synonym database and business semantic model. For example, it automatically associates "subscription fee" with "paid amount", "user payment", "monthly fee", etc., and associates "discount" with "discount", "discount ratio", "promotional coefficient", etc., to improve keyword coverage and retrieval robustness.
[0098] Each structured expression corresponds to a unique keyword mapping table, with the keywords recorded in the table serving as index items for the expression. The system supports subsequent expression matching queries based on any user-entered keyword or keyword combination. When keywords overlap across multiple expressions, the system ranks candidate expressions based on keyword matching, historical usage frequency, or business context for user selection.
[0099] The introduction of the keyword mapping table has greatly improved the system's searchability and interpretability of expressions, allowing users to quickly retrieve and reuse expressions based on business semantic vocabulary even if they do not have the ability to remember specific names or understand expression structures. This enhances the system's human-computer interaction friendliness and expression knowledge management capabilities.
[0100] Figure 3 A schematic diagram of a data table classification mapping method provided by an embodiment of the present disclosure. Figure 3 , further elaborating on the specific embodiments of the present application.
[0101] S1. Construct an equivalence relationship mapping table for semantically classifying multiple data tables. The semantic classification indicates that different data tables are equivalent in field structure or business meaning.
[0102] In this embodiment, to enable the reuse of structured expressions across different data tables, the system pre-builds an equivalence relationship mapping table to semantically categorize multiple business data tables. An equivalence relationship mapping table is a structured relationship configuration mechanism used to characterize the equivalence between different data tables in terms of field structure, data logic, or business semantics. This allows the same structured expression to be applied across tables to data sources with similar business logic but different table or field names.
[0103] The system first analyzes the field structure of all data tables registered in the current system, extracting metadata such as the name, type, unit, frequency of occurrence, and business semantic tags of the fields in each table. It then calculates the semantic similarity between data tables based on metrics such as field semantic similarity, field naming pattern matching, and historical expression usage records. If the similarity exceeds a set threshold, the system classifies the group of data tables into the same semantic category. For example, the field "vip_fee" in table a1 and the field "premium_subscription" in table a2 may have different names, but their data types, units, and contextual business meanings all refer to the subscription fees of VIP users. The system can classify a1 and a2 as "subscription tables."
[0104] After categorization, the system binds each data table to its semantic category and records it in an equivalence relationship mapping table. This mapping table is typically implemented using a hash structure or nested dictionary structure, supporting fast queries and dynamic expansion. Each semantic category has a unique identifier and is associated with multiple data table identifiers. Based on this mapping relationship, the system can determine whether a structured expression can be migrated and reused in a new table for execution.
[0105] For example, when executing the expression "Calculate Net Profit of Subscription Fees," if the expression was originally bound to table a1 and the user entered table b1, the system will first determine whether b1 belongs to the same semantic category as a1. If a match is found, the expression will be migrated and executed, automatically completing field mapping and parameter binding. If a match fails, the system will prompt the user to select whether to assign b1 to the target category or to adapt the expression structure before executing.
[0106] By constructing an equivalence relationship mapping table, the present invention significantly enhances the versatility, compatibility, and portability of expressions, reduces the cost for users to maintain multiple similar expressions, and ensures the consistency of data and expression logic. It is particularly suitable for application scenarios where unified computing is carried out in multi-source, multi-format, and multi-business domain data environments.
[0107] S2. When the user calls the structured expression and inputs a data table that is not classified or classified into different categories, the system determines whether its category matches based on the equivalence relationship mapping table.
[0108] In this embodiment, after the system constructs the equivalence mapping table, when a user calls a saved structured expression and attempts to use a new data table as an input parameter, an equivalence check process is triggered. The core goal of this process is to determine whether the input data table belongs to the semantic category originally adapted by the structured expression. This ensures the expression's field matching, semantic logic, and data unit consistency, preventing miscalculations due to differences in table structure or business meaning.
[0109] Specifically, when a user enters a natural language statement such as "Apply table b2 to the subscription net profit calculation" or "Re-execute the VIP expression using table x1," the system first identifies the structured expression ID being called and retrieves its original binding semantic category identifier from the expression metadata. The system then searches the equivalence relation mapping table for the semantic category of the table currently entered (such as b2 or x1) and matches it with the category of the target expression.
[0110] If the currently entered data table is not registered in the equivalence relationship mapping table, or is explicitly classified as inconsistent with the expression, the system will determine it as "mismatched" and prevent the direct execution of the expression. At this time, the system will trigger an interactive feedback mechanism, prompting the user interface with a message stating that "the current table category is inconsistent with the table category required by the target expression, which may result in incompatible field structures, inconsistent field units, or business semantic deviations." The user is advised to proceed with caution.
[0111] If the system finds that a table, while not yet explicitly categorized, has a highly similar field structure, unit type, or field name to other tables in the target category (e.g., a similarity above a preset threshold), it will generate a "Suggest Category" prompt, guiding the user to temporarily categorize the table into that category before executing the expression. Users can choose between "Auto-categorize," "Manual Confirm," or "Wait for Now," making their own decisions based on the business context.
[0112] For example, if a user calls a structured expression to "Calculate Subscription Net Profit," the expression is originally targeted at table a1, which belongs to the "Subscription Fee Table" category. However, the user enters table b2. The system detects that b2 does not belong to this category, but its fields, such as "member_fee," "discount_rate," and "user_count," closely match the semantics of the fields required by the target expression. The system then prompts, "Table b2 is not categorized in the target category. Do you want to assign it to the 'Subscription Fee Table' category to continue execution?"
[0113] S3. If the categories do not match, a prompt message is generated to guide the user to choose whether to classify the data table into a category that matches the target expression before performing the calculation.
[0114] In this embodiment, when the system determines, based on the equivalence relationship mapping table, that the currently input data table does not belong to the semantic category matched by the target expression during the execution of a structured expression, it triggers an error handling and interactive prompt mechanism. The core goal of this mechanism is to provide the user with a reasonable correction path, without directly rejecting the calculation request, to help them decide whether to classify the current data table into the target semantic category and continue using the structured expression for calculations.
[0115] The system first generates a prompt containing the current classification judgment result and presents it to the user in the interactive interface using clear text and graphic symbols. The prompt typically includes: the category to which the target structured expression belongs (such as "Subscription Fee Category"), the name of the current input data table (such as "Table b2"), the inferred category or unclassified status, and the reason for the conflict (such as "Field Structure Mismatch" or "Key Field Unrecognized"). The prompt may further include a summary of the comparison results, such as the overlap between the required fields of the expression and the mappable fields of the current data table, and the matching of field units, to assist the user in making a judgment.
[0116] The system then provides action options to guide the user in making a decision, including but not limited to: "Categorize the current data table into the target category and continue executing the expression," "Do not classify for now and return to modify the field mapping," and "Abort the current operation." If the user chooses to confirm the classification, the system will temporarily bind the data table to the target semantic category and record it in the equivalence relationship mapping table; this binding can be one-time or permanent, depending on the classification strategy set by the user.
[0117] For example, if a user attempts to call the structured expression "Calculate Subscription Net Profit" using the data table "x1" and "x1" is not classified as a "Subscription Table," the system will prompt: "The current table 'x1' does not belong to the 'Subscription Fee' category. The match between this table field and the target expression field is 82%. Do you want to classify table 'x1' into this category and continue?" If the user clicks "Confirm Classification and Execute," the system will automatically update the mapping table and complete the expression field filling and calculation.
[0118] Figure 4 This is a schematic diagram of a method for checking the dimension of data associated with operator strings provided by an embodiment of the present disclosure. Figure 4 , further elaborating on the specific embodiments of the present application.
[0119] S310. The system automatically records the dimensional relationship between fields during the execution of the historical structured expression.
[0120] In this embodiment, to achieve dynamic verification of expression semantic correctness and learnable evolution of expression structure, the system automatically records the dimensional relationships between fields in each historical structured expression during each execution. This recording behavior is automatically triggered by the dimensional management module during the expression calculation phase, requiring no manual user intervention and providing a fully transparent and embedded process.
[0121] Specifically, after receiving a user's request to execute a structured expression, the system will parse each operator node in the expression and identify the fields or constants involved in the calculation on both sides. Subsequently, the system extracts the dimension identifier of the field based on the metadata of each field in the data table (such as field unit, field naming, historical semantic annotation, etc.). For example, the dimension of the field "subscription fee" can be marked as "yuan", the dimension of the "number of users" as "person", the dimension of the "working hours" field as "hours", and so on.
[0122] When the system detects that two fields, or a field and a constant, participate in operations requiring strict dimensional consistency, such as addition or subtraction, the system establishes a logical "dimensional equality" relationship between the two fields and records it in the dimensional relationship repository. This record is typically expressed as a key-value pair or tuple, for example, (field A, field B, dimensional equality), indicating that the two fields can be considered values of the same dimensional unit for practical business purposes and can participate in quantitative operations such as addition and subtraction.
[0123] This dimensional relationship is recorded not only for addition and subtraction operations but also for derived dimensions generated by multiplication and division. For example, if an expression contains the division operation "Total cost ÷ Number of users," the system will record "Total cost / Number of users = Cost per capita" and attach the derived dimension "Cost per capita" to the expression output for subsequent verification or prompting.
[0124] For two fields that are added or subtracted in historical structured expressions, the system marks them as dimensionally equal. For example, if the user enters the natural language "add each customer's subscription fee to the platform's cashback amount to obtain their total income," the system constructs the expression "total_income = subscription_fee + rebate_amount" after processing, and identifies the subscription_fee and rebate_amount fields as two operands of the addition operation. Because both represent "currency amount" type data in this context, the system creates an equivalence relationship mapping in the dimensional record module, marked as "subscription_fee ≈ rebate_amount (unit: yuan)", and stores it in the dimensional knowledge base.
[0125] S320: When generating a new structured expression, the system verifies the dimensional consistency between the fields involved in the new structured expression based on the dimensional relationship of the historical records.
[0126] In this embodiment, to improve the logical correctness and semantic integrity of newly generated structured expressions, the system incorporates a historical dimensional relationship verification mechanism during the generation process. Specifically, during expression construction, the system compares the current field combination with known dimensional relationships in historical expressions in real time to verify whether there are any physical dimensional conflicts in the operation structure.
[0127] It's important to note that when constructing expressions based on natural language, the expression and parsing of bracket structures are always the most error-prone steps. Because natural language lacks an explicit priority control mechanism, users often express the intention of nested operations in statements through sequential phrases such as "first... then..." However, this approach is difficult to accurately map to the explicit bracket operations in programming languages. For example, the statements "First add up all VIP customers' fees and then multiply by 0.9" and "Multiply all VIP customers' fees by 0.9 separately and then add them up" have similar semantics, but the calculation results are completely different. If the system misjudges the placement of the brackets, the correctness of the result will be directly affected.
[0128] Therefore, while the system generates the overall abstract expression, it also constructs the operation syntax tree and verifies the dimensional consistency of the field pairs involved in each addition and subtraction operation node. The system matches these field pairs with the "dimensional equality" set in the historical records. If the field combination has appeared as two participating fields in the addition and subtraction operation in the historical expression, the two are considered dimensionally consistent. Otherwise, it is considered a potential risk and the user is prompted to check the bracket structure and field selection for appropriateness.
[0129] For example, if the natural language input is "multiply each customer's subscription fee by their discount coefficient and add the total shipping fee", the system may construct two different abstract expressions: Expression A: r = (subscription fee × discount coefficient) + total shipping fee; Expression B: r = subscription fee × (discount coefficient + total shipping fee).
[0130] In this case, only expression A is reasonable; the addition of "coefficient + freight" in expression B violates dimensional consistency. Because brackets aren't clearly expressed in natural language, the system relies on historical dimensional data to verify the "discount coefficient + freight" combination. If there's no historical record of dimensional consistency, it automatically identifies this as a risky expression and prompts the user to correct the logic in subsequent steps.
[0131] In addition, for the first appearance of a field combination, the system will record it as a new dimension pair relationship after the expression is verified and successfully executed, expand the system's dimension knowledge base, and provide support for the verification of subsequent expressions.
[0132] Through the above mechanism, the present invention can effectively alleviate expression construction errors caused by ambiguous natural language descriptions (especially unclear expressions of brackets and nested structures), ensure the consistency of expression structure and business semantics, and at the same time improve the intelligence and usability of converting natural language to structured expressions.
[0133] Figure 5 A schematic diagram of a computing system for dynamically generating complex expressions based on natural language processing provided by an embodiment of the present disclosure. Figure 5 , further elaborating on the specific embodiments of the present application.
[0134] The operator parsing module is used to extract all operator strings in the statement to be parsed.
[0135] In this embodiment, the system first receives a natural language sentence input by the user, which is typically used to describe a certain data processing, statistical, or billing logic. The system parses the sentence based on natural language processing technology and extracts expressions with computational semantics. To achieve this goal, the system pre-builds an operator recognition model that supports the recognition and normalization of computational verbs, prepositional phrases, and domain-specific expressions in natural language. This recognition model can be built based on a rule engine, a part-of-speech tagging algorithm, and a contextual semantic analysis algorithm, and can extract language fragments with numerical computational significance from complex or nested expressions.
[0136] During the processing, the system first performs word segmentation on the sentence and identifies potential operational expressions based on the context. For example, for the sentence "Add the subscription fee to the shipping fee and subtract the management fee", the system recognizes that "plus" and "minus" correspond to addition and subtraction semantics respectively. Subsequently, the system maps the identified natural language fragments to internal standard operators for the subsequent construction of abstract expressions. This mapping process is completed based on a predefined operator mapping table, which defines the mapping relationship between natural language phrases and standard mathematical operators. For example, "plus", "total", and "addition" are mapped to "+", "minus", "reduce", and "difference from..." are mapped to "-", "multiply by", and "amplify" are mapped to "×", and "divide by" and "distribute equally" are mapped to "÷", etc.
[0137] To ensure accurate extraction, the system also determines the position of the operation phrase in the original sentence and marks its scope of action in the semantic structure. In particular, when there are multiple nested operations, the system identifies the master-slave relationship by calculating dependency paths and word distances. For example, in the sentence "All VIP users' subscription fees are multiplied by the discount and added to the subscription fees of ordinary users," the system can identify that "multiplied" applies to "VIP users' subscription fees" and "discount," and that "added" applies to the result of the entire discount and "ordinary users' subscription fees," thus establishing the correct order of precedence.
[0138] For example, suppose a user enters the following statement: "Add the subscription fees of all VIP customers in table a1, and then subtract a per capita management fee of 10 yuan per person." After word segmentation, the system identifies two keywords with operation semantics: "add" and "subtract," and maps them to "+" and "-," respectively. The system also records the relative position of each operator string in the original statement and any related data fields before and after it, laying the foundation for the subsequent construction of abstract expressions.
[0139] Ultimately, the output of this step is a sequentially ordered list of standardized operators, which is used in the next step to parse variables and construct the operation structure. This step not only makes the operation logic in natural language explicit and structured, but also provides foundational support for semantic combination, field mapping, and dimensionality verification in subsequent steps.
[0140] The expression generation module is used to parse the operation semantic relationship based on the statement to be parsed and all the operator strings, and construct an overall abstract expression, wherein the overall abstract expression includes at least one input parameter.
[0141] In this embodiment, after extracting the operator strings, the system continues to parse the semantic structure of the operations within the original natural language sentence and the extracted operator information, thereby constructing a holistic abstract expression. This holistic abstract expression describes the user's complete computational intent and serves as the core semantic unit for subsequent parameter mapping, expression validation, and computation execution.
[0142] The system first analyzes the context surrounding the operator string in the statement using a semantic analysis model to identify the operands (variables or constant values) corresponding to each operator. This process relies on the calculation rules defined in the operator mapping table. For example, "plus" requires two variables to be located before and after the keyword, while "and the difference" requires the system to identify the two variables before and after the "and." Therefore, the system calibrates the semantic template for each operator, including the number of parameters, their relative positions, and their scope.
[0143] The system then combines the results of natural language word segmentation, part-of-speech tagging, and entity recognition to locate all candidate variable phrases and match them with the various operators to restore the computational relationships. During this process, the system not only identifies the textual form of the variables but also extracts their roles within the semantic structure, such as as addend, subtrahend, factor, or denominator, thereby accurately describing their logical relationships with the operators.
[0144] To enhance expression reusability and cross-table adaptability, the system abstracts identified variables into parameter forms and constructs an overall abstract expression consisting of one or more input parameters. These input parameters can be field names, table identifiers, fixed values, or conditional expressions. The system abstracts these using a unified expression structure that aligns with natural language semantics.
[0145] For example, for the statement "Multiply the subscription fees of all VIP customers in table a1 by 0.6, add the sum to the subscription fees of regular customers, and subtract a per capita management fee of 10 yuan," the system will recognize the three operators "multiply," "add," and "subtract" in S100. In this step, it will identify the following semantic relationship: multiply the VIP customer subscription fee by 0.6; add the result to the regular customer subscription fee; and subtract 10 yuan multiplied by the total number of customers. The system ultimately constructs the overall abstract expression: r = (v1 * 0.6 + v2) - v3, where v1 is the VIP customer subscription fee, v2 is the regular customer subscription fee, and v3 is the per capita management fee multiplied by the number of customers. The system maps v1, v2, and v3 as input parameters to data table fields or constant values, respectively, and uses r as the calculation result.
[0146] The dimension checking module is used to perform dimension checking on the data associated before and after all the operator strings.
[0147] In this embodiment, after successfully constructing the overall abstract expression, the system enters the dimension checking phase. The main purpose of this step is to verify the consistency of the units of the fields or constants involved in various operations in the expression to prevent calculation logic errors caused by dimension mismatch. The so-called dimension refers to the physical properties or statistical caliber of a value, such as "amount (yuan)", "number of people (person)", "time (hours)", etc. Direct addition, subtraction, or certain multiplication and division operations cannot be performed between different dimensions.
[0148] The system first traverses each operator in the overall abstract expression and identifies the fields or constants involved in the operation before and after. Each field usually corresponds to a column in a data table. The system will further obtain the unit information or type identifier bound to the field in the original data source through the field mapping relationship. If the field itself does not explicitly mark the unit, the system can make intelligent inferences based on the usage context in the historical expression. For example, if the field name contains roots such as "amount", "cost", "quantity", "duration", etc., or semantic completion is performed through a joint relationship with other fields.
[0149] After obtaining the dimension information for the fields or constants on both sides of the operator, the system compares them using pre-set dimension rules. For example, for addition and subtraction operations, both operands must have the same dimension; otherwise, an exception is generated. However, for multiplication and division operations, different dimensions are permitted, and a new derived dimension is generated after the operation. For example, "amount ÷ number of people" can be converted into a new type called "amount per person."
[0150] For example, if the expression is "r = Total Fee - Discount Amount," the system recognizes that both "Total Fee" and "Discount Amount" come from data columns with a unit of "yuan." Therefore, the addition and subtraction operations are considered consistent in dimensionality and allowed. However, if the expression is "r = Total Fee - Number of Customers," a dimensionality inconsistency prompt will be triggered because the unit of "Number of Customers" is "person," which cannot be directly subtracted from the unit of "Total Fee" (yuan). In this case, the system will automatically mark the operation unit and prompt the user through the interactive interface in subsequent steps.
[0151] In more complex expressions, such as "r = VIP subscription fee * 0.6 + standard subscription fee - 10 * number of customers," the system will sequentially check whether each data item connected by the "*," "+," and "-" operators satisfies unit matching. In particular, in multiplication and division operations, the system also supports dimensional derivation and tracking, allowing for subsequent unit derivation and visualization of the entire expression calculation path.
[0152] The expression saving module is used to save the overall abstract expression as a structured expression if the checking result is correct.
[0153] In this embodiment, after the system completes the data dimension check for all operator-associated fields in the overall abstract expression, if all check items pass (i.e., there are no field unit conflicts, inconsistent dimensions, or expression logic errors), the system will persist the overall abstract expression as an executable expression structure, forming a structured expression. Structured expressions are the core expression unit in this invention that abstracts, standardizes, and reusably processes natural language input.
[0154] Specifically, structured expressions are based on components such as expression trees, operator sequences, field mappings, and input parameter placeholders, stored in a unified data structure within an expression knowledge base or configuration database. This structure not only preserves the expression's operator precedence, parenthesis nesting, field dependencies, and constant values, but also records the mapping logic to the input data, allowing the system to call it at any time and directly calculate the result after rebinding the data source.
[0155] When saving structured expressions, the system also supports naming them to enhance the convenience of subsequent retrieval and management. Expression names can be automatically generated by the system based on semantics, such as "Formula for calculating VIP subscription net profit," or they can be customized by the user. Furthermore, the system supports the establishment of a keyword indexing mechanism, automatically extracting the core field names, operation types, business scenario descriptions, and other information involved in the expression to form a keyword mapping table to support fuzzy search and prompt recommendation functions.
[0156] For example, suppose the user enters the following statement: "Multiply the subscription fees of all VIP customers in table a1 by 0.6, add this to the fees of regular customers, and then subtract a per capita management fee of 10 yuan per person." After steps S100 to S300, the system identifies a semantically correct and structurally sound expression relationship. The system then generates the structured expression r = (v1 * 0.6 + v2) - v3, where v1 represents the VIP fee field, v2 represents the regular fee field, and v3 represents the per capita management fee multiplied by the number of people. The system then stores this expression structure, along with the field mapping and semantic description, in the expression library.
[0157] The error reporting module is used to prompt the user in the interactive interface that there may be an error in the statement to be parsed if the check result is incorrect.
[0158] The operation structure of the structured expression is displayed graphically in a user interface; the system automatically locates the operation unit with dimensional error in the structured expression and highlights it in the user interface to guide the user to correct the expression logic.
[0159] In this embodiment, if the system detects any discrepancies with pre-set rules during the dimensional consistency check of the overall abstract expression in step S300, such as inconsistent units between the two operands of addition or subtraction operations, incompatible field types, missing variable positions, or an incomplete logical structure, the expression will be deemed invalid and will not meet the execution conditions. To prevent calculation anomalies caused by directly executing the incorrect expression, the system will activate an error prompt mechanism, providing clear feedback on the status of the current expression in the user interface.
[0160] Specifically, the system first locates the specific field or constant item with the error based on the inconsistent operator nodes. Then, based on the semantic location in the original natural language sentence, it generates prompts consistent with the user's expression habits. Prompts may include, but are not limited to, "The fields 'Total Expenses' and 'Number of Customers' cannot be directly subtracted. Please check the field meaning or units," "The units for 'Per Capita Expenses' are not clearly stated in the sentence. Please confirm if there is any ambiguity," etc., helping users quickly identify anomalies in the semantic structure.
[0161] To improve the readability and ease of use of error prompts, the system also presents error prompts graphically in the interactive interface. The system will highlight the operation units with dimensional conflicts in the expression structure tree or formula display area, or insert graphic symbols between operators and variables to indicate the conflict points, while simultaneously displaying diagnostic suggestions on the right side or bottom of the interface. For example, if the expression contains the incorrect combination "(250 yuan - 3 people)", the system will mark the subtraction node in red and pop up a prompt box stating that "yuan and people cannot be directly calculated."
[0162] In addition, the system supports prompting users to make corrections. Users can adjust the original statement, replace fields, add unit descriptions, or modify the expression's logical structure based on the system's suggestions. Each time the user modifies the input, the system automatically re-executes steps S100 to S300 and, once dimensional consistency requirements are met, enters the structured expression saving process, ensuring the expression's semantic integrity and logical consistency before execution.
[0163] According to an embodiment of the present disclosure, an electronic device is provided. The electronic device may include: a processor, a communications interface, a memory, and a communications bus. The processor, the communications interface, and the memory communicate with each other via the communications bus. The processor may invoke logic instructions in the memory to execute a configuration software-based soft authorization implementation method.
[0164] In addition, the logical instructions in the above-mentioned memory can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0165] On the other hand, the present disclosure further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the configuration software soft authorization implementation method provided by the above methods.
[0166] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0167] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
[0168] It should be understood that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present disclosure.
Claims
1. A computational method for dynamically generating complex expressions based on natural language processing, characterized in that: include: Extract all operator strings in the statement to be parsed; Based on the statement to be parsed and all the operator strings, parsing the operation semantic relationship, and constructing an overall abstract expression, wherein the overall abstract expression includes at least one input parameter; Performing dimension checking on all data associated with the operator string; If the check result is correct, the overall abstract expression is saved as a structured expression; If the check result is incorrect, the user will be prompted in the interactive interface that the statement to be parsed may be incorrect; The input parameter of the overall abstract expression includes a data table name. The system automatically extracts multiple field values in the data table that are semantically related to the overall abstract expression based on the data table name, and substitutes the multiple field values into the overall abstract expression for calculation. The method further comprises: Constructing an equivalence relationship mapping table for semantically classifying multiple data tables, wherein the semantic classification indicates that different data tables are equivalent in field structure or business meaning; When a user calls the structured expression and inputs a data table that is not classified or classified into different categories, the system determines whether its category matches based on the equivalence relationship mapping table; If the categories do not match, a prompt message is generated to guide the user to choose whether to classify the data table into a category that matches the target expression before performing the calculation.
2. The method for dynamically generating complex expressions based on natural language processing according to claim 1, characterized in that: The step of saving the overall abstract expression as a structured expression further includes: naming the structured expression; Constructing a keyword mapping table for searching the structured expression according to the keyword; The keyword mapping table at least includes a set of field names that are semantically related to the overall abstract expression.
3. The method for dynamically generating complex expressions based on natural language processing according to claim 1, characterized in that: The dimension checking of the data associated with all the operator strings may further include: The system automatically records the dimensional relationship between fields during the execution of historical structured expressions; When generating a new structured expression, the system verifies the dimensional consistency between the fields involved in the new structured expression based on the dimensional relationship of the historical records.
4. The method for dynamically generating complex expressions based on natural language processing according to claim 3, characterized in that: The system automatically records the dimensional relationship between fields during execution of the historical structured expression, and further includes: Two fields that are added or subtracted in a history structured expression are marked as dimensionally equal.
5. The method for dynamically generating complex expressions based on natural language processing according to claim 1, characterized in that: If the check result is incorrect, the user is prompted in the interactive interface that the sentence to be parsed may be incorrect, further comprising: Displaying the operation structure of the structured expression in a graphical manner in a user interface; The system automatically locates the operation unit with dimensional error in the structured expression and prompts it in the user interface in a highlighted manner to guide the user to correct the expression logic.
6. A computing system for dynamically generating complex expressions based on natural language processing, applied to the method according to any one of claims 1 to 5, characterized in that: The system comprises: Operator parsing module, used to extract all operator strings in the statement to be parsed; An expression generation module, configured to parse the semantic relationship of operations based on the statement to be parsed and all the operator strings, and construct an overall abstract expression, wherein the overall abstract expression includes at least one input parameter; A dimension checking module, used for performing dimension checking on the data associated with all the operator strings; An expression saving module, configured to save the overall abstract expression as a structured expression if the check result is correct; The error reporting module is used to prompt the user in the interactive interface that there may be an error in the statement to be parsed if the check result is incorrect.
7. An electronic device comprising: A processor and a memory communicatively connected to the processor; characterized in that: Memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to perform the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Content calculation method, device and apparatus based on machine learning
CN109992785A
Method and device for generating SQL (Structured Query Language) based on natural language, and computer equipment
CN119106043A