Method for processing command, device for processing command, and electronic device
AssigneeLenovo (Beijing) Limited
InventorsYu Li, Guannan Zhang
Life of this patent
Estimating the term…
Abstract
A method for processing command includes obtaining an input command-line interface (CLI) command, converting the CLI command into a tree structure to obtain a to-be-processed command tree, determining a target subtree corresponding to the to-be-processed command tree in a standard command tree, and parsing the to-be-processed command tree according to nodes and a connection structure between the nodes of the target subtree to obtain a command parsing result. The standard command tree is a command tree obtained by converting standard commands in a standard command set into an integrated tree structure.
Claims20
A method for processing command, comprising:
- obtaining an input command-line interface (CLI) command;
- converting the CLI command into a tree structure to obtain a to-be-processed command tree, the converting the CLI command into the tree structure comprises splitting a command string of the CLI command in levels according to coupling strength degrees between Tokens represented by connection symbols from weak to strong, the coupling strength degrees corresponding to the levels increase with increasing levels such that each higher level corresponds to a stronger coupling strength degree than each lower splitting level;
- determining a target subtree corresponding to the to-be-processed command tree in a standard command tree, the standard command tree being a command tree obtained by converting standard commands in a standard command set into an integrated tree structure;
- parsing the to-be-processed command tree according to nodes and a connection structure between the nodes of the target subtree to obtain a command parsing result including a command logic corresponding to the target subtree, wherein each node of the to-be-processed command tree corresponds to a command keyword of the CLI command, and the connection structure between the nodes represents semantic relationships between command keywords, thereby reducing parsing errors and avoiding performance degradation and abnormal errors caused by complex coupling associations between the command keywords of the CLI command;
- determining, based on the command parsing result, a to-be-performed action corresponding to the command logic;
- and
- triggering the to-be-performed action to execute the input CLI command.
A non-transitory computer-readable storage medium storing a computer instruction set that, when executed by a processor, causes the processor to:
- obtain an input command-line interface (CLI) command;
- convert the CLI command into a tree structure to obtain a to-be-processed command tree, the converting the CLI command into the tree structure comprises splitting a command string of the CLI command in levels according to coupling strength degrees between Tokens represented by connection symbols from weak to strong, the coupling strength degrees corresponding to the levels increase with increasing levels such that each higher level corresponds to a stronger coupling strength degree than each lower splitting level;
- determine a target subtree of the to-be-processed command tree corresponding to a standard command tree, the standard command tree being a command tree obtained by converting standard commands of a standard command set into an integrated tree structure;
- parse the to-be-processed command tree according to nodes and a connection structure of the nodes of the target subtree to obtain a command parsing result including a command logic corresponding to the target subtree, wherein each node of the to-be-processed command tree corresponds to a command keyword of the CLI command, and the connection structure between the nodes represents semantic relationships between command keywords, thereby reducing parsing errors and avoiding performance degradation and abnormal errors caused by complex coupling associations between the command keywords of the CLI command;
- determine, based on the command parsing result, a to-be-performed action corresponding to the command logic;
- and
- trigger the to-be-performed action to execute the input CLI command.
An electronic device comprising:
- a processor;
- and
- a memory storing a computer instruction set that, when executed by the processor, causes the processor to:
- obtain an input command-line interface (CLI) command;
- convert the CLI command into a tree structure to obtain a to-be-processed command tree, the converting the CLI command into the tree structure comprises splitting a command string of the CLI command in levels according to coupling strength degrees between Tokens represented by connection symbols from weak to strong, the coupling strength degrees corresponding to the levels increase with increasing levels such that each higher level corresponds to a stronger coupling strength degree than each lower splitting level;
- determine a target subtree of the to-be-processed command tree corresponding to a standard command tree, the standard command tree being a command tree obtained by converting standard commands of a standard command set into an integrated tree structure;
- parse the to-be-processed command tree according to nodes and a connection structure of the nodes of the target subtree to obtain a command parsing result including a command logic corresponding to the target subtree, wherein each node of the to-be-processed command tree corresponds to a command keyword of the CLI command, and the connection structure between the nodes represents semantic relationships between command keywords, thereby reducing parsing errors and avoiding performance degradation and abnormal errors caused by complex coupling associations between the command keywords of the CLI command;
- determine, based on the command parsing result, a to-be-performed action corresponding to the command logic;
- and
- trigger the to-be-performed action to execute the input CLI command.
Dependencies are inferred from the claim text.