Refactoring computer code

By training code editing neural network models, using abstract syntax trees and graph neural networks, the automation problem of code editing under a small number of samples is solved, and efficient structural optimization and functional maintenance of the code is achieved.

JP7628630B2Active Publication Date: 2025-02-10NEC CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
JP2023570435
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2022-05-09
Filing Date
2022-05-10
Publication Date
2025-02-10
Estimated Expiration
2042-05-10

AI Technical Summary

Technical Problem

It is difficult to efficiently automate the editing of computer code in the prior art, especially when the sample size is limited, it is difficult to achieve structural optimization and functional maintenance of the code.

Method used

Using a neural network-based method, the code editing model is trained, abstract syntax trees and unified abstract syntax description language graphs are used, and graph neural networks are combined to realize efficient editing of the code from the initial state to the modified state.

Benefits of technology

It realizes automated code editing under a small number of samples, improves code efficiency and structural optimization effects, and reduces manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007628630000066
    Figure 0007628630000066
  • Figure 0007628630000067
    Figure 0007628630000067
  • Figure 0007628630000068
    Figure 0007628630000068
Patent Text Reader

Abstract

A system and method for automated computer code editing is provided. The method includes training a code editing neural network model using a corpus of code editing data samples including pre-edit samples and post-edit samples, and parsing the pre-edit samples and post-edit samples into an abstract syntax tree (AST). The method further includes converting the AST tree into a unified abstract syntax description language graph for various programming languages ​​using a grammar specification, and computing a vector representation of each node in the unified abstract syntax description language graph using a gate graph neural network. The method further includes selecting and integrating supporting samples based on the query code using a multi-extent ensemble method, and iteratively modifying the query code using the code editing neural network model and patterns learned from the pre-edit samples and post-edit samples.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] This application claims priority to U.S. Provisional Patent Application No. 63 / 189,236, filed May 17, 2021, U.S. Provisional Patent Application No. 63 / 189,274, filed May 17, 2021, and U.S. Provisional Patent Application No. 17 / 739,727, filed May 9, 2022, the disclosures of which are incorporated herein in their entireties.

[0002] The present invention relates to the use of neural networks to edit computer code and software from a first state to a more efficiently modified second state, and more particularly to the use of neural network encoders to convert computer code and software from a first state to a modified second state. [Background technology]

[0003] A neural network encoder is a type of artificial neural network used to learn efficient coding of unlabeled data. An encoder can receive input data and convert it into state values. A decoder can map the encoded state values ​​to outputs. Machine translation is concerned with the automatic conversion of source text in one language into output text in another language, where an input sequence is processed to produce an output sequence.

[0004] Code editing in software engineering aims to modify the design, structure, functionality or implementation of existing programming code into a desired form. Refactoring transforms computer code into a new form that works similarly to before but is more efficient. Automated refactoring can remove unnecessary or redundant code without changing the functionality of the system, transform unstructured code into well-structured code, and transform procedural code into object-oriented code.

[0005] In computer programming, the decomposition paradigm is a strategy for organizing a program into multiple parts, usually meaning a particular way of organizing the program text. Few-shot learning is the problem of making predictions based on a limited number of examples. Summary of the Invention

[0006] According to one aspect of the present invention, a method for automated computer code editing is provided. The method includes training a code editing neural network model using a corpus of code editing data samples including pre-edit samples and post-edit samples, and parsing the pre-edit samples and post-edit samples into an Abstract Syntax Tree (AST). The method further includes converting the AST tree into a Unified Abstract Syntax Description Language (ASDL) graph for various programming languages ​​using a grammar specification, and computing a vector representation of each node in the Unified Abstract Syntax Description Language (ASDL) graph using a Gate Graph Neural Network (GGNN). The method further includes selecting and integrating supporting samples based on the query code using a multi-extent ensemble method, and iteratively modifying the query code using the code editing neural network model and the patterns learned from the pre-edit samples and post-edit samples.

