Change measurement device, method and program

The change degree measuring device uses function name prediction and probability distribution analysis to accurately assess functional changes in source codes, improving software development efficiency by accurately measuring the degree of change.

JP7536722B2Active Publication Date: 2024-08-20KK TOSHIBA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
JP2021137219
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Filing Date
2021-08-25
Publication Date
2024-08-20
Estimated Expiration
2041-08-25

AI Technical Summary

Technical Problem

Existing software development methods struggle to accurately measure the degree of change between functions in source codes, leading to inefficiencies in derivative development due to misinterpretation of functional changes.

Method used

A change degree measuring device and method that utilizes function name prediction through machine learning to quantify the degree of change between functions in source codes, using a trained model to compare probability distributions of predicted function names.

Benefits of technology

Accurately measures the degree of change between functions, distinguishing between functional changes and refactoring, thereby enhancing the efficiency of software development processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007536722000006
    Figure 0007536722000006
  • Figure 0007536722000012
    Figure 0007536722000012
  • Figure 0007536722000001
    Figure 0007536722000001
Patent Text Reader

Abstract

To provide a change degree measuring device, a method, and a program capable of measuring a change degree between functions included in two source codes.SOLUTION: A change degree measuring device includes: input means; first prediction means; second prediction means; measurement means; and output means. The input means inputs a first source code and a second source code. The first prediction means parses a first function included in the first inputted source code, and predicts a function name of a first function on the basis of the parsed result. The second prediction means parses a second function included in the second inputted source code, and predicts a function name of the second function on the basis of the parsed result. The measurement means measures a first change degree between the first and second functions by comparing a prediction result of a function name of the first function with a prediction result of a function name of the second function. The output means outputs a first measured change degree.SELECTED DRAWING: Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] An embodiment of the present invention relates to an apparatus, method, and program for measuring degree of change. [Background technology]

[0002] In general, in software product development such as software product line (SPL) development, derivative development is carried out using source code to realize an existing software product.

[0003] In order to carry out this derivative development efficiently, it is necessary to analyze (understand) the changed and unchanged parts between two source codes to realize the same type and series of software products. For this analysis, it is useful to measure the degree to which the functions included in the source codes have been changed (hereinafter referred to as the degree of change). [Prior art documents] [Patent documents]

[0004] [Patent Document 1] International Publication No. 2020 / 049622 Summary of the Invention [Problem to be solved by the invention]

[0005] Therefore, an object of the present invention is to provide an apparatus, method, and program for measuring the degree of change between functions included in two source codes. [Means for solving the problem]

[0006] A degree of change measurement device according to an embodiment includes an input means, a first prediction means, a second prediction means, a measurement means, and an output means. The input means inputs a first source code including a first function and a second source code including a second function. The first prediction means analyzes the syntax of the first function included in the input first source code, and predicts a function name of the first function based on the syntax analysis result. The second prediction means analyzes the syntax of a second function included in the input second source code, and predicts a function name of the second function based on the syntax analysis result. The measurement means measures a first degree of change between the first and second functions by comparing a prediction result of the function name of the first function with a prediction result of the function name of the second function. The output means outputs the measured first degree of change. [Brief description of the drawings]

[0007] [Figure 1] FIG. 2 is a block diagram showing an example of the functional configuration of an inter-function change measurement device according to the first embodiment. [Diagram 2] FIG. 1 is a diagram showing an example of a system configuration of an inter-function change measurement device. [Diagram 3] FIG. 2 is a diagram for explaining an outline of the operation of an inter-function change measurement device; [Figure 4] 11 is a flowchart showing an example of a processing procedure of an inter-function change measurement device. [Diagram 5] FIG. 1 is a diagram showing an example of an AST. [Figure 6] FIG. 11 is a diagram showing a specific example of a function included in a source code. [Figure 7] FIG. 13 is a diagram showing an example of a display screen on which a degree of change is displayed. [Figure 8] FIG. 13 is a diagram showing an example of a display screen on which a degree of change is displayed. [Figure 9] FIG. 1 is a diagram for explaining a configuration in which a source code management tool is used. [Figure 10] FIG. 11 is a block diagram showing an example of the functional configuration of an inter-function change measurement device according to a second embodiment. [Figure 11] 11 is a flowchart showing an example of a processing procedure of an inter-function change measurement device. [Figure 12] FIG. 13 is a diagram showing an example of a display screen on which first and second change degrees are displayed. [Figure 13] FIG. 13 is a diagram showing another example of the display screen on which the first and second change degrees are displayed. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0008] Each embodiment will be described below with reference to the drawings. (First embodiment) First, a first embodiment will be described. The change degree measurement device according to this embodiment is used to measure the change degree between functions included in two source codes in order to efficiently perform derivative development in the development of a software product. In the following description, the change degree measurement device according to this embodiment is conveniently referred to as an inter-function change degree measurement device.

[0009] Here, in order to measure the degree of change between functions, it is conceivable to extract the differences between the functions. One tool for extracting the differences between functions is, for example, a text comparison tool called Diff.

