Source code retrieval system and source code retrieval method

The source code search system addresses the limitation of existing systems by incorporating contextual information, allowing for more relevant code searches by pairing code and context data, thereby enhancing search efficiency and development productivity.

WO2024237034A1PCT designated stage expired Publication Date: 2024-11-21HITACHI LTD

Patent Information

Application Number
PCT/JP2024/015853
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-15
Filing Date
2024-04-23
Publication Date
2024-11-21

AI Technical Summary

Technical Problem

Existing code search systems fail to consider broader contextual information, such as project purpose or domain, when returning search results, limiting their ability to provide relevant code snippets for developers.

Method used

A source code search system that inputs reference information into a code base, extracts and stores code information along with corresponding context information, allowing for the presentation of search results based on both code functions and contextual data, using a database to pair and store code and context information.

Benefits of technology

Enables users to search for source code based on abstract information like project purpose or domain, reducing search time and improving development productivity by providing relevant code snippets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2024015853_21112024_PF_FP_ABST
    Figure JP2024015853_21112024_PF_FP_ABST
Patent Text Reader

Abstract

This source code retrieval system comprises: a code information extraction unit that inputs reference information to a codebase for storing a repository in which the source code of a program is registered and outputs code information obtained by adding supplementary information to the source code acquired from the codebase; a context information extraction unit that inputs the code information to the codebase, extracts context information corresponding to the code information from the codebase, and outputs the context information together with the code information; and a source code retrieval database that stores the code information and the context information corresponding to the code information as a pair.
Need to check novelty before this filing date? Find Prior Art

Description

Source code search system and source code search method

[0001] The present invention relates to a source code search system and a source code search method.

[0002] Over the past two decades, huge code bases have emerged that are openly accessible on the Web. Reusing source code (hereafter referred to as "code") contained in such code bases significantly improves the efficiency and quality of software development. Semantic code search (hereafter referred to as "code search") is an important technique for finding reusable code in specific situations. Code search aims to find code that best matches a given natural language query. A natural language query is, for example, a command that a user can use to issue a search instruction by entering natural language, such as a question sentence.

[0003] To tackle the task of code search, many deep neural network (DNN)-based models have been proposed, such as those shown in Non-Patent Document 1. These models are constructed to capture the association between queries and code in a vector space. Queries are usually performed by specifying the code features that the user wants to retrieve, such as "How can I sort users?"

[0004] In recent years, many benchmarks have been proposed to measure the search performance of these models. The most well-known benchmark is CodeSearchNet (CSN), described in Non-Patent Document 2. CSN contains a training dataset consisting of a large number of functions collected from a code base. Each function is paired with a comment (a natural language sentence written immediately after the function definition). This comment usually describes the functionality of the code.

[0005] Pairs of functions and comments are suitable for learning the relationship between code and queries, and have been used to train DNNs. As mentioned above, existing research has focused on searching code based on its functions.

[0006] Zhensu Sun, Yan Liu, Chen Yang, and Yu Qian. Pscs: A path-based neural model for semantic code search. arXiv preprint arXiv:2008.03042, 2020. Husain, Hamel, et al. "Codesearchnet challenge: Evaluating the state of semantic code search." arXiv preprint arXiv:1909.09436 (2019).

[0007] However, in real-world software development, not only the functionality of the code but also the broader context is important. For example, when a developer is working on a specific software development project, the code they develop must reflect the specific purpose or domain of that project (e.g., the industry in which the program will be used, such as a financial system, customer management system, or distribution system). Therefore, a developer's query may include contextual information, such as "How can I sort users in an ad recommendation system?" Existing models only considered the query and the code during the search, making it impossible to return search results that take the above contextual information into account.

[0008] The present invention has been made in light of the above circumstances, and aims to enable code search to present search results based not only on the code's function but also on broader contextual information.

[0009] The source code search system of the present invention includes a code information extraction unit that inputs reference information into a code base that stores a repository in which program source code is registered, and outputs code information in which supplemental information is added to source code obtained from the code base; a context information extraction unit that inputs code information into the code base, extracts context information corresponding to the code information from the code base, and outputs the context information together with the code information; and a source code search database that stores code information and context information corresponding to the code information as pairs.

