Realization method for inputting real-time association at terminal based on Trie tree

By using Trie tree indexing to generate candidate commands and parameter suggestion lists in real time during terminal input, the problems of insufficient real-time performance and weak parameter suggestion capability of existing terminal input completion mechanisms are solved, achieving an efficient and intelligent terminal interaction experience.

CN121786232APending Publication Date: 2026-04-03ANHUI XIKE SECURITY TECHNOLOGY SERVICES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-30
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

The existing terminal input completion mechanism lacks real-time performance, cannot synchronously display candidate commands as the user inputs character by character, and lacks auxiliary information on command interpretation and parameter meaning, resulting in insufficient parameter association ability. The overall terminal input efficiency and interactive experience need to be improved.

Method used

By employing the Trie tree prefix matching method, a command resource library is constructed and a Trie tree index is built in memory. User input is captured in real time, a candidate command and parameter association list is generated, and the list is displayed near the input cursor position in the terminal, realizing real-time association of commands and parameters.

Benefits of technology

It improves the fluency and efficiency of terminal input, reduces the number of keystrokes and input interruptions, lowers the risk of misoperation, and enhances user experience and learning efficiency, especially significantly improving the fluency of operation when inputting complex commands and parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121786232A_ABST
    Figure CN121786232A_ABST
Patent Text Reader

Abstract

The invention discloses an implementation method for inputting real-time association at a terminal based on a Trie tree, and the method comprises the following steps: constructing a command resource library, and carrying out the structural arrangement to generate a command resource file; performing deserialization processing and constructing a Trie tree index; capturing user input characters in real time and generating a current input prefix string; executing prefix matching retrieval to generate a candidate command set when the space character is not detected; associating the candidate command set with command paraphrases, generating a command association list, and displaying the command association list in real time; when a space character is detected, analyzing the space character into a confirmed command string, and generating a parameter context set; continuously receiving and generating a parameter input prefix string, and generating a matching parameter set and a parameter association list; and displaying the parameter association list at a position adjacent to an input cursor of the terminal in real time, and updating the parameter association list when the user changes. According to the method, a Trie tree prefix matching method is adopted, real-time association of terminal commands and parameters is achieved, and the method has the advantages of being fast in response, high in efficiency and convenient to use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer terminal technology, and in particular to a method for implementing real-time input association on a terminal based on a Trie tree. Background Technology

[0002] In existing operation and maintenance and development scenarios, users typically connect to remote servers via SSH clients and perform system management, deployment configuration, and program debugging operations through command lines in the terminal interface. Existing terminal environments generally provide command completion mechanisms triggered by the Tab key. This mechanism mainly relies on predefined rules or simple matching logic, and only returns candidate commands after the user explicitly triggers the completion command. The overall interaction method is mainly passively triggered, which is difficult to integrate naturally with the continuous input process.

[0003] However, the aforementioned existing technologies still have significant shortcomings in practical use: on the one hand, the completion function lacks real-time performance and cannot synchronously display candidate commands as the user inputs character by character; on the other hand, the completion results usually only contain the command itself, lacking auxiliary information on command interpretation and parameter meaning, increasing the user's learning and memory costs. Furthermore, traditional completion mechanisms have limited support for the contextual association between commands and parameters, making it difficult to accurately define the range of available parameters based on the entered command, resulting in insufficient parameter association capabilities. Overall, terminal input efficiency and interactive experience still need improvement.

[0004] Therefore, how to provide a method for real-time terminal input association based on Trie trees is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] One objective of this invention is to propose a method for real-time association of terminal input based on Trie trees. This invention uses the Trie tree prefix matching method to realize real-time association of terminal commands and parameters, which has the advantages of fast response, high efficiency and ease of use.

[0006] According to an embodiment of the present invention, a method for real-time input association based on a Trie tree in a terminal includes the following steps: Build a command resource library and organize it into a structured format to generate command resource files; Read the command resource file and perform deserialization to obtain a set of command records, and build a Trie tree index residing in memory; Listen for user keyboard input events, capture user input characters in real time and maintain the character buffer of the current input line, and generate the current input prefix string based on the character buffer; When no space character is detected in the character buffer, prefix matching search is performed, matching nodes are located along the character path and traversal operations are performed to generate a set of candidate commands. The candidate command set is associated with the corresponding command definitions in the command resource file to generate a command suggestion list, which is displayed in real time near the input cursor on the terminal. When a space character is detected in the character buffer, the character sequence before the space character is parsed into a confirmed command string, and the corresponding parameter set field is located in the Trie tree index to generate a parameter context set. Continue to receive user input and generate parameter input prefix strings, perform prefix matching in the parameter context set to generate a matching parameter set, and associate it with the corresponding parameter interpretation to generate a parameter association list; The parameter suggestion list is displayed in real time near the input cursor on the terminal, and is updated as the user's input changes.

