Software defect data generation method and device, computer equipment, readable storage medium and program product

By processing maintenance logs and defect reports from software projects, a high-quality software defect dataset is generated, which solves the data imbalance problem and improves the accuracy and generalization ability of defect prediction.

CN121935136APending Publication Date: 2026-04-28ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD
Filing Date
2026-01-09
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Existing software defect datasets suffer from data imbalance, which limits the performance of software defect prediction, especially the ability to identify minority class samples.

Method used

By acquiring maintenance logs and defect reports from software projects, word embedding technology is used to transform the source code into sequence features. Pre-defined cleaning rules are applied to clean up noise and inter-class overlapping features. Combined with a defect sample screening network, the synthesized features are screened to generate a high-quality software defect dataset.

Benefits of technology

It effectively solves the problems of weakened identification and overfitting caused by data imbalance, enhances the model's ability to learn defect patterns, and improves the accuracy and generalization ability of defect prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121935136A_ABST
    Figure CN121935136A_ABST
Patent Text Reader

Abstract

The invention relates to a software defect data generation method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the steps of obtaining source codes and defect reports based on a maintenance log of a software project; determining target source codes with defects in the source codes based on the defect report; converting the target source code into sequence features through a word embedding technology; cleaning the sequence features through a preset cleaning rule to obtain cleaned features; based on the cleaned features, through a preset generation technology, obtaining synthetic features; screening the synthetic features based on a defect sample screening network to obtain screened features; and generating a software defect data set based on the screening features, the source code and the defect report. By adopting the method, scarce defective samples can be supplemented, and the problems of weak recognition and easy over-fitting caused by data imbalance of a traditional method are effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for generating software defect data. Background Technology

[0002] In software development, if defects are not fixed early, the cost of fixing them later will increase by 5-10 times, and may also lead to system failures, user churn, and other risks. Software defect prediction, as a core technology for quality assurance, can identify high-risk modules in advance through historical data, helping to intervene in development early, achieve cost control and quality improvement, and is a key link in the development of large-scale projects. High-quality datasets are the core prerequisite for the implementation of defect prediction technology: they are the basic raw materials for models to learn the association between "features and defect labels". Their completeness (covering multiple types and modules of defects) determines the model's generalization ability, and their accuracy (no label errors, no missing features) directly affects the reliability of prediction. Without high-quality data, the model will find it difficult to form effective and reliable predictive capabilities.

[0003] However, in real-world projects, existing software defect datasets generally suffer from "data imbalance," meaning that the number of defective modules (minority class samples) often accounts for only 1%-15% of the number of "defect-free modules" (majority class samples), a significant difference that has become the core bottleneck restricting the performance of software defect prediction. Summary of the Invention

[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for generating software defect data that can solve the problem of imbalance in software defect datasets, in order to address the aforementioned technical issues.

[0005] Firstly, this application provides a method for generating software defect data, including:

[0006] Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects.

[0007] The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthetic features are obtained using preset generation techniques.

[0008] The synthetic features are filtered using a defect sample screening network to obtain the filtered features; based on the filtered features, source code, and defect reports, a software defect dataset is generated.

[0009] In one embodiment, synthetic features are filtered based on a defect sample screening network to obtain screened features, including:

[0010] The synthetic features are input into the action network of the defect sample screening network to obtain action results; the action results are either retained or discarded; the action results are input into the value network of the defect sample screening network to obtain value results; based on the action results and value results, the synthetic features are screened to obtain screened features.

[0011] In one embodiment, the action result is input into the value network of the defect sample screening network to obtain the value result, including:

[0012] The action result is input into the feature extraction layer of the value network to obtain the value feature; the value feature is input into the noise layer of the value network to obtain the noise feature; and the noise feature is input into the output layer of the value network to obtain the value result.

[0013] In one embodiment, the method further includes:

[0014] Based on the action results, synthetic features, and a pre-established defect detection network, the Matthews correlation coefficient is determined. The pre-established defect detection network is trained based on the source code and defect reports. The target value is determined based on the Matthews correlation coefficient and the initial Matthews correlation coefficient. The initial Matthews correlation coefficient is determined by the source code, defect reports, and the pre-established defect detection network. Based on the value results and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss.

[0015] In one embodiment, the sequence features are cleaned using preset cleaning rules to obtain cleaned features, including:

[0016] The cleaned features are obtained by removing noisy samples from sequence features and inter-class overlapping features between defective and non-defective sequence features through preset cleaning rules.

[0017] In one embodiment, the method further includes:

[0018] The pre-established software defect detection network is trained based on the software defect dataset to obtain the trained software defect detection network; the trained software defect detection network is then used to detect defects in the software.

[0019] Secondly, this application also provides a software defect data generation apparatus, comprising:

[0020] The acquisition module is used to acquire source code and defect reports based on the maintenance logs of a software project; and to identify target source code containing defects based on the defect reports.

[0021] The synthesis module is used to transform the target source code into sequence features through word embedding technology; clean the sequence features according to preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthesized features are obtained through preset generation technology.

[0022] The generation module is used to filter synthetic features based on the defect sample screening network to obtain screened features; and to generate a software defect dataset based on the screened features, source code, and defect reports.

[0023] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0024] Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects.