[0010] However, such text comparison tools extract the differences between the functions included in two source codes (texts) by comparing two source codes (texts) including functions written in a specific programming language, so that even if there is no major change in functionality, if the description of the source code (function) has been significantly changed by refactoring, etc., a large difference will be extracted and a high degree of change will be measured. Similarly, even if there is a major change in functionality, if the change in the description of the source code (function) is small, the extracted difference will be small and a low degree of change will be measured.

[0011] For this reason, in this embodiment, in order to quantify the degree to which two functions differ from a functional point of view, a technology is used to predict the function name of a function from the function (body) as one application of natural language processing using machine learning.

[0012] Specifically, for example, if the function names (predicted names) of two functions are "sortByName" and "sortByIndex" (function names representing a sort function), the functions of the two functions are considered to be similar (i.e., the degree of change is small). On the other hand, if the function names (predicted names) of two functions are "sortByName" and "showDialog", the functions of the two functions are considered to be dissimilar (i.e., the degree of change is large).

[0013] The inter-function change measurement device 10 according to this embodiment has a configuration for measuring the degree of change between functions from a functional perspective (the degree of change between functions taking into account the magnitude of functional change) by utilizing the prediction results of the function names described above.

[0014] FIG. 1 is a block diagram showing an example of the functional configuration of an inter-function change degree measurement device according to the present embodiment.

[0015] As shown in FIG. 1, the inter-function change degree measurement device 10 includes an input unit 11, a function name prediction unit 12, a change degree measurement unit 13, and an output unit 14.

[0016] The input unit 11 inputs two source codes (hereinafter referred to as first and second source codes) designated by a user (a user who develops a software product) who uses the inter-function change degree measurement device 10, for example.

[0017] In this embodiment, the first and second source codes input by the input unit 11 include functions written in a predetermined program language as described above. The first and second source codes are source codes for realizing software products of the same type and series (e.g., software products of different versions) in software product line development, for example.

[0018] In addition, the first and second source codes input by the input unit 11 may be pre-stored in a storage unit (not shown) included in the inter-function change degree measurement device 10, or may be received from a server device or the like external to the inter-function change degree measurement device 10.

[0019] The function name prediction unit 12 performs syntax analysis on a function (hereinafter referred to as a first function) included in the first source code input by the input unit 11, and predicts the function name of the first function based on the syntax analysis result. The function name prediction unit 12 also performs syntax analysis on a function (hereinafter referred to as a second function) included in the second source code input by the input unit 11, and predicts the function name of the second function based on the syntax analysis result.

[0020] The degree of change measurement unit 13 measures (calculates) the degree of change of the first and second functions by comparing the prediction result of the function name of the first function and the prediction result of the function name of the second function by the function name prediction unit 12.

[0021] The output unit 14 outputs the degree of change measured by the degree of change measurement unit 13. In this embodiment, it is assumed that the output unit 14 is, for example, a display processing unit that displays the degree of change, but it may be a transmission unit or the like that transmits the degree of change to an external server device or the like.

[0022] Fig. 2 shows an example of a system configuration of the inter-function change degree measurement device 10 shown in Fig. 1. Here, the inter-function change degree measurement device 10 will be described as being, for example, a personal computer (PC) or the like, but the inter-function change degree measurement device 10 may be another electronic device (information processing device).

[0023] As shown in FIG. 2, the inter-function change measurement device 10 includes a CPU 101, a non-volatile memory 102, a main memory 103, a BIOS-ROM 104, a system controller 105, an input device 106, a display device 107, an embedded controller (EC) 108, and the like.

[0024] The CPU 101 is a processor that controls the operation of each component in the inter-function change degree measurement device 10. The CPU 101 executes various programs loaded from the non-volatile memory 102, which is a storage device, to the main memory 103. These programs include an operating system (OS) and a program for measuring the degree of change between functions (hereinafter referred to as an inter-function change degree measurement program), etc.

[0025] The CPU 101 also executes a basic input / output system (BIOS) stored in a BIOS-ROM 104. The BIOS is a program for controlling hardware.

[0026] The system controller 105 is a device that connects the local bus of the CPU 101 and various components.

[0027] The input device 106 includes, for example, a keyboard and a mouse, etc. The display device 107 includes, for example, a display such as a liquid crystal display device, etc. The EC 108 is a one-chip microcomputer for power management.

[0028] In FIG. 2, only the CPU 101, the non-volatile memory 102, the main memory 103, the BIOS-ROM 104, the system controller 105, the input device 106, the display device 107 and the EC 108 are shown, however, the inter-function change degree measurement device 10 may be provided with other storage devices such as an HDD (Hard Disk Drive) and an SSD (Solid State Drive), or may be provided with a communication device configured to perform communication with an external device.

[0029] In this embodiment, some or all of the units 11 to 14 shown in Fig. 1 are realized by, for example, causing a CPU 101 (i.e., the computer of the inter-function change degree measurement device 10) shown in Fig. 2 to execute the inter-function change degree measurement program described above, that is, by software. The inter-function change degree measurement program can be distributed by being stored in advance in a computer-readable storage medium, or it may be downloaded to the inter-function change degree measurement device 10 via a network.