[0007] Optionally, the generation of the command resource file includes: Collect Linux / Unix commands, standardize and deduplicate command names to form a set of command entries; For each command entry in the command entry set, extract the corresponding command string and write the command string into the command string field; For each command entry in the command entry set, extract the command definition that corresponds one-to-one with the command string, and write the command definition into the command definition field; For each command entry in the command entry set, collect the names of the subcommands that are allowed to be directly followed by the command in the terminal input, arrange them in a fixed order to generate a subcommand set, and write the subcommand set into the subcommand set field; For each command entry in the command entry set, collect the parameters that the command is allowed to use in terminal input, arrange them in a fixed order to generate a parameter set, and write the parameter set into the parameter set field; For each parameter item in the parameter set, configure the corresponding parameter constraint field, and associate and store the parameter constraint field with the parameter set field; The command string field, command definition field, subcommand set field, parameter set field, and parameter constraint field are encapsulated in a structured manner to generate a command resource file, which is then stored in the command resource library.

[0008] Optionally, the generation of the Trie tree index residing in memory includes: During the startup or initialization phase of the terminal interactive program, the command resource file is read, deserialization processing is performed on the command resource file, and the command string field, command interpretation field, subcommand set field, parameter set field and parameter constraint field contained in the command resource file are parsed into a command record set; Read the command string fields sequentially from the command record set, and generate a character sequence according to the order of the characters in the command string fields; Starting from the root node of the Trie tree, the node positioning operation is performed character by character in the order of the character sequence. When the current character in the character sequence does not have a corresponding character identifier in the child node reference of the current node, a new node is created and the character identifier of the corresponding character is stored in the node. At the same time, the child node reference relationship between the new node and its parent node is established. After locating or creating nodes corresponding to all characters in the character sequence, at the end node corresponding to the character sequence, the parameter set field in the command record is bound to the end node to generate a parameter index pointer, and the parameter index pointer is stored in the end node. After completing the insertion operation of all command string fields in the command record set, a Trie tree index residing in memory is obtained.

[0009] Optionally, the generation of the current input prefix string includes: Listen for user keyboard input events on the terminal interface, and parse the corresponding user input character and the operation type corresponding to the user input character for each keyboard input event; Maintain a character buffer for the current input line. When the operation type corresponding to the parsed user input character is a character input operation, write the user input character into the character buffer at the logical insertion position indicated by the cursor position index, and increment and update the cursor position index after writing is completed. When the operation type corresponding to the parsed user input character is a deletion operation, the position of the character to be deleted in the character buffer is determined according to the cursor position index, the corresponding user input character is deleted from the character buffer, and the cursor position index is decremented after the deletion is completed. When the operation type corresponding to the parsed user input character is a cursor movement operation, the cursor position index is adjusted according to the cursor movement direction, and the order of the user input characters stored in the character buffer is kept unchanged. When the character buffer or cursor position index changes, the current input prefix string is generated based on the user input character sequence from the start position to the corresponding position of the cursor position index in the character buffer.

[0010] Optionally, the generation of the candidate command set includes: The character content in the character buffer is checked to confirm that there are no space characters in the character buffer, and the corresponding current input prefix string in the character buffer is read and used as the search prefix; In a Trie tree index, the root node is used as the starting node. The node location operation is performed based on the child node references between nodes according to the order of characters in the search prefix. After the node location of all characters in the search prefix is ​​completed, the matching node is obtained. When a character cannot be found in the child node references of the current node during the node positioning operation, an empty set of candidate commands is generated. When a matching node is obtained, the matching node is used as the starting node for traversal, and the traversal operation is performed on the subtree corresponding to the matching node. When a node that no longer has child node references is reached during the traversal, the character path is concatenated with the search prefix to generate a command string. The command strings obtained from the traversal are then summarized and deduplicated to generate a candidate command set.

[0011] Optionally, displaying the command suggestion list in real time near the input cursor on the terminal includes: Read the candidate command set, and extract the command string corresponding to each candidate command in the order of the command strings in the candidate command set; Using the command string as the search criteria, perform a matching and location operation in the command resource file to obtain the command records that correspond one-to-one with the command string; Read the command definition field corresponding to the command string from the command record, and establish an association between the command definition field and the corresponding command string; Based on the order of the command strings in the candidate command set, the command strings are combined with their corresponding command definition fields in sequence to generate a command suggestion list; The command association list is output to the position near the input cursor in the terminal in the order it was generated.

[0012] Optionally, the generation of the parameter context set includes: The input characters are detected in the character buffer. When a space character is detected, the character sequence before the space character is determined as the confirmed command string and the confirmed command string is used as the command confirmation identifier. In the Trie tree index, the root node is used as the starting node. The node positioning operation is performed along the character path according to the order of the characters in the confirmed command string. After the positioning of the nodes corresponding to all characters in the confirmed command string is completed, the positioned node is determined as the command confirmation node corresponding to the confirmed command string. Read the stored parameter index pointer from the command confirmation node; The corresponding parameter set field is obtained based on the parameter index pointer, and during the parameter input process after the space character is detected, the parameter set field is determined as the unique and valid parameter context set.