[0025] The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthetic features are obtained using preset generation techniques.

[0026] The synthetic features are filtered using a defect sample screening network to obtain the filtered features; based on the filtered features, source code, and defect reports, a software defect dataset is generated.

[0027] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0028] Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects.

[0029] The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthetic features are obtained using preset generation techniques.

[0030] The synthetic features are filtered using a defect sample screening network to obtain the filtered features; based on the filtered features, source code, and defect reports, a software defect dataset is generated.

[0031] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0032] Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects.

[0033] The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthetic features are obtained using preset generation techniques.

[0034] The synthetic features are filtered using a defect sample screening network to obtain the filtered features; based on the filtered features, source code, and defect reports, a software defect dataset is generated.

[0035] The aforementioned software defect data generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire source code and defect reports based on the maintenance logs of a software project; determine the target source code containing defects based on the defect reports; convert the target source code into sequence features using word embedding technology; clean the sequence features using preset cleaning rules to obtain cleaned features; obtain synthetic features based on the cleaned features using preset generation technology; filter the synthetic features using a defect sample screening network to obtain filtered features; and generate a software defect dataset based on the filtered features, source code, and defect reports. This application, by generating synthetic features and performing screening, supplements scarce defective samples, effectively solving the problems of weak identification and overfitting caused by data imbalance in traditional methods. Attached Figure Description

[0036] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0037] Figure 1 This is a flowchart illustrating a software defect data generation method in one embodiment;

[0038] Figure 2 This is a detailed flowchart of a software defect data generation method in one embodiment;

[0039] Figure 3 A structural block diagram of a software defect data generation device in one embodiment;

[0040] Figure 4 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0042] In one embodiment, such as Figure 1 As shown, a method for generating software defect data is provided. This embodiment illustrates the method by applying it to a terminal. It is understood that this method can also be applied to a server, and further to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0043] Step 102: Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects.

[0044] Within the predetermined timeframe of the software project, runtime logs are collected periodically at the function level, including the software's source code and its runtime status. Defect reports indicate which code contains defects and which does not; the source code is input data from the internet, and the actual label indicates whether a defect exists.

[0045] Step 104: The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and synthetic features are obtained based on the cleaned features using preset generation technology.

[0046] Since most source code is free of defects and defective source code is rare, this leads to data imbalance. Therefore, the synthetic features generated here are based on defective target source code and are all synthetic features with defects.

[0047] Optionally, source code content consisting of letters and numbers cannot directly serve as input features for the neural network. In this step, a pre-trained CodeBERT (Code Bidirectional Encoder Representations from Transformers) model is first used to implement word embeddings, converting the source code into sequence features. CodeBERT is a pre-trained model specifically designed for source code syntax and semantics. By learning from a large code corpus, it can effectively capture information such as syntactic structure, function calls, and variable definitions in the code. By converting the source code into sequence features generated by CodeBERT, the semantic information of the code can be preserved, while mapping the complex structure of the source code into low-dimensional vectors, improving the accuracy and generalization ability of the subsequent defect prediction model. The preset cleaning rule can be NCL (Neighborhood Cleaning Rule). The preset generation technique can be Borderline (Borderline-Synthetic Minority Oversampling Technique).