[0030] Here, it has been described that some or all of the units 11 to 14 are realized by software, but some or all of the units 11 to 14 may be realized, for example, by hardware, or by a combination of software and hardware.

[0031] The operation of the inter-function change measurement device 10 according to this embodiment will be described below. First, an overview of the operation of the inter-function change measurement device 10 (the change measurement unit 13) according to this embodiment will be described with reference to FIG.

[0032] In this embodiment, the inter-function change degree measurement device 10 (function name prediction unit 12) is assumed to hold in advance a trained model 12a generated by machine learning so as to output a prediction result of the function name of a function by inputting the function. The prediction result of the function name output from this trained model is assumed to include, for example, a plurality of candidates of the function name (hereinafter referred to as function name candidates) and a probability that each of the plurality of function name candidates is the function name (legitimate function name) of the function input to the trained model (hereinafter referred to as function name probability).

[0033] Here, it is assumed that a first function is input to the trained model 12a. In this case, the trained model 12a outputs, for example, three function name candidates of the first function and the probabilities of each of the three function name candidates as prediction results of the function name of the first function.

[0034] On the other hand, assume that a second function is input to the trained model 12a. In this case, the trained model 12a outputs, for example, three function name candidates for the second function and the probabilities of each of the three function name candidates as prediction results for the function name of the second function.

[0035] In this embodiment, the degree of change between the first and second functions is measured based on the prediction result of the function name of the first function and the prediction result of the function name of the second function. In this case, the degree of change between the first and second functions is measured (calculated) based on the difference between the probability distribution of the three function name candidates of the first function and the probability distribution of the three function name candidates of the second function, for example.

[0036] Next, an example of a processing procedure of the inter-function change degree measurement device 10 will be described with reference to a flowchart of FIG.

[0037] First, the input unit 11 inputs, for example, two source codes (first and second source codes) designated by a user (step S1). Note that the first and second source codes are source codes for realizing software products of different versions as described above (hereinafter, referred to as different version source codes).

[0038] Next, functions (first and second functions) for measuring the degree of change are extracted from each of the first and second source codes input in step S1 (step S2).

[0039] Here, the first and second source codes each generally contain (describe) a plurality of functions, but as described above, the first and second source codes are source codes of different versions, and information indicating the correspondence between the first function included in the first source code and the second function included in the second source code, the degree of change of which is to be measured (hereinafter, referred to as function correspondence information), is assumed to be managed in advance. This function correspondence information is assumed to be managed, for example, in a source code management tool (platform) used by a user who develops a software product, and the function name prediction unit 12 extracts the first function from the first source code and the second function from the second source code based on such function correspondence information.

[0040] When the process of step S2 is executed, the function name prediction unit 12 predicts the function names of the first function and the second function extracted in step S2, using the trained model described above.

[0041] Here, in this embodiment, for example, a trained model disclosed in code2seq (Generating Sequences from Structured Representations of Code) (hereinafter referred to as a trained model of code2seq) can be used to predict the function name.

[0042] Below is a brief overview of the code2seq trained model. The code2seq trained model is generated by applying machine learning algorithms such as neural networks, and in order to predict the name of a function, which is a fragment of source code, the function is parsed to build an AST (Abstract Syntax Tree) that represents the function, and the path from the leftmost node to the rightmost node of the AST is used as input to the neural network.

[0043] Here, FIG. 5 shows an example of an AST in a simplified manner. The AST has a tree structure in which the smallest unit (token) that makes sense in the source code (function) is a node. In the example shown in FIG. 5, path information 201 to 203 are shown as examples of path information input to the trained model of code2seq. Note that the path information 201 is a path from node 201a, which is the leftmost node of the AST, to node 201b, which is the rightmost node. Furthermore, the path information 202 is a path from node 202a, which is the leftmost node of the AST, to node 202b, which is the rightmost node. Furthermore, the path information 203 is a path from node 203a, which is the leftmost node of the AST, to node 203b, which is the rightmost node.

[0044] The learned model of code2seq is constructed (generated) so that by inputting multiple path information (e.g., about 200 paths) such as the above-mentioned path information 201 to 203, it outputs multiple function name candidates, each composed of a series of words, and the probability of each of the function name candidates.

[0045] The function name prediction unit 12 inputs the first and second functions (path information of the AST representing them) into the learned model of code2seq, thereby obtaining multiple function name candidates for the first function and the respective probabilities of the function name candidates, and multiple function name candidates for the second function and the respective probabilities of the function name candidates (step S3).

[0046] When a trained model of code2seq is used to predict function names, multiple function name candidates and their respective predicted probability distributions can be obtained by beam search. The number of function names obtained as function name candidates is determined by the beam width of the beam search.

[0047] In this embodiment, a learned model of code2seq is described as being used, but a learned model generated based on another algorithm may also be used as long as it can predict the function name of an input function.