[0013] Optionally, the generation of the parameter association list includes: After the space character is detected, continue to receive user input characters and write the user input characters received after the space character into the character buffer; Read the character sequence following the space character from the character buffer and use this character sequence as the parameter input prefix string; Using the parameter context set as the only valid matching range, read the parameter set fields contained in the parameter context set; Read each parameter item sequentially from the parameter set field and extract the parameter name corresponding to each parameter item; The parameter name of each parameter item is compared with the parameter input prefix string by character prefix, and the parameter items that match the parameter input prefix string are filtered out to generate a set of matching parameters; Read the parameter definition corresponding to each parameter item in the matching parameter set, and associate the parameter definition with the corresponding parameter item; Based on the order of the parameter items in the matching parameter set, the parameter items and their corresponding parameter definitions are combined to generate a parameter association list.

[0014] Optionally, displaying the parameter suggestion list in real time near the terminal input cursor and updating the parameter suggestion list when the user's input characters change includes: Get the current position of the terminal input cursor in the terminal interface, and determine the current position of the terminal input cursor as the display reference position of the parameter suggestion list; Convert the parameter suggestion list into displayable text and display the parameter suggestion list near the terminal input cursor based on the display reference position; The terminal interface continuously receives user input characters and detects whether the user input characters change. When a change in user input characters is detected, an update operation is performed based on the current parameter suggestion list to obtain an updated parameter suggestion list, and the updated parameter suggestion list is displayed near the terminal input cursor based on the display reference position.

[0015] The beneficial effects of this invention are: Addressing the issues of insufficient real-time input, missing definitions, and weak parameter association capabilities in the aforementioned technologies, this invention constructs a command resource library and establishes a Trie tree-based data index structure in memory. This transforms the terminal input process from traditional passive trigger-based completion to an active, continuous, real-time association process. When a user inputs a command character by character, the system can instantly match and retrieve the input prefix and dynamically generate a candidate command list without requiring additional keystrokes. This significantly reduces the number of keystrokes and input interruptions, improving the overall smoothness and efficiency of terminal operation.

[0016] Furthermore, this invention synchronously associates and displays the command string with its corresponding command definition during the command association process. This ensures that the candidate results not only include the executable command name but also its functional meaning and usage instructions. This approach effectively reduces users' reliance on command memorization and external document lookups. Especially for beginners or users in cross-environment operation and maintenance scenarios, it enables them to understand the command semantics instantly during input, thereby reducing the risk of misoperation and improving learning efficiency.

[0017] Furthermore, this invention introduces parameter index pointers into Trie tree nodes and combines this with a command confirmation mechanism triggered by a space character, achieving automatic differentiation and context locking between the command input stage and the parameter input stage. Once a command is confirmed, the system only performs parameter prefix matching within the parameter context set corresponding to that command, thus avoiding cross-command parameter confusion and achieving a continuous and natural "command + parameter" input flow. Based on this, the efficient prefix retrieval characteristics of the Trie tree structure ensure stable, low-latency query responses even with large command and parameter sizes, comprehensively meeting the real-time and performance requirements of terminal interaction scenarios and significantly improving the intelligence level of terminal input and user experience. Attached Figure Description

[0018] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a schematic diagram of the overall process of a method for real-time input association on a terminal based on a Trie tree proposed in this invention. Figure 2 This is a schematic diagram of the Trie tree index structure in the implementation method of real-time input association based on Trie tree proposed in this invention; Figure 3 This is a schematic diagram illustrating the real-time input association interaction in a method for implementing real-time input association based on a Trie tree proposed in this invention. Detailed Implementation

[0019] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0020] refer to Figures 1-3 A method for real-time input association on a terminal based on a Trie tree includes the following steps: Build a command resource library, organize Linux / Unix commands with their corresponding command definitions, subcommand information and parameter information in a structured manner, generate command resource files, and configure command string fields, command definition fields, subcommand set fields, parameter set fields and parameter constraint fields for each command; During the startup or initialization phase of the terminal interactive program, the command resource file is read, the command resource file is deserialized to obtain a set of command records, and the command record set is inserted into the Trie tree one by one according to the character order of the command string to build a Trie tree index residing in memory. The nodes of the Trie tree are used to store character identifiers, child node references and parameter index pointers. The parameter index pointers are used to associate the parameter set field of the corresponding command in the command record set, so that the character path from the root node to any node corresponds to the command prefix or the complete command. Listen for user keyboard input events on the terminal interface, capture user input characters in real time and maintain the character buffer of the current input line, and generate the current input prefix string based on the character buffer; When no space character is detected in the character buffer, the current input prefix string is used as the search prefix to perform prefix matching search in the Trie tree index, the matching node is located along the character path, and the traversal operation is performed based on the subtree corresponding to the matching node to generate a set of candidate commands; The candidate command set is associated with the corresponding command definitions in the command resource file to generate a command suggestion list, which is then displayed in real time near the input cursor on the terminal. When a space character is detected in the character buffer, the character sequence before the space character is parsed into a confirmed command string, and the node corresponding to the confirmed command string is located in the Trie tree index. The corresponding parameter set field is obtained through the parameter index pointer stored in the node, and a parameter context set is generated. After the space character, continue to receive user input and generate a parameter input prefix string. Perform prefix matching on the parameter input prefix string in the parameter context set to generate a matching parameter set. Then associate the matching parameter set with the corresponding parameter definition to generate a parameter association list. The parameter suggestion list is displayed in real time near the input cursor on the terminal, and is updated as the user's input changes.