[0048] Step 106: Filter the synthetic features based on the defect sample screening network to obtain the screened features; generate a software defect dataset based on the screened features, source code, and defect report.

[0049] Optionally, the synthetic features can be input into the defect sample screening network in batches for screening. The batch size can be 4, 8, etc., and there is no limit here. That is, 8 synthetic features can be input each time.

[0050] In this system, source code serves as the input data for the network, with the true label indicating whether a defect exists or not. The true label for the filtered features is that a defect exists. When used to train the software defect prediction network, a judgment is made. If the filtered features are used, they are directly input into the software defect prediction network. If the source code is used, it is first input into an additional feature extraction network, and then the extracted features are input into the software defect prediction network.

[0051] The aforementioned method for generating software defect data involves: acquiring source code and defect reports based on the maintenance logs of a software project; identifying target source code with defects based on the defect reports; converting the target source code into sequence features using word embedding technology; cleaning the sequence features using preset cleaning rules to obtain cleaned features; generating synthetic features based on the cleaned features using preset generation techniques; filtering the synthetic features using a defect sample filtering network to obtain filtered features; and generating a software defect dataset based on the filtered features, source code, and defect reports. This application, by generating synthetic features and filtering them, supplements scarce defective samples and effectively solves the problems of weak identification and overfitting caused by data imbalance in traditional methods.

[0052] In an exemplary embodiment, synthetic features are filtered based on a defect sample screening network to obtain screened features, including:

[0053] The synthetic features are input into the action network of the defect sample screening network to obtain action results; the action results are either retained or discarded; the action results are input into the value network of the defect sample screening network to obtain value results; based on the action results and value results, the synthetic features are screened to obtain screened features.

[0054] Optionally, the action network and value network can be Bi-RNN (Bidirectional Recurrent Neural Network).

[0055] For example, the synthetic features are input into the first Bi-RNN (action network) in the defect sample screening network to obtain action results; the action results are to retain or discard; the action results are input into the second Bi-RNN (value network) in the defect sample screening network to obtain value results; based on the action results and value results, the synthetic features are screened to obtain screened features.

[0056] In this embodiment, by coordinating the judgment of actions and values, it is ensured that the selected features can effectively enhance the model's ability to learn defect patterns.

[0057] In an exemplary embodiment, the action result is input into the value network of the defect sample screening network to obtain the value result, including:

[0058] The action result is input into the feature extraction layer of the value network to obtain the value feature; the value feature is input into the noise layer of the value network to obtain the noise feature; and the noise feature is input into the output layer of the value network to obtain the value result.

[0059] To effectively select a high-quality subset from the synthetic samples, this step constructs an adaptive undersampler based on NoisyNet-DQN (Noisy Neural Network) as an agent to solve the Markov decision process. NoisyNet-DQN enhances the agent's exploratory nature by introducing a noise layer, preventing the model from prematurely converging to local optima, thereby improving the undersampler's adaptability and diversity. Specifically, the noise layer perturbs the weights in the value network, subjecting each action selection to a certain degree of randomness and preventing overfitting of the model.

[0060] For example, the action result is input into the feature extraction layer of the value network to obtain value features; the value features are input into the noise layer of the value network to obtain noise features; the noise features are input into the output layer of the value network to obtain the value result. The output of the value network is:

[0061] .

[0062] in, and These are the weight matrices for the forward and backward RNNs of the value network, respectively. and Yes, it is a bias term. It is the input for time step t. It is an activation function.

[0063] In this embodiment, after the action result is transformed into value features by the feature extraction module, random noise is injected into the weight matrix and bias term of the forward and backward RNNs using a noise layer. This ensures that the value result output by the value network retains the basic judgment of the long-term value of the action, while also having a moderate degree of randomness due to the noise disturbance. This ensures that the value features can fully reflect the semantic logic of the synthesized features and the correlation with the selected action. On the other hand, the noise injection mechanism of NoisyNet avoids the value assessment from getting trapped in local optima.