[0048] Also, for example, if a function name candidate with a probability lower than a predetermined value (e.g., several percent) is included among the multiple function name candidates output from the trained model, the function name candidate may be excluded and only the remaining function name candidates may be acquired. In this case, a process of normalizing the probability of the acquired function name candidates may be further executed. That is, in this embodiment, a process of appropriately formalizing the prediction results of the function names of the first function and the second function described above may be executed.

[0049] Next, the degree of change measurement unit 13 measures (determines) the degree of change between the first and second functions based on the probability distribution of multiple function name candidates for the first function (hereinafter referred to as the first probability distribution) obtained in step S3 and the probability distribution of multiple function name candidates for the second function (hereinafter referred to as the second probability distribution) (step S4).

[0050] In step S4, the degree of change is measured based on the difference between the first and second probability distributions, which is calculated using a calculation method (metric) such as KL (Kullback-Leibler) divergence or JS (Jensen-Shannon) divergence.

[0051] The output unit 14 outputs the degree of change measured in step S4 (step S5). In this case, the output unit 14 may output the degree of change to the display device 107 and display the degree of change on the display device 107.

[0052] A specific example of the operation of the inter-function change degree measurement device 10 according to this embodiment will be described below. As shown in Fig. 6, it is assumed that there are source codes of different versions for realizing software products of the same type and series, such as source code 301 of version 1, source code 302 of version 2.1, and source code 303 of version 2.2. Note that the source codes 301 to 303 contain a plurality of functions, but Fig. 6 shows only the functions (i.e., corresponding functions) for which the above-mentioned change degree should be measured, among the plurality of functions contained in the source codes 301 to 303.

[0053] Here, it is assumed that the degree of change between a function included in a source code 301 and a function included in a source code 302 is measured. Fig. 7 shows an example of a display screen 107a of a display device 107 on which the degree of change between a function included in the source code 301 and a function included in the source code 302 measured by inputting the source codes 301 and 302 into the inter-function change measurement device 10 is displayed.

[0054] As shown in FIG. 7, display screen 107a displays the prediction result of the function name of a function included in source code 301 (function of version 1), the prediction result of the function name of a function included in source code 302 (function of version 2.1), the KL divergence value, and the degree of change between the functions.

[0055] The prediction result of the function name of a function included in source code 301 includes a plurality of function name candidates for the function and the probability of each of the plurality of function name candidates. In the example shown in Fig. 7, the prediction result of the function name of a function included in source code 301 is displayed as a function name candidate "sort" and its probability of "72.6%", a function name candidate "reverse" and its probability of "15.6%", and a function name candidate "bubblesort" and its probability of "11.8%".

[0056] The prediction result of the function name of the function included in the source code 302 includes a plurality of function name candidates of the function and the probability of each of the plurality of function name candidates. In the example shown in FIG. 7, as the prediction result of the function name of the function included in the source code 302, the function name candidate "printArray" and the probability of the function name candidate "72.6%", the function name candidate "dumpArray" and the probability of the function name candidate "30.5%", and the function name candidate "sort" and the probability of the function name candidate "13.5%" are displayed.

[0057] The KL divergence value is a numerical value representing the difference between the probability distribution (the distribution of the probabilities of a plurality of function name candidates of the function included in the source code 301) based on the prediction result of the function name of the function included in the source code 301 calculated using the above-mentioned KL divergence and the probability distribution (the distribution of the probabilities of a plurality of function name candidates of the function included in the source code 302) based on the prediction result of the function name of the function included in the source code 302. In the example shown in FIG. 7, "4.893" is displayed as the KL divergence value.

[0058] Here, it is assumed that the degree of change in the present embodiment is measured based on the above-mentioned KL divergence value. Specifically, the degree of change includes, for example, "none", "small", and "large". If the KL divergence value = 0, it is determined that there is no difference between the functions as functions, and the degree of change "none" is measured. Also, if 0 < KL divergence value < 1.5, it is determined that the difference between the functions as functions is small, and the degree of change "small" is measured. Further, if the KL divergence value ≧ 1.5, it is determined that the difference between the functions as functions is large, and the degree of change "large" is measured.

[0059] In this case, in the example shown in FIG. 7, since the KL divergence value is "4.893", the degree of change "large" measured based on the KL divergence value is displayed on the display screen 107a.

[0060] When comparing the functions included in source code 301 and source code 302 shown in Fig. 6, most of the text is the same, so that the degree of change is likely to be determined to be small when using a text comparison tool such as Diff. However, in this embodiment, the degree of change can be measured as "large" by determining that the difference between the functions as functions is large based on the KL divergence value.

[0061] Next, a case will be considered where the degree of change between a function included in source code 301 and a function included in source code 303 is measured. Fig. 8 shows an example of a display screen 107b of a display device 107 on which the degree of change between a function included in source code 301 and a function included in source code 303 measured by inputting source codes 301 and 303 to an inter-function change measurement device 10 is displayed.

[0062] As shown in FIG. 8, display screen 107b displays the prediction result of the function name of a function included in source code 301 (function of version 1), the prediction result of the function name of a function included in source code 303 (function of version 2.2), the KL divergence value, and the degree of change between the functions.

