Software traceability chain recovery method based on code ownership information and deep learning

By combining code ownership information and deep learning technology, the text similarity between software products is calculated, and the problem of low accuracy caused by the inability to understand software semantics in the prior art is solved, and high-accuracy software tracking capability chain recovery is achieved.

CN114691147BActive Publication Date: 2025-03-28ZHEJIANG GONGSHANG UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210316741.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-29
Publication Date
2025-03-28
Estimated Expiration
2042-03-29

AI Technical Summary

Technical Problem

The existing software tracking capability chain recovery method relies on information retrieval and cannot understand the semantics of software products, resulting in low accuracy and cannot meet the requirements of high accuracy.

Method used

Using a method based on code ownership information and deep learning, we use RNN neural network to calculate the similarity of the tracking capability chain recovery by calculating the text similarity between advanced products and source code ownership information, and combining the code ownership information, to calculate the similarity using RNN neural network to improve the accuracy of tracking capability chain recovery.

Benefits of technology

It significantly improves the accuracy of the tracking capability chain between requirements and code, and can more effectively restore the links between software products and meet the requirements of high accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691147B_ABST
    Figure CN114691147B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of software tracing capability chain recovery, and discloses a software tracing capability chain recovery method based on code ownership information and deep learning, characterized in that it includes the following steps: Step 1: Calculate a list of candidate links between high-level artifacts and source code; Step 2: Identify the author of each source code artifact; Step 3: Define the author context; Step 4: Combine the code ownership information with the text information. The method proposed by the present invention is suitable for recovering the tracing capability chain between requirements and codes, and it can make full use of the code ownership information contained in the code, and use the deep learning neural network to calculate the similarity, which greatly improves the accuracy of recovering the tracing capability chain between requirements and codes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of software tracing capability chain recovery, and in particular, relates to a software tracing capability chain recovery method based on code ownership information and deep learning. Background Art

[0002] A traceability chain refers to a specific relationship between a pair of software artifacts, where one artifact is the source artifact and the other is the target artifact. It records various dependencies, influences, causal relationships, etc. between the artifacts, and can be unidirectional or bidirectional. The direction of the chain is only an indication of the time sequence or causal relationship, and traceability chains can usually be established in both directions at the same time. Currently, most software traceability research focuses on traceability chains, mainly because various traceability chains between artifacts help software developers understand, efficiently develop, and effectively manage systems. At the same time, traceability chains can help relevant personnel at all stages of software development activities complete their development tasks.

[0003] Currently, in the research on tracking capability chains, most of them use information retrieval (IR) methods to recover the tracking capability chain. These technologies recover the links between software artifacts based on their text similarity, that is, the higher the similarity, the higher the possibility that there is a link between two artifacts.

[0004] Diana Diaz et al. proposed a method to achieve tracking capability chain recovery by combining code ownership information with IR. Specifically, they extracted the author of each source code component and identified the context of his work for each author, that is, all code components written by the developer. For a specific query from an external document, an information retrieval method is used to calculate the similarity between it and the author's context to determine the author of the context with the highest similarity to the specific query. Then, a standard IR-based method is used to retrieve classes related to the specific query, while rewarding those classes that belong to the corresponding author context, that is, to increase the similarity of the class with the specific query. However, the IR method cannot understand the semantics of software products, which makes its accuracy low and cannot adapt well to the current requirements for high accuracy. With the rise of artificial intelligence, various neural networks have also been applied to various fields.

[0005] Nasir Ali et al. developed a method called ConPOS, which recovers trace links based on constraint-based pruning. ConPOS uses the main POS (Parts Of Speech) category and applies constraints to the recovered trace links for pruning as a filtering process to improve the effectiveness of IR-based techniques. It integrates CLM with part-of-speech tagging (POS Tagging). ConPOS first marks all locations of requirements, and uses two IR techniques, VSM and Jensen-Shannon model, to recover the traceability chain between given requirements and code files, and then identifies and removes false positive trace links based on the constraint-based pruning strategy. Considering the importance of verbs in requirements and source code, ConPOS selects verbs as the default constraint for pruning. However, its accuracy is still low, and it cannot effectively help developers recover trace links.

[0006] Anas Mahmoud et al. proposed a non-functional software requirements inspection, classification and tracking method based on unsupervised learning. This method uses the semantics of non-functional software requirements text to infer potential quality constraints in the system, systematically compares LSA (Latent Semantic Analysis), SVM, vocabulary-based methods, partition clustering and hierarchical clustering methods, and restores the traceability chain between non-functional requirements and code by calculating the textual similarity between them. However, this method currently lacks tool support. Summary of the invention