[0064] In one exemplary embodiment, the method further includes:

[0065] Based on the action results, synthetic features, and a pre-established defect detection network, the Matthews correlation coefficient is determined. The pre-established defect detection network is trained based on the source code and defect reports. The target value is determined based on the Matthews correlation coefficient and the initial Matthews correlation coefficient. The initial Matthews correlation coefficient is determined by the source code, defect reports, and the pre-established defect detection network. Based on the value results and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss.

[0066] Optionally, the pre-established defect detection network can be any defect detection network. Regarding parameter updates, a simulated annealing-based Gumbel-Softmax method is designed for action decision sampling. The Gumbel-Softmax method introduces Gumbel noise to sample discrete actions, thereby generating an approximate discrete action distribution in continuous space. The simulated annealing strategy dynamically adjusts the temperature parameter, allowing for broader exploration in the early stages of training and preventing the model from prematurely converging to local optima. As training progresses, the temperature gradually decreases, and the strategy tends to utilize more resources, thus improving training stability and convergence speed. Specifically, the state update probability during simulated annealing is adjusted according to the current temperature T, which gradually decreases as training progresses. Preferably, to improve the agent's exploration efficiency, a priority experience replay mechanism is incorporated. Under this mechanism, the agent prioritizes replaying experiences that have a higher impact on model learning, improving sample selection efficiency during training and further enhancing the learning effect.

[0067] For example, for the synthetic features input in the current batch, after determining which are discarded and which are retained based on the action results, the retained synthetic features are input into a pre-established defect detection network to obtain a first prediction result. Then, the Matthews correlation coefficient is calculated based on the first prediction result to obtain the Matthews correlation coefficient. Based on the Matthews correlation coefficient and the initial Matthews correlation coefficient, the target value is determined. The initial Matthews correlation coefficient is determined by the source code, defect report, and pre-established defect detection network. Based on the value result and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss.

[0068] The Matthews correlation coefficient (MCC) is calculated as follows: To calculate the MCC, four basic statistics in binary classification tasks must first be defined. Taking software defect prediction as an example: TP (True Positive): The number of samples that are actually defective modules but the model predicts are defective. TN (True Negative): The number of samples that are actually non-defective modules but the model predicts are non-defective. FP (False Positive): The number of samples that are actually non-defective modules but the model incorrectly classifies as defective. FN (False Negative): The number of samples that are actually defective modules but the model incorrectly classifies as non-defective. The MCC value ranges from [-1, 1]: a value of 1 represents a completely correct prediction, -1 represents a completely incorrect prediction, and 0 represents a prediction consistent with random guessing. The specific formula is:

[0069]

[0070] The initial Matthews correlation coefficient is calculated in the same way as described above, except that the data used is not synthetic features, but rather source code and defect reports obtained from the maintenance logs of the software project.

[0071] In this embodiment, the actual effect of the screening action (Matthews correlation coefficient) is compared with the initial baseline (initial Matthews correlation coefficient) to ensure that the optimization direction of the screening network is consistent with the core goal of improving the accuracy of defect detection (especially minority class identification). Ultimately, the selected synthetic features can effectively enhance the quality of the dataset and alleviate the prediction bias caused by data imbalance.

[0072] In an exemplary embodiment, sequence features are cleaned using preset cleaning rules to obtain cleaned features, including:

[0073] The cleaned features are obtained by removing noisy samples from sequence features and inter-class overlapping features between defective and non-defective sequence features through preset cleaning rules.

[0074] For example, suppose the sequence features transformed by CodeBERT contain two types of interfering data: one is noise samples (such as features with abnormal semantic vectors due to messy code comments), and the other is overlapping features between classes (such as the "nested loop" syntax feature that frequently appears in both the "defective" and "non-defective" modules, making it impossible to effectively distinguish between the two types of samples). Using preset cleaning rules (such as NCL neighborhood cleaning rules), noise samples are first identified; the k nearest neighbors of each sequence feature are calculated, and if most of the nearest neighbor labels of a feature conflict with its own label (such as a feature labeled "defective" where 80% of its neighbors are non-defective), it is determined to be noise and removed; secondly, for overlapping features between classes, by calculating the distribution similarity of the feature in the two types of samples (such as cosine similarity), features with similarity higher than a threshold (such as the "nested loop" feature where the distribution difference between the two types of samples is less than 5%) are removed.