[0010] According to the present invention, a source code search system includes a source code search database that stores code information and corresponding context information as pairs, enabling code search results to be presented based on a broader range of context information rather than just the code's function. Problems, configurations, and advantages other than those described above will become clear from the following description of the embodiment.

[0011] FIG. 1 is a block diagram showing an example of the overall configuration of a source code search system according to a first embodiment of the present invention. FIG. 2 is a diagram showing an example of code information according to a first embodiment of the present invention. FIG. 3 is a diagram showing an example of an extraction target of character string information according to a first embodiment of the present invention. FIG. 4 is a diagram showing an example of context information according to a first embodiment of the present invention. FIG. 5 is a diagram showing an example of a source code search screen and a search result display screen according to a first embodiment of the present invention. FIG. 6 is a flowchart showing an example of a method for saving code information and context information according to a first embodiment of the present invention. FIG. 7 is a flowchart showing an example of a code search method according to a first embodiment of the present invention. FIG. 8 is a block diagram showing an example of the hardware configuration of a computer according to a first embodiment of the present invention. FIG. 9 is a block diagram showing an example of the overall configuration of a source code search system according to a second embodiment of the present invention. FIG. 10 is a diagram showing an example of rough context information according to a second embodiment of the present invention.

[0012] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In this specification and drawings, components having substantially the same functions or configurations are designated by the same reference numerals, and redundant description will be omitted.

[0013] First Embodiment FIG. 1 is a block diagram showing an example of the overall configuration of a source code search system 1 according to a first embodiment of the present invention.

[0014] The source code search system 1 includes a code information extraction unit MD1, a context information extraction unit MD2, a code and context information database DB1 (an example of a source code search database), and a search unit MD3. The source code search system 1 is configured, for example, by a cloud server. A user can access the source code search system 1 through a web browser by operating a PC2. A code base DB0 is provided outside the source code search system 1 and stores a repository in which program source code is registered. The code base DB0 is an example of a database system that stores a large number of codes.

[0015] The code information extraction unit MD1 inputs reference information to the code base DB0 and outputs code information obtained by adding supplemental information to source code acquired from the code base DB0. For example, the code information extraction unit MD1 receives an input of a uniform resource locator (URL), which is access information for the code base DB0, to access the code base DB0, and extracts and outputs multiple pieces of code information D0 from the code base DB0. The supplemental information is information other than the code character strings in the code information D0 shown in FIG. 2, which will be described later.

[0016] The code information extraction unit MD1 can also divide the source code acquired from the code base DB0 into specified units (for example, by function), add supplemental information to the divided source code, and output the code information D0. The data structure of the code information D0 is such that supplemental information is added to each piece of information obtained by dividing the code present in the code base DB0 into small, specified units.

[0017] 2 is a diagram showing an example of code information D0. In the code information D0 shown in FIG. 2, a function is used as the above-mentioned "small-scale unit."

[0018] Code information D0 has the fields "Code String," "Original File," and "Number of Lines." "Code String" stores the string information of one function. "Original File" is the URL of the file in which the function stored in "Code String" was written. This URL is an example of access information that indicates the storage location of the file in which the function was written. In this case, the storage location of a program file written in the Python language is indicated by the URL. "Number of Lines" is the start and end line numbers of the "Code String" written in the file in which the function was written. "Number of Lines" is expressed in the format [start line number, end line number].

[0019] The code information extraction unit MD1 can identify the string information of a function and the supplementary information for the string information, such as the "original file" and "number of lines," from the code base DB0 by applying a source code analysis technique to each file included in the code base DB0. The source code analysis technique is one of the functions of the code information extraction unit MD1, and makes it possible to divide the source code into functions, which are defined units, by using, for example, regular expressions or by analyzing the source code using a compiler.

[0020] As described above, the supplemental information is information other than the "code string," that is, information that includes at least one of the "original file" and the "number of lines."