[0007] The purpose of the present invention is to provide a software tracking capability chain recovery method based on code ownership information and deep learning to solve the above-mentioned technical problems.

[0008] In order to solve the above technical problems, the present invention integrates deep learning and code ownership information to propose a method for recovering the tracking capability chain, thereby improving the accuracy of recovering the tracking capability chain. The specific technical solution of the present invention is as follows:

[0009] A software tracking capability chain recovery method based on code ownership information and deep learning includes the following steps:

[0010] Step 1: Compute a list of candidate links between high-level artifacts and source code;

[0011] Step 2: Identify the author of each source code artifact;

[0012] Step 3: Define the author context;

[0013] Step 4: Combine the code ownership information with the text information.

[0014] Furthermore, the step 1 comprises:

[0015] Compute the textual similarity between all possible pairs of a set of high-level artifacts and a set of target artifacts, given a source code A s And advanced product A t The text content of A s and A t Each word in is first mapped to a vector through the Word Embedding layer, and the mapping strategy is trained from the domain corpus through the Skip-gram model.

[0016] Furthermore, the step 1 comprises:

[0017] The source code S1, S2, ..., S n The word vectors in are sent sequentially to the RNN neural network and output as a single vector that represents its semantic information. In the case of the bidirectional RNN neural network, the word vectors are also sent in the opposite order. Similarly, for high-level products, we use the RNN neural network to generate the target semantic vector in the same way. Finally, the source semantic vector and the target semantic vector are compared in the semantic relationship evaluation layer.

[0018] Furthermore, the step 1 includes a semantic relationship evaluation layer, which is used to semantically classify the sentences, and the calculation formula is:

[0019] r pmul =v s ⊙v t

[0020] r sub =|v s -v t |

[0021] r=σ(W r r pmul +U r r sub +b r )

[0022] P = softmax(W p r+b p )

[0023]

[0024] Here ⊙ is a point-wise multiplication operator used to compare the direction of the source semantic vector and the target semantic vector in each dimension, and the result of the absolute value vector subtraction r sub Represents the distance between two vectors in each dimension; then a sigmoid layer is used to integrate rpmul and r sub And output a vector to represent their semantic similarity; finally, the output layer uses the result of the sigmoid layer to generate the probability of the existence of a valid tracking link, where the result of the softmax function is a K-dimensional vector composed of real values ​​in the range of (0,1), which add up to 1. Here, the K value is 2, and LSTM is selected as the neural network;

[0025] The results calculated by RNN are sorted to obtain a list of candidate links between source code and target artifacts.

[0026] Furthermore, the step 2 selects a method of viewing source code comments to obtain code ownership, including using the Javadoc tag @author to specify, or obtaining code ownership by analyzing the history of the software system.

[0027] Furthermore, the context described in step 3 refers to the author's work information. All source code components written by the developer are merged together and placed in one document. Then, the context of each author is indexed in the corpus of high-level artifacts and source code according to exactly the same normalization method.

[0028] Furthermore, step 4 includes the following specific steps:

[0029] The text similarity between source and target artifacts is integrated with code ownership information. First, for each source artifact, i.e., high-level artifact, the IR method is used to calculate the text similarity between a given query and the author's context, thereby identifying the authors who are most likely to have developed all the functions described in the high-level artifact; assuming that all classes created by developers are related to high-level artifacts in some way, a reward β is added to them to increase the similarity between these classes and high-level artifacts, thereby improving the ranking of links between these artifacts.

[0030] The software tracing capability chain recovery method based on code ownership information and deep learning of the present invention has the following advantages: the method proposed by the present invention is suitable for recovering the tracing capability chain between requirements and codes, it can make full use of the code ownership information contained in the code, and use the deep learning neural network to calculate the similarity, which greatly improves the accuracy of recovering the tracing capability chain between requirements and codes. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a schematic diagram of the overall framework of the method of the present invention;

[0032] Figure 2 A schematic diagram of the steps of generating a candidate connection table according to the present invention;

[0033] Figure 3 It is a comparison chart of the accuracy of the other three methods and the method of the present invention;

[0034] Figure 4 It is a comparison chart of the recall rates of the other three methods and the method of the present invention. DETAILED DESCRIPTION