[0063] In the example shown in Figure 8, similar to Figure 7 described above, the predicted function names of functions included in source code 301 are displayed as the function name candidate "sort" and its probability of being a candidate of "72.6%, "the function name candidate "reverse" and its probability of being a candidate of "15.6%, and "the function name candidate "bubblesort" and its probability of being a candidate of "11.8%".

[0064] The prediction result of the function name of the function included in the source code 303 includes a plurality of function name candidates for the function and the probability of each of the plurality of function name candidates. In the example shown in FIG. 8, as the prediction result of the function name of the function included in the source code 303, the function name candidate "sort" and the probability of the function name candidate "70.8%", the function name candidate "bubbleSort" and the probability of the function name candidate "23.7%", and the function name candidate "reverse" and the probability of the function name candidate "5.5%" are displayed.

[0065] The KL divergence value is a numerical value representing the difference between the probability distribution based on the prediction result of the function name of the function included in the source code 301 (the distribution of the probabilities of a plurality of function name candidates of the function included in the source code 301) and the probability distribution based on the prediction result of the function name of the function included in the source code 303 (the distribution of the probabilities of a plurality of function name candidates of the function included in the source code 303). In the example shown in FIG. 8, "1.254" is displayed as the KL divergence value.

[0066] Assuming that if the KL divergence value = 0, the degree of change "none" is measured, if 0 < KL divergence value < 1.5, the degree of change "small" is measured, and if the KL divergence value ≧ 1.5, the degree of change "large" is measured, in the example shown in FIG. 8, since the KL divergence value is "1.254", the degree of change "small" measured based on the KL divergence value is displayed on the display screen 107b.

[0067] When comparing the function included in source code 301 and the function included in source code 303 shown in Fig. 6, the text has been significantly changed, so that it is highly likely that the degree of change is determined to be large when a text comparison tool such as Diff is used. However, the function included in source code 301 is a sorting function based on an algorithm called bubble sort, and the function included in source code 303 is a sorting function based on an algorithm called selection sort, and the function included in source code 301 and the function included in source code 303 are functionally common. In this case, in this embodiment, it is determined that the difference between the functions as functions is small based on the KL divergence value, so that the degree of change can be measured as "small."

[0068] In addition, in Figures 7 and 8, it has been explained that the prediction result of the function name of the function included in the source code, the KL divergence value, and the degree of change are displayed on the display screen. However, it is sufficient that at least the degree of change is displayed on the display screen, and at least one of the prediction result and the KL divergence value may be omitted.

[0069] In addition, although it has been described here that one of the three degrees of change, "none", "small" and "large", is measured, a degree of change such as "medium" which is between the degree of change "small" and the degree of change "large" may also be measured. Furthermore, in this embodiment, the above-mentioned KL divergence value (i.e., a numerical value representing the difference in probability distribution based on the prediction result of the function name) may be used as the degree of change, or a numerical value calculated based on the KL divergence may be used as the degree of change. In other words, the degree of change in this embodiment may be based on an interpretation according to any standard.

[0070] As described above, in this embodiment, a first source code including a first function and a second source code including a second function are input, the first function included in the input first source code is parsed, a function name of the first function is predicted based on the parsing result, a second function included in the input second source code is parsed, and a function name of the second function is predicted based on the parsing result. In this embodiment, the degree of change between the first and second functions (first degree of change) is measured by comparing the prediction result of the function name of the first function and the prediction result of the function name of the second function.

[0071] In this embodiment, with such a configuration, it is possible to measure an appropriate degree of change between functions included in two source codes.

[0072] Specifically, when measuring the degree of change using a text comparison tool such as Diff, if the elements that make up the function for which the degree of change is being measured (elements that do not include blank lines or spaces, etc.) are not arranged (described) in the correct order, they will not be recognized as common parts of the functions, so even if the functions have a common function, if the text (description) that represents the function has changed significantly, it is highly likely that the degree of change between the functions will be determined to be large. On the other hand, even if the functions do not have a common function, if they have many common parts, it is possible that the degree of change between the functions will be determined to be small.

[0073] In contrast, in this embodiment, even if the text (description) representing the function has been significantly changed, if the difference based on the predicted function name is small, it is possible to determine that the degree of change is small (i.e., measure the degree of change as "small").On the other hand, even if the text representing the function contains many common parts, if the difference based on the predicted function name is large, it is possible to determine that the degree of change is large (i.e., measure the degree of change as "large").

[0074] That is, in this embodiment, it is possible to measure the degree of change between appropriate functions based on functional changes.

[0075] In this embodiment, the function names of a first function included in a first source code and a second function included in a second source code are predicted using a trained model generated by machine learning so as to output a prediction result of the function name when a function is input, thereby making it possible to obtain a highly accurate prediction result.

[0076] Furthermore, the trained model described above is generated to output a plurality of function name candidates (a plurality of candidates for the function name) and the probability that each of the plurality of function name candidates is the function name as a prediction result of the function name, and in this embodiment, the degree of change is measured based on the difference between the distribution of the probability that each of the plurality of function name candidates for the first function output from the trained model as a prediction result of the function name of the first function is the function name of the first function, and the distribution of the probability that each of the plurality of function name candidates for the second function output from the trained model as a prediction result of the function name of the second function is the function name of the second function. With such a configuration, it is possible to measure an appropriate degree of change using the trained model.