[0021] In this embodiment, the generation of the command resource file includes: Collect Linux / Unix commands, standardize and deduplicate command names, use the command string field as a unique identifier, standardize the format of command names and merge duplicates, so that each command corresponds to only one command entry in the command entry set, thereby ensuring consistency and determinism in the process of Trie tree path construction, command confirmation node location and parameter context set generation, forming a command entry set; For each command entry in the command entry set, extract the corresponding command string, read the command name information used to represent the command body from each command entry, and determine the command name as the command string field while keeping the character content and order unchanged, so as to serve as the unique string for Trie tree path construction, command confirmation node location and parameter index pointer binding, and write the command string into the command string field. For each command entry in the command entry set, extract the command definition that corresponds one-to-one with the command string, and write the command definition into the command definition field; For each command entry in the command entry set, collect the names of the subcommands that can be directly followed by the command in the terminal input. The collection of the names of the subcommands that can be directly followed by the command in the terminal input syntax is to extract the fixed keyword strings that can be directly entered after the command in the terminal input syntax by separating them with spaces for each command string field, form a subcommand set field by forming the keyword strings that meet the conditions in a fixed order, generate a subcommand set by arranging them in a fixed order, and write the subcommand set into the subcommand set field. For each command entry in the command entry set, collect the parameters that the command is allowed to use in terminal input, arrange them in a fixed order to generate a parameter set, and write the parameter set into the parameter set field; For each parameter item in the parameter set, a corresponding parameter constraint field is configured, and the parameter constraint field is associated with the parameter set field for storage. The association between the parameter constraint field and the parameter set field is to establish a one-to-one correspondence between each parameter item in the parameter set field and the corresponding parameter constraint field, and to encapsulate the correspondence in a structured manner in the command resource file so that the parameter constraint information can be uniformly indexed and read along with the parameter set field. The command string field, command definition field, subcommand set field, parameter set field, and parameter constraint field are structurally encapsulated. The structural encapsulation is to encapsulate the command string field, command definition field, subcommand set field, parameter set field, and parameter constraint field into a data structure of a single command entry according to a fixed hierarchical relationship, so that it can be stored, deserialized, and indexed as a complete data unit, generating a command resource file, and storing the command resource file in the command resource library.

[0022] In this embodiment, the generation of the Trie tree index residing in memory includes: During the startup or initialization phase of the terminal interactive program, the command resource file is read, and deserialization processing is performed on the command resource file. The command string field, command definition field, subcommand set field, parameter set field and parameter constraint field contained in the command resource file are parsed into a command record set, so that the hierarchical relationship and association relationship between the fields are kept consistent in memory. The command string fields are read sequentially from the command record set, and a character sequence is generated according to the order of the characters in the command string fields. The character sequence is used to uniquely represent the insertion path of the corresponding command in the Trie tree index. Starting from the root node of the Trie tree, node positioning operations are performed character by character in the order of the character sequence. When the current character in the character sequence does not have a corresponding character identifier in the child node reference of the current node, a new node is created and the character identifier of the corresponding character is stored in the node. At the same time, a child node reference relationship is established between the new node and its parent node. The establishment of a child node reference relationship between the new node and its parent node means that after creating a new node, the new node is registered as one of the child nodes of its parent node, and a reference pointing to the new node is recorded in the parent node, so that the two form a parent-child connection relationship in the Trie tree structure that can be accessed by the character positioning operation. After locating or creating nodes corresponding to all characters in the character sequence, at the end node corresponding to the character sequence, the parameter set field in the command record is bound to the end node, a parameter index pointer is generated to point to the parameter set field, and the parameter index pointer is stored in the end node. After completing the insertion operation of all command string fields in the command record set, a Trie tree index residing in memory is obtained, so that the character path from the root node to any node not only corresponds to the command prefix or the complete command, but also allows direct location of the parameter set field corresponding to the command through the parameter index pointer stored in the end node.