[0035] In order to better understand the purpose, structure and function of the present invention, the following is a further detailed description of a software tracking capability chain recovery method based on code ownership information and deep learning of the present invention in conjunction with the accompanying drawings.

[0036] Since the traditional IR method has a low accuracy rate when restoring the tracking capability chain, in order to improve the accuracy of restoring the tracking capability chain, we use a code ownership-based method to reward relevant links in the candidate connection ranking table. At the same time, in order to further improve the accuracy of tracking capability chain recovery, we use the RNN neural network in the current advanced deep learning technology to calculate the similarity.

[0037] The process of restoring the tracking capability chain in this method is mainly divided into two parts: ① Using the RNN neural network to calculate the similarity between the query and the relevant classes in the source code, and obtain a candidate link ranking; ② Extracting the author information from the source code component and defining the author context, so as to calculate the similarity between the author context and the query through the IR method, and obtain an author similarity ranking. Finally, the links belonging to the high-ranking authors are rewarded, that is, the candidate connection rankings are re-ranked, and finally the final ranking is obtained. An overview of the method is as follows: Figure 1 shown.

[0038] The software tracking capability chain recovery method based on code ownership information and deep learning of the present invention comprises the following steps:

[0039] ① Compute a list of candidate links between high-level artifacts and source code

[0040] Compute the textual similarity between all possible pairs of a set of high-level artifacts and a set of target artifacts, given a source code A s And advanced product A t The text content of A s and A t Each word in is first mapped to a vector representation through the WordEmbedding layer. This mapping strategy is trained from the domain corpus using the Skip-gram model. Then the source code S1, S2, ..., S n The word vectors in S are sent sequentially to the RNN neural network and output as a single vector that represents its semantic information. In the case of a bidirectional RNN, the word vectors are also sent in the opposite order, such as S n , Sm-1 , ..., S1, and finally generate the source semantic vector V s Similarly, for high-level products, we use the RNN neural network to generate the target semantic vector V in the same way. t Finally, the source semantic vector V s and the target semantic vector V t The comparison is performed in the semantic relationship evaluation layer.

[0041] Among them, we use a more common structure for the semantic relationship evaluation layer: Figure 2 As shown, the purpose is to semantically classify the sentence. The calculation of this part is:

[0042] r pmul =v s ⊙v t

[0043] r sub =|v s -v t |

[0044] r=σ(W r r pmul +U r r sub +b r )

[0045] P = softmax(W p r+b p )

[0046]

[0047] Here ⊙ is a point-wise multiplication operator used to compare the direction of the source semantic vector and the target semantic vector in each dimension. The result of the absolute value vector subtraction r sub Represents the distance between two vectors in each dimension. Then a sigmoid layer is used to integrate r pmul and r sub And output a vector to represent their semantic similarity. Finally, the output layer uses the result of the sigmoid layer to generate the probability of the existence of a valid tracking link, where the result of the softmax function is a K-dimensional vector composed of real values ​​in the range of (0,1), which add up to 1, and the K value here is 2. We choose LSTM as our neural network because it has certain advantages in sequence modeling problems, has long-term memory function, and is relatively simple to implement. To a certain extent, it can solve the problems of gradient disappearance and gradient explosion in the process of long sequence training.

[0048] We will use the results calculated by RNN to perform sink sorting to obtain a list of candidate links between source code and target artifacts.

[0049] ②Identify the author of each source code artifact

[0050] Identifying the author of each source code artifact is to obtain code ownership information. Code ownership can be obtained in many different ways, and we choose the more commonly used method of viewing source code comments to obtain code ownership. For example, in software systems written in Java, the author of a class (or method) is usually specified using the Javadoc tag @author. In this way, we can easily get code ownership information. At the same time, there are other ways to obtain code ownership by analyzing the history of the software system. For example, the owner of a source code component is the developer who performs the most changes (e.g., commits) to that component. These methods can all be tried.

[0051] ③Define author context

[0052] In this step, we need to define the context in which the developer is working in order to better utilize the code ownership information. The so-called context refers to the author's work information. This context is crucial for identifying high-level artifacts related to a specific author. To define the developer's context, we merge all source code components written by this developer into a single document. Such a document (author context) contains information about the system functions implemented by the developer, which is encapsulated in source code comments and identifiers. The context of each author is then indexed in the corpus of high-level artifacts and source code following exactly the same normalization method. In this way, the author context is represented in the same term space of the tracked high-level artifacts and source code.

[0053] ④ Combine code ownership information with text information.