[0021] The input to the code information extraction unit MD1 does not have to be a URL, as long as it is information that can specify source code from the repository of the code base DB0. For example, if the original data of the code base DB0 is available, the storage location of that data may be used.

[0022] The context information extraction unit MD2 inputs code information into the code base DB0, extracts context information corresponding to the code information from the code base DB0, and outputs the context information together with the code information. For example, the context information extraction unit MD2 receives code information D0 as input and identifies context information D1 corresponding to the code information D0 from the code base DB0. The context information extraction unit MD2 then outputs the identified context information D1 and the code information D0.

[0023] FIG. 3 is a diagram showing an example of a target for extracting character string information. Source code (1) in FIG. 3 shows an example of source code written in Java (registered trademark), a programming language. This source code represents a function that calculates the sum of variables a and b. The code information extraction unit MD1 extracts the entire text of this source code as character string information of the function.

[0024] Source code (2) in Figure 3 shows an example of source code written in Python (registered trademark), a programming language. This source code represents a function that calculates the sum of variables a and b. The code information extraction unit MD1 extracts the entire text of this source code as string information of the function.

[0025] 3, only functions such as those shown in (1) and (2) are stored as source code in the code base DB0. In this case, the code information extraction unit MD1 outputs the source code acquired from the code base DB0 to the context information extraction unit MD2 without dividing it.

[0026] Source code (3) in Figure 3 shows an example of source code written in Python. This source code uses an if statement to compare the sizes of variables a and b and output the different value, and is not a function. Therefore, the code information extraction unit MD1 does not output this source code as character string information. Note that if an if statement is included in a function defined as shown in source code (1) or (2), the entire function including the if statement can be extracted as character string information.

[0027] 4 is a diagram showing an example of context information D1. As shown in FIG. 1, context information D1 is information extracted from code base DB0 by context information extraction unit MD2, and is meta-information. Meta-information is information that explains the contents of code information D0, and is also called metadata.

[0028] Context information D1 has the items "target string," "original file," and "number of lines." "Target string" is a string that indicates the purpose of the original repository that contained the code. "Original file" is the URL of the original file that contained the "target string." This URL is an example of access information that indicates the storage location of the original file. In this case, the storage location of the README file is indicated by a URL as the original file. "Number of lines" is the start and end line numbers in the file where the "target string" is written. "Number of lines" is expressed in the format [start line number, end line number].

[0029] There are various possible methods for the context information extraction unit MD2 to identify the information of the context information D1 from the code base DB 0. For example, if the original repository includes a README file, the context information extraction unit MD2 identifies the README file using a string-based rule, such as a rule that "the file name contains the string readme or README."

[0030] The context information extraction unit MD2 also extracts a specific number of lines from the identified README file, for example, "lines 1 to 3," as the "target character string." The reason for using "lines 1 to 3" as an example is that the first text in a README file often contains information such as the repository's purpose, domain (the industrial field in which the program is used), or project details. In addition to the README file, file comments, class comments, and the like, which will be described later, can also be extracted as context information.

[0031] The context information extraction unit MD2 can also use file comments as a method for identifying the context information D1. The context information extraction unit MD2 can extract top-level comments in the original file containing the code using a source code analysis technique and use the extracted comments as context information. This is because top-level comments often describe the purpose of the code in the file. The source code analysis technique is one of the functions of the context information extraction unit MD2.

[0032] The context information extraction unit MD2 can also use class comments as a method for identifying the context information D1. The context information extraction unit MD2 can extract comments written at the top level of the original class that contained the code using a source code analysis technique or the like, and use these as the context information D1. The reason for this is that the top-level comments of a class often describe the purpose of the code in that class.

[0033] The context information extraction unit MD2 pairs the context information D1 extracted from the code base DB0 with the code information D0 input from the code information extraction unit MD1 and stores them in the code and context information database DB1. Note that when the context information extraction unit MD2 extracts code information D0 that differs from the context information D1, the code information D0 and the context information D1 corresponding to the code information D0 are stored in a one-to-many relationship in the code and context information database DB1.