[0077] In this embodiment, the difference between the distribution of the probability that each of the multiple function name candidates for the first function is the function name of the first function (probability distribution of the multiple function name candidates for the first function) and the distribution of the probability that each of the multiple function name candidates for the second function is the function name of the second function (probability distribution of the multiple function name candidates for the second function) has been described as being calculated using KL divergence or JS divergence, but the difference may be calculated by other methods.

[0078] In addition, since function names are represented as vector expressions on a neural network (trained model), in this embodiment, the difference between functions based on the vector expressions may be calculated using, for example, cosine similarity or Euclidean distance, and the degree of change may be measured based on the difference.

[0079] Here, it has been described that the degree of change is measured based on the difference between the predicted result (probability distribution or vector expression) of the function name of the first function and the predicted result (probability distribution or vector expression) of the function name of the second function, but the degree of change may also be measured using the similarity of the predicted results.

[0080] In this embodiment, the degree of change measured as described above is displayed (output) so that the user can easily grasp the degree of change between the first and second functions, but the inter-function change degree measurement device 10 according to this embodiment may be configured to further display (output) prediction results (function name candidates and probabilities) of the function names of the first and second functions in addition to the degree of change. With this configuration, the user can also grasp the content (summary) of the change between the first and second functions based on the prediction results of the function names of the first and second functions.

[0081] In addition, in the present embodiment, the first and second source codes are simply input by the inter-function change measurement device 10 (input unit 11), but the first and second source codes may be managed by a source code management tool (configuration management tool) 15 shown in FIG. 9. The source code management tool 15 has a function of managing source codes (versions, etc.) for implementing software products, for example, and by using the source code management tool 15, it becomes possible to efficiently extract and input source codes for implementing software products of the same type and series as described in the present embodiment. That is, in the present embodiment, by embedding the source code management tool 15 in the inter-function change measurement device 10, it is possible to easily realize a configuration in which a user arbitrarily specifies a function of a different version, and the source code including the specified function is extracted from the source code management tool 15 to predict the function name and measure the change degree.

[0082] The inter-function change measurement device 10 according to the present embodiment is used, for example, to efficiently perform derivative development, and the change degree measured by the inter-function change measurement device 10 can also be used as an index for checking whether the change content of a function included in source code is appropriate when the function is changed. Specifically, when a function is changed by refactoring but the change degree of the function is determined to be large (i.e., the change degree is measured as "large"), it is possible to prompt the user to check the function because there is a possibility that an unintended change has been made to the function. On the other hand, when a function is changed to change the function but the change degree of the function is determined to be small (i.e., the change degree is measured as "small"), it is possible to prompt the user to check the function. Also, when a different version of the same function is determined to have a large change in function, it is possible that the content of the function has been significantly changed from the original function, so it is possible to prompt the user to check the necessity of changing the function name itself.

[0083] In addition, in the present embodiment, the learned model is used to predict the function name of a function from a function included in a source code, and the degree of change between functions is measured based on the difference between the predicted function names. However, the present embodiment may be configured to measure the degree of change between source codes (functions included in the source code) based on the difference between the summaries using a learned model constructed to input source codes (functions included in the source code) and output a summary of the source codes (functions included in the source code) (i.e., predict the summary of the source code from the source code). That is, the change measurement device according to the present embodiment may be realized as a source code change measurement device that inputs first and second source codes, predicts the summary of the first source code based on the syntax analysis result of the input first source code, predicts the summary of the second source code based on the syntax analysis result of the input second source code, and compares the summaries to measure the degree of change between the first and second source codes. In this case, the prediction result output from the learned model may be in a format such as a comment, or may be in a format such as summary data that is added arbitrarily by hand.

[0084] Furthermore, in this embodiment, it is also possible to configure the present invention so that the degree of change between source codes (classes) is measured based on the difference in class names predicted from the classes described in the source codes.

[0085] That is, this embodiment may be configured to measure the degree of change based on the difference in the predicted results regarding the function realized by the input source code (or the function included in the source code).

[0086] Second embodiment Next, a second embodiment will be described. This embodiment differs from the first embodiment in that it outputs the degree of change measured in the first embodiment and the degree of change measured using a text comparison tool such as Diff.

[0087] Fig. 10 is a block diagram showing an example of the functional configuration of an inter-function change measurement device according to this embodiment. In Fig. 10, the same parts as those in Fig. 1 described above are given the same reference numerals, and detailed explanations thereof will be omitted. Note that the first change measurement unit 13 shown in Fig. 10 is the same functional unit as the change measurement unit 13 described in the first embodiment described above.

[0088] 10, the inter-function change degree measurement device 10 includes a second change degree measurement unit 16. The second change degree measurement unit 16 uses a text comparison tool such as Diff described above to measure a change degree based on a difference between (a text representing) a first function included in the first source code input by the input unit 11 and (a text representing) a second function included in the second source code.