[0023] In this embodiment, the generation of the current input prefix string includes: Listen for user keyboard input events on the terminal interface, and parse the corresponding user input character and the operation type corresponding to the user input character for each keyboard input event; Maintain a character buffer for the current input line, the character buffer is used to store user input characters in the input order, and synchronously maintain a cursor position index, the cursor position index is used to indicate the logical insertion position of the user input character in the character buffer; When the operation type corresponding to the parsed user input character is a character input operation, the user input character is written into the character buffer at the logical insertion position indicated by the cursor position index, and the cursor position index is incremented after the writing is completed; When the operation type corresponding to the parsed user input character is a deletion operation, the position of the character to be deleted in the character buffer is determined according to the cursor position index, the corresponding user input character is deleted from the character buffer, and the cursor position index is decremented after the deletion is completed. When the operation type corresponding to the parsed user input character is a cursor movement operation, the cursor position index is adjusted according to the cursor movement direction, and the order of the user input characters stored in the character buffer is kept unchanged. When the character buffer or cursor position index changes, the current input prefix string is generated based on the user input character sequence from the start position to the corresponding position of the cursor position index in the character buffer.

[0024] In this embodiment, the generation of the candidate command set includes: The character content in the character buffer is checked to confirm that there are no space characters in the character buffer, and the corresponding current input prefix string in the character buffer is read and used as the search prefix; In a Trie tree index, the root node is used as the starting node. The node location operation is performed based on the child node references between nodes according to the order of characters in the search prefix. After the node location of all characters in the search prefix is ​​completed, the matching node is obtained. When any character cannot be found in the child node reference of the current node during the node positioning operation, an empty candidate command set is generated. The empty candidate command set means that when the current input prefix string cannot complete the character path matching in the Trie tree index, the candidate command set is determined to be an empty set that does not contain any command string, so as to indicate that there is no associative command corresponding to the input prefix string. When a matching node is obtained, the matching node is used as the starting node for traversal. The traversal operation is performed on the subtree corresponding to the matching node. The traversal operation visits the child nodes in the fixed order of the child node references, and records the character path from the matching node to the visited node during the traversal process. When a node that no longer has child node references is reached during the traversal, the character path is concatenated with the search prefix to generate a command string. The generation of the command string includes connecting the character path corresponding to the matching node to the currently visited node with the search prefix that serves as the starting point of the search in character order during the traversal of the Trie tree, thereby forming a complete command string. The command strings obtained from the traversal are then summarized and deduplicated to generate a candidate command set.

[0025] In this embodiment, displaying the command suggestion list in real time near the input cursor on the terminal includes: Read the candidate command set, and extract the command string corresponding to each candidate command in the order of the command strings in the candidate command set; Using the command string as the search condition, a matching and locating operation is performed in the command resource file. The matching and locating operation includes comparing and searching item by item in the target data set based on the given search condition, thereby determining the position or index of the data item corresponding to the search condition in the data set, and obtaining the command record corresponding to the command string. Read the command definition field corresponding to the command string from the command record, and establish an association between the command definition field and the corresponding command string. The establishment of the association between the command definition field and the corresponding command string includes binding the command definition field used to describe the meaning of the command to its corresponding command string field in the command resource file or command record set, so that any command string can synchronously obtain its corresponding command definition information when it is located or referenced. According to the order of the command strings in the candidate command set, the command strings are combined with their corresponding command interpretation fields in sequence. The combination of the command strings with their corresponding command interpretation fields in sequence includes pairing each command string with its one-to-one corresponding command interpretation field to form a combination item, which is used to form the basic display unit of the command association list and generate the command association list. The command association list is output to the position near the input cursor in the terminal in the order it was generated.

[0026] In this embodiment, the generation of the parameter context set includes: The input characters are detected in the character buffer. When a space character is detected, the character sequence before the space character is determined as the confirmed command string and the confirmed command string is used as the command confirmation identifier. In the Trie tree index, starting from the root node, the node location operation is performed along the character path according to the order of characters in the confirmed command string. The node location operation means that, starting from the root node in the Trie tree, each character is matched and searched in the child node reference of the current node according to the order of characters in the input character sequence, so as to determine the node position corresponding to the character sequence. After the location of the node corresponding to all characters in the confirmed command string is completed, the located node is determined as the command confirmation node corresponding to the confirmed command string. The stored parameter index pointer is read from the command confirmation node. The parameter index pointer is used to point to the parameter set field that corresponds one-to-one with the confirmed command string. The corresponding parameter set field is obtained based on the parameter index pointer, and during the parameter input process after the space character is detected, the parameter set field is determined as the unique and valid parameter context set.

[0027] In this embodiment, the generation of the parameter association list includes: After the space character is detected, continue to receive user input characters and write the user input characters received after the space character into the character buffer; Read the character sequence following the space character from the character buffer and use this character sequence as the parameter input prefix string; Using the parameter context set as the only valid matching range, read the parameter set fields contained in the parameter context set; Read each parameter item sequentially from the parameter set field and extract the parameter name corresponding to each parameter item; The parameter name of each parameter item is compared with the parameter input prefix string by character prefix comparison. The character prefix comparison includes comparing the parameter input prefix string with the parameter name of the parameter item one by one in character order, and determining whether the starting character sequence of the parameter name is completely consistent with the parameter input prefix string, so as to determine whether the parameter item meets the prefix matching condition, filter out the parameter items that match the parameter input prefix string, and generate a matching parameter set. Read the parameter definition corresponding to each parameter item in the matching parameter set, and associate the parameter definition with the corresponding parameter item; Based on the order of the parameter items in the matching parameter set, the parameter items and their corresponding parameter definitions are combined to generate a parameter association list.