[0034] The code and context information database DB1 stores code information D0 and context information D1 corresponding to the code information D0 as a pair. The code information D0 and the context information D1 may be stored in a one-to-one relationship or in a many-to-one relationship. When the code information D0 and the context information D1 are stored in a many-to-one relationship, the context information D1 may be the same in all of the multiple pairs stored between a certain piece of context information D1 and the code information D0.

[0035] The search unit MD3 shown in FIG. 1 is an example of a search algorithm activated by the PC 2 operated by a user. The user inputs a query to the PC 2 to specify the code to be searched. For example, the query is input as "How can I sort users in an ad recommendation system." The query may be a command written in a natural language or a command generally used in database search operations.

[0036] The search unit MD3 searches the code and context information database DB1 for context information D1 corresponding to the input query based on the query, and outputs the searched context information D1 and the code information D0 stored as a pair with the context information D1 as search results. For example, the search unit MD3 transmits to the PC2 the pair of code information D0 and context information D1 searched from the code and context information database DB1 based on a query received from the PC2. The PC2 displays the pair of code information D0 and context information D1 received from the search unit MD3, allowing the user to check the code information D0.

[0037] FIG. 5 shows examples of the source code search screen W1 and the search result display screen W2.

[0038] First, a source code search screen W1 is displayed on the PC 2. The source code search screen W1 includes a query input section W11, a programming language selection section W12, a search button W13, and a query example display section W14.

[0039] The query input section W11 is where the user inputs the text they wish to search for as a query. The programming language selection section W12 is used to select the programming language in which the source code they wish to obtain is written. Examples of programming languages ​​include Python and Java.

[0040] The search button W13 is a button for inputting an instruction to the search unit MD3 to search for a code from the code and context information database DB1 based on a query. This search button W13 functions as a trigger for transmitting the query input into the query input unit W11 to the search unit MD3.

[0041] The query example display section W14 displays a list of examples of queries that are recommended for input. When inputting a query into the query input section W11, the user can select any query from the displayed list of query examples.

[0042] After pressing the search button W13, a search result display screen W2 is displayed on the PC 2. The search result display screen W2 has the following items: score, project, context, and code.

[0043] The score item displays the relevance score between the context information D1 and the code information D0. Although not shown, the top n search results based on relevance score may be displayed as a list on the search result display screen W2 as records having the items of score, project, context, and code.

[0044] The project item displays the name of the project in which the code searched in the code and context information database DB1 is used. The context item displays context information D1 (for example, the contents of the target string item shown in FIG. 3) obtained from context information D1 that is a pair with code information D0. The code item displays code information D0 searched from the code and context information database DB1 by search unit MD3. The user can use the code information D0 displayed in the code item.

[0045] <Example of Processing Performed in Code Search System> Next, an example of a method for storing code information and context information and a method for searching code performed in the source code search system 1 will be described with reference to FIGS. 6 and 7. FIG.

[0046] (Method of Storing Code Information and Context Information) FIG. 6 is a flowchart showing an example of a method of storing code information and context information.

[0047] First, the chord information extraction unit MD1 extracts chord information D0 from the chord base DB0 (S1). The chord information D0 is output to the context information extraction unit MD2.

[0048] Next, the context information extraction unit MD2 extracts context information D1 from the code base DB0 based on the code information D0 (S2).

[0049] Finally, the context information extraction unit MD2 stores the code information D0 and the context information D1 as a pair in the code and context information database DB1 (S3). The series of processes shown in Fig. 6 are repeated at predetermined intervals, and the contents of the code and context information database DB1 are updated.

[0050] (Code Search Method) Fig. 7 is a flowchart showing an example of a code search method. First, the user inputs a query on the source code search screen W1 shown in Fig. 5 and instructs to start a search (S11).

[0051] Next, the search unit MD3 receives the query from the PC2 and searches the code and context information database DB1 for the code information D0 in accordance with the query (S12).

[0052] Next, the search unit MD3 outputs the code contained in the searched code information D0 as the search result to the PC2 (S13).

[0053] Finally, the PC 2 displays the code included in the code information D0 as the search result on the search result display screen W2 (S14). The user can use the code displayed on the search result display screen W2 in software development.