[0089] Note that the system configuration of the inter-function change degree measurement device 10 is similar to that of the first embodiment described above, but part or all of the second change degree measurement unit 16 described above is realized by causing the CPU 101 shown in Fig. 2 described above to execute an inter-function change degree measurement program, that is, by software. Note that part or all of the second change degree measurement unit 16 may be realized by hardware, or a combination of software and hardware.

[0090] Next, an example of a processing procedure of the inter-function change degree measurement device 10 will be described with reference to a flowchart of FIG.

[0091] First, the processes of steps S11 to S13 corresponding to the processes of steps S1 to S3 shown in FIG. 4 are executed.

[0092] Next, the first change degree measurement unit 13 measures a first change degree between the first and second functions based on the distribution (first probability distribution) of each of the multiple function name candidates for the first function acquired in step S13 and the distribution (second probability distribution) of each of the multiple function name candidates for the second function (step S14).

[0093] Note that the process of step S14 (i.e., the first degree of change measured in step S14) is similar to the process of step S4 shown in Fig. 4 (i.e., the degree of change measured in step S4), and therefore a detailed description thereof will be omitted here. In this embodiment, for example, a KL divergence value (a numerical value representing a difference in probability distribution based on a prediction result of a function name) is measured as the first degree of change. Also, the first degree of change in this embodiment corresponds to the degree of change between the first and second functions as functions.

[0094] Next, the second change degree measurement unit 16 measures the second change degree between the first and second functions extracted in step S12 using a text comparison tool (step S15). In this embodiment, the second change degree is measured as a numerical value representing the difference in text between the first and second functions, for example. The second change degree in this embodiment corresponds to the change degree between the first and second functions as text.

[0095] Although detailed explanation will be omitted, in step S15, similar to the degree of change in the first embodiment described above, a process may be executed in which a degree of change of "large" is measured when the difference in text between the first and second functions is large, and a degree of change of "small" is measured when the difference in text between the first and second functions is small.

[0096] For the sake of convenience, the processing of steps S11 to S15 has been described as being executed in order, but the processing of steps S13 and S14 and the processing of step S15 may be interchanged in order or may be executed in parallel.

[0097] When the process of step S15 is executed, the output unit 14 outputs the first degree of change measured in step S14 and the second degree of change measured in step S15 (step S16).

[0098] Here, in step S16, for example, the first and second change degrees can be displayed on the display device 107, and FIG. 12 shows an example of the display screen of the display device 107 on which the first and second change degrees are displayed.

[0099] In Figure 12, as described above, it is assumed that the KL divergence value (i.e., a numerical value representing the difference in probability distribution based on the prediction results of the function names of the first and second functions) is measured as the first degree of change, and a numerical value representing the difference in text between the first and second functions is measured as the second degree of change.

[0100] 12, the first and second degrees of change are displayed by plotting the measured correspondence between the first and second degrees of change on a graph with the horizontal axis representing the first degree of change and the vertical axis representing the second degree of change, for example. This makes it possible to easily grasp the comparison result between the first and second degrees of change.

[0101] When the correspondence relationship between the first and second degrees of change is plotted in area 401 shown in Fig. 12, it means that the degree of change between the first and second functions as a function is small, but the degree of change between the first and second functions as text is large. Also, when the correspondence relationship between the first and second degrees of change is plotted in area 402 shown in Fig. 12, it means that the degree of change between the first and second functions as a function is large, but the degree of change between the first and second functions as text is small.

[0102] On the other hand, when the correspondence between the first and second change degrees is plotted, for example, in area 403, it means that the degree of change between the first and second functions as functions and the degree of change between the first and second functions as text are roughly similar.

[0103] Although the display screen 107c shows an example in which only one correspondence relationship between the first and second change degrees is plotted, it is also possible to display a display screen 107d as shown in Fig. 13 when the first and second change degrees are measured for each pair of two functions whose change degrees are to be measured among a plurality of functions included in each of the first and second source codes. This display screen 107d makes it possible to grasp the change degrees of the entire first and second source codes.

[0104] As described above, in this embodiment, the second degree of change between the first and second functions is measured by comparing text representing a first function included in the first source code with text representing the second function included in the second source code, and the measured second degree of change is output together with the first degree of change, allowing the user to grasp the degree of change between the first and second functions while also taking into account the second degree of change.

[0105] Furthermore, in this embodiment, by displaying the first and second change degrees (their corresponding relationship) on graphs such as those shown in Figures 12 and 13 described above, the user can easily understand the comparison results of the first and second change degrees.

[0106] In this embodiment, the first and second change degrees are described as being displayed on a graph, but the first and second change degrees may be displayed in other formats such as a table format, etc. Furthermore, the first and second change degrees may be represented as "none," "small," and "large" change degrees as described in the first embodiment, and such first and second change degrees may be displayed in a comparable manner.

[0107] In other words, in this embodiment, as long as the first and second change degrees are output and the user can understand the output first and second change degrees, the content and display format of the first and second change degrees, etc. may be changed as appropriate.