[0028] In this embodiment, displaying the parameter suggestion list in real time near the terminal input cursor and updating the parameter suggestion list when the user's input characters change includes: Get the current position of the terminal input cursor in the terminal interface, and determine the current position of the terminal input cursor as the display reference position of the parameter suggestion list; Convert the parameter suggestion list into displayable text and display the parameter suggestion list near the terminal input cursor based on the display reference position; The terminal interface continuously receives user input characters and detects whether the user input characters change. When a change in user input characters is detected, an update operation is performed based on the current parameter suggestion list to obtain an updated parameter suggestion list, and the updated parameter suggestion list is displayed near the terminal input cursor based on the display reference position.

[0029] Example 1: To verify the feasibility of this invention in practice, it was applied to a remote operation and maintenance (O&M) and development scenario of a large internet company. In this scenario, O&M personnel and developers routinely connect to data center servers distributed across different regions via SSH clients to perform system configuration, service deployment, log analysis, and code building operations in a Linux terminal environment. Due to the large number of servers, the complexity of commands, and the involvement of numerous command combinations with complex parameters, users frequently face problems such as heavy command memorization burdens, easy parameter errors, and interruptions to the operation process when consulting documentation during terminal input. Traditional Tab key-triggered auto-completion methods are insufficient to meet the actual needs of high-frequency, continuous input.

[0030] In this scenario, the invention is integrated into the terminal interaction program used daily by operations and maintenance personnel. During the terminal startup phase, a pre-built command resource file is loaded, and a corresponding Trie tree index structure is generated in memory. The command resource file contains commonly used system commands, operations and maintenance tool commands, and their corresponding command definitions, sub-command information, and parameter information. Each field is structured and encapsulated according to a fixed hierarchical relationship, ensuring that each command can be uniquely parsed and indexed in memory. During the operation of the terminal interaction program, this Trie tree index remains resident in memory, providing basic data support for subsequent real-time association.

[0031] When maintenance personnel begin entering commands on the terminal interface, the system continuously listens for keyboard input events and maintains the character buffer of the current input line in real time. During input, whenever the character buffer or cursor position changes, the system immediately generates an input prefix string based on the current character sequence and performs a prefix matching search on the Trie tree index for that input prefix string without requiring additional user intervention. At this time, the system can dynamically locate the node that matches the input prefix as the user inputs character by character, and generate a candidate command set based on the subtree corresponding to that node, displaying the relevant commands and their corresponding definitions in real time near the input cursor on the terminal.

[0032] In practical use, when the user's input does not yet contain a space character, the terminal interface continuously displays a list of command suggestions that match the current input prefix. Users can intuitively understand the possible commands and their meanings without interrupting their input. This interaction method significantly reduces the user's reliance on external documents or memory during the command selection phase, maintaining the continuity of the input process and avoiding the efficiency loss caused by frequent switching of focus.

[0033] When a user enters a space after a command, the system automatically recognizes this input as a command confirmation action and parses the character sequence before the space as a confirmed command string. The system then locates the command confirmation node corresponding to this confirmed command string in the Trie tree index and directly retrieves the parameter set field corresponding to the command through the parameter index pointer stored in that node, thereby generating a unique and valid parameter context set. At this stage, the system no longer matches other commands or irrelevant parameters, but strictly limits the scope of subsequent parameter associations to this parameter context set.

[0034] During the parameter input phase, the user continues to enter parameter prefix characters in the terminal. The system reads the character sequence after the space from the character buffer and generates a parameter input prefix string. It then performs a character prefix comparison on the parameter names within the defined parameter context set. Parameters that match the prefix matching criteria are selected and associated with their corresponding parameter definitions, generating a parameter suggestion list that is displayed in real-time near the input cursor. In this way, users can clearly see the available parameters and their meanings when entering complex parameter combinations, effectively reducing parameter input errors and repeated attempts.

[0035] In actual operation, this implementation method continuously runs in a remote server maintenance environment during a certain working period, covering the daily terminal operation behavior of multiple users. Comparing usage before and after the introduction of this invention, it can be observed that the number of pauses when users input commands and parameters is significantly reduced, the frequency of consulting external documents is significantly decreased, and the fluency and smoothness of the input process are significantly improved. Especially when processing commands with many parameters and complex semantics, this invention, through context locking and real-time association mechanisms, enables users to construct correct instructions without interrupting input, thereby reducing the operational burden and the risk of misoperation.

[0036] Furthermore, since this invention uses a Trie tree as the core index structure, all associative retrieval operations are completed in memory. In actual use, no terminal response delays or input lag occurred, enabling it to adapt to the continuously expanding application requirements of command resources. This embodiment fully demonstrates that this invention can run stably in real-world operation and development scenarios, effectively solving the problems of insufficient real-time performance, missing definitions, and weak parameter association capabilities in existing terminal input processes, significantly improving terminal interaction experience and operational efficiency.