[0007] According to another aspect of the present invention, there is provided a system for automated computer code editing, the system having one or more processors, a computer memory operatively connected to at least one of the one or more processors, and a computer display operatively connected to the at least one of the one or more processors and the computer memory, the computer memory including instruction codes for causing the computer system to train a code editing neural network model using a corpus of code editing data samples including pre-edit samples and post-edit samples, parse the pre-edit samples and the post-edit samples into an Abstract Syntax Tree (AST), convert the AST tree into a Unified Abstract Syntax Description Language (ASDL) graph for various programming languages ​​using a grammar specification, compute a vector representation of each node in the Unified Abstract Syntax Description Language (ASDL) graph using a Gate Graph Neural Network (GGNN), select and integrate supporting samples based on a query code using a multi-extent ensemble method, and iteratively modify the query code using the code editing neural network model and patterns learned from the pre-edit samples and the post-edit samples.

[0008] These and other features and advantages will become apparent from the following detailed description of exemplary embodiments, which is to be read in conjunction with the accompanying drawings.

[0009] In the present disclosure, preferred embodiments are described in detail with reference to the following drawings, as described below. [Brief description of the drawings]

[0010] [Figure 1] FIG. 1 is a block / flow diagram illustrating a high level system / method for a code edit from few-shot samples (CEFS) approach to address the code edit problem, in accordance with one embodiment of the present invention.

[0011] [Diagram 2]FIG. 2 is a block / flow diagram illustrating a system / method for synthesizing supporting samples based on a query code based on a multi-extent sample construction according to one embodiment of the present invention.

[0012] [Diagram 3] FIG. 3 is a block diagram illustrating a computer system / method for computer code refactoring of input computer code according to one embodiment of the present invention.

[0013] [Figure 4] FIG. 4 is a block diagram illustrating a computer system for computer code refactoring, according to one embodiment of the present invention. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0014] According to an embodiment of the present invention, a system and method are provided for a process of restructuring an existing computer code or programming language. In computer programming, it is of interest to refactor the code according to some instances that exhibit a particular editing pattern or coding style. Refactoring aims to improve the design, structure and / or implementation of the software while preserving its functionality. From a given code sample, the editing pattern can be adapted to a query code written with different content. Predetermined editing operations of the code samples in the support set can be combined to generate a new editing representation for editing the query code. The similarity of the code syntax tree can be evaluated between the query sample and the support sample before editing.

[0015] In one or more embodiments, a graph-based tree encoder can be utilized to modify computer code and software from a first state to a modified second state, where the second state operates in the same way as before, but is more efficient.

[0016] In a non-limiting exemplary embodiment,

[0017] Input: Both exemplars and new query code;

[0018] Pre-edit;

[0019] normalized = list(filter(lambda x; x is not None, map(harvester.normalize, harvested[:25])))

[0020] Post-edit:

[0021] normalized = list([x for x in map(harvester normalize, harvested[:25]) if x is not None])

[0022] New query:

[0023] chunk = filter(lambda x: x.feature == feature, ichunk

[0024] Output (edited code for new query using the learned pattern from exemplars):

[0025] chunk = [x for x in ichunk if x.feature == feature] It is.

[0026] In one or more embodiments, given a corpus of code edit data samples, including pre-edit and post-edit samples and their corresponding edit types, a code editing model learns from a few edits and transfers the knowledge (the ability to handle a task with a trained edit type) to unknown edit types for which training data is not available. Code in the same project may be uniform in some typical coding styles. To address the problem of code editing in a setting where only a few samples are available to show how to edit the code, a Code Editing Approach from Few-shot Samples (CEFS) is presented. A standard coding style can be automatically applied to a project, eliminating the need for human programmers to manually inspect the written computer code.

[0027] In various embodiments, the similarity with respect to the code syntax tree is evaluated before editing between the query sample and the support sample, and the similarity signal can be used for editing combination. In editing, some behaviors can be borrowed simply by the consistency of some individual nodes in the syntax tree, but some behaviors are environment-dependent. Therefore, we evaluate the multi-extent similarity between individual nodes and the set across the syntax tree.

[0028] In various embodiments, a C - and C for the desired output tree. + We can represent computer code using abstract syntax trees such as - Let C be the desired output tree. + Same editing method as shown

number

[0029] Query Sample

number

[0030] The Graph2Edit framework may include the following (1) to (3): (1) a graph-based tree encoder for an input abstract syntax tree C - A vector

number

number

number

[0031] Tree embedding history

number

number

[0032]

number

[0033]

number

[0034] Support Samples

number

number

[0035] In various embodiments, an evaluation of the similarity between the query sample and the support sample in the output space Z of the tree encoder is performed. A support set that maximizes the adoptability of the edited representation of the query sample from existing resources.

number

[0036] For example, Abstract Syntax Trees (ASTs) are often generated by compilers as they operate on code. Most compilers first generate an AST from the computer language they are compiling, then another piece of code reads the AST and generates new computer code from it. It is a syntax tree because it represents the syntax of the language. The syntax of something is the structure of its statements. Having valid syntax means that something has been written that makes sense according to the rules of a particular grammar.

[0037] It is possible to perform an evaluation of the similarity between the query sample and the support sample in the output space Z of the tree encoder, and to convert the evaluation value back to the support set

number

[0038] Based on code edits and abstract syntax trees, some edits of a node are selected based on its context, while some edits should not be affected by its neighbors. For example, bucket deletion should not be visible to the content inside. From this perspective, we design a multi-extent graph pooling evaluation that performs a sliding trade-off between matching of individual nodes and a collective tree representation.

[0039] However, such standard graph pooling tasks do not consider matching between individual nodes among samples.

[0040] Based on code edits and abstract syntax trees, some edits of a node are selected based on its context, while some edits should not be affected by its neighbors. For example, bucket deletion should not be visible to the content inside. From this perspective, we design a multi-extent graph pooling evaluation that performs a sliding trade-off between matching of individual nodes and a collective tree representation.

[0041] Instead of simply averaging all node representations, we design it to emphasize some individual nodes that match similar nodes in the opposite sample.

number

number

[0042]

number

[0043]

number

[0044] Where:

number

[0045]

number

[0046]

number

[0047] Based on the above individual node representations, a collective tree representation of one query sample and K support samples is obtained using weighted average pooling as shown below.

[0048]

number

[0049]

number

[0050] Where:

number

number

number

number

[0051] Using the collective tree representation, we obtain an updated tree representation that generates an expression for generating an edit expression for the following sample edit query:

[0052]

number

[0053] where φ(·,·) is the similarity measure for the query and support tree representations.

[0054] In a single extent, the robustness coefficient for the combination

number

number

number

[0055] However, when λ is arbitrarily set in the model construction, not all extents can provide a good tree representation, and some extents may not provide a good overall tree representation.

number

number

number

number

[0056] First, we evaluate the similarity between the query and the supported edit expressions using the cosine similarity measure:

[0057]

number

[0058] The error for each λ can be accessed by:

[0059]

number

[0060] where Γ(·) is the index mapping of K support samples such that sΓ(1)>sΓ(2)>...sΓ(k), i.e., s k is a mapping to sort the nearest support sample in descending order, and ρ is a margin set as a hyperparameter. This formula indicates how much better the nearest support sample is than other support samples, and the coefficient

number

number

[0061] Using multiple extents λ and the inverse of their errors, we can appropriately ensemble to form the following edit representation:

[0062]

number

[0063] We perform training as a meta-training process, optimizing the network over a series of training episodes, including one query example and a support set with K support examples. In training, we use the ground truth C + This provides the l λ We can explicitly compute and train a predictor R to approximate such a distribution.

[0064] In various embodiments, all the support samples and the query samples are included in one episode.

number

[0065]

number

[0066] Furthermore, simply l λ of

number

[0067]

number

[0068] L Y is equivalent to jointly maximizing the probability of each edit decoder module making the correct decision (predicting the operation and localizing the execution node and associated operation value) at each time step.

[0069] Reference is now made in detail to the drawing, FIG. 1, where like numerals represent the same or similar elements. FIG. 1 is a block / flow diagram illustrating a high level system / method for a Code Edit from Few-Shot Samples approach (CEFS) to address the code edit problem, in accordance with one embodiment of the present invention.

[0070] In block 110, the corpus data of query code snippets includes a set of query code snippets for each edit type. The query code is used as an initial input for code edits. In a training phase, both pre-edited and post-edited code snippets are provided for training purposes, while the pre-edited code snippet can be used in a testing phase. The edit samples, including the original and modified supporting code snippets, exhibit specific edit patterns, implying the edit intent of the query code snippet. A machine learning approach adapts the edit patterns derived from a small number of representative examples to the query code snippet.

[0071] In block 120, for each query code, a set of supporting code snippets is provided as edit samples. Both pre-edit and post-edit code snippets are provided in the training and testing phases. The supporting samples must belong to the same edit category.

[0072] In block 130, the code snippet is parsed into its Abstract Syntax Tree (AST) format, and the grammar specification is used to convert the AST format into Abstract Syntax Description Language (ASDL) format as an abstract representation graph of the code. The code snippet can be parsed into an Abstract Syntax Tree using a language-specific grammar. Abstract Syntax Description Language (ASDL) is a language designed to describe tree-like data structures. ASDL represents code as a syntactically meaningful syntax tree structure that goes beyond a sequence of programming tokens. The original AST tree is extended by adding bidirectional edges between parent and child nodes and adjacent sibling nodes. Graph2Edit uses an edit encoder to embed a sequence of edit actions and inputs it in a tree embedding of a portion of code. It then predicts the edit actions, edit positions and associated action values, and repeats the procedure in multiple steps.

[0073] A gated graph neural network (GGCN) is used to compute a vector representation of each node in the ASDL graph, at block 140. Average pooling can be used to represent the entire graph.

[0074] In block 150, given an edit pair, a vector representing the intent behind the edits can be learned, where the vector contains the information necessary to represent the edits, such as token-level differences between the pre-edit and post-edit code snippets. The edit representation can be learned by encoding a sequence of structural editing operations that transform the pre-edit and post-edit code.

[0075] In block 160, based on the edited representation of the support sample set generated in block 150, one can select to integrate support samples based on the query code in the steps of Query and Support Activation Learning, Collective Graph Representation Generation, and Multi-Extent Ensemble.

[0076] In various embodiments, a multi-extent ensemble method may be used to learn how to transform support samples based on features of the query code.

[0077] In block 170, the edit decoder predicts the operations using three components: an operator predictor, a node selector, and a node value predictor. At each time, the operator predictor determines an operator from four choices: Delete, Add, CopySubTree, and Stop. The node selector predicts a node from the tree and identifies a target location to apply one of the four operations. Finally, if the operation is Add or CopySubTree, the value predictor determines the additional value of these operators.

[0078] The process includes:

[0079] Step 1. Code preprocessing and parsing. In this step, we parse the code snippet into its Abstract Syntax Tree (AST) format and use the grammar specification to convert the AST tree into a unified graph for various programming languages.

[0080] Step 2. Graph-based code encoder: We use a gated graph neural network (GGCN) to compute a vector representation of each node in the ASDL graph.

[0081] Step 3. Sequential edit encoder. Given an edit pair, our goal is to learn a vector that represents the intent behind the edit, which contains the information needed to represent the edit.

[0082] Step 4. Multi-extent sample ensemble. To learn the transformation method, we use the multi-extent ensemble method to select and integrate supporting samples based on the query code.

[0083] Step 5. Edit Action Decoder: The edit decoder predicts edit actions in three aspects: the operator, the node position, and the corresponding node value.

[0084] FIG. 2 is a block / flow diagram illustrating a system / method for synthesizing supporting samples based on a query code using a multi-extent sample configuration, according to one embodiment of the present invention.

[0085] In block 210, activations are calculated for both the query sample and the support sample. In particular, the similarity assessment using one query sample and one support sample is performed as follows:

number

[0086]

number

[0087]

number

[0088] Where:

number

[0089] In block 220, a query and support activation is performed that generates a chord graph representation with additional variables to control intermediate positions between individual and collective graph attention. The enhanced query activation can be expressed as follows:

[0090]

number

[0091] A graph representation of the query code graph can be generated as follows:

[0092]

number

[0093]

number

[0094] Where:

number

[0095] In block 230, a multi-extent ensemble method is used to select and synthesize edited representations of the supporting samples. A multi-layer perceptron predictor R is used to select and synthesize the query code representation

number

number

number

[0096]

number

[0097] where Γ(·) is the k is an index mapping for sorting in descending order. Therefore, we can obtain a tree representation by adaptively ensembling the results from multiple extents as follows:

[0098]

number

[0099] The loss of a predictor R can be expressed as:

[0100]

number

[0101] This loss is combined with the decoder loss to train the full model in block 170. By simply referring to a limited set of code samples with different content but the same editing patterns, we can train a model that can automatically realize editing of new query samples.

[0102] FIG. 3 is a block diagram illustrating a computer system / method for computer code refactoring of input computer code according to one embodiment of the present invention.

[0103] In one or more embodiments, the original computer code 310 can be fed into a code refactorer 320, which outputs a modified version 330 of the input code, modified from the query code by iteratively using learned patterns that generate more efficient code from pre-edit and post-edit samples. The code refactorer 320 may include a trained graph neural network, which may include a graph-based code encoder and an edit operation decoder. The graph-based code encoder may use a gated graph neural network (GGCN) to compute a vector representation of each node in the ASDL graph.

[0104] FIG. 4 is a block diagram illustrating a computer system for computer code refactoring, according to one embodiment of the present invention.

[0105] In one or more embodiments, computer refactoring system 400 may include one or more processors 410, which may be a central processing unit (CPU), a graphics processing unit (GPU), or a combination thereof, and computer memory 420 in communication with one or more processors 410. Computer memory 420 may be a random access memory (RAM), a solid state drive (SSD), a hard disk drive (HDD), an optical disk drive (ODD), or the like. Memory 420 may be configured to store code snippets 470, a code parser 460, and a refactorer 450. Code snippets 470 may be query code snippets and / or sample code snippets. Code parser 460 may be configured to parse code snippets into an abstract syntax tree (AST) format and convert the AST format into an abstract syntax description language (ASDL) format using a grammar specification as an abstract representation graph of the code. The refactorer 450 can be configured to generate new computer code from the input code using a trained neural network implementing the sequential edit encoder 150 with the code graph-based encoder 140 and the edit operation decoder 170. The multi-extent sample ensemble 160 can select and synthesize supporting samples based on the query code. The computer display module 430 can present the original code and the modified code to a user. The memory 420 and the one or more processors 410 can be in electrical communication with the display device 430 via the system bus 415 and the I / O controller, and the display device 430 can present the output of the refactorer 450 to a user.

[0106] The embodiments described herein may be implemented entirely in hardware, entirely in software, or contain both hardware and software elements, in a preferred embodiment, the invention is implemented in software, which includes but is not limited to firmware, resident software, microcode, etc.

[0107] An embodiment may include a computer program product accessible from a computer usable or computer readable medium that provides program code for use by or in connection with a computer or any instruction execution system. A computer usable or computer readable medium may include any device that stores, conveys, propagates, or transfers a program for use by or in connection with an instruction execution system, device, or apparatus. The medium may be a magnetic, optical, electronic, electromagnetic, infrared, or semiconductor system (or device or apparatus), or a propagation medium. The medium may include computer readable media such as semiconductor or solid state memory, magnetic tape, removable computer diskettes, random access memory (RAM), read-only memory (ROM), rigid magnetic disk, and optical disk.

[0108] Each computer program is stored in a machine-readable recording medium or device (e.g., a program memory or a magnetic disk) that can be read by a general-purpose or special-purpose programmable computer. The computer program is read from the recording medium or device by a computer that executes the procedures described herein for configuring and controlling operations of the computer. The system of the present invention also contemplates a computer-readable recording medium that includes a computer program configured to cause a computer to operate in a specific and predefined manner to perform the functions described herein.

[0109] A data processing system suitable for storing and / or executing program code may include at least one processor coupled directly or indirectly to memory elements via a system bus. The memory elements may include local memory, bulk memory devices, and cache memory for temporarily storing at least some program code used during the actual execution of the program code to reduce the number of times code is retrieved from bulk memory devices during execution of a process. Input / output or I / O devices (including but not limited to keyboards, displays, pointing devices, etc.) may be connected to the system either directly or through I / O controllers.

[0110] Network adapters may be coupled with the data processing system to enable the system to be coupled to other data processing systems or remote printers or memory devices through private or public networks. Modems, cable modems and Ethernet cards are just a few of the currently available types of network adapters.

[0111] As used herein, the term "hardware processor subsystem" or "hardware processor" may refer to a processor, memory, software, or combination thereof that cooperate to perform one or more specific tasks. In useful embodiments, the hardware processor subsystem may include one or more data processing elements (e.g., logic circuits, processing circuits, instruction execution units, etc.). The one or more data processing elements may include a central processing unit, a graphics processing unit, and / or individual processors or computing element-based controllers (e.g., logic gates, etc.). The hardware processor subsystem may include one or more on-board memories (e.g., caches, dedicated memory arrays, read-only memories, etc.). In any embodiment, the hardware processor subsystem may include one or more memories that may be on-board or off-board, or may be dedicated for use with the hardware processor subsystem (e.g., ROM, RAM, Basic Input / Output System (BIOS), etc.).

[0112] In some embodiments, the hardware processor subsystem may include and execute one or more software elements, which may include an operating system and / or one or more applications and / or specific code for achieving a particular result.

[0113] In other embodiments, the hardware processor subsystem may include dedicated circuitry to perform one or more electronic processing functions to achieve a specified result. Such circuitry may include one or more application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), and / or programmable logic arrays (PLAs).