[0054] <Example of Computer Hardware Configuration> Next, a description will be given of the hardware configuration of the computer 20 that constitutes each device of the source code search system 1. Fig. 8 is a block diagram showing an example of the hardware configuration of the computer 20. The computer 20 is an example of hardware used as a computer that can operate as the source code search system 1 according to this embodiment.

[0055] The computer 20 includes a CPU (Central Processing Unit) 21, a ROM (Read Only Memory) 22, and a RAM (Random Access Memory) 23, each connected to a bus 24. The computer 20 further includes a display device 25, an input device 26, a non-volatile storage 27, and a network interface 28.

[0056] The CPU 21 reads out program code of software that realizes each function according to this embodiment from the ROM 22, loads it into the RAM 23, and executes it. Variables, parameters, etc. generated during the calculation processing of the CPU 21 are temporarily written to the RAM 23, and these variables, parameters, etc. are read out as appropriate by the CPU 21. However, a GPU (Graphics Processing Unit) may be used instead of the CPU 21, or the CPU 21 and a GPU may be used together.

[0057] The display device 25 is, for example, a liquid crystal display monitor, and displays to the developer the results of the processing performed by the computer 20. The input device 26 is, for example, a keyboard, a mouse, etc., and allows the developer (for example, a user) to input predetermined operations and give instructions.

[0058] The nonvolatile storage 27 may be, for example, a hard disk drive (HDD), a solid state drive (SSD), a flexible disk, an optical disk, a magneto-optical disk, a CD-ROM, a CD-R, a magnetic tape, or a nonvolatile memory. In addition to an operating system (OS) and various parameters, programs for operating the computer 20 are recorded in the nonvolatile storage 27. The ROM 22 and the nonvolatile storage 27 record programs, data, and the like necessary for the CPU 21 to operate, and are used as examples of computer-readable, non-transitory storage media that store programs executed by the computer 20.

[0059] The network interface 28 may be, for example, a NIC (Network Interface Card), and various data may be transmitted and received between devices via a LAN (Local Area Network), dedicated line, etc. connected to the NIC terminal.

[0060] In the source code search system 1 according to the first embodiment described above, a code and context information database DB1 is constructed in which code information D0 and context information D1 are stored in a correlated state. A user can use the code and context information database DB1 and the search unit MD3 to search for source code that takes the context information D1 into consideration. This makes it easier for developers to search for the code they need from the code base DB0, which stores a large amount of code.

[0061] For example, when a query is input by a user, the search unit MD3 calculates the relevance score of a pair of certain code information D0 and context information D1, and returns the top n search results with the highest relevance scores. The following method can be used to calculate the relevance score between the query and the pair of code information D0 and context information D1. In this method, for example, the search unit MD3 calculates the relevance score between the query and a character string in the code information D0 using a deep neural network (DNN), and also calculates the relevance score between the query and a character string in the context information D1 using the DNN. The search unit MD3 can then calculate a weighted sum of the two relevance scores.

[0062] The user can obtain the desired code simply by inputting a natural language query into the query input section W11. While conventional code searches require input of code logic, the source code search system 1 allows the user to search for code based on highly abstract information such as the purpose or domain of a project.

[0063] Furthermore, users can indirectly access the code base DB0 through the source code search screen W1 to obtain code. This significantly reduces search time compared to the conventional method of accessing the code base DB0 and visually searching for the desired code from among a large number of codes. Furthermore, users can reuse the obtained code in development, thereby reducing development time and improving productivity.

[0064] Second Embodiment

[0065] In the source code search system 1 according to the first embodiment, for example, the process of extracting context information D1 from a README file was described, focusing on the fact that the first text in the README file describes the purpose of the repository. However, in addition to the intended use and domain of the source code to be extracted as context information D1, the README file also contains redundant information such as program installation methods and project usage methods. This may prevent the context information extraction unit MD2 according to the first embodiment from correctly extracting information that could become context information D1 from the README file. Therefore, in the source code search system 1 according to the second embodiment, as shown in FIG. 9 , the context information extraction unit MD2 extracts rough context information R1 from the code base DB0, and then adds a process of identifying context information D1 from the rough context information R1. Below, an example of the configuration and operation of a source code search system 1A according to the second embodiment of the present invention is described.