[0037] Table 1. Comparison of Experimental Data for Real-Time Associative Input Methods in Terminals As shown in Table 1, the experimental data reveals a significant efficiency bottleneck in the traditional Tab-based auto-completion method during command and parameter input. On average, the traditional method takes 7.8 seconds for command input, while the real-time auto-completion method based on Trie trees takes only 3.2 seconds, a reduction of nearly 60%. This is primarily due to the real-time prefix matching mechanism, which avoids frequent manual triggering, allowing users to complete command selection during continuous input.

[0038] In the parameter input phase, the traditional method requires users to try and roll back multiple times due to the lack of a context locking mechanism, with an average time consumption of 6.5 seconds. However, the method of this invention directly limits the parameter context set by parameter index pointer, reducing the parameter input time to 2.6 seconds, effectively reducing invalid input and repeated attempts.

[0039] From an error rate perspective, the traditional method has error rates of 9.6% and 11.2% during command and parameter input, respectively, while the real-time auto-completion method reduces the error rates to 4.2% and 5.5%, respectively. This difference stems from the synchronous display of command and parameter definitions, allowing users to confirm semantic correctness during the input stage, thereby significantly reducing the probability of misoperation.

[0040] Furthermore, the real-time association method based on Trie trees demonstrates significant advantages in terms of document retrieval frequency and input interruption frequency per unit time. The document retrieval frequency decreased from 14 times to 8 times, and the number of interruptions decreased from 18 times to 12 times, indicating that the present invention has significant effects in maintaining input continuity and reducing cognitive switching.

[0041] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for real-time input association on a terminal based on a Trie tree, characterized in that, Includes the following steps: Build a command resource library and organize it into a structured format to generate command resource files; Read the command resource file and perform deserialization to obtain a set of command records, and build a Trie tree index residing in memory; Listen for user keyboard input events, capture user input characters in real time and maintain the character buffer of the current input line, and generate the current input prefix string based on the character buffer; When no space character is detected in the character buffer, prefix matching search is performed, matching nodes are located along the character path and traversal operations are performed to generate a set of candidate commands. The candidate command set is associated with the corresponding command definitions in the command resource file to generate a command suggestion list, which is displayed in real time near the input cursor on the terminal. When a space character is detected in the character buffer, the character sequence before the space character is parsed into a confirmed command string, and the corresponding parameter set field is located in the Trie tree index to generate a parameter context set. Continue to receive user input and generate parameter input prefix strings, perform prefix matching in the parameter context set to generate a matching parameter set, and associate it with the corresponding parameter interpretation to generate a parameter association list; The parameter suggestion list is displayed in real time near the input cursor on the terminal, and is updated as the user's input characters change.

2. The method for real-time input association based on a Trie tree in a terminal according to claim 1, characterized in that, The generation of the command resource file includes: Collect Linux / Unix commands, standardize and deduplicate command names to form a set of command entries; For each command entry in the command entry set, extract the corresponding command string and write the command string into the command string field; For each command entry in the command entry set, extract the command definition that corresponds one-to-one with the command string, and write the command definition into the command definition field; For each command entry in the command entry set, collect the names of the subcommands that are allowed to be directly followed by the command in the terminal input, arrange them in a fixed order to generate a subcommand set, and write the subcommand set into the subcommand set field; For each command entry in the command entry set, collect the parameters that the command is allowed to use in terminal input, arrange them in a fixed order to generate a parameter set, and write the parameter set into the parameter set field; For each parameter item in the parameter set, configure the corresponding parameter constraint field, and associate and store the parameter constraint field with the parameter set field; The command string field, command definition field, subcommand set field, parameter set field, and parameter constraint field are encapsulated in a structured manner to generate a command resource file, which is then stored in the command resource library.

3. The method for real-time input association on a terminal based on a Trie tree according to claim 1, characterized in that, The generation of the Trie tree index residing in memory includes: During the startup or initialization phase of the terminal interactive program, the command resource file is read, deserialization processing is performed on the command resource file, and the command string field, command interpretation field, subcommand set field, parameter set field and parameter constraint field contained in the command resource file are parsed into a command record set; Read the command string fields sequentially from the command record set, and generate a character sequence according to the order of the characters in the command string fields; Starting from the root node of the Trie tree, the node positioning operation is performed character by character in the order of the character sequence. When the current character in the character sequence does not have a corresponding character identifier in the child node reference of the current node, a new node is created and the character identifier of the corresponding character is stored in the node. At the same time, the child node reference relationship between the new node and its parent node is established. After locating or creating nodes corresponding to all characters in the character sequence, at the end node corresponding to the character sequence, the parameter set field in the command record is bound to the end node to generate a parameter index pointer, and the parameter index pointer is stored in the end node. After completing the insertion operation of all command string fields in the command record set, a Trie tree index residing in memory is obtained.

