# US 2024/0004778 A1 · Method for processing command, device for processing command, and electronic device

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0004778 A1
- Document ID: US20240004778A1
- Status: Published application
- Kind: A1
- Application number: 18/345,806
- Filed: 2023-06-30
- Published: 2024-01-04
- Earliest claimed: 2022-07-01
- Assignees: Lenovo (Beijing) Limited
- Applicants: Lenovo (Beijing) Limited
- Inventors: Yu LI; Guannan ZHANG
- Web page: https://patentgrep.com/patent/US20240004778A1

## CPC

- G06F 11/3612: {by runtime analysis (performance monitoring G06F11/3466)}
- G06F 8/427: {Parsing}
- G06F 9/45512: {Command shells}
- G06F 16/9024: {Graphs; Linked lists (G06F16/9027 takes precedence)}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for processing command includes obtaining an input command-lineinterface (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.

## Claims

### Claim 1

A method for processing command, comprising:
obtaining an input command-lineinterface (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, the standard command tree being a command tree obtained by converting standard commands in a standard command set into an integrated tree structure; 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.

### Claim 2 (depends on 1)

The method according to claim 1, wherein converting the CLI command into the tree structure includes:
constructing a command string corresponding to the CLI command as an initial node;
performing a splitting process on the initial node to split the command string in the initial node into different Tokens, forming different tree nodes corresponding to the different Tokens, forming a connection structure between different tree nodes according to connection symbols of the different Tokens, and obtaining a tree structure of the to-be-processed.

### Claim 3 (depends on 2)

The method according to claim 2, wherein performing the splitting process on the initial node to split the command string in the initial node into different Tokens, forming different tree nodes corresponding to the different Tokens, and forming the connection structure between different tree nodes according to the connection symbols of the different Tokens includes:
performing first-level splitting on the initial node to obtain different first-level tree nodes formed by first-level command symbols of the command string;
forming a connection structure between different first-level tree nodes according to connection symbols between different first-level command symbols;
in response to a first-level command symbol in a Token combination type, performing second-level splitting on a target first-level tree node corresponding to the first-level command symbol in the Token combination type, and obtaining different second-level tree nodes formed by second-level command symbols of the target first-level tree node; and
forming a connection structure between the different second-level tree nodes according to connection symbols of different second-level command symbols until a command symbol corresponding to each tree node is a single Token by splitting the tree nodes in levels.

### Claim 4 (depends on 3)

The method according to claim 3, wherein:
the tree nodes are split according to a command description file; and
the command description file includes a Token description and a description of a semantic relationship or a semantic structure represented by a connection symbol that is used to connect the different Tokens.

### Claim 5 (depends on 3)

The method according to claim 3, further comprising:
in response to the to-be-processed command tree being an expanded command tree, obtaining the to-be-processed command tree when splitting the tree node in levels to cause a command symbol corresponding to each tree node to be a single Token; and
in response to the to-be-processed command tree being a compressed command tree, obtaining the to-be-processed command tree and combining the tree structure when splitting the tree node in levels to cause the command symbol corresponding to each tree node to be the single Token.

### Claim 6 (depends on 5)

The method according to claim 5, wherein combining the tree structure includes:
combining different branches of branches of the tree structure corresponding to a same character prefix to cause the combined different branches corresponding to the same character prefix to share a same tree node, a character prefix corresponding to a branch of the tree structure includes a prefix of a string formed by Tokens corresponding to tree nodes included in the branch.

### Claim 7 (depends on 1)

The method according to claim 1, wherein determining the target subtree corresponding to the to-be-processed command tree in the standard command tree includes:
performing subtree matching on the to-be-processed command tree in the standard command tree to obtain the target subtree corresponding to the to-be-processed command tree in the standard command tree.

### Claim 8 (depends on 1)

The method according to claim 1, wherein:
nodes of the standard command tree are associated with corresponding semantic description information; and
parsing the to-be-processed command tree according to the nodes and connection structure of the nodes of the target subtree includes:
obtaining semantic description information associated with nodes of the target subtree;
determining the semantic relationship between the nodes according to the connection structure between the nodes of the target subtree; and
determining the command logic corresponding to the target subtree according to the semantic description information associated with the nodes and the semantic relationship between the nodes of the target subtree and using the command logic as the command parsing result of the to-be-processed command tree.

### Claim 9

A computer-readable storage medium storing a computer instruction set that, when executed by a processor, causes the processor to:
obtain an input command-lineinterface (CLI) command;
convert the CLI command into a tree structure to obtain a to-be-processed command tree;
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; and
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.

### Claim 10 (depends on 9)

The storage medium according to claim 9, wherein the processor is further configured to:
construct a command string corresponding to the CLI command as an initial node;
perform a splitting process on the initial node to split the command string in the initial node into different Tokens, form different tree nodes corresponding to the different Tokens, form a connection structure between different tree nodes according to connection symbols of the different Tokens, and obtain a tree structure of the to-be-processed.

### Claim 11 (depends on 10)

The storage medium according to claim 10, wherein the processor is further configured to:
perform first-level splitting on the initial node to obtain different first-level tree nodes formed by first-level command symbols of the command string;
form a connection structure between different first-level tree nodes according to connection symbols between different first-level command symbols;
in response to a first-level command symbol in a Token combination type, perform second-level splitting on a target first-level tree node corresponding to the first-level command symbol in the Token combination type, and obtain different second-level tree nodes formed by second-level command symbols of the target first-level tree node; and
form a connection structure between the different second-level tree nodes according to connection symbols of different second-level command symbols until a command symbol corresponding to each tree node is a single Token by splitting the tree nodes in levels.

### Claim 12 (depends on 11)

The storage medium according to claim 11, wherein:
the tree nodes are split according to a command description file; and
the command description file includes a Token description and a description of a semantic relationship or a semantic structure represented by a connection symbol that is used to connect the different Tokens.

### Claim 13

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-lineinterface (CLI) command;
convert the CLI command into a tree structure to obtain a to-be-processed command tree;
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; and
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.

### Claim 14 (depends on 13)

The device according to claim 13, wherein the processor is further configured to:
construct a command string corresponding to the CLI command as an initial node;
perform a splitting process on the initial node to split the command string in the initial node into different Tokens, form different tree nodes corresponding to the different Tokens, form a connection structure between different tree nodes according to connection symbols of the different Tokens, and obtain a tree structure of the to-be-processed.

### Claim 15 (depends on 14)

The device according to claim 14, wherein the processor is further configured to:
perform first-level splitting on the initial node to obtain different first-level tree nodes formed by first-level command symbols of the command string;
form a connection structure between different first-level tree nodes according to connection symbols between different first-level command symbols;
in response to a first-level command symbol in a Token combination type, perform second-level splitting on a target first-level tree node corresponding to the first-level command symbol in the Token combination type, and obtain different second-level tree nodes formed by second-level command symbols of the target first-level tree node; and
form a connection structure between the different second-level tree nodes according to connection symbols of different second-level command symbols until a command symbol corresponding to each tree node is a single Token by splitting the tree nodes in levels.

### Claim 16 (depends on 15)

The device according to claim 15, wherein:
the tree nodes are split according to a command description file; and
the command description file includes a Token description and a description of a semantic relationship or a semantic structure represented by a connection symbol that is used to connect the different Tokens.

### Claim 17 (depends on 15)

The device according to claim 15, the processor is further configured to:
in response to the to-be-processed command tree being an expanded command tree, obtain the to-be-processed command tree when splitting the tree node in levels to cause a command symbol corresponding to each tree node to be a single Token; and
in response to the to-be-processed command tree being a compressed command tree, obtain the to-be-processed command tree and combine the tree structure when splitting the tree node in levels to cause the command symbol corresponding to each tree node to be the single Token.

### Claim 18 (depends on 17)

The device according to claim 17, wherein the processor is configured to:
combine different branches of branches of the tree structure corresponding to a same character prefix to cause the combined different branches corresponding to the same character prefix to share a same tree node, a character prefix corresponding to a branch of the tree structure includes a prefix of a string formed by Tokens corresponding to tree nodes included in the branch.

### Claim 19 (depends on 13)

The device according to claim 13, wherein the processor is further configured to:
perform subtree matching on the to-be-processed command tree in the standard command tree to obtain the target subtree corresponding to the to-be-processed command tree in the standard command tree.

### Claim 20 (depends on 13)

The device according to claim 13, wherein:
nodes of the standard command tree are associated with corresponding semantic description information; and
the processor is further configured to:
obtain semantic description information associated with nodes of the target subtree;
determine the semantic relationship between the nodes according to the connection structure between the nodes of the target subtree; and
determine the command logic corresponding to the target subtree according to the semantic description information associated with the nodes and the semantic relationship between the nodes of the target subtree and using the command logic as the command parsing result of the to-be-processed command tree.