[0066] FIG. 9 is a block diagram showing an example of the overall configuration of a source code search system 1A according to the second embodiment of the present invention.

[0067] The source code search system 1A according to the second embodiment has the same configuration as the source code search system 1 according to the first embodiment shown in Fig. 1, but differs in the internal configuration of the context information extraction unit MD2. The context information extraction unit MD2 has a function of extracting context information from the code base DB0. This context information extraction unit MD2 includes a text block identification unit MD41 and an intra-text block context information identification unit MD42.

[0068] The text block identification unit MD41 (an example of a rough information identification unit) has the same function as the context information extraction unit MD2 according to the first embodiment, but differs in that it acquires text containing context information D1 from the code base DB0 as rough context information R1 based on the code information D0. In this case, the text block identification unit MD41 identifies the text containing context information D1 as a text block on a file-by-file basis and outputs the identified text block as rough context information R1 to the intra-text block context information identification unit MD42. The rough context information R1 is information that roughly identifies the context information D1 and includes a larger range of information than the context information D1. A file unit is, for example, a unit such as a README file. Furthermore, a "text block" refers to "text that is expected to contain context information." For example, the entire file or the entire natural language comment written at the top of the file is a text block used as rough context information R1.

[0069] The text block context information identification unit MD42 (an example of a context information identification unit) is used to identify the context at a finer level of granularity based on the rough context information R1. The text block context information identification unit MD42 identifies in detail the portion of the rough context information R1 where the context information D1 is written and outputs the identified detailed portion as context information D1. In this case, the text block context information identification unit MD42 identifies the detailed portion from the text block. For example, as shown in FIG. 10 (described later), the text block context information identification unit MD42 identifies only the portion of the string representing the purpose from the "rough purpose string" included in the rough context information R1. For example, a text block containing a single sentence containing "purpose" and "domain" may be identified as the detailed portion from the rough context information R1. The text block identified as the detailed portion may not only be the sentence containing "purpose" and "domain" but also include the sentences before and after that sentence. Information such as the purpose and domain of the project identified from the rough context information R1 is output to the code and context information database DB1 as context information D1.

[0070] 10 is a diagram showing an example of the rough context information R1. The rough context information R1 has the items "rough target character string", "original file", and "number of lines".

[0071] The "rough objective string" contains the rough objective of the code as a string, and is information written at the top of the file, such as "The purpose of this library is to recommend optimal advertisements to users. Specifically, the user is first converted into a vector using DNN, and then...". The "original file" is the URL of the original file that contained the "rough objective string". This URL is an example of access information that indicates the storage location of the original file. Here, the storage location of the README file is indicated by the URL as the original file. The "number of lines" is the start and end line numbers in the file where the "rough objective string" is written. The "number of lines" is expressed in the format [start line number, end line number].

[0072] The context information D1 identified from the rough context information R1 by the intra-text block context information identification unit MD42 is expressed as, for example, "The purpose of this library is to recommend optimal advertisements to users." Therefore, information other than the purpose, such as "Specific processing involves first converting the user into a vector using DNN, and then...," is not extracted as the context information D1.

[0073] The text block context information identification unit MD42 may extract the context information D1 from the rough context information R1 using, for example, information extraction and relationship extraction techniques that extract specific portions from text. Alternatively, automatic summarization techniques may be used to convert the rough context information R1 into context information D1 that includes only character strings related to the target. The text block context information identification unit MD42 outputs the character string extracted from the rough context information R1 as context information D1 that includes the "target character string" shown in FIG. 4. The pair of code information D0 and context information D1 is stored in the code and context information database DB1. The subsequent method for a user to search for a code is the same as that described in the first embodiment, and therefore a detailed description thereof will be omitted.

[0074] In the source code search system 1A according to the second embodiment described above, after the text block identification unit MD41 identifies rough context information R1 from the code base DB0, the intra-text block context information identification unit MD42 identifies context information D1. Then, the context information D1 corresponding to the code information D0 is appropriately identified, and the code information D0 and the context information D1 are stored as a pair in the code and context information database DB1. Therefore, when a user inputs a query into the PC2, the code information D0 corresponding to the context information D1 can be easily searched for.