4. The method for real-time input association based on a Trie tree in a terminal according to claim 1, characterized in that, The generation of the current input prefix string includes: Listen for user keyboard input events on the terminal interface, and parse the corresponding user input character and the operation type corresponding to each keyboard input event; Maintain a character buffer for the current input line. When the operation type corresponding to the parsed user input character is a character input operation, write the user input character into the character buffer at the logical insertion position indicated by the cursor position index, and increment and update the cursor position index after writing is completed. When the operation type corresponding to the parsed user input character is a deletion operation, the position of the character to be deleted in the character buffer is determined according to the cursor position index, the corresponding user input character is deleted from the character buffer, and the cursor position index is decremented after the deletion is completed. When the operation type corresponding to the parsed user input character is a cursor movement operation, the cursor position index is adjusted according to the cursor movement direction, and the order of the user input characters stored in the character buffer is kept unchanged. When the character buffer or cursor position index changes, the current input prefix string is generated based on the user input character sequence from the start position to the corresponding position of the cursor position index in the character buffer.

5. The method for real-time input association based on a Trie tree in a terminal according to claim 1, characterized in that, The generation of the candidate command set includes: The character content in the character buffer is checked to confirm that there are no space characters in the character buffer, and the corresponding current input prefix string in the character buffer is read and used as the search prefix; In a Trie tree index, the root node is used as the starting node. The node location operation is performed based on the child node references between nodes according to the order of characters in the search prefix. After the node location of all characters in the search prefix is ​​completed, the matching node is obtained. When a character cannot be found in the child node references of the current node during the node positioning operation, an empty set of candidate commands is generated. When a matching node is obtained, the matching node is used as the starting node for traversal, and the traversal operation is performed on the subtree corresponding to the matching node. When a node that no longer has child node references is reached during the traversal, the character path is concatenated with the search prefix to generate a command string. The command strings obtained from the traversal are then summarized and deduplicated to generate a candidate command set.

6. The method for real-time input association based on a Trie tree in a terminal according to claim 1, characterized in that, The step of displaying the command suggestion list in real time near the input cursor on the terminal includes: Read the candidate command set, and extract the command string corresponding to each candidate command in the order of the command strings in the candidate command set; Using the command string as the search criteria, perform a matching and location operation in the command resource file to obtain the command records that correspond one-to-one with the command string; Read the command definition field corresponding to the command string from the command record, and establish an association between the command definition field and the corresponding command string; Based on the order of the command strings in the candidate command set, the command strings are combined with their corresponding command definition fields in sequence to generate a command suggestion list; The command association list is output to the position near the input cursor in the terminal in the order it was generated.

7. The method for real-time input association based on a Trie tree in a terminal according to claim 1, characterized in that, The generation of the parameter context set includes: The input characters are detected in the character buffer. When a space character is detected, the character sequence before the space character is determined as the confirmed command string and the confirmed command string is used as the command confirmation identifier. In the Trie tree index, the root node is used as the starting node. The node positioning operation is performed along the character path according to the order of the characters in the confirmed command string. After the positioning of the nodes corresponding to all characters in the confirmed command string is completed, the positioned node is determined as the command confirmation node corresponding to the confirmed command string. Read the stored parameter index pointer from the command confirmation node; The corresponding parameter set field is obtained based on the parameter index pointer, and during the parameter input process after the space character is detected, the parameter set field is determined as the unique and valid parameter context set.

8. The method for real-time input association on a terminal based on a Trie tree according to claim 1, characterized in that, The generation of the parameter association list includes: After the space character is detected, continue to receive user input characters and write the user input characters received after the space character into the character buffer; Read the character sequence following the space character from the character buffer and use this character sequence as the parameter input prefix string; Using the parameter context set as the only valid matching range, read the parameter set fields contained in the parameter context set; Read each parameter item sequentially from the parameter set field and extract the parameter name corresponding to each parameter item; The parameter name of each parameter item is compared with the parameter input prefix string by character prefix, and the parameter items that match the parameter input prefix string are filtered out to generate a set of matching parameters; Read the parameter definition corresponding to each parameter item in the matching parameter set, and associate the parameter definition with the corresponding parameter item; Based on the order of the parameter items in the matching parameter set, the parameter items and their corresponding parameter definitions are combined to generate a parameter association list.

9. The method for real-time input association based on a Trie tree in a terminal according to claim 1, characterized in that, The step of displaying the parameter suggestion list in real time near the input cursor on the terminal and updating the parameter suggestion list when the user's input characters change includes: Get the current position of the terminal input cursor in the terminal interface, and determine the current position of the terminal input cursor as the display reference position of the parameter suggestion list; Convert the parameter suggestion list into displayable text and display the parameter suggestion list near the terminal input cursor based on the display reference position; The terminal interface continuously receives user input characters and detects whether the user input characters change. When a change in user input characters is detected, an update operation is performed based on the current parameter suggestion list to obtain an updated parameter suggestion list, and the updated parameter suggestion list is displayed near the terminal input cursor based on the display reference position.