IP Library Granted Patent US 11,782,703
Granted Patent B2
US 11,782,703 · App. 17/739,727 · Granted Oct 10, 2023

Computer code refactoring

Inventors: Xuchao Zhang (Elkridge, MD); Haifeng Chen (West Windsor, NJ); Wei Cheng (Princeton Junction, NJ)
G06F8/72G06F8/30
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,782,703
App. No.
17/739,727
Granted
Oct 10, 2023
Kind
B2
Abstract

Systems and methods are provided for automated computer code editing. The method includes training a code-editing neural network model using a corpus of code editing data samples, including the pre-editing samples and post-editing samples, and parsing the pre-editing samples and post-editing samples into an Abstract Syntax Tree (AST). The method further includes using a grammar specification to transform the AST tree into a unified Abstract Syntax Description Language (ASDL) graph for different programming languages, and using a gated graph neural network (GGNN) to compute a vector representation for each node in the unified Abstract Syntax Description Language (ASDL) graph. The method further includes selecting and aggregating support samples based on a query code with a multi-extent ensemble method, and altering the query code iteratively using the pattern learned from the pre- and post-editing samples.

Claims (143)

1. A computer implemented method for automated computer code editing, comprising:

training a code-editing neural network model using a corpus of code editing data samples, including the pre-editing samples and post-editing samples;

parsing the pre-editing samples and post-editing samples into an Abstract Syntax Tree (AST);

using a grammar specification to transform the AST tree into a unified Abstract Syntax Description Language (ASDL) graph for different programming languages;

using a gated graph neural network (GGNN) to compute a vector representation for each node in the unified Abstract Syntax Description Language (ASDL) graph;

selecting and aggregating support samples based on a query code with a multi-extent ensemble method; and

altering the query code iteratively using the code-editing neural network model and the pattern learned from the pre- and post-editing samples.

2. The computer implemented method of claim 1 , wherein the pre-editing samples and post-editing samples are combined using the multi-extent ensemble method.

3. The computer implemented method of claim 2 , wherein a query code snippet corpus data includes a set of query code snippets for each edit type.

4. The computer implemented method of claim 3 , further comprising inputting the query code as an initial input for code editing.

5. The computer implemented method of claim 4 , wherein the query code is a set of support code snippets provided as edit samples for both the pre-edit and post-edit code snippets in training.

6. The computer implemented method of claim 5 , further comprising extending the original AST tree by adding bidirectional edges between parent and child nodes.

7. The computer implemented method of claim 6 , further comprising utilizing mean-pool to represent a whole graph.

8. The computer implemented method of claim 7 , further comprising computing an activation for each of the query and support samples.

9. The computer implemented method of claim 8 , wherein the activations of the query and support samples are given by:

σ n q :=max{φ( f q ( z n q ), f s ( z i s ))} i=1 N s and σ n s :=max{φ( f s ( z n s ), f q ( z i q ))} i=1 N q ,

respectively.

10. The computer implemented method of claim 9 , wherein the graph representation of a query code graph and a support code graph is generated by:

t

λ

q

:=

n

=

1

N

q

k

=

1

K

1

K

σ

n

,

λ

q

k

z

n

q

and

t

λ

S

:=

n

=

1

N

s

σ

n

,

λ

s

z

n

s

,

respectively.

11. A computer system for automated computer code editing, comprising:

one or more processors;

a computer memory operatively coupled to at least one of the one or more processors;

a computer display operatively coupled to the computer memory and the at least one of the one or more processors, wherein the computer memory contains instruction code that can cause the computer system to perform the operations of:

training a code-editing neural network model using a corpus of code editing data samples, including the pre-editing samples and post-editing samples;

parsing the pre-editing samples and post-editing samples into an Abstract Syntax Tree (AST);

using a grammar specification to transform the AST tree into a unified Abstract Syntax Description Language (ASDL) graph for different programming languages;

using a gated graph neural network (GGNN) to compute a vector representation for each node in the unified Abstract Syntax Description Language (ASDL) graph;

selecting and aggregating support samples based on a query code with a multi-extent ensemble method; and

altering the query code iteratively using the code-editing neural network model and the pattern learned from the pre- and post-editing samples.

12. The computer system of claim 11 , wherein the pre-editing samples and post-editing samples are combined using the multi-extent ensemble method.

13. The computer system of claim 12 , wherein a query code snippet corpus data includes a set of query code snippets for each edit type.

14. The computer system of claim 13 , further comprising instruction code that can cause the computer system to perform the operations of inputting the query code as an initial input for code editing.

15. The computer system of claim 14 , wherein the query code is a set of support code snippets provided as edit samples for both the pre-edit and post-edit code snippets in training.

16. The computer system of claim 15 , further comprising instruction code that can cause the computer system to perform the operations of extending the original AST tree by adding bidirectional edges between parent and child nodes.

17. The computer system of claim 16 , further comprising instruction code that can cause the computer system to perform the operations of utilizing mean-pool to represent a whole graph.

18. The computer system of claim 17 , further comprising instruction code that can cause the computer system to perform the operations of computing an activation for each of the query and support samples.

19. The computer system of claim 18 , wherein the activations of the query and support samples are given by:

σ n q :=max{φ( f q ( z n q ), f s ( z i s ))} i=1 N s and σ n s :=max{(φ( f s ( z n s ), f q ( z i q ))} i=1 N q ,

respectively.

20. The computer system of claim 19 , wherein the graph representation of a query code graph and a support code graph is generated by:

t

λ

q

:=

n

=

1

N

q

k

=

1

K

1

K

σ

n

,

λ

q

k

and

z

n

q

t

λ

S

:=

n

=

1

N

s

σ

n

,

λ

s

z

n

s

,

respectively.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 10, 2023
From: NEC LABORATORIES AMERICA, INC.
To: NEC CORPORATION
Reel/Frame 064551/0299 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded May 9, 2022
From: ZHANG, XUCHAO; CHEN, HAIFENG; CHENG, WEI
To: NEC LABORATORIES AMERICA, INC.
Reel/Frame 059872/0075 →
Continuity (3)
Provisional Application 63189236 · May 17, 2021
Provisional Application 63189274 · May 17, 2021
Related Publication 20220374232A1 · Nov 24, 2022