[0054] The textual similarity between source and target artifacts is integrated with code ownership information. First, for each source artifact, i.e., high-level artifact, we use the IR method to calculate the textual similarity of a given query with the author's context, thereby identifying the authors who are most likely to have developed all the features described in the high-level artifact. In other words, these developers with textual similarity to the high-level artifact are the main contributors to the implementation of the features described in the high-level artifact.

[0055] Assuming that all classes created by developers are related to high-level artifacts in some way, we add a bonus β to them, increasing the similarity between these classes and high-level artifacts, so that the links between these artifacts are ranked higher.

[0056] The method proposed in this paper is suitable for recovering the traceability chain between requirements and codes. It can make full use of the code ownership information contained in the code and use deep learning neural network to calculate similarity, which greatly improves the accuracy of the traceability chain between recovery requirements and codes.

[0057] 3) Experimental results

[0058] We compared the other three methods with our proposed method, and the accuracy and recall of these four methods were compared. Figure 3 Figure 4 As shown in Figure 2, it can be seen that our method is significantly better than the other two methods in terms of both precision and recall.

[0059] It is to be understood that the present invention is described by some embodiments, and it is known to those skilled in the art that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, under the teachings of the present invention, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the scope of protection of the present invention.

Claims

1. A software tracking capability chain recovery method based on code ownership information and deep learning, characterized in that: The steps include: Step 1: Compute a list of candidate links between high-level artifacts and source code; The source code S1, S2, ..., S n The word vectors in are sent sequentially to the RNN neural network and output as a single vector, which represents its semantic information. In the case of the bidirectional RNN neural network, the word vectors are also sent in the opposite order. Similarly, for high-level products, we use the RNN neural network to generate the target semantic vector in the same way. Finally, the source semantic vector and the target semantic vector are compared in the semantic relationship evaluation layer. The step 1 includes a semantic relationship evaluation layer, which is used to semantically classify sentences. The calculation formula is: , Here is a point-wise multiplication operator used to compare the direction of the source semantic vector and the target semantic vector in each dimension. The result of the absolute value vector subtraction r sub Represents the distance between two vectors in each dimension; then a sigmoid layer is used to integrate r pmul and r sub And output a vector to represent their semantic similarity; finally, the output layer uses the result of the sigmoid layer to generate the probability of the existence of a valid tracking link, where the result of the softmax function is a K-dimensional vector composed of real values ​​in the range of (0, 1), which add up to 1. Here, the K value is 2, and LSTM is selected as the neural network; The results calculated by RNN are sorted to obtain a list of candidate links between source code and target artifacts; Step 2: Identify the author of each source code artifact; Step 3: Define the author context; Step 4: Combine the code ownership information with the text information.

2. The software tracking capability chain recovery method based on code ownership information and deep learning according to claim 1 is characterized in that: The step 1 comprises: Compute the textual similarity between all possible pairs of a set of high-level artifacts and a set of target artifacts, given a source code A s And advanced product A t The text content of A s and A t Each word in is first mapped to a vector through the Word Embedding layer, and the mapping strategy is trained from the domain corpus through the Skip-gram model.

3. The software tracking capability chain recovery method based on code ownership information and deep learning according to claim 1 is characterized in that: The step 2 selects a method of checking source code comments to obtain code ownership, including using the Javadoc tag @author to specify, or obtaining code ownership by analyzing the history of the software system.

4. The software tracking capability chain recovery method based on code ownership information and deep learning according to claim 1 is characterized in that: The context described in step 3 refers to the author's work information. All source code components written by developers are merged together in one document, and then the context of each author is indexed in the corpus of high-level artifacts and source code according to exactly the same normalization method.

5. The software tracking capability chain recovery method based on code ownership information and deep learning according to claim 1 is characterized in that: The step 4 comprises the following specific steps: The text similarity between source and target artifacts is integrated with code ownership information. First, for each source artifact, i.e., high-level artifact, the IR method is used to calculate the text similarity between a given query and the author's context, thereby identifying the author who is most likely to have developed all the described features in the high-level artifact. Assuming that all classes created by developers are related to high-level artifacts in some way, we add a reward β to them, increasing the similarity between these classes and high-level artifacts, so that the ranking of links between these artifacts is improved.

Citation Information

Patent Citations

  • Demand tracking recovery method based on information retrieval

    CN111124366A

  • Verification and tracking method based on digital fingerprints in deep learning system

    CN112507312A