Dynamic context-aware text character string editing and verifying system and method
Through a dynamic context-aware text string editing and verification system, the syntax and context of text strings are checked in real time, and strict and loose verification modes are provided. This solves the problem of time-consuming and low-accuracy manual verification by users, and achieves efficient and accurate text string verification.
Patent Information
- Application Number
- CN202510762876.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-09-12
AI Technical Summary
In the prior art, the process of manually verifying text strings by users is time-consuming and has low accuracy. It is also impossible to fully check the specific context of functions and variables, resulting in low accuracy of text strings.
A dynamic context-aware text string editing and validation system is used, including a text string editing user interface component, a validation engine, a predefined function repository, and a variable context manager. It verifies text strings in real time, provides strict and loose validation modes, and checks syntax, parameter types, and the correct use of functions and variables.
Improves the efficiency and accuracy of text string verification, reduces debugging time, and ensures that formula and expression structures are standardized and unified, making them easy to understand and maintain.
Smart Images

Figure CN120631732A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of software development tools, and in particular relates to a dynamic context-aware text string editing and verification system and method. Background Art
[0002] In software development, especially in configurable systems like workflow designers, users often need to use formulas or expressions to define custom logic. These formulas and expressions can be collectively referred to as text strings. In practical applications, to ensure the accuracy of user-defined text strings, text string validation is necessary.
[0003] In the related art, the method of verifying whether a text string is correct is usually: manual verification by users, which makes the verification process time-consuming and inefficient; and users are usually only able to verify basic syntax and cannot understand the specific context of available functions and variables in the application, resulting in certain errors in the text string not being checked, which in turn leads to low accuracy of the text string. Summary of the Invention
[0004] The purpose of this invention is to enable a variable context manager to dynamically perceive context and generate variables, helping the verification engine to perform comprehensive, real-time, and accurate verification of text strings, thereby improving the accuracy of text strings. Furthermore, two flexible verification modes, strict and relaxed, are provided to accommodate the needs of different development stages.
[0005] In a first aspect, an embodiment of the present invention provides a dynamic context-aware text string editing and verification system, the system comprising: a text string editing user interface component, a verification engine, a predefined function repository, and a variable context manager, wherein the variable context manager includes predefined variables and variables dynamically generated based on application state;
[0006] The text string editing user interface component is used to receive a text string input by a user;
[0007] The verification engine is configured to perform real-time verification on the text string based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager, and if an error is found during the verification, send an error result and a modification suggestion for the error result to the text string editing user interface component;
[0008] The text string editing user interface component is further configured to receive and display the error result and modification suggestion, receive the correct text string input by the user, and trigger the verification engine to verify again;
[0009] The verification process includes checking for syntax errors, parameter type compatibility, correct use of functions and variables, and parameter compliance with predefined requirements.
[0010] The verification mode includes a strict verification mode and a loose verification mode. The strict verification mode is used to verify the entire text string, and the loose verification mode is used to verify the formula call in the text string.
[0011] Optionally, the text string editing user interface component is further used to:
[0012] In the process of receiving a text string input by a user, searching for functions and variables matching the input string in the predefined function repository and the variable context manager;
[0013] generating a suggestion list based on the searched functions and variables, and displaying the suggestion list;
[0014] A user selection instruction for a function or variable in the suggestion list is received, and the function or variable corresponding to the selection instruction is determined as a text string input by the user.
[0015] Optionally, if the verification mode is strict verification mode, the real-time verification of the text string based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager includes:
[0016] Preliminarily checking whether the text string contains pre-set common errors;
[0017] If it is determined that the text string does not have a preset common error, parsing the text string using a parser, generating an abstract syntax tree, and traversing the abstract syntax tree node by node;
[0018] For each node, calling a function and comparing the calling result with the predefined functions stored in the predefined function repository to verify the function name, the number of function parameters, and the parameter types;
[0019] For each node, verify that the variable exists in the variable context manager and that the full path of the member expression is in the variable context manager;
[0020] For each node, verify whether the literals, expressions, and nesting depth are accurate; the literals include strings, numbers, and Boolean values, and the expressions include unary expressions and update expressions.
[0021] Optionally, if the verification mode is a loose verification mode, performing real-time verification on the text string based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager includes:
[0022] Extract all formula calls that occur within the text string;
[0023] For each extracted formula call, preliminarily checking whether the formula call has a preset general error;
[0024] If it is determined that the formula call does not have a preset conventional error, the formula call is parsed by a parser to generate an abstract syntax tree, and the abstract syntax tree is traversed node by node;
[0025] For each node, calling a function and comparing the calling result with the predefined functions stored in the predefined function repository to verify the function name, the number of function parameters, and the parameter types;
[0026] For each node, verify that the variable exists in the variable context manager and that the full path of the member expression is in the variable context manager;
[0027] For each node, verify whether the literals, expressions, and nesting depth are accurate; the literals include strings, numbers, and Boolean values, and the expressions include unary expressions and update expressions.
[0028] Optionally, the variable context manager is specifically used to:
[0029] Check the current state of the host application;
[0030] Based on the current state, identifying available entities of the host application, the available entities comprising: workflow nodes, developer components, and session attributes;
[0031] For each available entity, a variable applicable to the available entity is generated.
[0032] Optionally, the text string editing user interface component is integrated with a form system, triggering the validation engine to validate the form in the form system.
[0033] Optionally, after the text string editing user interface component displays the suggestion list, the text string editing user interface component is further configured to:
[0034] Highlighting the functions and variables in the suggestion list that have a matching degree with the input string higher than a preset matching degree;
[0035] When a selection instruction for a highlighted function or variable is received from the user, the selected function or variable is inserted into a corresponding input area, and the mouse cursor is automatically moved to the input area.
[0036] In a second aspect, an embodiment of the present invention provides a dynamic context-aware text string editing and verification method, which is applied to a dynamic context-aware text string editing and verification system. The system includes: a text string editing user interface component, a verification engine, a predefined function repository, and a variable context manager. The variable context manager includes predefined variables and variables dynamically generated based on application state. The method includes:
[0037] The text string editing user interface component receives a text string input by a user;
[0038] The verification engine performs real-time verification on the text string based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager. If an error is found during the verification, the verification engine sends an error result and a modification suggestion for the error result to the text string editing user interface component.
[0039] The text string editing user interface component receives and displays the error result and modification suggestion, receives the correct text string input by the user, and triggers the verification engine to verify again;
[0040] The verification process includes checking for syntax errors, parameter type compatibility, correct use of functions and variables, and parameter compliance with predefined requirements.
[0041] The verification mode includes a strict verification mode and a loose verification mode. The strict verification mode is used to verify the entire text string, and the loose verification mode is used to verify the formula call in the text string.
[0042] In a third aspect, an embodiment of the present invention provides an electronic device, wherein the electronic device is equipped with a dynamic context-aware text string editing and verification system, including:
[0043] at least one processor;
[0044] a memory for storing the at least one processor-executable instruction;
[0045] Wherein, the at least one processor is configured to execute the instructions to run the dynamic context-aware text string editing and verification system described in the first aspect.
[0046] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to run the dynamic context-aware text string editing and verification system described in the first aspect.
[0047] According to the technical solution provided by the embodiment of the present invention, the variable context manager can dynamically perceive the context and dynamically generate variables, which helps the verification engine to comprehensively and accurately verify the text string. When the user enters or submits a formula or expression, the verification engine performs immediate and thorough verification, including checking syntax errors, parameter type compatibility, correct use of functions and variables, and compliance with parameter requirements. In addition, two flexible verification modes, strict verification mode and loose verification mode, are provided to meet the needs of different development stages. Through the technical solution provided by the embodiment of the present invention, the time required for debugging formulas or expressions is significantly reduced by capturing errors early and providing clear and actionable modification suggestions. The verification efficiency and verification accuracy of formulas and expressions can be improved. Moreover, through clear definition and verification, the standardization and uniformity of formula and expression structures are ensured, making formulas and expressions easier to understand and maintain. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A flow chart of the verification process of a dynamic context-aware text string editing and verification system provided by an embodiment of the present invention;
[0049] Figure 2 A flowchart of a specific implementation method provided by an embodiment of the present invention;
[0050] Figure 3 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The present invention will be described in detail below through examples.
[0052] In software development, especially in configurable systems like workflow designers, users often need to use formulas or expressions to define custom logic. These formulas and expressions can be collectively referred to as text strings. In practical applications, to ensure the accuracy of user-defined text strings, text string validation is necessary.
[0053] In the related art, the method of verifying whether a text string is correct is usually: manual verification by users, which makes the verification process time-consuming and inefficient; and users are usually only able to verify basic syntax and cannot understand the specific context of available functions and variables in the application, resulting in certain errors in the text string not being checked, which in turn leads to low accuracy of the text string.
[0054] The present invention aims to provide an advanced text string editing and validation system and method that overcomes the limitations of existing solutions. Embodiments of the present invention provide a user-friendly, context-aware environment, particularly suitable for dynamic applications such as workflow designers. Its core goal is to reduce user errors and improve productivity when creating and maintaining text string-based logic.
[0055] The following describes a dynamic context-aware text string editing and verification system provided by an embodiment of the present invention. The system includes: a text string editing user interface component, a verification engine, a predefined function repository, and a variable context manager. The variable context manager includes predefined variables and variables dynamically generated based on the application state.
[0056] Among them, the text string editing user interface component is a component that provides a text string input box and an integrated suggestion function, which is used to enter text strings such as formulas and expressions in the component.
[0057] The validation engine is responsible for parsing and validating text strings. In other words, the validation engine is used to validate formulas and expressions.
[0058] The predefined function library, also known as the formula definition library, is a library of predefined functions (such as FX_AND, FX_OR), which details the name, description, parameter requirements (number and type) and return type of each predefined function.
[0059] A variable context manager is used to manage available variables, including predefined constants (such as True or False) and variables dynamically generated based on the application state (such as workflow nodes and their attributes). Specifically, the variable context manager can include a variable generation module that is specifically used to: check the current state of the host application; based on the current state, identify the available entities of the host application, where available entities include workflow nodes, developer components, and session attributes; for each available entity, generate a variable applicable to the available entity, with the generated variable having a name, type, and description. These dynamically generated variables can then be provided to the validation engine and the suggestion mechanism of the text string editing user interface component.
[0060] like Figure 1 Shown is a schematic diagram of the workflow of the verification system.
[0061] S110, a text string editing user interface component is used to receive a text string input by a user.
[0062] Specifically, the text string editing user interface component includes an input area, which can be configured as a single line or multiple lines of text. The user can enter text strings such as formulas or expressions in the input area, and the text string editing user interface component receives the text strings entered by the user.
[0063] As an implementation of an embodiment of the present invention, the text string editing user interface component is further used to:
[0064] In the process of receiving the text string input by the user, the function and variable matching the input string are searched in the predefined function repository and variable context manager.
[0065] Generates a suggestion list based on the functions and variables you look up and displays the suggestion list.
[0066] A user selection instruction for a function or variable in the suggestion list is received, and the function or variable corresponding to the selection instruction is determined as a text string input by the user.
[0067] As an implementation of an embodiment of the present invention, after the text string editing user interface component displays the suggestion list, the text string editing user interface component is further configured to:
[0068] In the suggestion list, functions and variables that match the input string more closely than the preset matching degree are highlighted.
[0069] When a selection instruction for a highlighted function or variable is received from the user, the selected function or variable is inserted into the corresponding input area, and the mouse cursor is automatically moved to the input area.
[0070] Specifically, the text string editing user interface component has a mechanism for dynamic automatic suggestions based on the current context of the application. When the user enters a text string, the component recognizes the current word or prefix. It queries the predefined function repository and variable context manager for functions and variables that match the current input string, generates a suggestion list (including function and variable names, types, descriptions, etc.), displays the suggestion list, and highlights functions and variables with higher matching degrees. Users can use the keyboard arrow keys (up / down) to browse the suggestion list and use the Enter key or mouse click to select a function or variable. After selection, the selected function or variable will be inserted into the input field. For functions, brackets () are usually appended and the cursor is placed in them.
[0071] Furthermore, in actual applications, the text string editing UI component can also be integrated with the form system to trigger the validation engine to validate the form in the form system. Furthermore, a modal editor can be introduced that can call a dedicated modal dialog box (e.g., via an "FX" button) for a more focused formula editing experience.
[0072] S120, a verification engine, is used to perform real-time verification on text strings based on predefined functions stored in a predefined function repository and variables managed in a variable context manager. If errors are found during the verification, an error result and modification suggestions for the error result are sent to a text string editing user interface component.
[0073] The verification process includes checking whether there are any syntax errors, whether the parameter types meet the compatibility, whether the functions and variables are used correctly, and whether the parameters meet the predefined requirements.
[0074] Verification modes include strict verification mode and loose verification mode. Strict verification mode is used to verify the entire text string, and loose verification mode is used to verify formula calls in the text string.
[0075] The embodiments of the present invention verify formulas or expressions comprehensively and in real time. Specifically, the verification engine performs immediate and thorough verification when a user inputs or submits a formula or expression, checking for syntax errors, parameter type compatibility, correct use of functions and variables, and compliance with parameter requirements.
[0076] In addition, two flexible verification modes are provided: strict verification mode and loose verification mode. If it is strict verification mode, the entire text string will be fully parsed and verified based on the abstract syntax tree AST; if it is loose verification mode, only the recognized formula calls in the text string will be verified to meet the needs of different development stages.
[0077] During the validation process, if any validation check fails, suggestions for the error results will be generated and sent to the text string editing UI component along with modification suggestions for the error results. The modification suggestions can display descriptive, internationalized error messages to the user.
[0078] In order to make the solution description complete and clear, the verification process in the strict verification mode and the loose verification mode will be described in detail in the following embodiments.
[0079] S130, a text string editing user interface component is further used to receive and display error results and modification suggestions, receive the correct text string input by the user, and trigger the verification engine to verify again.
[0080] The text string editing user interface component displays error results and suggested corrections, allowing users to clearly identify the location of the error in the currently entered text string, the specific error, and how to correct it. This allows users to efficiently correct incorrect formulas or expressions, improving their accuracy. Furthermore, triggering the validation engine for revalidation further improves the accuracy of formulas and expressions.
[0081] According to the technical solution provided by the embodiment of the present invention, the variable context manager can dynamically perceive the context and dynamically generate variables, which helps the verification engine to comprehensively and accurately verify the text string. When the user enters or submits a formula or expression, the verification engine performs immediate and thorough verification, including checking syntax errors, parameter type compatibility, correct use of functions and variables, and compliance with parameter requirements. In addition, two flexible verification modes, strict verification mode and loose verification mode, are provided to meet the needs of different development stages. Through the technical solution provided by the embodiment of the present invention, the time required for debugging formulas or expressions is significantly reduced by capturing errors early and providing clear and actionable modification suggestions. The verification efficiency and verification accuracy of formulas and expressions can be improved. Moreover, through clear definition and verification, the standardization and uniformity of formula and expression structures are ensured, making formulas and expressions easier to understand and maintain.
[0082] In order to make the solution description complete and clear, the verification process in the strict verification mode and the loose verification mode will be described in detail in the following embodiments.
[0083] As an implementation of an embodiment of the present invention, if the verification mode is a strict verification mode, real-time verification of a text string based on predefined functions stored in a predefined function repository and variables managed in a variable context manager may include the following steps, namely, steps a1 to a5:
[0084] Step a1: Preliminary check whether the text string contains any preset common errors.
[0085] When checking, error prevention is performed first. Specifically, preset common errors may include: prohibiting in-line comments and trailing commas in formulas, ensuring the correct literal format (for example, strings use double quotes, integers have no leading zeros unless they are "0", and floating point numbers are not allowed in integer scenarios), and checking the existence and correct usage of operators and variables, thereby proactively preventing common errors. If there are preset common errors in the text string, an error report is fed back to the text string editing user interface component so that the user can modify the error.
[0086] Step a2: When it is determined that the text string does not have any preset common errors, the text string is parsed by a parser to generate an abstract syntax tree, and the abstract syntax tree is traversed node by node.
[0087] Specifically, a robust parser (such as Acorn) is used to parse the input text string to generate an abstract syntax tree (AST). This step ensures the basic grammatical correctness of the expression. If the parsing fails (for example, mismatched brackets, illegal characters, etc., which will cause parsing failure), an error report is fed back to the text string editing user interface component, so that the user can modify the error. After the verification engine receives the text string without the preset general errors, it parses the text string again through the parser to generate an abstract syntax tree, and traverses the abstract syntax tree node by node.
[0088] Step a3: For each node, call the function and compare the call result with the predefined functions stored in the predefined function repository to verify the function name, the number of function parameters, and the parameter types.
[0089] Specifically, you can verify whether the function name exists in the predefined function repository; check whether the number of provided parameters meets the minimum and maximum parameter requirements defined for the function; and recursively verify each parameter. Check whether the type of each parameter is compatible with the expected parameter type defined for the function.
[0090] Step a4: for each node, verify whether the variable exists in the variable context manager, and verify whether the full path of the member expression is in the variable context manager.
[0091] Specifically, you can verify identifiers such as variables and constants, verify whether the variable exists in the variable context manager, and verify whether the full path of the member expression exists in the variable context manager.
[0092] Step a5: For each node, verify the accuracy of the literals, expressions, and nesting depth. Literals include strings, numbers, and Boolean values, and expressions include unary expressions and update expressions.
[0093] Specifically, verify that string, number, and Boolean literals are accurate, ensuring that strings are enclosed in double quotes; prohibiting the use of floating-point numbers where integers are required; prohibiting integers with leading zeros (for example, "01") unless the number itself is "0"; prohibiting the Boolean literals true or false, and forcing the use of predefined constants True or False.
[0094] For unary expression validation, you can restrict the use of valid operators (such as '-' for numbers) and verify the operands. Other unary operators (such as +, !, and ~) are prohibited from being used directly in formula input.
[0095] For validation of update expressions, expressions like ++ or -- can be disallowed.
[0096] For nesting depth validation, you can check whether the formula exceeds a predefined maximum nesting level.
[0097] It should be explained that when the verification engine performs the above verification process, it can call the following key practical functions:
[0098] 1. Named containsComments(expression): This function intelligently detects line comments ( / / ) and block comments ( / *...* / ) in text strings, while correctly ignoring comment-like sequences in string literals (such as URLs).
[0099] 2. ContainsTrailingComma(expression): This function is used to identify whether a text string contains a trailing comma in a function argument, for example, FX_AND(True, False,). It correctly handles nested function calls and ignores commas in string literals.
[0100] extractFormulaCalls(expression) parses a text string to extract all complete formula calls, correctly handling nested brackets and multiple formulas in a string.
[0101] 4. Name is findMatchingClosingBracket(str,openBracketIndex): Given a string and the index of a left bracket, this utility finds the index of its corresponding right bracket, correctly managing nested structures.
[0102] 5. replaceFormulaCalls(expression, replacer): This function identifies all formula calls in a given text string and replaces each call with the output of the provided replacer function. This is useful, for example, when validating the non-formula portion of a mixed content string.
[0103] replaceAllSpaces(str) : A utility for replacing various whitespace characters (including non-breaking spaces) with standard spaces to ensure consistency in formula processing.
[0104] It can be seen that if the verification mode is strict verification mode, the verification engine performs immediate and thorough verification when the user enters or submits text strings such as formulas or expressions, including checking syntax errors, parameter type compatibility, correct use of functions and variables, and compliance with parameter requirements.
[0105] As another implementation of the embodiment of the present invention, if the verification mode is a relaxed verification mode, real-time verification of a text string based on predefined functions stored in a predefined function repository and variables managed in a variable context manager may include the following steps, namely steps b1 to b6:
[0106] Step b1, extract all formula calls that appear in the text string.
[0107] Step b2: For each extracted formula call, a preliminary check is performed to determine whether the formula call has any preset general errors.
[0108] Step b3: When it is determined that there is no preset general error in the formula call, the formula call is parsed by a parser, an abstract syntax tree is generated, and the abstract syntax tree is traversed node by node.
[0109] Step b4: For each node, call the function and compare the call result with the predefined functions stored in the predefined function repository to verify the function name, the number of function parameters, and the parameter types.
[0110] Step b5: for each node, verify whether the variable exists in the variable context manager, and verify whether the full path of the member expression is in the variable context manager.
[0111] Step b6: For each node, verify the accuracy of the literals, expressions, and nesting depth. Literals include strings, numbers, and Boolean values, and expressions include unary expressions and update expressions.
[0112] Specifically, in relaxed validation mode, the validation engine identifies all occurrences of formula calls within the input text string. It then validates each extracted formula call individually using the strict validation mode process described above. This allows formulas to be embedded within larger text strings.
[0113] Since the verification process in strict verification mode has been described in detail in the above embodiments, the verification process in relaxed verification mode is similar to that in strict verification mode and will not be repeated here. By providing two flexible verification modes, strict verification mode and relaxed verification mode, the requirements of different development stages can be met.
[0114] In order to describe the solution clearly, the embodiment of the present invention will be described below with reference to a specific example. Figure 2 As shown. First, the text string editing user interface component monitors input changes, that is, the user inputs a text string through the text string editing user interface component, updates the cursor position, and searches for the current input word (that is, string), searches for functions or variables that match the current input string, and generates a list. Next, it can determine whether to display the suggestion list. If so, it processes keyboard events, that is, the user can scroll up and down the suggestion list through the keyboard, and can also select a suggestion item in the suggestion list (that is, the user clicks on a variable or function), and can also hide the suggestion list. If a suggestion item is selected, then check the type of the selected suggestion item. If it is a variable, then add var; if it is a function, then add brackets. The text string editing user interface component can update the input value, that is, add the suggestion item selected by the user to the input box, and update the cursor position, waiting for the user to continue input. It should be noted that, Figure 2 The verification process is not shown. For details, see Figure 1 Example.
[0115] In addition to the contents described in the above embodiments, the embodiments of the present invention can also expand the system through a pluggable architecture to support user-defined functions or user-defined variables / data sources.
[0116] The validation engine can be exposed as a standalone API or library for batch validation of formulas, or integrated into other developer tools, linters, or CI / CD processes.
[0117] Embodiments of the present invention may also add support for other formula grammars or expression languages beyond the current "FX_" prefix and related grammars.
[0118] Embodiments of the present invention may also provide a visual formula builder interface (e.g., drag-and-drop blocks) as an alternative or supplement to a text-based editor. More advanced static analysis capabilities may also be integrated, such as detecting potential runtime errors or performance issues in complex formulas. It may also integrate with version control systems to track changes to formula definitions and usage. Furthermore, internationalization support for formula names, descriptions, and error messages may be enhanced based on user locale settings.
[0119] In a second aspect, an embodiment of the present invention provides a dynamic context-aware text string editing and verification method, which is applied to a dynamic context-aware text string editing and verification system. The system includes: a text string editing user interface component, a verification engine, a predefined function repository, and a variable context manager. The variable context manager includes predefined variables and variables dynamically generated based on application state. The method includes:
[0120] The text string editing user interface component is used to receive a text string input by a user;
[0121] The verification engine is configured to perform real-time verification on the text string based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager, and if an error is found during the verification, send an error result and a modification suggestion for the error result to the text string editing user interface component;
[0122] The text string editing user interface component is further configured to receive and display the error result and modification suggestion, receive the correct text string input by the user, and trigger the verification engine to verify again;
[0123] The verification process includes checking for syntax errors, parameter type compatibility, correct use of functions and variables, and parameter compliance with predefined requirements.
[0124] The verification mode includes a strict verification mode and a loose verification mode. The strict verification mode is used to verify the entire text string, and the loose verification mode is used to verify the formula call in the text string.
[0125] In a third aspect, an embodiment of the present invention provides an electronic device, such as Figure 3 As shown, the electronic device is equipped with a dynamic context-aware text string editing and verification system, including:
[0126] at least one processor 301;
[0127] a memory 302 for storing the at least one processor-executable instruction;
[0128] Wherein, the at least one processor is configured to execute the instructions to run the dynamic context-aware text string editing and verification system described in the first aspect.
[0129] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to run the dynamic context-aware text string editing and verification system described in the first aspect.
[0130] Although the embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and are not to be construed as limitations on the present invention. A person skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention without departing from the principles and purpose of the present invention.
Claims
1. A dynamic context-aware text string editing and verification system, characterized in that: The system includes: a text string editing user interface component, a validation engine, a predefined function repository, and a variable context manager, wherein the variable context manager includes predefined variables and variables dynamically generated based on application status; The text string editing user interface component is used to receive a text string input by a user; The verification engine is configured to perform real-time verification on the text string based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager, and if an error is found during the verification, send an error result and a modification suggestion for the error result to the text string editing user interface component; The text string editing user interface component is further configured to receive and display the error result and modification suggestion, receive the correct text string input by the user, and trigger the verification engine to verify again; The verification process includes checking for syntax errors, parameter type compatibility, correct use of functions and variables, and parameter compliance with predefined requirements. The verification mode includes a strict verification mode and a loose verification mode. The strict verification mode is used to verify the entire text string, and the loose verification mode is used to verify the formula call in the text string.
2. The system according to claim 1, wherein: The text string editing user interface component is further used to: In the process of receiving a text string input by a user, searching for functions and variables matching the input string in the predefined function repository and the variable context manager; generating a suggestion list based on the searched functions and variables, and displaying the suggestion list; A user selection instruction for a function or variable in the suggestion list is received, and the function or variable corresponding to the selection instruction is determined as a text string input by the user.
3. The system according to claim 1, wherein: If the verification mode is the strict verification mode, the text string is verified in real time based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager, including: Preliminarily checking whether the text string contains pre-set common errors; If it is determined that the text string does not have a preset common error, parsing the text string using a parser, generating an abstract syntax tree, and traversing the abstract syntax tree node by node; For each node, calling a function and comparing the calling result with the predefined functions stored in the predefined function repository to verify the function name, the number of function parameters, and the parameter types; For each node, verify that the variable exists in the variable context manager and that the full path of the member expression is in the variable context manager; For each node, verify whether the literals, expressions, and nesting depth are accurate; the literals include strings, numbers, and Boolean values, and the expressions include unary expressions and update expressions.
4. The system according to claim 1, wherein: If the verification mode is the loose verification mode, the text string is verified in real time based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager, including: Extract all formula calls that occur within the text string; For each extracted formula call, preliminarily checking whether the formula call has a preset general error; If it is determined that the formula call does not have a preset conventional error, the formula call is parsed by a parser to generate an abstract syntax tree, and the abstract syntax tree is traversed node by node; For each node, calling a function and comparing the calling result with the predefined functions stored in the predefined function repository to verify the function name, the number of function parameters, and the parameter types; For each node, verify that the variable exists in the variable context manager and that the full path of the member expression is in the variable context manager; For each node, verify whether the literals, expressions, and nesting depth are accurate; the literals include strings, numbers, and Boolean values, and the expressions include unary expressions and update expressions.
5. The system according to any one of claims 1 to 4, characterized in that The variable context manager is specifically used to: Check the current state of the host application; Based on the current state, identifying available entities of the host application, the available entities comprising: workflow nodes, developer components, and session attributes; For each available entity, a variable applicable to the available entity is generated.
6. The system according to any one of claims 1 to 4, characterized in that The text string editing user interface component is integrated with the form system, triggering the verification engine to verify the form in the form system.
7. The system according to claim 2, wherein: After the text string editing user interface component displays the suggestion list, the text string editing user interface component is further configured to: Highlighting the functions and variables in the suggestion list that have a matching degree with the input string higher than a preset matching degree; When a selection instruction for a highlighted function or variable is received from the user, the selected function or variable is inserted into a corresponding input area, and the mouse cursor is automatically moved to the input area.
8. A dynamic context-aware text string editing and verification method, characterized in that: The method is applied to a dynamic context-aware text string editing and verification system, the system comprising: a text string editing user interface component, a verification engine, a predefined function repository, and a variable context manager, wherein the variable context manager comprises predefined variables and variables dynamically generated based on application state; the method comprises: The text string editing user interface component receives a text string input by a user; The verification engine performs real-time verification on the text string based on the predefined functions stored in the predefined function repository and the variables managed in the variable context manager. If an error is found during the verification, the verification engine sends an error result and a modification suggestion for the error result to the text string editing user interface component. The text string editing user interface component receives and displays the error result and modification suggestion, receives the correct text string input by the user, and triggers the verification engine to verify again; The verification process includes checking for syntax errors, parameter type compatibility, correct use of functions and variables, and parameter compliance with predefined requirements. The verification mode includes a strict verification mode and a loose verification mode. The strict verification mode is used to verify the entire text string, and the loose verification mode is used to verify the formula call in the text string.
9. An electronic device, characterized in that: The electronic device is equipped with a dynamic context-aware text string editing and verification system, comprising: at least one processor; a memory for storing the at least one processor-executable instruction; The at least one processor is configured to execute the instructions to run the dynamic context-aware text string editing and verification system according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to run the dynamic context-aware text string editing and verification system according to any one of claims 1 to 7.
Citation Information
Cited By
Dynamic line number and multi-rule real-time verification text editing method and system
CN121960407A
A text editing method and system with dynamic line numbers and real-time multi-rule validation
CN121960407B