[0075] [Modification] The source code search system 1, 1A according to each of the above-described embodiments may be configured inside the PC 2. In this case, pairs of code information D0 and context information D1 are stored in a code and context information database DB1 configured in the PC 2. Therefore, even in an offline environment such as a server room where online access is not possible, a user can input a query from the PC 2 to search for code and continue development.

[0076] The source code search system 1, 1A may also be configured to include a code base DB 0. In this case, a possible configuration is one in which the code base DB 0 is used to manage source code in an existing system that holds source code that is not intended to be made public.

[0077] The present invention is not limited to the above-described embodiments, and various other applications and modifications are possible without departing from the spirit and scope of the present invention as defined in the claims. For example, the above-described embodiments provide detailed and specific descriptions of the device and system configurations to clearly explain the present invention, and are not necessarily limited to those including all of the described configurations. Furthermore, it is possible to replace part of the configuration of one embodiment with the configuration of another embodiment, or even to add the configuration of another embodiment to the configuration of one embodiment. Furthermore, it is also possible to add, delete, or replace part of the configuration of each embodiment with other configurations. Furthermore, the control lines and information lines shown are those considered necessary for the explanation, and not all control lines and information lines are necessarily shown in the product. In reality, it can be assumed that almost all components are interconnected.

[0078] 1, 1A... source code search system, D1... context information, DB1... context information database, MD1... code information extraction unit, MD2... context information extraction unit, MD3... search unit, MD41... text block identification unit, MD42... context information identification unit within text block, R1... rough context information, W1... source code search screen, W2... search result display screen

Claims

1. A source code search system comprising: a code information extraction unit that inputs reference information into a code base that stores a repository in which program source code is registered, and outputs code information in which supplemental information has been added to the source code obtained from the code base; a context information extraction unit that inputs the code information into the code base, extracts context information corresponding to the code information from the code base, and outputs the context information together with the code information; and a source code search database that stores the code information and the context information corresponding to the code information as a pair.

2. The source code search system according to claim 1, wherein the code information extraction unit divides the source code obtained from the code base into specified units, adds the supplementary information to the divided source code, and outputs the code information.

3. The source code search system according to claim 2, wherein the unit of the definition is each function.

4. The source code search system according to claim 3, wherein the supplemental information is information of the code information other than a code character string.

5. The source code search system according to claim 3, wherein the context information is meta-information.

6. A source code search system as described in claim 3, wherein when the context information extraction unit extracts code information that differs from the context information, the code information and the context information corresponding to the code information are stored in a one-to-many relationship in the source code search database.

7. A source code search system as described in claim 2, further comprising a search unit that searches the source code search database for context information corresponding to an input query based on the query, and outputs the searched context information and the code information stored as a pair with the context information as search results.

8. The source code search system of claim 7, wherein the context information extraction unit comprises: a rough information identification unit that identifies text including the context information from the code base as rough information; and a context information identification unit that identifies in detail the portion of the rough information in which the context information is written, and outputs the identified detailed portion as the context information.

9. The source code search system according to claim 8, wherein the rough information identification unit identifies the text including the context information as a text block on a file basis and outputs the rough information, and the context information identification unit identifies the detailed portion from the text block.

10. A source code search method comprising the steps of: inputting reference information into a code base that stores a repository in which program source code is registered, and outputting code information in which supplemental information has been added to the source code obtained from the code base; inputting the code information into the code base, extracting context information corresponding to the code information from the code base, outputting the context information together with the code information, and storing the code information and the context information corresponding to the code information as a pair in a source code search database.

Citation Information

Patent Citations

  • Filter-based comments in source code

    EP2124144A1

  • Semantic code search based on augmented programming language corpus

    JP2022115815A

  • Embedding Software Developer Comments In Source Code Of Computer Programs

    US20100162209A1

Cited By

  • Method and device for performing context retrieval based on code repository

    CN119883276A