Source code judgment model creating device, source code judgment device, source code judgment model creating method, source code judgment method, and source code judgment system
The source code judgment model effectively evaluates complex editing operations by vectorizing editing processes and source code changes, enhancing defect detection and software reliability.
Patent Information
- Application Number
- JP2022069374
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2022-04-20
- Publication Date
- 2025-11-06
- Estimated Expiration
- 2042-04-20
AI Technical Summary
Existing technologies fail to effectively evaluate complex editing operations in source code, leading to undetected software defects.
A method for creating a source code judgment model that vectorizes editing processes and source code changes, using machine learning to identify defects by analyzing the relationship between pre-edit and post-edit source code graphs.
Enables detection of defects in source code resulting from complex editing operations, improving software reliability by accurately identifying issues.
Smart Images

Figure 0007765342000001 
Figure 0007765342000002 
Figure 0007765342000003
Abstract
Description
[Technical Field]
[0001] The present invention relates to a source code judgment model creating device, a source code judgment device, a source code judgment model creating method, a source code judgment method, and a source code judgment system. [Background technology]
[0002] Software defects are often caused by operational errors when editing the source code. Editing source code (in this specification, "editing" refers to editing a unit of work, such as recording a single commit in a repository) is usually done with multiple intentions (tangled changes), so editing source code involves multiple operations. Unexpected software malfunctions are often caused by editing that involves multiple operations like this.
[0003] As a technology related to source code analysis, Patent Document 1 discloses that an information processing device automatically creates improvement plans for function and file dependencies (GA unit), evaluates the improved dependencies (AI unit), and outputs an improved dependency graph in order to improve dependencies in a computer program by moving functions between files or moving files between folders.
[0004] Furthermore, Patent Document 2 describes that in order to determine bugs in source code, a source code evaluation device performs machine learning by generating vectors in which numerical values defined according to the type of each lexical phrase in the difference before and after a change in source code are arranged in the order of each lexical phrase in the description of the difference, sets a window containing a predetermined number of lexical phrases for the source code to be evaluated, generates a vector for each lexical phrase contained in the window, and evaluates the possibility that the description within the window contains a bug based on the generated vectors and the learning results. [Prior art documents] [Patent documents]
[0005] [Patent Document 1] Patent Publication No. 2021-81913 [Patent Document 2] Japanese Patent Application Publication No. 2019-21037 Summary of the Invention [Problem to be solved by the invention]
[0006] In Patent Document 1, source code is evaluated by graphing the source code, but it does not evaluate changes to the source code. On the other hand, in Patent Document 2, bugs are identified by machine learning based on the lexical content of source code differences, but if the source code differences contain multiple intentions (operations), they cannot be evaluated. As such, there is not enough technology available to appropriately evaluate various edits to source code.
[0007] The present invention has been made in consideration of the above circumstances, and its object is to provide a source code judgment model creation device, a source code judgment device, a source code judgment model creation method, a source code judgment method, and a source code judgment system that are capable of detecting defects that occur in source code due to complex editing operations. [Means for solving the problem]
[0008] One aspect of the present invention for solving the above problem is to provide a method for editing source code before editing and a method for editing source code after editing. and a processing unit that identifies an editing process from the unedited source code to the edited source code, creates an editing operation column vector that is information obtained by vectorizing the identified editing process, creates a pre-edit source code vector that is information obtained by vectorizing the unedited source code, and creates a trained model that stores the relationship between the editing operation column vector, the pre-edit source code vector, and the training information.
[0009] Another aspect of the present invention for solving the above-described problem is a source code judgment device including: a storage device that stores a trained model that stores a relationship between an editing operation column vector, which is information obtained by vectorizing the editing process from pre-edited source code to edited source code; a pre-edit source code vector, which is information obtained by vectorizing the pre-edited source code; and teacher information that indicates whether a defect has occurred in the edited source code due to editing; and a processing device that accepts input from a user of a pre-edit source code for determination, which is the source code before editing, and a post-edit source code for determination, which is the source code after editing, identifies the editing process from the pre-edit source code for determination to the post-edit source code for determination, creates a pre-edit operation column vector for judgment, which is information obtained by vectorizing the identified editing process, and creates a pre-edit source code vector for determination, which is information obtained by vectorizing the pre-edit source code for determination, and inputs the editing operation column vector for judgment and the pre-edit source code vector for judgment into the trained model, thereby outputting information that indicates whether a defect has occurred in the post-edit source code for determination. [Effects of the Invention]
[0010] According to the present invention, defects that occur in source code due to complex editing operations can be detected. Configurations and effects other than those described above will become apparent from the following description of the embodiments. [Brief explanation of the drawings]
[0011] [Figure 1] 1 is a diagram illustrating an example of a configuration of a source code determination system according to an embodiment of the present invention. [Figure 2] FIG. 2 is a diagram illustrating an example of functional units included in the source code judgment model generation device. [Figure 3] FIG. 2 is a diagram illustrating an example of functional units included in a source code determination device. [Figure 4] FIG. 2 illustrates an example of hardware included in the source code judgment model generation device. [Figure 5] FIG. 1 is a diagram illustrating an outline of processing performed in a source code determination system. [Figure 6] FIG. 10 is a flow diagram illustrating a learning process. [Figure 7] FIG. 10 is a diagram illustrating an example of unedited learning source code. [Figure 8] FIG. 10 is a diagram illustrating an example of edited source code for learning. [Figure 9] FIG. 10 is a diagram showing an example of an AST (pre-editing AST) created from pre-editing learning source code. [Figure 10] FIG. 9 is a diagram showing an example of an AST (edited AST) created from the edited learning source code shown in FIG. 8. [Figure 11] FIG. 11 is a diagram showing an example of a learning graph editing operation sequence created from the pre-editing AST and post-editing AST shown in FIGS. [Figure 12] FIG. 10 is a diagram showing another example of edited learning source code containing a bug. [Figure 13] FIG. 13 is a diagram showing an example of an edited AST for learning created from the edited source code for learning shown in FIG. 12. [Figure 14] FIG. 14 is a diagram showing an example of a training graph editing operation sequence created from the training pre-editing AST and training post-editing AST shown in FIGS. [Figure 15] FIG. 10 is a diagram showing an example of edited learning source code that does not contain bugs. [Figure 16]FIG. 16 is a diagram showing an example of an edited AST for learning created from the edited source code for learning shown in FIG. 15. [Figure 17] FIG. 17 is a diagram showing an example (part) of a training graph editing operation sequence created from the training pre-editing AST and training post-editing AST shown in FIGS. [Figure 18] FIG. 10 is a diagram showing another example of edited learning source code that does not contain bugs. [Figure 19] FIG. 19 is a diagram showing an example of an edited AST created from the edited learning source code shown in FIG. 18. [Figure 20] FIG. 20 is a diagram showing an example (part) of a training graph editing operation sequence created from the training pre-editing AST and training post-editing AST shown in FIGS. [Figure 21] An example in which the graph editing operation column D shown in FIG. 20 is converted into an editing operation column vector will be shown below. [Figure 22] FIG. 10 is a diagram illustrating an example of a method for learning a source code determination model. [Figure 23] FIG. 10 is a flow diagram illustrating a determination process. DETAILED DESCRIPTION OF THE INVENTION
[0012] An embodiment of the present invention will be described with reference to the drawings. 1 is a diagram showing an example of the configuration of a source code judgment system 1 according to this embodiment. The source code judgment system 1 includes information processing devices: a source code judgment model creation device 10 that creates a source code judgment model, which is a trained model for determining whether or not a defect exists in source code; a user terminal 20 used by a user who develops source code; and a source code judgment device 30 that determines whether or not a defect exists in source code specified by the user using the source code judgment model.
[0013] The source code judgment model generating device 10, the user terminal 20, and the source code judgment device 30 can communicate with each other through a wired or wireless communication network 5 such as the Internet, a LAN (Local Area Network), a WAN (Wide Area Network), or a dedicated line. are.
[0014] FIG. 2 is a diagram illustrating an example of functional units included in the source code decision model generating device 10. As shown in FIG. The source code judgment model creation device 10 includes functional units, namely, an unedited source code input unit for learning 101, an edited source code input unit for learning 102, a source code graphing unit for learning 103, a graph editing operation sequence generation unit for learning 104, a graph editing operation sequence vectorization unit for learning 105, a teacher information input unit 106, a data accumulation unit 107, and a learning unit 108.
[0015] The learning source code pre-edit input unit 101 accepts input of source code created by the user in the past before editing (hereinafter referred to as learning source code pre-edit). Note that in this embodiment, editing means changing the source code in units of commits to the repository (i.e., including multiple editing operations (add, delete, change, move, etc.)).
[0016] The source code consists of one or more process group descriptions (hereinafter referred to as process blocks). Each process block consists of one or more process descriptions. There is also a certain logical relationship between the process blocks (for example, one process block depends on the other process block (parent element and child element relationship), or one process block includes the other process block).
[0017] The edited learning source code input unit 102 accepts input of edited source code (hereinafter referred to as edited learning source code) from among source codes previously created by the user.
[0018] The learning source code graphing unit 103 generates graphed data of the learning pre-edit source code and the learning post-edit source code (hereinafter referred to as learning pre-edit source code graph data and learning post-edit source code graph data, respectively). These graphed data are data consisting of a set of nodes and edges. A node corresponds to a process (or a process block), and an edge corresponds to a logical relationship between processes (or between process blocks).
[0019] The learning graph editing operation sequence generation unit 104 generates information indicating the editing process from the learning pre-edit source code to the learning post-edit source code (hereinafter referred to as the learning graph editing operation sequence) based on the learning pre-edit source code graph data and the learning post-edit source code graph data. In this embodiment, the learning graph editing operation sequence is discrete data including a combination of the type of editing and the edit target.
[0020] Learning graph editing operation column vectorization unit 105 creates data obtained by vectorizing the learning graph editing operation column (hereinafter referred to as a learning editing operation column vector).
[0021] Furthermore, the learning graph edit operation column vectorization unit 105 creates data obtained by vectorizing the learning pre-edit source code graph data (hereinafter referred to as learning pre-edit source code vector).
[0022] The training information input unit 106 receives input of information (hereinafter referred to as training information) indicating whether or not a defect (bug) has occurred in the source code as a result of editing the source code from the pre-edit source code to the edited source code.
[0023] The data storage unit 107 stores the learning editing operation column vector, the learning unedited source code vector, and the teaching information.
[0024] The learning unit 108 performs predetermined machine learning to create a learned model that stores the relationship between the learning editing operation column vector, the learning unedited source code vector, and the learning teacher information.
[0025] Next, FIG. 3 is a diagram illustrating an example of functional units included in the source code determination device 30. As shown in FIG. The source code determination device 30 includes functional units, namely, a pre-edited source code input unit for determination 301, a post-edited source code input unit for determination 302, a source code graphing unit for determination 303, a graph editing operation sequence generation unit for determination 304, a graph editing operation sequence vectorization unit for determination 305, a determination unit 306, and a result output unit 307.
[0026] The pre-edit source code for judgment input unit 301 accepts input of source code before editing performed by a user (hereinafter referred to as pre-edit source code for judgment).
[0027] The edited source code for judgment input unit 302 accepts input of source code after editing performed by the user (hereinafter referred to as edited source code for judgment).
[0028] The source code graphing unit for judgment 303 generates graphed data of the pre-edit source code and the post-edit source code (hereinafter referred to as pre-edit source code graph data for judgment and post-edit source code graph data for judgment, respectively). This graphed data is data consisting of a set of nodes and edges. A node represents a process (or process The edges correspond to logical relationships between processes (or processing blocks).
[0029] The determination graph editing operation sequence generation unit 304 generates information indicating the editing process from the determination pre-edit source code to the determination post-edit source code (hereinafter referred to as a determination graph editing operation sequence) based on the determination pre-edit source code graph data and the determination post-edit source code graph data. In this embodiment, the determination graph editing operation sequence is discrete data including a combination of the type of edit and the edit target.
[0030] The determination graph editing operation column vectorization unit 305 creates data obtained by vectorizing the determination graph editing operation column (hereinafter referred to as a determination editing operation column vector).
[0031] Furthermore, the learning graph edit operation column vectorization unit 105 creates data obtained by vectorizing the pre-edit source code graph data for judgment (hereinafter referred to as pre-edit source code vector for judgment).
[0032] The judgment unit 306 inputs the pre-edit source code vector for judgment and the editing operation column vector for judgment into the source code judgment model created by the learning unit 108 of the source code judgment model creation device 10, and outputs information indicating whether or not a defect (bug) has occurred in the post-edit source code for judgment due to editing of the pre-edit source code for judgment.
[0033] The result output unit 307 displays the information output by the determination unit 306 on the screen.
[0034] 4 is a diagram showing an example of hardware included in the source code judgment model generation device 10. The source code judgment model generation device 10 includes a processing device 41 (processor) such as a CPU (Central Processing Unit), a DSP (Digital Signal Processor), a GPU (Graphics Processing Unit), or an FPGA (Field-Programmable Gate Array), a main storage device 42 (memory) such as a ROM (Read Only Memory) or a RAM (Random Access Memory), an auxiliary storage device 43 such as an HDD (Hard Disk Drive) or an SSD (Solid State Drive), a NIC (Network Interface Card), an The user terminal 20 and the source code judgment device 30 may include a communication device 44 configured with a wired communication module, a USB (Universal Serial Interface) module, a serial communication module, or the like, an input device 45 configured with a mouse, a keyboard, or the like, and an output device 46 configured with a liquid crystal display, an organic EL (Electro-Luminescence) display, or the like. Note that the user terminal 20 and the source code judgment device 30 also include the same hardware as that of the source code judgment model creation device 10.
[0035] The functions of the functional units of each of the information processing devices of the source code judgment model creation device 10, the user terminal 20, and the source code judgment device 30 described above are realized by the processing device reading and executing a program stored in a main storage device or an auxiliary storage device. The above programs can be recorded on a recording medium and distributed, for example. Note that all or part of each information processing device may be realized using virtual information processing resources provided using virtualization technology, process space separation technology, or the like, such as a virtual server provided by a cloud system. Furthermore, all or part of the functions provided by each information processing device may be realized by a service provided by a cloud system via an API (Application Programming Interface), for example.
[0036] Next, the processing performed by the source code determination system 1 will be described. 5 is a diagram illustrating an outline of the processing performed by the source code determination system 1. First, the source code determination model creation device 10 executes a learning process s10 to create a source code determination model based on the unedited source code for learning and the edited source code for learning.
[0037] Thereafter, the source code judgment device 30 receives designation of the pre-edit source code for judgment and the post-edit source code for judgment from the user, and executes judgment process s20 to judge whether or not a defect (bug) has occurred due to editing of the source code for judgment, based on the pre-edit source code for judgment and the post-edit source code for judgment and the source code judgment model created in the learning process s10. The learning process s10 and the determination process s20 may each be repeatedly executed multiple times.
[0038] Next, the learning process s10 will be described in detail. <Learning process> FIG. 6 is a flow diagram illustrating the learning process s10.
[0039] First, the learning-use unedited source code input unit 101 accepts input of learning-use unedited source code from a user (s101). Also, the learning-use edited source code input unit 102 accepts input of learning-use edited source code from a user (s102).
[0040] For example, the source code determination device 30 displays a predetermined input screen on the user terminal 20 and receives designations from the user of the files of the unedited learning source code and the edited learning source code.
[0041] (Unedited source code for learning purposes) 7 is a diagram showing an example of a pre-edit source code for learning. This pre-edit source code for learning 500 describes processes such as variable declaration, conditional branching, variable value assignment, and calculations. In this pre-edit source code for learning 500, a division 502 "g = g / a;" relating to a variable is described within a processing block 501 relating to a conditional branch "if (a > 1)" using the variable. Therefore, in this pre-edit source code for learning 500, There is no bug regarding the variable a.
[0042] (Edited source code for learning purposes) 8 is a diagram showing an example of edited learning source code. In this edited learning source code 510, compared to the unedited learning source code 500 in FIG. 7, the division 512 "g = g / a;" has been moved outside the processing block 511 related to the conditional branch "if (a > 1)". Therefore, the edited learning source code 510 has a bug related to the variable a.
[0043] 6, the learning source code graphing unit 103 graphs the learning pre-edit source code and the learning post-edit source code, respectively, to generate learning pre-edit source code graph data and learning post-edit source code graph data (s103, s104). In this embodiment, the learning source code graphing unit 103 generates graph data of an Abstract Syntax Tree (AST).
[0044] (Pre-edited AST) 9 is a diagram showing an example of an AST (pre-edit AST) created from the pre-edit source code for learning. This pre-edit AST 520 is data obtained by removing descriptions (e.g., parentheses, spaces, and comments) that are not necessary for identifying the processing content from the pre-edit source code for learning, and extracting dependencies between processes (or processing blocks) (e.g., whether or not a process is executed depends on another process, or a variable used in one process is used in another process).
[0045] Specifically, the pre-edit AST 520 includes a line 521 of a node corresponding to each process of the pre-edit learning source code. The block is indented (tabbed) by an amount corresponding to the block. The amount of indentation 522 indicates the logical relationship with other processing blocks (for example, the relationship between a parent element and a child element).
[0046] For example, in the pre-edit AST 520, the indentation amount of the line 523 (child element) corresponding to the division 502 "g = g / a;" line in the pre-edit source code shown in FIG. 7 is The indentation is larger than the indentation of line 524 (parent element) corresponding to the line of the conditional branch "if (a > 1)" in the code. Also, the semicolon information in division 502 has been removed.
[0047] (Edited by AST) Next, FIG. 10 is a diagram showing an example of an AST (edited AST) created from the edited learning source code 510 shown in FIG. 8. In this edited AST 530, the division "g = g / a;" has been moved to the back position (the symbol No. 531).
[0048] The above pre-edited and post-edited ASTs can be generated using, for example, the pycparser library of Python. It can be created using
[0049] Furthermore, the method of creating graph data using AST described here is just one example, and for example, a program dependency graph (PDG) may also be used.
[0050] Next, as shown in FIG. 6, the learning graph editing operation sequence vectorization unit 105 creates a graph editing operation sequence indicating changes from the learning pre-editing source code graph data to the learning post-editing source code graph data, based on the learning pre-editing source code graph data and the learning post-editing source code graph data created in s103 and s104 (s105).
[0051] In this embodiment, the learning graph editing operation sequence is made up of first information indicating the type of editing operation and second information indicating the processing part that is the target of the editing. The first information includes "Move" indicating movement, "Add" indicating addition, "Remove" indicating deletion, and "Remove" indicating a variable or function. It is assumed that there is "Rename" which indicates a change in the name of a number, etc. The second information is assumed to be the same as the description of each process in the pre-edit source code graph data for learning or the post-edit source code graph data for learning.
[0052] (Learn graph editing operation sequence) 11 is a diagram showing an example of a learning graph editing operation sequence created from the pre-editing AST 520 and post-editing AST 530 shown in FIGS. 9 and 10. This learning graph editing operation sequence 540 (hereinafter also referred to as graph editing operation sequence A) includes a description portion 541 of "Move" as first information, and a processing block of division "g = g / a;" whose description position has been moved as second information. and a description portion 542 of the
[0053] Here, other examples of the edited learning source code, the edited learning AST, and the learning graph editing operation sequence will be described.
[0054] (Other source code where the bug exists) 12 is a diagram showing another example of edited learning source code containing a bug. In this edited learning source code 550, a new division 551 "g = g / a;" has been added, which is a copy of the division 502 "g = g / a;" in the unedited learning source code 500. However, since this new division 551 has been copied outside the processing block 552 related to the conditional branch "if (a > 1)", the edited learning source code 550 does not contain a bug related to a. do.
[0055] 13 is a diagram showing an example of an edited AST for learning created from the edited learning source code 550 shown in FIG. 12. This edited AST for learning 560 contains a description 562 that is the same as a description 561 of the division "g = g / a;" that also exists in the unedited learning AST 520, as follows: It is added in a later position (specifically, outside the conditional branch "if ( a > 1 )").
[0056] 14 is a diagram showing an example of a learning graph editing operation sequence created from the pre-editing learning AST and the post-editing learning AST shown in FIGS. 9 and 13. This learning graph editing operation sequence 570 (hereinafter also referred to as graph editing operation sequence B) includes "Add" (first information 571) indicating the addition of a process. and second information 572 indicating the processing portion to be added ("g = g / a ;"). Next, the edited learning source code that does not contain any bugs will be described.
[0057] (Bug-free source code-1) FIG. 15 is a diagram showing an example of edited learning source code that does not contain any bugs. Compared to the unedited learning source code 500, this edited learning source code 580 has a new conditional branch "if (a > 1)" processing block 581 and a new division 582 "g = g / a;" added to the processing block 581. Therefore, this edited learning source code Source code 580 is bug-free.
[0058] Fig. 16 is a diagram showing an example of an edited AST for learning created from the edited source code for learning shown in Fig. 15. Compared to the unedited AST for learning 520, this edited AST for learning 590 has a description portion 591 of the processing block of the conditional branch "if (a > 1)" added, and the description portion 591 has an indented description corresponding to the division "g = g / a;" There is a portion 592.
[0059] FIG. 17 is a diagram showing an example (part) of a learning graph editing operation sequence created from the learning pre-editing AST and learning post-editing AST shown in FIGS. 9 and 16. This learning graph editing operation sequence 600 (hereinafter also referred to as graph editing operation sequence C) includes "Add" (first information 600) indicating addition. 1) and second information 602 indicating each processing portion to be added.
[0060] (Bug-free source code-2) 18 is a diagram showing another example of edited learning source code that does not contain any bugs. In this edited learning source code 610, a processing block 612 of a conditional branch "if (a != 0)" that targets the entire processing block 611 that existed in the unedited learning source code 500, and a new division processing 613 of "g = g / a;" within this processing block 612 have been added. Since this process 613 exists within the process block 612 of the conditional branch "if (a != 0)", there is no bug in this edited learning source code 610.
[0061] Fig. 19 is a diagram showing an example of an edited AST created from the edited learning source code shown in Fig. 18. Compared to the unedited AST 520, this edited AST 620 has a new conditional branch "if (a != 0)" processing block 621 and a new division "g = g / a;" A description section 622 has been added.
[0062] 20 is a diagram showing an example (part) of a learning graph editing operation sequence created from the learning pre-editing AST and learning post-editing AST shown in FIGS. 9 and 19. This learning graph editing operation sequence 630 (hereinafter also referred to as graph editing operation sequence D) includes an operation sequence portion 631 consisting of the addition of each process related to conditional branching ("Add") and a portion describing the target of the addition ("if (a != 0)"). It includes an operation sequence part 632 that moves ("Move") the description indicated by the operation sequence part 631 to a predetermined position, and an operation sequence part 633 consisting of an addition of division ("Add") and a part that describes the target of the addition ("g = g / a;").
[0063] The method of describing the graph editing operation sequence is not limited to the above, but may be any method that allows at least the type of editing and the target of editing to be specified.
[0064] Next, as shown in FIG. 6, the learning graph edit operation column vectorization unit 105 creates a learning pre-edit source code vector by converting the learning pre-edit source code graph data into a vector (s106).
[0065] For example, the learning graph editing operation column vectorization unit 105 creates vector data by identifying the strength of the relationship between each node in the learning pre-edit source code graph data. Note that in this embodiment, the learning graph editing operation column vectorization unit 105 creates vector data using node2vec, but other methods may be used. For example, the learning graph editing operation column vectorization unit 105 may convert the graph data into a continuous vector space by assigning each node (and edge) in the graph data to a specific position in the vector space.
[0066] Furthermore, in s106, learning graph editing operation column vectorization unit 105 creates a learning editing operation column vector by converting the learning graph editing operation column created in s105 into a vector.
[0067] For example, the learning graph edit operation sequence vectorization unit 105 encodes the type of edit operation (first information) in the learning graph edit operation sequence (for example, Add is 0, Move is 1, Remove is is set to 2, and Rename is set to 3). In addition, the learning graph edit operation column vectorization unit 105 sets a numerical value for each operation target (second information) (different numerical values are assigned to different types of processing targets).
[0068] Fig. 21 shows an example in which the graph editing operation sequence D shown in Fig. 20 is converted into an editing operation column vector. As shown in the figure, this editing operation column vector 640 is data corresponding to a learning graph editing operation sequence 641, and is configured to include one or more sets 646 of numerical values 643 corresponding to first information 642 of learning graph editing operation sequence 641 and numerical values 645 corresponding to second information 644. Note that the method of describing the editing operation column vector shown in the figure is just one example, and other formats of vector data may also be used (for example, by swapping the vector matrix).
[0069] 6, the teacher information input unit 106 receives input of teacher information associated with the unedited learning source code and the edited learning source code (s107). For example, the teacher information input unit 106 causes the user terminal 20 to display a predetermined input screen showing the unedited learning source code and the edited learning source code, and receives input of teacher information (whether there is a defect or not) from the user.
[0070] Then, the data storage unit 107 associates the learning editing operation column vector and learning unedited source code vector created in s106 with the teaching information input in s107 and stores them in a predetermined database (s108). The source code decision model generating device 10 repeats the above-described processes from s101 to s108 multiple times.
[0071] Thereafter, the learning unit 108 creates a source code determination model by machine learning the relationship between the edit operation column vectors accumulated in s108, the learning pre-edit source code vectors, and the training information.
[0072] In this embodiment, this machine learning is performed by creating a BERT (Bidirectional Encoder Representations from Transformers) model. BERT is a model that uses a vector input layer and It is a neural network with a hidden layer and an output layer, and a Transformer as a hidden layer. The learning unit 108 stores the created source code judgment model, and the learning process s10 is now complete.
[0073] In this embodiment, as described above, BERT is used as the machine learning model, but other machine learning models may be adopted as long as they are models that realize natural language processing that can take into account the relationship between words (tokens) that are distant from each other in the description, i.e., the context.
[0074] 22 is a diagram illustrating an example of a method for learning a judgment model. The learning unit 108 generates and stores feature vectors consisting of a learning pre-editing source code vector 701 and a learning editing operation column vector 702 (a learning editing operation column vector 702A related to graph editing operation sequence A, a learning editing operation column vector 702B related to graph editing operation sequence B, a learning editing operation column vector 702C related to graph editing operation sequence C, and a learning editing operation column vector 702D related to graph editing operation sequence D, etc.). The learning unit 108 then classifies and stores each feature vector based on the generated feature vector and corresponding teacher information 703 (whether or not there is a defect). Next, the determination process s20 will be described. <Determination process>
[0075] Next, FIG. 23 is a flow diagram illustrating the determination process s20. First, the judgment-use unedited source code input unit 301 accepts input of judgment-use unedited source code from the user (s201). Also, the judgment-use edited source code input unit 302 accepts input of judgment-use edited source code from the user (s202).
[0076] For example, the source code judgment device 30 displays a predetermined input screen on the user terminal 20 and receives designation of the files of the judgment-use pre-edit source code and the judgment-use post-edit source code from the user.
[0077] Then, similar to s103 and s104, the source code graphing unit 303 for judgment graphs the pre-edit source code for judgment and the post-edit source code for judgment, thereby creating pre-edit source code graph data for judgment and post-edit source code graph data for judgment, respectively (s203, s204).
[0078] The determination graph editing operation sequence vectorization unit 305 creates a determination graph editing operation sequence indicating changes from the determination pre-edit source code graph data to the determination post-edit source code graph data, similar to s105, based on the determination pre-edit source code graph data and the determination post-edit source code graph data created in s203 and s204 (s205).
[0079] The determination graph edit operation column vectorization unit 305 creates a determination pre-edit source code vector by converting the determination pre-edit source code graph data into a vector, similar to s106 (s206).
[0080] Furthermore, in s206, the determination graph editing operation column vectorization unit 305 creates a determination editing operation column vector by converting the determination graph editing operation column created in s205 into a vector, similar to s106.
[0081] The judgment unit 306 obtains output data (s207) by inputting the unedited source code vector for judgment and the editing operation column vector for judgment created in s206 into the source code judgment model created by the learning unit 108. In this embodiment, the output data is "there is a defect" or "there is no defect."
[0082] The result output unit 307 outputs information including the output data acquired in s207 to the output device of the source code determination device 30 or the user terminal 20 (s208). For example, the result output unit 307 displays a screen on which the unedited source code for determination, the unedited source code for determination, and the output data ("defect present" or "no defect present") are arranged.
[0083] As described above, the source code judgment model creation device 10 of this embodiment identifies the editing process from the pre-edited learning source code to the post-edited learning source code (learning graph editing operation sequence), creates a learning editing operation sequence vector by vectorizing the identified editing process, and further creates a pre-edited learning source code vector by vectorizing the pre-edited learning source code.The source code judgment model creation device 10 then creates a source code judgment model that stores the relationship between the learning editing operation sequence vector, the pre-edit source code vector, and training information indicating whether editing has caused a defect in the post-edited learning source code.
[0084] In this way, the source code judgment model creation device 10 vectorizes the source code and the source code editing process, and creates a trained model using these vectorized data and corresponding training data (presence or absence of defects) as learning data, thereby making it possible to create a trained model that takes into account cases where the editing process involves complex operations (multiple operations) that cause defects in the source code.
[0085] As described above, the source code decision model generating device 10 of this embodiment can detect defects that occur in source code due to complex editing operations.
[0086] The source code judgment device 30 of this embodiment accepts input of pre-edit source code for judgment and post-edit source code for judgment from the user, creates a pre-edit operation column vector for judgment that vectorizes the editing process from the pre-edit source code for judgment to the post-edit source code for judgment, and also creates a pre-edit source code vector for judgment that vectorizes the pre-edit source code for judgment, and inputs the pre-edit operation column vector for judgment and the pre-edit source code vector for judgment into a source code judgment model, thereby outputting information indicating whether a defect has occurred in the post-edit source code for judgment.
[0087] This allows the user to easily know whether or not a problem has occurred as a result of editing the source code that he or she is currently editing.
[0088] Furthermore, the source code judgment model creation device 10 of this embodiment creates pre-edit source code graph data and post-edit source code graph data, which are graph data that identify the content of each process and the relationship between processes, for each of the pre-edit source code for learning and the post-edit source code for learning, and identifies the editing process based on these data (learning graph editing operation sequence).
[0089] In this way, by converting source code into graph data specified by the content of processes and the relationships between processes, the source code editing process can be expressed logically and efficiently. For example, compared to when natural language processing is performed on the source code, the source code editing process can be expressed logically and efficiently.
[0090] Furthermore, the source code judgment model generating device 10 of this embodiment uses the pre-edit source code graph data and the post-edit source code graph data to generate a learning graph edit operation sequence including a combination of the type of edit and the part to be edited.
[0091] This allows the source code editing process to be digitized concisely and accurately.
[0092] Furthermore, the source code judgment model creation device 10 of this embodiment creates a learning edit operation column vector by encoding the type of edit in the learning graph edit operation sequence and setting a predetermined index for the part to be edited in the learning graph edit operation sequence.
[0093] Specifically, the source code decision model generation device 10 of this embodiment uses the following types of edits in the learning graph edit operation sequence: adding a process (Add), changing the position of a process (Move), A learning graph editing operation sequence is created in which at least one of deleting a variable or a process (Remove) or changing the name of a variable or a process (Rename) is set.
[0094] This allows the source code editing process to be vectorized simply and accurately.
[0095] Although the embodiments of the present invention have been described above, the present invention is not limited to the above embodiments and can be implemented using any components within the scope of the gist of the present invention. The above-described embodiments and modifications are merely examples, and the present invention is not limited to these contents as long as the characteristics of the invention are not impaired. Furthermore, although various embodiments and modifications have been described above, the present invention is not limited to these contents. Other aspects conceivable within the scope of the technical idea of the present invention are also included within the scope of the present invention.
[0096] For example, some of the functional units provided in each device of this embodiment may be provided in another device, or functional units provided in another device may be provided in the same device.
[0097] In addition, in this embodiment, the first information (type of edit) of the graph edit operation sequence is assumed to be move, add, delete, or change the name of a variable or function, etc., but other types of edit (for example, insert) may also be added.
[0098] In this embodiment, the source code judgment model outputs a result of "defect present" or "defect absent," but may output a probability of the presence of a defect. [Explanation of symbols]
[0099] 1 Source code judgment system, 10 Source code judgment model creation device, 30 Source code judgment device
Claims
1. a storage device that stores the source code before and after editing, and training information indicating whether or not a defect has occurred in the edited source code due to editing; and Identifying an editing process from the source code before editing to the source code after editing, and creating an editing operation column vector which is information obtained by vectorizing the identified editing process; creating a pre-edit source code vector, which is vectorized information of the pre-edit source code; a processing device for creating a trained model that stores the relationship between the edit operation column vector, the pre-edit source code vector, and the training information; A source code decision model generation device comprising:
2. the processing device creates pre-edit source code graph data, which is graph data that specifies the content of each process in the source code before editing and the relationships between the processes, and post-edit source code graph data, which is graph data that specifies the content of each process in the source code after editing and the relationships between the processes, and identifies the editing process based on the created pre-edit source code graph data and post-edit source code graph data. The source code judgment model generating device according to claim 1 .
3. the processing device identifies the editing process by creating a graph editing operation sequence, which is information including a combination of types of editing and target parts of the editing, based on the pre-edit source code graph data and the post-edit source code graph data. The source code judgment model generating device according to claim 2 .
4. the processing device encodes the type of edit in the created graph edit operation sequence, and sets a predetermined index for a target part of the edit in the created graph edit operation sequence, thereby creating the edit operation column vector. The source code judgment model generating device according to claim 3 .
5. the processing device creates the graph editing operation sequence in which at least one of adding a process, changing a position of a process, deleting a process, or changing a name of a variable or a process is set as the type of editing; The source code judgment model generating device according to claim 3 .
6. a storage device that stores a trained model that stores a relationship between an editing operation column vector, which is information that vectorizes the editing process from the source code before editing to the source code after editing, a pre-edit source code vector, which is information that vectorizes the source code before editing, and training information that indicates whether or not a defect has occurred in the source code after editing due to editing; and Accepting inputs from a user of a source code before editing for determination, which is source code before editing, and a source code after editing for determination, which is source code after editing; Identifying an editing process from the unedited source code for determination to the edited source code for determination, and creating an editing operation column vector for determination, which is information obtained by vectorizing the identified editing process; creating a pre-edited source code vector for determination, which is information obtained by vectorizing the pre-edited source code for determination; a processing device that outputs information indicating whether a defect has occurred in the edited source code for determination by inputting the edit operation column vector for determination and the pre-edit source code vector for determination into the trained model; A source code determination device comprising:
7. The information processing device storing the source code before and after editing, and training information indicating whether or not a defect has occurred in the edited source code due to the editing; Identifying an editing process from the source code before editing to the source code after editing, and creating an editing operation column vector which is information obtained by vectorizing the identified editing process; creating a pre-edit source code vector, which is vectorized information of the pre-edit source code; creating a trained model that stores the relationship between the edit operation column vector, the pre-edit source code vector, and the training information; How to create a source code judgment model.
8. The information processing device storing a trained model that stores a relationship between an editing operation column vector, which is information that vectorizes the editing process from the source code before editing to the source code after editing, a pre-edit source code vector, which is information that vectorizes the source code before editing, and training information that indicates whether or not a defect has occurred in the source code after editing due to editing; Accepting inputs from a user of a source code before editing for determination, which is source code before editing, and a source code after editing for determination, which is source code after editing; Identifying an editing process from the unedited source code for determination to the edited source code for determination, and creating an editing operation column vector for determination, which is information obtained by vectorizing the identified editing process; creating a pre-edited source code vector for determination, which is information obtained by vectorizing the pre-edited source code for determination; outputting information indicating whether a defect has occurred in the edited source code for determination by inputting the edit operation column vector for determination and the pre-edit source code vector for determination into the trained model; Source code determination method.
9. a storage device that stores the source code before and after editing, and training information indicating whether or not a defect has occurred in the edited source code due to editing; and Identifying an editing process from the source code before editing to the source code after editing, and creating an editing operation column vector which is information obtained by vectorizing the identified editing process; creating a pre-edit source code vector, which is vectorized information of the pre-edit source code; a processing device for creating a trained model that stores the relationship between the edit operation column vector, the pre-edit source code vector, and the training information; a source code decision model generating device comprising: a storage device that stores the trained model; and Accepting inputs from a user of a source code before editing for determination, which is source code before editing, and a source code after editing for determination, which is source code after editing; Identifying an editing process from the unedited source code for determination to the edited source code for determination, and creating an editing operation column vector for determination, which is information obtained by vectorizing the identified editing process; creating a pre-edited source code vector for determination, which is information obtained by vectorizing the pre-edited source code for determination; a processing device that outputs information indicating whether a defect has occurred in the edited source code for determination by inputting the edit operation column vector for determination and the pre-edit source code vector for determination into the trained model; a source code determination device comprising: A source code judgment system comprising:
Citation Information
Patent Citations
Source code evaluation program
JP2018018197A
Source code evaluation device, source code evaluation method and source code evaluation program
JP2019021037A
Information processing device and information processing program
JP2021081913A
Matching graphs generated from source code
US20220066752A1