[0075] In this embodiment, the cleaned features obtained by cleaning the data not only eliminate interference noise but also reduce ambiguous features, making the boundary between defective and non-defective features clearer, thus laying a pure feature foundation for the subsequent synthesis of high-quality minority class samples.

[0076] In one exemplary embodiment, the method further includes:

[0077] The pre-established software defect detection network is trained based on the software defect dataset to obtain the trained software defect detection network; the trained software defect detection network is then used to detect defects in the software.

[0078] For example, the generated software defect dataset is input into a pre-built software defect detection network for training: First, the network is trained with the original source code and defect reports to obtain an initial model. Then, synthetic features (focusing on the semantic features of defective samples) are added for iterative optimization. Through dynamic networking, the ability to identify minority defect features is further enhanced based on learning the patterns of the original data. After training, the source code of the software module to be detected (such as newly added functions or updated code segments) is converted into sequence features by CodeBERT and input into the trained detection network. The network will output a prediction result of whether the module has defects or not, and can combine confidence indicators to mark high-risk modules.

[0079] In this embodiment, the detection network trained with the expanded dataset learns richer defect patterns (especially the features of scarce defect samples), which enables it to more accurately identify hidden defects in real-world scenarios and significantly reduce the cost of subsequent repairs.

[0080] In one exemplary embodiment, such as Figure 2 As shown, a method for generating software defect data includes: obtaining source code and defect reports based on maintenance logs of a software project; identifying target source code containing defects based on the defect reports; converting the target source code into sequence features using word embedding technology; removing noise samples and inter-class overlap between defective and non-defective sequence features from the sequence features using preset cleaning rules to obtain cleaned features; obtaining synthetic features based on the cleaned features using preset generation techniques; inputting the synthetic features into the action network of a defect sample filtering network to obtain action results; the action results are either retained or discarded; inputting the action results into the feature extraction layer of a value network to obtain value features; inputting the value features into the noise layer of the value network to obtain noise features; inputting the noise features into the output layer of the value network to obtain value results; and filtering the synthetic features based on the action results and value results to obtain filtered features. For the synthetic features input in the current batch, after determining which are discarded and which are retained based on the action results, the retained synthetic features are input into a pre-established defect detection network to obtain a first prediction result. Then, the Matthews correlation coefficient is calculated based on the first prediction result. Based on the Matthews correlation coefficient and the initial Matthews correlation coefficient, the target value is determined. The initial Matthews correlation coefficient is determined by the source code, defect reports, and the pre-established defect detection network. Based on the value result and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss. A software defect dataset is generated based on the screening features, source code, and defect reports. The pre-established software defect detection network is trained based on the software defect dataset to obtain a trained software defect detection network. Defect detection is performed on the software based on the trained software defect detection network.

[0081] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0082] In one exemplary embodiment, such as Figure 3 As shown, a software defect data generation device is provided, comprising: an acquisition module 301, a synthesis module 302, and a generation module 303, wherein:

[0083] The acquisition module is used to acquire source code and defect reports based on the maintenance logs of a software project; and to identify target source code containing defects based on the defect reports.

[0084] The synthesis module is used to transform the target source code into sequence features through word embedding technology; clean the sequence features according to preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthesized features are obtained through preset generation technology.

[0085] The generation module is used to filter synthetic features based on the defect sample screening network to obtain screened features; and to generate a software defect dataset based on the screened features, source code, and defect reports.

[0086] In one embodiment, the generation module is further configured to:

[0087] The synthetic features are input into the action network of the defect sample screening network to obtain action results; the action results are either retained or discarded; the action results are input into the value network of the defect sample screening network to obtain value results; based on the action results and value results, the synthetic features are screened to obtain screened features.

[0088] In one embodiment, the generation module is further configured to:

[0089] The action result is input into the feature extraction layer of the value network to obtain the value feature; the value feature is input into the noise layer of the value network to obtain the noise feature; and the noise feature is input into the output layer of the value network to obtain the value result.

