# US 2023/0273776 A1 · Code Processing Method and Apparatus, Device, and Medium

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

- Number: US 2023/0273776 A1
- Document ID: US20230273776A1
- Status: Published application
- Kind: A1
- Application number: 18/310,749
- Filed: 2023-05-02
- Published: 2023-08-31
- Earliest claimed: 2020-11-02
- Assignees: Huawei Cloud Computing Technologies Co., Ltd.
- Applicants: Huawei Cloud Computing Technologies Co., Ltd.
- Inventors: Yawei Wang; Petrochenko Pavel; Karpenko Dmitry
- Web page: https://patentgrep.com/patent/US20230273776A1

## CPC

- G06F 8/33: Intelligent editors
- G06F 8/36: Software reuse
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Code inputted by a user is received through a user interface. A feature of context of to-be-completed code is determined based on the code inputted by the user. Next, at least one candidate item of the to-be-completed code is determined from a context database based on the feature of context of the to-be-completed code. The context database stores sample code and a feature of context of the sample code. Then, the at least one candidate item is presented to the user through the user interface.

## Claims

### Claim 1

A code processing method, comprising:
receiving, through a user interface, first code from a user;
determining a first feature of context of to-be-completed code based on the code;
determining at least one candidate item of the to-be-completed code from a context database based on the first feature, wherein the context database stores sample code and a second feature of context of the sample code; and
presenting the at least one candidate item to the user through the user interface.

### Claim 2 (depends on 1)

The code processing method of claim 1, further comprising:
obtaining statistical information of the at least one candidate item in the context database; and
filtering the at least one candidate item based on the statistical information to obtain a first candidate item, and
wherein presenting the at least one candidate item to the user comprises presenting the first candidate item to the user through the user interface.

### Claim 3 (depends on 1)

The code processing method of claim 1, further comprising inputting the at least one candidate item and the first feature into an assessment model to obtain a recommendation probability of the at least one candidate item, and wherein presenting the at least one candidate item to the user comprises:
determining a target candidate item in the at least one candidate item based on the recommendation probability; and
presenting the target candidate item to the user through the user interface.

### Claim 4 (depends on 1)

The code processing method of claim 1, wherein the candidate item comprises a function name, wherein the code processing method further comprises filling the at least one candidate item with a parameter based on second code in a code file that comprises the first code to generate a filled-in at least one candidate item that is filled with the parameter, and wherein presenting the at least one candidate item to the user comprises presenting, to the user through the user interface, the filled-in at least one candidate item.

### Claim 5 (depends on 1)

The code processing method of claim 1, wherein determining the at least one candidate item comprises:
searching the context database based on the first feature using a depth-first search algorithm; and
determining the at least one candidate item based on the searching.

### Claim 6 (depends on 1)

The code processing method of claim 1, wherein the first code comprises a prefix of the to-be-completed code, and wherein determining the at least one candidate item comprises determining, from the context database based on the first feature, one or more candidate items that match the prefix.

### Claim 7 (depends on 1)

The code processing method of claim 1, wherein the context database comprises at least one of a first database based on an open source dataset or a second database based on a private dataset of the user.

### Claim 8 (depends on 1)

The code processing method of claim 1, wherein the to-be-completed code comprises second code in a class method, and wherein the first code comprises a return type.

### Claim 9 (depends on 8)

The code processing method of claim 8, further comprising determining, based on the first feature, a role called by the class method corresponding to the to-be-completed code, wherein the role is for assisting in determining a recommendation probability of the at least one candidate item.

### Claim 10 (depends on 1)

The code processing method of claim 1, further comprising filtering a candidate item having a circular reference out of the at least one candidate item to obtain a subset of the at least one candidate item, wherein presenting the at least one candidate item to the user comprises presenting the subset of the at least one candidate item to the user through the user interface.

### Claim 11

A code processing apparatus, wherein the apparatus comprises:
an interface configured to receive, through a user interface, first code from a user;
a feature extractor configured to determine a first feature of context of to-be-completed code based on the first code; and
one or more processors coupled to the interface and the feature extractor and configured to determine at least one candidate item of the to-be-completed code from a context database based on the first feature,
wherein the context database stores sample code and a second feature of context of the sample code, and
wherein the interface is further configured to present the at least one candidate item to the user through the user interface.

### Claim 12 (depends on 11)

The code processing apparatus of claim 11, wherein the one or more processors are further configured to:
obtain statistical information of the at least one candidate item in the context database; and
filter the at least one candidate item based on the statistical information to determine a first candidate item, and
wherein the interface is further configured to present the first candidate item to the user through the user interface.

### Claim 13 (depends on 11)

The code processing apparatus of claim 11, wherein the one or more processors are further configured to:
input the at least one candidate item and the feature of context of the to-be-completed code into an assessment model to obtain a recommendation probability of the at least one candidate item; and
determine a target candidate item in the at least one candidate item based on the recommendation probability, and
wherein the interface is further configured to present the target candidate item to the user through the user interface.

### Claim 14 (depends on 12)

The code processing apparatus of claim 12, wherein the one or more processors are further configured to fill, when the first candidate item comprises a function name, the at least one candidate item with a parameter based on second code in a code file that comprises the first code to generate a filled-in at least one candidate item that is filled with the parameter, and wherein the interface is further configured to present, to the user through the user interface, the filled-in at least one candidate item.

### Claim 15 (depends on 11)

The code processing apparatus of claim 11, wherein the one or more processors are further configured to:
search the context database based on the first feature using a depth-first search algorithm; and
determine the at least one candidate item based on the search.

### Claim 16 (depends on 11)

The code processing apparatus of claim 11, wherein the first code comprises a prefix of the to-be-completed code, and wherein the one or more processors are further configured to determine, from the context database based on the feature of context of the to-be-completed code, one or more candidate items that match the prefix.

### Claim 17 (depends on 11)

The code processing apparatus of claim 11, wherein the context database comprises at least one of a first database that is based on an open source dataset or a second database that is based on a private dataset of the user.

### Claim 18 (depends on 11)

The code processing apparatus of claim 11, wherein the to-be-completed code comprises second code in a class method, and wherein the first code comprises a return type.

### Claim 19 (depends on 18)

The code processing apparatus of claim 18, wherein the one or more processors are further configured to determine, based on the feature of context of the to-be-completed code, a role called by the class method corresponding to the to-be-completed code, wherein the role is for assisting in determining a recommendation probability of the candidate item of the to-be-completed code.

### Claim 20 (depends on 11)

The code processing apparatus of claim 11, wherein the one or more processors are further configured to filter a candidate item having a circular reference out of the at least one candidate item to obtain a subset of the at least one candidate item, and wherein the interface is further configured to present the subset of the at least one candidate item to the user through the user interface.