[0114] These and other variations of the hardware processor subsystem are also contemplated by embodiments of the present invention.

[0115] Reference herein to "one embodiment" or "one embodiment," as well as other variations, of the invention means that a particular feature, configuration, characteristic, etc. described in connection with an embodiment is included in at least one embodiment of the invention. Thus, appearances of the phrases "in one embodiment" or "in an embodiment," as well as any other variations appearing in various places throughout this specification, are not necessarily all referring to the same embodiment. However, it should be understood that given the teachings of the invention provided herein, features of one or more embodiments may be combined.

[0116] For example, the use of any of "A / B," "A and / or B," and "at least one of A and B" should be understood to be intended to include the selection of only the first listed option (A), the selection of only the second listed option (B), or the selection of both options (A and B). By way of further example, in the case of "A, B, and / or C" and "at least one of A, B, and C," such language is intended to include the selection of only the first listed option (A), the selection of only the second listed option (B), the selection of only the third listed option (C), the selection of only the first and second listed options (A and B), the selection of only the first and third listed options (A and C), the selection of only the second and third listed options (B and C), or the selection of all three options (A, B, and C). The above examples may be expanded depending on the number of items listed.

[0117] The foregoing should be understood in all respects as illustrative and exemplary, and not restrictive, and the scope of the invention disclosed herein should be determined not from the detailed description, but from the claims which are to be interpreted in accordance with the broadest possible interpretation permitted by the Patent Law. It should be understood that the embodiments shown and described herein are merely illustrative of the principles of the invention, and that various modifications may be made by those skilled in the art without departing from the scope and spirit of the invention. Various other feature combinations may be implemented by those skilled in the art without departing from the scope and spirit of the invention. Although aspects of the invention have been described above with the fine detail and particularity required by the Patent Law, the scope of the claims which are sought to be protected by Letters Patent are set forth in the appended claims.