[0090] In one embodiment, the generation module is further configured to:

[0091] Based on the action results, synthetic features, and a pre-established defect detection network, the Matthews correlation coefficient is determined. The pre-established defect detection network is trained based on the source code and defect reports. The target value is determined based on the Matthews correlation coefficient and the initial Matthews correlation coefficient. The initial Matthews correlation coefficient is determined by the source code, defect reports, and the pre-established defect detection network. Based on the value results and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss.

[0092] In one embodiment, the synthesis module is further configured to:

[0093] The cleaned features are obtained by removing noisy samples from sequence features and inter-class overlapping features between defective and non-defective sequence features through preset cleaning rules.

[0094] In one embodiment, it further includes: a prediction module, for:

[0095] The pre-established software defect detection network is trained based on the software defect dataset to obtain the trained software defect detection network; the trained software defect detection network is then used to detect defects in the software.

[0096] Each module in the aforementioned software defect data generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0097] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores synthetic features. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a software defect data generation method.

[0098] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0099] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0100] Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects.

[0101] The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthetic features are obtained using preset generation techniques.

[0102] The synthetic features are filtered using a defect sample screening network to obtain the filtered features; based on the filtered features, source code, and defect reports, a software defect dataset is generated.

[0103] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0104] The synthetic features are input into the action network of the defect sample screening network to obtain action results; the action results are either retained or discarded; the action results are input into the value network of the defect sample screening network to obtain value results; based on the action results and value results, the synthetic features are screened to obtain screened features.

[0105] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0106] The action result is input into the feature extraction layer of the value network to obtain the value feature; the value feature is input into the noise layer of the value network to obtain the noise feature; and the noise feature is input into the output layer of the value network to obtain the value result.

[0107] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0108] Based on the action results, synthetic features, and a pre-established defect detection network, the Matthews correlation coefficient is determined. The pre-established defect detection network is trained based on the source code and defect reports. The target value is determined based on the Matthews correlation coefficient and the initial Matthews correlation coefficient. The initial Matthews correlation coefficient is determined by the source code, defect reports, and the pre-established defect detection network. Based on the value results and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss.

[0109] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0110] The cleaned features are obtained by removing noisy samples from sequence features and inter-class overlapping features between defective and non-defective sequence features through preset cleaning rules.

[0111] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0112] The pre-established software defect detection network is trained based on the software defect dataset to obtain the trained software defect detection network; the trained software defect detection network is then used to detect defects in the software.

[0113] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0114] Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects.

[0115] The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthetic features are obtained using preset generation techniques.

[0116] The synthetic features are filtered using a defect sample screening network to obtain the filtered features; based on the filtered features, source code, and defect reports, a software defect dataset is generated.

[0117] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0118] The synthetic features are input into the action network of the defect sample screening network to obtain action results; the action results are either retained or discarded; the action results are input into the value network of the defect sample screening network to obtain value results; based on the action results and value results, the synthetic features are screened to obtain screened features.

[0119] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0120] The action result is input into the feature extraction layer of the value network to obtain the value feature; the value feature is input into the noise layer of the value network to obtain the noise feature; and the noise feature is input into the output layer of the value network to obtain the value result.

[0121] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0122] Based on the action results, synthetic features, and a pre-established defect detection network, the Matthews correlation coefficient is determined. The pre-established defect detection network is trained based on the source code and defect reports. The target value is determined based on the Matthews correlation coefficient and the initial Matthews correlation coefficient. The initial Matthews correlation coefficient is determined by the source code, defect reports, and the pre-established defect detection network. Based on the value results and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss.

[0123] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0124] The cleaned features are obtained by removing noisy samples from sequence features and inter-class overlapping features between defective and non-defective sequence features through preset cleaning rules.

[0125] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0126] The pre-established software defect detection network is trained based on the software defect dataset to obtain the trained software defect detection network; the trained software defect detection network is then used to detect defects in the software.

[0127] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0128] Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects.

[0129] The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and based on the cleaned features, synthetic features are obtained using preset generation techniques.

