Information processing device, analysis support method, and analysis support program
The information processing device addresses the limitations of existing source code analysis by using a language model to generate explanatory texts for program components and their dependencies, improving program analysis capabilities.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- NSD ADVANCED TECHNOLOGY RESEARCH INSTITUTE CO LTD
- Filing Date
- 2024-10-11
- Publication Date
- 2026-04-23
AI Technical Summary
Existing source code analysis techniques, such as those described in Patent Document 1, fail to provide meaningful insights if the user does not understand the content of each software component, limiting the understanding of the program's mechanism.
An information processing device that includes a target portion acquisition unit and a generation control unit to input source code into a language model trained in natural language, generating explanatory texts for program components and their dependencies, along with element and target part detection units to identify and analyze hierarchical structures.
Facilitates accurate and comprehensive analysis of programs by generating explanatory texts that consider the dependencies and content of program components, enhancing user understanding.
Smart Images

Figure 2026069324000001_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an information processing apparatus that analyzes the source code of a program and the like.
Background Art
[0002] Techniques for analyzing the source code of a program have been conventionally known. For example, Patent Document 1 below describes that a source code analyzer extracts each software component from the source code and extracts a call relationship indicating the call and return relationships between the software components. Further, Patent Document 1 describes that a tree diagram generator generates a tree diagram of the source code based on each software component and the call relationship extracted as described above.
Prior Art Documents
Patent Documents
[0003]
Patent Document 1
Summary of the Invention
Problems to be Solved by the Invention
[0004] However, the tree diagram generated by the tree diagram generator described in Patent Document 1 is useful only when the user understands the content of each software component shown in the tree diagram. That is, if the user does not understand the content of each software component of the program, even if the relationship between the software components is understood from the tree diagram, the mechanism of the program cannot be understood and it is meaningless.
[0005] Therefore, a new technique for assisting in the analysis of a program is required. The object of the present invention is to provide an information processing apparatus and the like that assist in the analysis of a program.
Means for Solving the Problems
[0006] To solve the above problems, an information processing device according to one aspect of the present invention includes: a target portion acquisition unit that acquires a target portion from the source code constituting a program for which an explanatory text about its contents is to be generated; and a generation control unit that inputs the target portion and an explanatory text about a portion of the program that is dependent on the target portion into a language model that has been trained in natural language, and generates an explanatory text about the target portion.
[0007] Furthermore, in order to solve the above problems, an information processing device according to another aspect of the present invention includes an element detection unit that detects elements that depend on the description of a second layer, which is a layer directly below the first layer, from a first layer in a program having a hierarchical structure, and a target part detection unit that detects the portion that describes the element in the second layer as a target part to be analyzed in the program.
[0008] Furthermore, in order to solve the above problems, an analysis support method according to one aspect of the present invention is a program analysis support method executed by one or more information processing devices, comprising: a target part acquisition step of acquiring a target part from the source code constituting the program that is to be used to generate an explanatory text about its contents; and a generation control step of inputting the target part and an explanatory text about a part of the program that is dependent on the target part into a language model that has been trained in natural language, and causing the model to generate an explanatory text about the target part.
[0009] Furthermore, in order to solve the above problems, another aspect of the present invention provides a program analysis support method executed by one or more information processing devices, comprising: an element detection step of detecting elements that depend on the description of a second hierarchy, which is a hierarchy directly below the first hierarchy, from among the parts of the hierarchical structure constituting the program to be analyzed, and a target part detection step of detecting the part that describes the element in the second hierarchy as the target part to be analyzed in the program. [Effects of the Invention]
[0010] According to one aspect of the present invention, it is possible to support the analysis of a program. [Brief explanation of the drawing]
[0011] [Figure 1] This is a block diagram showing an example of the main components of the information processing device according to this embodiment. [Figure 2] This figure shows an example of detecting the target area. [Figure 3] This figure shows an example of generating a descriptive text for the lowest level of the target program. [Figure 4] This figure shows an example of generating a descriptive text for the part of the target program that belongs to the second level of hierarchy. [Figure 5] This flowchart shows an example of a process for detecting the target portion of a program. [Figure 6] This flowchart shows an example of the process for generating a description of the target program. [Modes for carrying out the invention]
[0012] [Configuration of Information Processing Device 1] Figure 1 is a block diagram showing an example of the main components of the information processing device 1 according to this embodiment. The information processing device 1 is a device equipped with functions to support the analysis of programs (computer programs). The information processing device 1 may be a device used by individual users who perform program analysis, or it may be a device (e.g., a server) that provides program analysis support services to multiple users. In the following, the program that the information processing device 1 analyzes will be referred to as the target program.
[0013] As shown in the figure, the information processing device 1 includes a control unit 10 that controls all parts of the information processing device 1, and a storage unit 11 that stores various data used by the information processing device 1. The information processing device 1 also includes a communication unit 12 for the information processing device 1 to communicate with other devices, an input unit 13 that receives input of various data to the information processing device 1, and an output unit 14 for the information processing device 1 to output various data. The control unit 10 also includes a dependency analysis unit 101, a presentation control unit 102, a reception unit 103, an element detection unit 104, a target part detection unit 105, a target part acquisition unit 106, and a generation control unit 107.
[0014] The dependency analysis unit 101 analyzes each part of the source code of the target program and generates dependency information that shows the hierarchical dependencies between those parts. For example, the dependency analysis unit 101 may divide the source code of the target program into predetermined units such as classes and methods (any unit with coherent content is acceptable), and then associate the parts that have dependencies among the parts obtained from the division. By performing such analysis, it is possible to generate dependency information that shows the multiple parts that make up the target program and the dependencies between those parts.
[0015] The method for generating dependency information is arbitrary. For example, a typical compiler has functions such as lexical analysis and syntactic analysis of the program's source code. Here, lexical analysis is the analysis that divides the source code into tokens and identifies the type of token, while syntactic analysis is the analysis that converts the token sequence into a syntax tree or parse tree. Both the syntax tree and the parse tree are tree structures that represent the structure of the program's source code. Therefore, the dependency analysis unit 101 can also generate dependency information by utilizing these functions of the compiler. In this case, the dependency analysis unit 101 can use the syntax tree or parse tree generated by the compiler as dependency information. Alternatively, the dependency analysis unit 101 may perform lexical analysis and syntactic analysis similar to that of the compiler, or the dependency analysis unit 101 may cause the compiler provided by the information processing device 1 or other devices to generate the dependency information.
[0016] Also, for example, the dependency analysis unit 101 can also generate dependency information by searching for strings included in the source code of the target program. In this case, the dependency analysis unit 101 divides the target program into predetermined units, searches for strings commonly included in a plurality of parts obtained by the division, and may detect parts containing common strings as parts having a dependency relationship. For this search, for example, grep (global regular expression print) or the like can also be used.
[0017] The presentation control unit 102 performs control to present various types of information related to the analysis support of the target program to the user of the information processing apparatus 1. For example, the presentation control unit 102 presents candidates for elements to be used for generating explanatory texts among the source codes that are components of the target program. Note that the presentation mode is arbitrary. For example, the presentation control unit 102 may present the information by causing the output unit 14 of the information processing apparatus 1 to output the information to be presented. Also, for example, the presentation control unit 102 may present the information by causing a terminal device outside the information processing apparatus 1 (for example, a terminal device used by a user of a program analysis support service) to output the information to be presented. The mode of information output may be display output, voice output, print output, or a combination thereof according to the information to be presented.
[0018] The reception unit 103 receives a user's instruction in the analysis of the target program. For example, the reception unit 103 receives a designation of an element to be used for generating an explanatory text among the components of the target program. The user's instruction may be received via the input unit 13 or via the communication unit 12.
[0019] The element detection unit 104 detects elements in each layer (exactly, each layer except the lowest layer) of the source code of the target program having a hierarchical structure that depend on the description of the layer immediately below that layer. What elements are to be the detection targets is arbitrary.
[0020] For example, in a program, it can be said that there is a dependency relationship between the part where a method is defined and the part where the defined method is called. Therefore, for example, the program may be hierarchically organized with the class containing the part that calls the defined method as the upper layer and the class that defines the method as the lower layer. Such a hierarchy is called a call hierarchy. In this case, the element detection unit 104 detects the part that calls the method in the upper layer as an element that depends on the description in the layer immediately below that layer.
[0021] Also, it can be said that there is a dependency relationship between the part where an import is declared and the part where the target of the import is defined. Therefore, for example, the program may be hierarchically organized with the class containing the import declaration as the upper layer and the class that defines the target of the import as the lower layer. Such a hierarchy is called an import hierarchy. In this case, the element detection unit 104 detects the part of the import declaration in the upper layer as an element that depends on the description in the layer immediately below that layer.
[0022] Also, it can be said that there is a dependency relationship between the part where a field or variable is defined and the part where the defined field or variable is referenced. Therefore, for example, the program may be hierarchically organized with the part that references the defined field or variable as the upper layer and the part that defines the field or variable as the lower layer. In this case, the element detection unit 104 detects the part that references the field or variable in the upper layer as an element that depends on the description in the layer immediately below that layer.
[0023] Note that the criterion for dividing the hierarchy is arbitrary. For example, one class may be divided into multiple parts (for example, the part where fields or variables are defined and the part where the defined fields or variables are referenced), and each part may be set as a different layer. Also, the details of the element detection method will be described later.
[0024] The target part detection unit 105 detects the portion of the source code of the target program that describes the element detected by the element detection unit 104 as the target portion for generating an explanatory text. For example, suppose the element detection unit 104 detects a portion of the target program that makes a call to a certain method, as an element that depends on the description of the second level, which is the level directly below the first level. In this case, the target part detection unit 105 detects the portion of the second level that describes the element, specifically the portion that defines the method, as the target portion of the target program to be analyzed. Details of the method for detecting the target portion will be described later.
[0025] The target part acquisition unit 106 acquires the target part from the source code that makes up the target program, which is the part from which an explanatory text about its contents will be generated. As described above, the target part detection unit 105 detects the target part, so the target part acquisition unit 106 only needs to acquire the target part detected by the target part detection unit 105.
[0026] The generation control unit 107 inputs the target part and the descriptive text of the part that is dependent on the target part in the target program into a language model that has been trained on natural language, and causes it to generate a descriptive text of the target part.
[0027] In this context, "training a model in natural language" more specifically means training it to learn the arrangement of its constituent elements (such as words) in natural language sentences, and the arrangement of sentences within a text. Examples of such language models include GPT (Generative Pre-trained Transformer) and BERT (Bidirectional Encoder Representations from Transformers).
[0028] The language model may be a general-purpose model that can be used for purposes other than generating program code descriptions, or it may be a model specifically designed for generating program code descriptions. Alternatively, a general-purpose language model that has been fine-tuned for generating program code descriptions may be used. The language model may be stored in the information processing device 1, or a language model provided by another device may be used. In the latter case, the generation control unit 107 can instruct the device equipped with the language model to generate the description and retrieve the generated description from that device.
[0029] As described above, the information processing device 1 includes a target part acquisition unit 106 that acquires a target part from the source code that constitutes the target program, and a generation control unit 107 that inputs the target part and the explanatory text of a part in the target program that is dependent on the target part, into a language model that has been trained in natural language, and generates an explanatory text for the target part.
[0030] According to the above configuration, not only the description of the target part but also the descriptions of the parts that depend on the target part are input, and a description of the target part is generated. This makes it possible to generate an accurate description that takes into account the descriptions of the parts that depend on the target part. Therefore, according to the above configuration, the effect of being able to support the analysis of the target program is obtained.
[0031] Furthermore, as described above, the information processing device 1 includes an element detection unit 104 that detects elements in a target program having a hierarchical structure that depend on the description of a second hierarchical level which is the hierarchical level directly below the first hierarchical level, and a target part detection unit 105 that detects the portion in the second hierarchical level that describes the above elements as a target part to be analyzed in the target program.
[0032] According to the above configuration, elements described in the first layer are detected, and the portion describing those elements in the second layer is detected as the target portion for analysis. This makes it easy to perform analysis focused on the description of the above element. Therefore, the above configuration has the effect of supporting the analysis of the target program.
[0033] [Method for detecting the target area] The method for detecting the target portion will be explained based on Figure 2. Figure 2 is a diagram illustrating an example of target portion detection. Figure 2 shows the structure of the source code of target program A in a tree structure. As shown in the diagram, target program A includes code A1, which belongs to the highest level, codes A21 and A22, which belong to the second level, and codes A31 and A32, which belong to the third level, i.e., the lowest level. In the same diagram, the dependencies between each code are indicated by arrows. That is, in target program A shown in the diagram, code A1 depends on codes A21 and A22. Also, code A21 depends on codes A31 and A32, and code A22 depends on code A32.
[0034] The process of dividing the target program A into multiple parts, code A1, A21, A22, A31, and A32, and analyzing the hierarchical dependencies between these parts is performed by the dependency analysis unit 101, as described above. Then, the dependency analysis unit 101 generates dependency information that shows the results of this analysis.
[0035] The dependency information generated by the dependency analysis unit 101 may represent a tree structure as shown in Figure 2. For example, the dependency information may include information indicating the scope occupied by each part, code A1, A21, A22, A31, and A32, in the source code of the target program, and information indicating which part depends on which part. The dependency information may also include information indicating which elements in each part depend on which elements in other parts (for example, information indicating which elements of code A1 depend on which elements of code A21).
[0036] The target part acquisition unit 106 acquires each of the series of parts that have hierarchical dependencies in the target program A as target parts, based on the dependency information generated as described above. Specifically, the target part acquisition unit 106 first acquires the part belonging to the highest level of the hierarchy as the target part of that hierarchy. Then, the target part acquisition unit 106 acquires the parts belonging to the hierarchy immediately below the hierarchy from which the target part was acquired that are dependent on the acquired target part, and repeats this process until the target part belonging to the lowest level of the hierarchy is acquired.
[0037] In the example shown in Figure 2, the target part acquisition unit 106 first acquires code A1 as the target part. Next, the target part acquisition unit 106 may acquire code A21, which is dependent on code A1, and finally acquire codes A31 and A32, which are dependent on code A21, as the target parts. The target part acquisition unit 106 may also acquire code A22, which is dependent on codes A1 and A32, as the target part, but for the sake of simplicity in the following explanation, code A22 will not be included as a target part.
[0038] Thus, the information processing device 1 includes a dependency analysis unit 101 that analyzes each part of the target program A and generates dependency information indicating the hierarchical dependencies between those parts. The information processing device 1 also includes a target part acquisition unit 106 that acquires each of the series of parts in the target program that have hierarchical dependencies as target parts, based on the dependency information generated by the dependency analysis unit 101.
[0039] According to the above configuration, each of the hierarchically dependent parts in target program A is acquired as a target part, making it possible to generate descriptive text for that series of parts. Such descriptive text is extremely useful for understanding the structure of target program A.
[0040] As mentioned above, the target program A may be hierarchically structured based on the dependency between method definitions and calls. In some programs, the same method name may be described in multiple classes, but the content of that method may differ between classes. For this reason, it is preferable for the dependency analysis unit 101 to generate dependency information that uniquely identifies each method, not only by the method name but also by combining the method name with the class name of the class in which that method name is described. This prevents parts that are not dependencies from being mistakenly selected as the target part.
[0041] [Narrowing down the scope of analysis in the target area] Furthermore, for each of the parts with hierarchical dependencies in the target program A, only a portion, rather than the entire part, may be designated as the target portion. In this case, the target portion detection unit 105 detects the portion based on the elements detected by the element detection unit 104, and the portion detected by the target portion detection unit 105 becomes the target portion.
[0042] In Figure 2, code A1 describes a class called "Aaa," which defines a method called "Xxx." The definition of method "Xxx" also includes a call to a method called "Yyy."
[0043] Furthermore, code A21 describes a class called "Bbb," which defines the aforementioned method "Yyy." The definition of method "Yyy" also includes a call to a method called "Zzz."
[0044] Furthermore, code A31 describes a class called "Ccc," which defines the aforementioned method "Zzz."
[0045] The element detection unit 104 and the target part detection unit 105 detect the target part based on the descriptions of each part. Specifically, the element detection unit 104 first detects elements from the description of code A1 belonging to the highest level of hierarchy that depend on the description of the second level of hierarchy, which is the level directly below the highest level of hierarchy.
[0046] Here, when the computer executes a call to method "Yyy" in code A1, which belongs to the highest level hierarchy, it refers to the definition of method "Yyy" in code A21, which belongs to the second level hierarchy. Therefore, the description regarding the call to method "Yyy" in code A1 can be said to depend on the definition of method "Yyy" in code A21. Accordingly, the element detection unit 104 detects the description regarding the call to method "Yyy" in code A1, which belongs to the highest level hierarchy, as an element that depends on the description in the second level hierarchy.
[0047] Furthermore, if the dependency information contains information indicating which elements in each part of the target program A depend on which elements in other parts, the element detection unit 104 can perform the above detection using the dependency information. On the other hand, if such information is not included in the dependency information, the element detection unit 104 can extract the methods included in code A1 and A21, respectively. The element detection unit 104 then identifies the method defined in code A21 at the second level of the hierarchy from among the methods that are called in code A1 at the highest level of the hierarchy, and detects the part at the highest level that calls the identified method as an element that depends on the description at the second level of the hierarchy.
[0048] As described above, when an element that depends on the description in the second level of hierarchy is detected, the target part detection unit 105 detects the part describing that element as the target part. In the example in Figure 2, the target part detection unit 105 detects the part describing the method "Yyy" in code A1, that is, the part related to the call of method "Yyy", as the target part in the highest level of hierarchy. In addition, the target part detection unit 105 detects the part describing the method "Yyy" in code A21, that is, the part describing the definition of method "Yyy", as the target part in the second level of hierarchy.
[0049] Furthermore, if code A1, which belongs to the highest level of hierarchy, contains multiple elements that depend on the description in the second level of hierarchy, the presentation control unit 102 may present those elements to the user. The reception unit 103 may then accept the user's specification of which elements from the presented elements should be used to generate explanatory text. For example, suppose code A1 contains a description that calls a method called "Xyz," and that method is defined in code A22. In this case, the presentation control unit 102 may present the methods "Xxx" and "Xyz" to the user, and the reception unit 103 may accept the user's specification of either of these methods. The information processing device 1 can also generate explanatory text for each of multiple elements. For this reason, the reception unit 103 may accept the specification of multiple elements.
[0050] Next, the element detection unit 104 detects elements that depend on the description of the third level hierarchy from the target portion in code A21. In the example in Figure 2, the part that calls the method "Zzz" is detected as an element that depends on the description of the third level hierarchy. Then, the target portion detection unit 105 detects the part in code A31 where the definition of the method "Zzz" is described as the target portion. As a result, target portions are detected from codes A1, A21, and A31. Although not shown in the figure, target portions are also detected from code A32 in the same manner.
[0051] Thus, the information processing device 1 includes an element detection unit 104 that detects elements in a target program A having a hierarchical structure that depend on the description of the second hierarchical level, which is the hierarchical level directly below the first hierarchical level, and a target part detection unit 105 that detects the portion of the second hierarchical level that describes the above elements as the target part. Here, "first hierarchical level" is any hierarchical level other than the lowest level. Also, "second hierarchical level" is any hierarchical level other than the highest level. For example, in the example in Figure 2, if the highest level is the first hierarchical level, then the second hierarchical level is the second level. Also, in the example in Figure 2, if the second level is the first hierarchical level, then the second hierarchical level is the third level.
[0052] The above configuration makes it possible to generate explanatory texts that focus solely on the elements mentioned above. Furthermore, this configuration minimizes the volume of the target portion input to the language model, making it possible to generate accurate explanatory texts even when using a language model with limitations on the number of characters that can be input.
[0053] [Method for generating explanatory text] The method for generating a descriptive text about the target program will be explained based on Figures 3 and 4. Figure 3 shows an example of generating a descriptive text for the lowest level of the target program A. Figure 4 shows an example of generating a descriptive text for the second-level of the target program A.
[0054] When generating a descriptive text for the lowest level of the target program A, the generation control unit 107 inputs the target section belonging to the lowest level into the language model. In the example in Figure 3, the generation control unit 107 generates prompt B31 which includes code A31 belonging to the lowest level (more specifically, the section containing the definition of the method "Zzz" as detected by the target section detection unit 105 from code A31). The generation control unit 107 then inputs the generated prompt B31 into the language model M to generate the descriptive text C31.
[0055] Prompt B31 instructs the system to document the code described in the prompt, or in other words, to generate a description of the code. For example, the generation control unit 107 can generate prompt B31 by inputting the string 'Zzz', which is the name of the method defined in target part A311, and the target part A311 detected by the target part detection unit 105 into a predetermined template.
[0056] Similarly, the generation control unit 107 also generates a prompt B32 for code A32, instructing the generation of an explanatory text for code A32 (more specifically, the target portion detected by the target portion detection unit 105 from code A31). The generated prompt B32 is then input to the language model M to generate the explanatory text C32.
[0057] After generating descriptive text for each part belonging to the lowest level as described above, the generation control unit 107 generates descriptive text for each part belonging to a higher level that is dependent on those parts. For example, after generating descriptive texts C31 and C32 for codes A31 and A32, which belong to the lowest level, the generation control unit 107 generates a descriptive text for code A21, which is dependent on codes A31 and A32.
[0058] Figure 4 shows an example of generating a description for code A21. In the example in Figure 4, the generation control unit 107 generates a prompt B21 that instructs the generation of a description for code A21 (more specifically, the part containing the definition of method "Yyy" that the target part detection unit 105 detected from code A21, i.e., the target part A211).
[0059] Compared to prompt B31 shown in Figure 3, prompt B21 changes the element and target part for which it requests explanation to be the method "Yyy" and target part A211 described in code A21. In addition, prompt B21 includes the explanatory text C31 and explanatory text C32 of code A31, as well as a statement instructing the user to enrich the explanation by referring to the information described in those explanatory texts. As a result, explanatory text C21 is generated that takes into account explanatory texts C31 and C32 of code A31 and A32, which are dependent on target part A211.
[0060] Note that prompt B21 only needs to instruct the system to generate an explanation considering explanatory texts C31 and C32, and does not necessarily need to instruct the system to enrich the explanation. For example, prompt B21 may instruct the system to select the necessary information considering explanatory texts C31 and C32 and explain the target part A211. This makes it possible to generate a concise explanation. Alternatively, prompt B21 may instruct the system to explain the target part A211 considering the meaning and purpose of the process explained in explanatory texts C31 and C32. This makes it possible to generate an abstract explanation of the target part A211.
[0061] Furthermore, although not shown in Figure 4, the generation control unit 107 generates the explanatory text for the target part of code A1 in the same manner as the explanatory text for code A21. In other words, in order to generate the explanatory text for the target part of code A1, the generation control unit 107 generates a prompt that includes the explanatory text generated for the target part belonging to a lower hierarchy than code A1. For example, the generation control unit 107 may generate a prompt that includes all of the explanatory texts C21, C31, and C32, or it may generate a prompt that includes explanatory text C21 but does not include C31 and C32. In either case, the likelihood of generating an accurate explanatory text can be increased compared to using a prompt that does not include an explanatory text.
[0062] As described above, the generation control unit 107 may, based on dependency information, have the language model M sequentially generate descriptive texts for each target part, from the lowest-level target part to the highest-level target part, among the target parts acquired by the target part acquisition unit 106. Furthermore, when the generation control unit 107 generates descriptions for target parts belonging to a higher level than the lowest level, it may also input the descriptive texts generated for target parts belonging to even lower levels into the language model M.
[0063] According to the above configuration, since the descriptive text for the target part belonging to each hierarchical level is generated sequentially using the descriptive text generated for the target part belonging to a lower hierarchical level, it becomes possible to efficiently generate accurate descriptive text for the target part of each hierarchical level.
[0064] [Processing flow: Detection of the target part] The process flow for detecting the target portion of the target program will be explained with reference to Figure 5. Figure 5 is a flowchart showing an example of the process for detecting the target portion of the target program. The process shown in Figure 5 includes each step of the analysis support method according to this embodiment. It is assumed that the source code of the target program is input to the information processing device 1 before the process in Figure 5 starts. The method of inputting the source code is arbitrary. For example, it may be input via the communication unit 12 or the input unit 13, or the source code may be input by having the information processing device 1 read the source code stored in external storage such as a USB (Universal Serial Bus) memory.
[0065] In S1, the dependency analysis unit 101 analyzes each part of the source code of the target program and generates dependency information that shows the hierarchical dependencies between each part. For example, the dependency analysis unit 101 may divide the source code of the target program into tokens, identify the type of each token, and then generate tree-structured dependency information that represents the structure of the source code of the target program based on the identification results.
[0066] In S2, the element detection unit 104, based on the dependency information generated in S1, targets the highest level of the target program (more precisely, the part of the multiple parts that make up the target program that is indicated to belong to the highest level in the dependency information) for processing.
[0067] In S3 (element detection step), the element detection unit 104 detects elements that depend on the description in the second level, which is the level directly below, from among the parts of the hierarchical structure that constitute the target program that are included in the highest level that was processed in S2. For example, the element detection unit 104 may detect as the above element a method that is called in the highest level of the target program and whose definition is described in the second level.
[0068] If multiple elements are detected in S3, the presentation control unit 102 may present the elements detected in S3 to the user as candidate elements for analysis. The reception unit 103 then accepts the user's selection of the elements to be analyzed from among the elements presented by the presentation control unit 102, and the element detection unit 104 may designate the selected elements as elements that depend on the description of the second level of hierarchy. These processes are not mandatory, and the processing from S4 onward may be performed for each of the multiple elements detected.
[0069] In S4 (Target Part Detection Step), the target part detection unit 105 detects the portion describing the element detected in S3 in the second level, which is the level directly below the highest level that was processed in S2, as the target part in the second level. For example, if a description of calling a method is detected in S3, in S4, the target part detection unit 105 detects the portion that defines that method as the target part. In addition, the target part detection unit 105 detects the portion describing the element detected in S3 (for example, the portion related to the above method call) in the highest level of the target program as the target part in the highest level.
[0070] Furthermore, if multiple target parts are detected from a single layer in S4, the presentation control unit 102 may present the detected multiple target parts to the user. The reception unit 103 may then accept the user's designation of a target part to be analyzed from among the multiple target parts presented by the presentation control unit 102. Also, if no target part is detected in S4, the reception unit 103 may accept the user's designation of a target part, and the target part detection unit 105 may detect the part designated by the user as the target part.
[0071] In S5, the target part detection unit 105 determines whether or not to terminate the detection of the target part. Specifically, the target part detection unit 105 determines whether to terminate the detection of the target part (YES in S5) if the detection of the target part has been completed for each level from the highest level to the lowest level, and whether to continue the detection of the target part (NO in S5) if there are levels where detection has not been completed. If the determination in S5 is YES, the process in Figure 4 ends. On the other hand, if the determination in S5 is NO, the process proceeds to S6.
[0072] In S6, the element detection unit 104 processes the hierarchy immediately below the hierarchy it most recently processed. For example, if the hierarchy most recently processed by the element detection unit 104 was the highest level, in S6 it processes the second-highest level.
[0073] After S6, the process returns to S3, and the element detection unit 104 detects elements that depend on the description of the immediately lower level from among the parts of the hierarchical structure that constitute the target program that are included in the hierarchical structure that was processed in S6. Then, in the following S4, the target part detection unit 105 detects the part that describes the element detected in the most recent S3 in the hierarchical structure immediately below the hierarchical structure that was processed in S6 as the target part of that hierarchical structure.
[0074] As described above, the analysis support method executed by the information processing device 1 includes an element detection step of detecting elements that depend on the description of the second level, which is the level directly below the first level, from among the parts of the hierarchical structure that constitute the target program that belong to the first level, and a target part detection step of detecting the part in the second level that describes the above element as the target part to be analyzed in the target program. With the above configuration, it becomes possible to easily perform analysis that focuses on the description of the above element. Therefore, with the above configuration, the effect of supporting the analysis of the target program can be obtained.
[0075] [Processing flow: Generating explanatory text] The process flow for generating a description of the target program will be explained with reference to Figure 6. Figure 6 is a flowchart showing an example of the process for generating a description of the target program. Note that the process in Figure 6 is performed after the process in Figure 5 is completed. Furthermore, the process shown in Figure 6 includes each step of the analysis support method according to this embodiment.
[0076] In S11, the target part acquisition unit 106 acquires the target part from the source code that constitutes the lowest level of the target program, which is the part from which an explanatory text about its contents will be generated. This target part was detected by the process shown in Figure 5. When generating an explanatory text for a target program that has multiple target parts in the lowest level, such as target program A shown in Figures 2 to 4, the target part acquisition unit 106 acquires each of the multiple target parts belonging to the lowest level. The same applies to S13, which will be described later, in which the target part acquisition unit 106 acquires each target part when there are multiple target parts in a single level.
[0077] In S12, the generation control unit 107 causes the language model to generate a descriptive text for the target portion acquired in S11. For example, the generation control unit 107 may generate a prompt by incorporating the target portion acquired in S11 and a string indicating the element detected by the element detection unit 104 for that target portion into a predetermined template that instructs the generation of a code descriptive text, and then input the generated prompt into the language model to generate the descriptive text. If multiple target portions are acquired in S11, the generation control unit 107 causes the language model to generate a descriptive text for each target portion. This is also the case in S14, which will be described later.
[0078] In step S13 (Target Part Acquisition Step), the Target Part Acquisition Unit 106 acquires the target part from the source code that constitutes one level above the lowest level of the target program, and which is the part from which an explanatory text about its contents will be generated. This target part was also detected by the process shown in Figure 5.
[0079] In S14 (generation control step), the generation control unit 107 inputs the target portion acquired in S13 and the explanatory text generated in S12 into a language model trained on natural language, causing it to generate an explanatory text for the target portion. For example, the generation control unit 107 may generate a prompt by incorporating the target portion acquired in S13, a string indicating the element detected by the element detection unit 104 for the target portion, and the explanatory text generated in S12 into a predetermined template that instructs the system to generate an explanatory text for the target code by referring to other explanatory texts that have been input, and then input the generated prompt into the language model to generate the explanatory text. The explanatory text generated in S12 is an explanatory text for a part of the target program that has a dependency on the target portion acquired in S13.
[0080] In S15, the generation control unit 107 determines whether or not to terminate the generation of explanatory texts. In S15, the generation control unit 107 determines whether to terminate the generation of explanatory texts (YES in S15) if explanatory texts have already been generated for each target part from the lowest level to the highest level, and whether to continue generation (NO in S15) if there are target parts for which explanatory texts have not yet been generated. If the result in S15 is YES, the process proceeds to S16; if the result in S15 is NO, the process returns to S13.
[0081] In S13, which follows from S15, the target part acquisition unit 106 acquires the target part from the source code that constitutes one level higher than the level acquired in the previous S13 within the target program, and which is the target for generating an explanatory text about its contents. Then, in the following S14, the generation control unit 107 inputs the target part acquired in the most recent S13 and each explanatory text that has been generated for the target program up to that point into the language model and generates an explanatory text.
[0082] In S16, the presentation control unit 102 presents the user with the generated explanatory text for the target portion at the highest level. This completes the process shown in Figure 6. In addition, in S16, the presentation control unit 102 may also present the explanatory texts generated for the target portions at lower levels. Furthermore, the presentation control unit 102 may present the generated explanatory text each time it is generated.
[0083] As described above, the analysis support method executed by the information processing device 1 includes a target part acquisition step of acquiring a target part from the source code that constitutes the target program, from which an explanatory text about its contents will be generated, and a generation control step of inputting the above target part and the explanatory text of a part in the target program that is dependent on the above target part into a language model that has been trained in natural language, and causing it to generate an explanatory text about the above target part.
[0084] According to the above configuration, not only the description of the target part but also the descriptions of the parts that depend on the target part are input, and a description of the target part is generated. This makes it possible to generate an accurate description that takes into account the descriptions of the parts that depend on the target part. Therefore, according to the above configuration, the effect of being able to support the analysis of the target program is obtained.
[0085] [Variation] The entity executing each process described in the above-described embodiment is arbitrary and is not limited to the examples given. In other words, the same functions as the information processing device 1 can be realized by multiple information processing devices that can communicate with each other. For example, each process shown in Figures 5 and 6 may be divided and executed by multiple information processing devices.
[0086] [Reference example] In the above-described embodiment, the element detection unit 104 and the target portion detection unit 105 do not necessarily require the existence of the target portion acquisition unit 106 and the generation control unit 107. In other words, in the information processing device 1, it is possible to omit the target portion acquisition unit 106 and the generation control unit 107 and instead provide only the element detection unit 104 and the target portion detection unit 105.
[0087] In this case, the detection result of the target part detection unit 105 may be output to another device equipped with a target part acquisition unit 106 and a generation control unit 107 to generate an explanatory text for the target part, or the detection result of the target part may be used for other purposes. For example, the information processing device 1 may be configured to include an element detection unit 104 and a target part detection unit 105, as well as a presentation control unit 102, and the detection result of the target part may be presented to the user by the presentation control unit 102. This allows the user to analyze the target program, etc., by referring to the detection result of the target part.
[0088] [Examples of implementation using software] The function of the information processing device 1 is a program that causes the computer to function as the information processing device 1, and this can be realized by a program (analysis support program) that causes the computer to function as each control block (particularly each part included in the control unit 10) of the information processing device 1.
[0089] In this case, the information processing device 1 includes a computer having at least one control device (e.g., a processor) and at least one storage device (e.g., memory) as hardware for executing the above program. By executing the above program using this control device and storage device, each of the functions described in the above embodiment is realized.
[0090] The above program may be recorded on one or more computer-readable recording media, not temporary ones. This recording media may or may not be provided by the information processing device 1. In the latter case, the program may be supplied to the information processing device 1 via any wired or wireless transmission medium.
[0091] Furthermore, some or all of the functions of each of the above control blocks can also be realized by logic circuits. For example, an integrated circuit in which logic circuits functioning as each of the above control blocks are formed is also included in the scope of the present invention. In addition, it is also possible to realize the functions of each of the above control blocks by, for example, a quantum computer.
[0092] The present invention is not limited to the embodiments described above, and various modifications are possible within the scope of the claims. Embodiments obtained by appropriately combining the technical means disclosed in different embodiments are also included in the technical scope of the present invention. [Explanation of Symbols]
[0093] 1. Information Processing Device 101 Dependency analysis part 102 Display Control Unit 104 Element detection unit 105 Target part detection unit 106 Target portion acquisition unit 107 Generation Control Unit
Claims
1. A target part acquisition unit that acquires the target part from the source code that makes up the program, which is the target for which an explanatory text about its content will be generated. An information processing device comprising: a language model trained on natural language, inputting the target portion and a descriptive text of a portion of the program that is dependent on the target portion, and causing the device to generate a descriptive text of the target portion.
2. The program includes a dependency analysis unit that analyzes each part of the program and generates dependency information showing the hierarchical dependencies between those parts. The information processing apparatus according to claim 1, wherein the target portion acquisition unit acquires each of a series of parts that have hierarchical dependencies in the program as the target portion based on the dependency information.
3. The generation control unit, Based on the dependency information, the language model sequentially generates descriptive texts for each of the target parts acquired by the target part acquisition unit, from the lowest-level target part to the highest-level target part. The information processing apparatus according to claim 2, wherein when generating a description of the target portion belonging to a hierarchy higher than the lowest hierarchy, the description text generated for the target portion belonging to an even lower hierarchy is also input to the language model.
4. An element detection unit that detects elements in a program having a hierarchical structure that depend on the description of a second hierarchy which is a hierarchy directly below the first hierarchy, The information processing apparatus according to claim 2 or 3, comprising: a target portion detection unit that detects the portion describing the element in the second hierarchy as the target portion.
5. An element detection unit that detects elements in a program having a hierarchical structure that depend on the description of a second hierarchy, which is the hierarchy directly below the first hierarchy, from a first hierarchy, An information processing apparatus comprising: a target portion detection unit that detects the portion describing the element in the second hierarchy as a target portion to be analyzed in the program.
6. A method for supporting program analysis, which is executed by one or more information processing devices, A target part acquisition step that acquires the part of the source code that makes up the program that will be used to generate an explanatory text about its contents, A method for supporting analysis, comprising a generation control step of inputting the target portion and a descriptive text of a portion of the program that is dependent on the target portion into a language model trained on natural language, and causing the model to generate a descriptive text of the target portion.
7. A method for supporting program analysis, which is executed by one or more information processing devices, An element detection step that detects elements that depend on the description of the second level, which is the level directly below the first level, from among the parts of the hierarchical structure that constitute the program to be analyzed, An analysis support method comprising: a target part detection step of detecting the portion describing the element in the second hierarchy as the target part to be analyzed in the program.
8. An analysis support program for causing a computer to function as an information processing device according to claim 1, wherein the computer functions as the target portion acquisition unit and the generation control unit.
9. An analysis support program for causing a computer to function as an information processing device according to claim 5, wherein the computer functions as the element detection unit and the target part detection unit.
Citation Information
Patent Citations
Sequence diagram generation apparatus
WO2020174578A1