[0108] According to at least one of the embodiments described above, it is possible to provide a degree of change measurement device, method, and program capable of measuring the degree of change between functions included in source code.

[0109] Although some embodiments of the present invention have been described, these embodiments are presented as examples and are not intended to limit the scope of the invention. These embodiments can be implemented in various other forms, and various omissions, substitutions, and modifications can be made without departing from the spirit of the invention. These embodiments and their modifications are included in the scope of the invention and its equivalents described in the claims, as well as in the scope and spirit of the invention. [Explanation of symbols]

[0110] 10...inter-function change degree measurement device, 11...input unit, 12...function name prediction unit, 13...change degree measurement unit, first change degree measurement unit, 14...output unit, 15...source code management tool, 16...second change degree measurement unit, 101...CPU, 102...non-volatile memory, 103...main memory, 104...BIOS-ROM, 105...system controller, 106...input device, 107...display device, 108...EC.

Claims

1. an input means for inputting a first source code including a first function and a second source code including a second function; a first prediction means for parsing a first function included in the input first source code and predicting a function name of the first function based on a result of the parsing; a second prediction means for parsing a second function included in the input second source code and predicting a function name of the second function based on a result of the parsing; a first measuring means for measuring a first degree of change between the first and second functions by comparing a predicted function name of the first function with a predicted function name of the second function; an output means for outputting the measured first degree of change; A change measurement device comprising:

2. The first prediction means predicts a function name of the first function using a trained model generated by machine learning so as to output a prediction result of a function name of the function by inputting a function; The second prediction means predicts a function name of the second function by using the trained model.

2. The change measurement device according to claim 1.

3. the learned model is generated so as to output, as a prediction result of a function name of the function, a plurality of candidates for the function name and a probability that each of the plurality of candidates is the function name of the function; The first measurement means measures the first degree of change based on a difference between a distribution of probability that each of a plurality of first candidates for the function name of the first function output from the trained model as a prediction result of the function name of the first function is the function name of the first function, and a distribution of probability that each of a plurality of second candidates for the function name of the second function output from the trained model as a prediction result of the function name of the second function is the function name of the second function.

3. The change measurement device according to claim 2.

4. 4. The change degree measurement device according to claim 3, wherein the difference between the distribution of the probability that each of the plurality of first candidates is the function name of the first function and the distribution of the probability that each of the plurality of second candidates is the function name of the second function is calculated using KL divergence or JS divergence.

5. The function names of the first and second functions are represented as vector expressions on the trained model; The first measurement means measures the first degree of change based on a difference between a vector expression representing a function name of the first function and a vector expression representing a function name of the second function.

3. The change measurement device according to claim 2.

6. 6. The degree of change measurement device according to claim 5, wherein the difference between the vector expression representing the function name of the first function and the vector expression representing the function name of the second function is calculated using cosine similarity or Euclidean distance.

7. 7. The degree of change measurement device according to claim 1, wherein the output means further outputs a prediction result of the function name of the first function and a prediction result of the function name of the second function.

8. a second measuring means for measuring a second degree of change between the first and second functions by comparing a text representing a first function included in the input first source code with a text representing a second function included in the input second source code; The output means further outputs the measured second degree of change. The change measurement device according to any one of claims 1 to 7.

9. 9. The degree of change measuring device according to claim 8, wherein said output means includes display processing means for displaying said first and second degrees of change on a graph.

10. an input means for inputting the first and second source codes; a first prediction means for analyzing the syntax of the input first source code and predicting a summary of the first source code based on a result of the syntax analysis; a second prediction means for analyzing the syntax of the input second source code and predicting a summary of the second source code based on a result of the syntax analysis; a first measuring means for measuring a first degree of change between the first and second source codes by comparing a prediction result of a summary of the first source code and a prediction result of a summary of the second source code; an output means for outputting the measured first degree of change; A change measurement device comprising:

11. A method performed by a degree of change measurement device, comprising: inputting a first source code including a first function and a second source code including a second function; parsing a syntax of a first function included in the input first source code, and predicting a function name of the first function based on a result of the syntax analysis; parsing a syntax of a second function included in the input second source code, and predicting a function name of the second function based on a result of the syntax analysis; measuring a first degree of change between the first and second functions by comparing a function name prediction result of the first function and a function name prediction result of the second function; outputting the measured first degree of change; A method comprising the steps of:

12. A program executed by a computer of a degree of change measurement device, The computer includes: inputting a first source code including a first function and a second source code including a second function; parsing a syntax of a first function included in the input first source code, and predicting a function name of the first function based on a result of the syntax analysis; parsing a syntax of a second function included in the input second source code, and predicting a function name of the second function based on a result of the syntax analysis; measuring a first degree of change between the first and second functions by comparing a function name prediction result of the first function and a function name prediction result of the second function; outputting the measured first degree of change; A program for executing.

Citation Information

Patent Citations

  • Code management system, and code management method

    JP2020160854A

  • Information processing device, analysis system, analysis method, and non-transitory computer-readable medium having analysis program stored thereon

    WO2020049622A1