[0130] The synthetic features are filtered using a defect sample screening network to obtain the filtered features; based on the filtered features, source code, and defect reports, a software defect dataset is generated.

[0131] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0132] The synthetic features are input into the action network of the defect sample screening network to obtain action results; the action results are either retained or discarded; the action results are input into the value network of the defect sample screening network to obtain value results; based on the action results and value results, the synthetic features are screened to obtain screened features.

[0133] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0134] The action result is input into the feature extraction layer of the value network to obtain the value feature; the value feature is input into the noise layer of the value network to obtain the noise feature; and the noise feature is input into the output layer of the value network to obtain the value result.

[0135] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0136] Based on the action results, synthetic features, and a pre-established defect detection network, the Matthews correlation coefficient is determined. The pre-established defect detection network is trained based on the source code and defect reports. The target value is determined based on the Matthews correlation coefficient and the initial Matthews correlation coefficient. The initial Matthews correlation coefficient is determined by the source code, defect reports, and the pre-established defect detection network. Based on the value results and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss.

[0137] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0138] The cleaned features are obtained by removing noisy samples from sequence features and inter-class overlapping features between defective and non-defective sequence features through preset cleaning rules.

[0139] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:

[0140] The pre-established software defect detection network is trained based on the software defect dataset to obtain the trained software defect detection network; the trained software defect detection network is then used to detect defects in the software.

[0141] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0142] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0143] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for generating software defect data, characterized in that, The method includes: Based on the maintenance logs of the software project, obtain the source code and defect reports; based on the defect reports, identify the target source code containing defects. The target source code is transformed into sequence features using word embedding technology; the sequence features are cleaned using preset cleaning rules to obtain cleaned features; and synthetic features are obtained based on the cleaned features using preset generation technology. The synthetic features are filtered using a defect sample screening network to obtain screened features; a software defect dataset is generated based on the screened features, the source code, and the defect report.

2. The method according to claim 1, characterized in that, The defect sample screening network filters the synthetic features to obtain the filtered features, including: The synthesized features are input into the action network of the defect sample screening network to obtain action results; the action results are either retained or discarded. The action results are input into the value network of the defect sample screening network to obtain the value results; Based on the action result and the value result, the synthetic features are filtered to obtain filtered features.

3. The method according to claim 2, characterized in that, The step of inputting the action result into the value network of the defect sample screening network to obtain the value result includes: The action result is input into the feature extraction layer in the value network to obtain the value features; The value features are input into the noise layer of the value network to obtain the noise features; The noise features are input into the output layer of the value network to obtain the value result.

4. The method according to claim 2, characterized in that, The method further includes: Based on the action results, the synthetic features, and the pre-established defect detection network, the Matthews correlation coefficient is determined; the pre-established defect detection network is trained based on the source code and defect reports. The target value is determined based on the Matthews correlation coefficient and the initial Matthews correlation coefficient; the initial Matthews correlation coefficient is determined by the source code, the defect report, and the pre-established defect detection network. Based on the value results and the target value, the loss of the defect sample screening network is determined, and the parameters of the defect sample screening network are optimized based on the loss.

5. The method according to claim 1, characterized in that, The step of cleaning the sequence features using preset cleaning rules to obtain cleaned features includes: The noise samples in the sequence features are removed by pre-defined cleaning rules, as well as the inter-class overlapping features of defective and non-defective sequence features, to obtain the cleaned features.

6. The method according to claim 1, characterized in that, The method further includes: The pre-established software defect detection network is trained based on the software defect dataset to obtain the trained software defect detection network. The trained software defect detection network is used to detect software defects.

7. A software defect data generation device, characterized in that, The device includes: The acquisition module is used to acquire source code and defect reports based on the maintenance logs of a software project; and to identify target source code containing defects based on the defect reports. The synthesis module is used to convert the target source code into sequence features using word embedding technology; clean the sequence features using preset cleaning rules to obtain cleaned features; and obtain synthesized features based on the cleaned features using preset generation technology. The generation module is used to filter the synthetic features based on the defect sample screening network to obtain screened features; and to generate a software defect dataset based on the screened features, the source code, and the defect report.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.