Claims

1. 1. A computer-implemented method for automated computer code editing, comprising: training a code edit neural network model (320) using a corpus of code edited data samples including pre-edited samples (110) and post-edited samples (120); Parsing (130) the pre-edited sample and the post-edited sample into an Abstract Syntax Tree (AST); Transforming (130) the AST tree into a unified Abstract Syntax Description Language (ASDL) graph for various programming languages ​​using the grammar specification; computing a vector representation (140, 150) of each node in the Unified Abstract Syntax Description Language (ASDL) graph using a Gate Graph Neural Network (GGNN) (320); selecting and integrating support samples based on the query code using a multi-extent ensemble method (160); and iteratively modifying (170) a query code using the code editing neural network model and patterns learned from the pre-edited samples and the post-edited samples.

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

3. The computer-implemented method of claim 2 , wherein the corpus data of query code snippets 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. 5. The computer-implemented method of claim 4, wherein the query code is a set of supporting code snippets that serve as edit samples for both the before-edit and after-edit code snippets during training.

6. 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. 7. The computer-implemented method of claim 6, further comprising the step of representing the entire graph using average pooling.

8. The computer-implemented method of claim 7 further comprising the step of computing activations for the query samples and the support samples.

9. The activation of the query sample comprises: [0010] is given by The activation of the support sample comprises: [0025] 9. The computer-implemented method of claim 8, wherein:

10. The graph representation of the query code graph may be [0030] and the graph representation of the support code graph is generated by [0045] 10. The computer-implemented method of claim 9, wherein the method is generated by:

11. 1. A computer system (400) for automated computer code editing, comprising: One or more processors (410); a computer memory (420) operatively connected to at least one of the one or more processors (410); a computer display device (430) operatively connected to at least one of the one or more processors and to the computer memory; and the computer memory includes, in the computer system: training a code edit neural network model (320) using a corpus of code edited data samples including pre-edited samples (110) and post-edited samples (120); Parsing (130) the pre-edited sample and the post-edited sample into an Abstract Syntax Tree (AST); Transforming (130) the AST tree into a unified Abstract Syntax Description Language (ASDL) graph for various programming languages ​​using the grammar specification; computing a vector representation (140, 150) of each node in the Unified Abstract Syntax Description Language (ASDL) graph using a Gate Graph Neural Network (GGNN) (320); selecting and integrating support samples based on the query code using a multi-extent ensemble method (160); Iteratively modifying (170) the query code using the code editing neural network model and patterns learned from the pre-edited and post-edited samples; The computer system includes instruction codes for executing the following:

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

13. The query code snippet corpus data includes a set of query code snippets for each edit type.

13. The computer system of claim 12.

14. 14. The computer system of claim 13, further comprising instruction code for causing the computer system to execute the step of inputting the query code as an initial input for code editing.

15. 15. The computer system of claim 14, wherein the query code is a set of supporting code snippets that serve as edit samples for both the before-edit code snippet and the after-edit code snippet during training.

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

17. 20. The computer system of claim 16, further comprising instruction code for causing the computer system to represent an entire graph using average pooling.

18. 20. The computer system of claim 17, further comprising instruction code for causing the computer system to perform the step of calculating activations for query samples and support samples.

19. The activation of the query sample comprises: [0050] is given by The activation of the support sample comprises: [006] 20. The computer system of claim 18, wherein: each.

20. The graph representation of the query code graph may be [0070] and the graph representation of the support code graph is generated by [0080] 20. The computer system of claim 19,

Citation Information

Patent Citations

  • Query optimizer for CPU utilization and code refactoring

    US20170351512A1

  • Automated identification of code changes

    WO2020236744A1